Robot¶
robot_environment.robot.robot.Robot
¶
Bases: RobotAPI
Source code in robot_environment/robot/robot.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 | |
Functions¶
__init__(environment, use_simulation=False, robot_id='niryo', verbose=False)
¶
Initialize the Robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
environment
|
'Environment'
|
Environment object this Robot is installed in. |
required |
use_simulation
|
bool
|
If True, simulate the robot, else use the real robot. |
False
|
robot_id
|
str
|
Robot identifier ("niryo" or "widowx"). |
'niryo'
|
verbose
|
bool
|
Enable verbose logging. |
False
|
Source code in robot_environment/robot/robot.py
calibrate()
¶
Calibrates the Robot.
Returns:
| Type | Description |
|---|---|
bool
|
True, if calibration was successful, else False |
environment()
¶
Returns the environment object.
Returns:
| Name | Type | Description |
|---|---|---|
Environment |
Environment
|
The environment instance. |
get_detected_objects()
¶
get_pose()
¶
Get current pose of gripper of robot.
Returns:
| Type | Description |
|---|---|
PoseObjectPNP
|
current pose of gripper of robot. |
get_target_pose_from_rel(workspace_id, u_rel, v_rel, yaw)
¶
Given relative image coordinates [u_rel, v_rel] and optionally an orientation of the point (yaw), calculate the corresponding pose in world coordinates. The parameter yaw is useful, if we want to pick at the given coordinate an object that has the given orientation. For this method to work, it is important that only the workspace of the robot is visible in the image and nothing else. At least for the Niryo robot this is important. This means, (u_rel, v_rel) = (0, 0), is the upper left corner of the workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
u_rel
|
float
|
horizontal coordinate in image of workspace, normalized between 0 and 1 |
required |
v_rel
|
float
|
vertical coordinate in image of workspace, normalized between 0 and 1 |
required |
yaw
|
float
|
orientation of an object at the pixel coordinates [u_rel, v_rel]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pose_object |
PoseObjectPNP
|
Pose of the point in world coordinates of the robot. |
Source code in robot_environment/robot/robot.py
handle_object_detection(objects_dict_list)
¶
Process incoming object detections from Redis
Source code in robot_environment/robot/robot.py
move2observation_pose(workspace_id)
¶
The robot will move to a pose where it can observe (the gripper hovers over) the workspace given by workspace_id. Before a robot can pick up or place an object in a workspace, it must first move to this observation pose of the corresponding workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in robot_environment/robot/robot.py
pick_object(object_name, pick_coordinate, z_offset=0.001)
¶
Command the pick-and-place robot arm to pick up a specific object using its gripper. The gripper will move to the specified 'pick_coordinate' and pick the named object.
Example call:
robot.pick_object("pen", [0.01, -0.15]) --> Picks the pen that is located at world coordinates [0.01, -0.15].
robot.pick_object("pen", [0.01, -0.15], z_offset=0.02) --> Picks the pen with a 2cm offset above its detected position (useful for stacked objects).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_name
|
str
|
The name of the object to be picked up. Ensure this name matches an object visible in |
required |
pick_coordinate
|
List
|
The world coordinates [x, y] where the object should be picked up. Use these |
required |
z_offset
|
float
|
Additional height offset in meters to apply when picking (default: 0.001). |
0.001
|
Source code in robot_environment/robot/robot.py
pick_object_from_workspace(object_name, workspace_id, pick_coordinate, z_offset=0.001)
¶
Pick an object from a specific workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_name
|
str
|
Name of the object to pick |
required |
workspace_id
|
str
|
ID of the workspace |
required |
pick_coordinate
|
List[float]
|
[x, y] coordinate in workspace |
required |
z_offset
|
float
|
Additional height offset in meters (default: 0.001) |
0.001
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful |
Source code in robot_environment/robot/robot.py
pick_place_object(object_name, pick_coordinate, place_coordinate, location=None, z_offset=0.001)
¶
Instructs the pick-and-place robot arm to pick a specific object and place it using its gripper. The gripper will move to the specified 'pick_coordinate' and pick the named object. It will then move to the specified 'place_coordinate' and place the object there. If you need to pick-and-place an object, call this function and not robot_pick_object() followed by robot_place_object().
Example call:
robot.pick_place_object( object_name='chocolate bar', pick_coordinate=[-0.1, 0.01], place_coordinate=[0.1, 0.11], location=Location.RIGHT_NEXT_TO ) --> Picks the chocolate bar that is located at world coordinates [-0.1, 0.01] and places it right next to an object that exists at world coordinate [0.1, 0.11].
robot.pick_place_object( object_name='cube', pick_coordinate=[0.2, 0.05], place_coordinate=[0.3, 0.1], location=Location.ON_TOP_OF, z_offset=0.02 ) --> Picks the cube with a 2cm z-offset (useful if it's on top of another object).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_name
|
str
|
The name of the object to be picked up. Ensure this name matches an object visible in |
required |
pick_coordinate
|
List
|
The world coordinates [x, y] where the object should be picked up. Use these |
required |
place_coordinate
|
List
|
The world coordinates [x, y] where the object should be placed at. |
required |
location
|
Union['Location', str, None]
|
Specifies the relative placement position of the picked object with respect to an object
being at the 'place_coordinate'. Possible values are defined in the |
None
|
z_offset
|
float
|
Additional height offset in meters to apply when picking (default: 0.001). |
0.001
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful |
Source code in robot_environment/robot/robot.py
pick_place_object_across_workspaces(object_name, pick_workspace_id, pick_coordinate, place_workspace_id, place_coordinate, location=None, z_offset=0.001)
¶
Pick an object from one workspace and place it in another workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_name
|
str
|
Name of the object to pick |
required |
pick_workspace_id
|
str
|
ID of the workspace to pick from |
required |
pick_coordinate
|
List[float]
|
[x, y] coordinate in pick workspace |
required |
place_workspace_id
|
str
|
ID of the workspace to place in |
required |
place_coordinate
|
List[float]
|
[x, y] coordinate in place workspace |
required |
location
|
Union['Location', str, None]
|
Relative placement location (Location enum or string) |
None
|
z_offset
|
float
|
Additional height offset in meters when picking (default: 0.001) |
0.001
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful, False otherwise |
Example
robot.pick_place_object_across_workspaces( object_name='cube', pick_workspace_id='niryo_ws_left', pick_coordinate=[0.2, 0.05], place_workspace_id='niryo_ws_right', place_coordinate=[0.25, -0.05], location=Location.RIGHT_NEXT_TO, z_offset=0.02 )
Source code in robot_environment/robot/robot.py
place_object(place_coordinate, location=None)
¶
Instruct the pick-and-place robot arm to place a picked object at the specified 'place_coordinate'. The function moves the gripper to the specified 'place_coordinate' and calculates the exact placement position from the given 'location'. Before calling this function you have to call robot_pick_object() to pick an object.
Example call:
robot.place_object([0.2, 0.0], "left next to") --> Places the already gripped object left next to the world coordinate [0.2, 0.0].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
place_coordinate
|
List[float]
|
The world coordinates [x, y] of the target object. |
required |
location
|
Union['Location', str, None]
|
Specifies the relative placement position of the picked object in relation to an object being at the 'place_coordinate'. Possible positions: 'left next to', 'right next to', 'above', 'below', 'on top of', 'inside', or None. |
None
|
Source code in robot_environment/robot/robot.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | |
place_object_in_workspace(workspace_id, place_coordinate, location=None)
¶
Place a picked object in a specific workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
ID of the target workspace |
required |
place_coordinate
|
List[float]
|
[x, y] coordinate in workspace |
required |
location
|
Union['Location', str, None]
|
Relative placement location |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if successful |
Source code in robot_environment/robot/robot.py
507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 | |
push_object(object_name, push_coordinate, direction, distance)
¶
Instruct the pick-and-place robot arm to push a specific object to a new position. This function should only be called if it is not possible to pick the object. An object cannot be picked if its shorter side is larger than the gripper.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_name
|
str
|
The name of the object to be pushed. |
required |
push_coordinate
|
List[float]
|
The world coordinates [x, y] where the object to push is located. |
required |
direction
|
str
|
The direction in which to push the object ("up", "down", "left", "right"). |
required |
distance
|
float
|
The distance (in millimeters) to push the object. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True |
Source code in robot_environment/robot/robot.py
robot()
¶
robot_in_motion()
¶
Check if the robot is currently in motion.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the robot is in motion, False otherwise. |
verbose()
¶
Returns the verbosity status.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if verbose is on, else False. |
Controllers¶
RobotController¶
robot_environment.robot.robot_controller.RobotController
¶
Bases: ABC
An abstract class for the pick-and-place robot that provides the primitive tasks of the robot like pick and place operations.
Source code in robot_environment/robot/robot_controller.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 | |
Functions¶
__del__()
¶
__init__(robot, use_simulation, verbose=False)
¶
Initializes the robot (connects to it and calibrates it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
Robot
|
object of the Robot class. |
required |
use_simulation
|
bool
|
True, if working with a simulation model of the robot, |
required |
verbose
|
bool
|
|
False
|
Source code in robot_environment/robot/robot_controller.py
calibrate()
abstractmethod
¶
Calibrates the Robot.
Returns:
| Type | Description |
|---|---|
bool
|
True, if calibration was successful, else False |
get_pose()
abstractmethod
¶
Get current pose of gripper of robot.
Returns:
| Type | Description |
|---|---|
PoseObjectPNP
|
current pose of gripper of robot. |
get_target_pose_from_rel(workspace_id, u_rel, v_rel, yaw)
abstractmethod
¶
Given relative image coordinates [u_rel, v_rel] and optionally an orientation of the point (yaw), calculate the corresponding pose in world coordinates. The parameter yaw is useful, if we want to pick at the given coordinate an object that has the given orientation. For this method to work, it is important that only the workspace of the robot is visible in the image and nothing else. At least for the Niryo robot this is important. This means, (u_rel, v_rel) = (0, 0), is the upper left corner of the workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
u_rel
|
float
|
horizontal coordinate in image of workspace, normalized between 0 and 1 |
required |
v_rel
|
float
|
vertical coordinate in image of workspace, normalized between 0 and 1 |
required |
yaw
|
float
|
orientation of an object at the pixel coordinates [u_rel, v_rel]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pose_object |
PoseObjectPNP
|
Pose of the point in world coordinates of the robot. |
Source code in robot_environment/robot/robot_controller.py
is_in_motion()
¶
lock()
¶
Returns:
| Type | Description |
|---|---|
Lock
|
a lock, to only call the robot interface with one method and not many methods in parallel, because for Niryo |
Lock
|
the interface is not thread safe. |
Source code in robot_environment/robot/robot_controller.py
move2observation_pose(workspace_id)
abstractmethod
¶
The robot should move to a pose where it can observe the workspace given by workspace_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
Source code in robot_environment/robot/robot_controller.py
robot()
¶
robot_ctrl()
¶
Returns:
| Type | Description |
|---|---|
|
the object of the underlying robot. For the Niryo Ned2 it is an object of the NiryoRobot class. |
robot_pick_object(pick_pose)
abstractmethod
¶
Calls the pick command of the self._robot_ctrl to pick an object at the given pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pick_pose
|
PoseObjectPNP
|
Pose where the object should be picked (includes z-offset if needed) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if pick was successful, else False |
Source code in robot_environment/robot/robot_controller.py
robot_place_object(place_pose)
abstractmethod
¶
Places an already picked object at the given place_pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
place_pose
|
PoseObjectPNP
|
Pose where to place the already picked object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if place was successful, else False |
Source code in robot_environment/robot/robot_controller.py
robot_push_object(push_pose, direction, distance)
abstractmethod
¶
Push given object (its Pose) into the given direction by the given distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
push_pose
|
PoseObjectPNP
|
the Pose of the object that should be pushed. |
required |
direction
|
str
|
"up", "down", "left", "right" |
required |
distance
|
float
|
distance in millimeters |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if push was successful, else False |
Source code in robot_environment/robot/robot_controller.py
NiryoRobotController¶
robot_environment.robot.niryo_robot_controller.NiryoRobotController
¶
Bases: RobotController
Class for the pick-and-place niryo ned2 robot that provides the primitive tasks of the robot like pick and place operations.
Source code in robot_environment/robot/niryo_robot_controller.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 | |
Functions¶
__init__(robot, use_simulation, verbose=False)
¶
Initializes the robot (connects to it and calibrates it).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
'Robot'
|
object of the Robot class. |
required |
use_simulation
|
bool
|
True, if working with a simulation model of the robot, |
required |
verbose
|
bool
|
|
False
|
Source code in robot_environment/robot/niryo_robot_controller.py
calibrate()
¶
Calibrates the NiryoRobot.
Returns:
| Type | Description |
|---|---|
bool
|
True, if calibration was successful, else False |
cleanup()
¶
Explicit cleanup method - call this when you're done with the object. This is more reliable than relying on del.
Source code in robot_environment/robot/niryo_robot_controller.py
get_camera_intrinsics()
¶
Get camera intrinsic matrix and distortion coefficients.
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: (mtx, dist) |
Source code in robot_environment/robot/niryo_robot_controller.py
get_img_compressed()
¶
Get compressed image from the robot's camera.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Compressed image data. |
Source code in robot_environment/robot/niryo_robot_controller.py
get_pose()
¶
Get current pose of gripper of robot.
Returns:
| Type | Description |
|---|---|
PoseObjectPNP
|
current pose of gripper of robot. |
Source code in robot_environment/robot/niryo_robot_controller.py
get_target_pose_from_rel(workspace_id, u_rel, v_rel, yaw)
¶
Given relative image coordinates [u_rel, v_rel] and optionally an orientation of the point (yaw), calculate the corresponding pose in world coordinates. The parameter yaw is useful, if we want to pick at the given coordinate an object that has the given orientation. For this method to work, it is important that only the workspace of the robot is visible in the image and nothing else. At least for the Niryo robot this is important. This means, (u_rel, v_rel) = (0, 0), is the upper left corner of the workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
u_rel
|
float
|
horizontal coordinate in image of workspace, normalized between 0 and 1 |
required |
v_rel
|
float
|
vertical coordinate in image of workspace, normalized between 0 and 1 |
required |
yaw
|
float
|
orientation of an object at the pixel coordinates [u_rel, v_rel]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pose_object |
'PoseObjectPNP'
|
Pose of the point in world coordinates of the robot. |
Source code in robot_environment/robot/niryo_robot_controller.py
get_target_pose_from_rel_timeout(workspace_id, x_rel, y_rel, yaw, timeout=0.75)
¶
Calculate world coordinates from relative image coordinates with a timeout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
ID of the workspace. |
required |
x_rel
|
float
|
Relative x-coordinate (0-1). |
required |
y_rel
|
float
|
Relative y-coordinate (0-1). |
required |
yaw
|
float
|
Orientation in radians. |
required |
timeout
|
float
|
Timeout in seconds. |
0.75
|
Returns:
| Name | Type | Description |
|---|---|---|
PoseObjectPNP |
'PoseObjectPNP'
|
Target pose in world coordinates. |
Source code in robot_environment/robot/niryo_robot_controller.py
move2observation_pose(workspace_id)
¶
The robot moves to a pose where it can observe the workspace given by workspace_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
Source code in robot_environment/robot/niryo_robot_controller.py
reset_connection()
¶
Reset the connection to the robot by safely disconnecting and reconnecting.
Source code in robot_environment/robot/niryo_robot_controller.py
robot_pick_object(pick_pose)
¶
Calls the pick command of the self._robot_ctrl to pick the object at the given pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pick_pose
|
'PoseObjectPNP'
|
Pose where to pick the object (z-offset already applied if needed) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if pick was successful, else False |
Source code in robot_environment/robot/niryo_robot_controller.py
robot_place_object(place_pose)
¶
Places an already picked object at the given place_pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
place_pose
|
'PoseObjectPNP'
|
Pose where to place the already picked object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if place was successful, else False |
Source code in robot_environment/robot/niryo_robot_controller.py
robot_push_object(push_pose, direction, distance)
¶
Push given object (its Pose) into the given direction by the given distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
push_pose
|
'PoseObjectPNP'
|
the Pose of the object that should be pushed. |
required |
direction
|
str
|
"up", "down", "left", "right" |
required |
distance
|
float
|
distance in millimeters |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if push was successful, else False |
Source code in robot_environment/robot/niryo_robot_controller.py
WidowXRobotController¶
robot_environment.robot.widowx_robot_controller.WidowXRobotController
¶
Bases: RobotController
Class for the pick-and-place WidowX robot that provides the primitive tasks of the robot like pick and place operations using the InterbotixManipulatorXS interface.
Source code in robot_environment/robot/widowx_robot_controller.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
Functions¶
__init__(robot, use_simulation, verbose=False)
¶
Initializes the robot (connects to it and sets up the interface).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
robot
|
'Robot'
|
object of the Robot class. |
required |
use_simulation
|
bool
|
True, if working with a simulation model of the robot, else False if we work with a real robot. |
required |
verbose
|
bool
|
enable verbose output |
False
|
Source code in robot_environment/robot/widowx_robot_controller.py
calibrate()
¶
Calibrates the WidowX robot.
Returns:
| Type | Description |
|---|---|
bool
|
True, if calibration was successful, else False |
get_camera_intrinsics()
¶
Get camera intrinsics for the WidowX camera (if available).
Returns:
| Type | Description |
|---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]: (camera_matrix, distortion_coefficients) |
Source code in robot_environment/robot/widowx_robot_controller.py
get_pose()
¶
Get current pose of gripper of robot.
Returns:
| Type | Description |
|---|---|
PoseObjectPNP
|
current pose of gripper of robot. |
Source code in robot_environment/robot/widowx_robot_controller.py
get_target_pose_from_rel(workspace_id, u_rel, v_rel, yaw)
¶
Given relative image coordinates [u_rel, v_rel] and optionally an orientation of the point (yaw), calculate the corresponding pose in world coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
u_rel
|
float
|
horizontal coordinate in image of workspace, normalized between 0 and 1 |
required |
v_rel
|
float
|
vertical coordinate in image of workspace, normalized between 0 and 1 |
required |
yaw
|
float
|
orientation of an object at the pixel coordinates [u_rel, v_rel]. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
pose_object |
'PoseObjectPNP'
|
Pose of the point in world coordinates of the robot. |
Source code in robot_environment/robot/widowx_robot_controller.py
move2observation_pose(workspace_id)
¶
The robot moves to a pose where it can observe the workspace given by workspace_id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
id of the workspace |
required |
Source code in robot_environment/robot/widowx_robot_controller.py
reset_connection()
¶
Reset the connection to the robot by safely disconnecting and reconnecting.
Source code in robot_environment/robot/widowx_robot_controller.py
robot_pick_object(pick_pose)
¶
Calls the pick command to pick an object at the given pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pick_pose
|
'PoseObjectPNP'
|
Pose where to pick the object (z-offset already applied if needed) |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if pick was successful, else False |
Source code in robot_environment/robot/widowx_robot_controller.py
robot_place_object(place_pose)
¶
Places an already picked object at the given place_pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
place_pose
|
'PoseObjectPNP'
|
Pose where to place the already picked object |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if place was successful, else False |
Source code in robot_environment/robot/widowx_robot_controller.py
robot_push_object(push_pose, direction, distance)
¶
Push given object (its Pose) into the given direction by the given distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
push_pose
|
'PoseObjectPNP'
|
the Pose of the object that should be pushed. |
required |
direction
|
str
|
"up", "down", "left", "right" |
required |
distance
|
float
|
distance in millimeters |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True, if push was successful, else False |