API Reference¶
This section contains the automatically generated documentation for the robot_workspace package.
Core Modules¶
robot_workspace.objects.object
¶
Classes¶
Object
¶
Bases: ObjectAPI
Class representing an object detected in a robot's workspace.
Each object is characterized by its bounding box (in both pixel and world coordinates), segmentation mask (if available), size, and additional metadata. This class also provides methods to calculate dimensions, orientation, and other properties of the object.
Attributes:
| Name | Type | Description |
|---|---|---|
_label |
str
|
Label identifying the object (e.g., "pencil"). |
_workspace |
Workspace
|
Workspace in which the object resides. |
_verbose |
bool
|
Whether verbose logging is enabled. |
_logger |
Logger
|
Logger instance. |
_original_mask_8u |
ndarray
|
Original segmentation mask. |
_u_rel_min |
float
|
Minimum U relative coordinate. |
_v_rel_min |
float
|
Minimum V relative coordinate. |
_u_rel_max |
float
|
Maximum U relative coordinate. |
_v_rel_max |
float
|
Maximum V relative coordinate. |
_width |
float
|
Width in relative coordinates. |
_height |
float
|
Height in relative coordinates. |
_gripper_rotation |
float
|
Suggested orientation for the robot gripper. |
_size_m2 |
float
|
Area of the object in square meters. |
_pose_center |
PoseObjectPNP
|
Pose of the geometric center. |
_u_rel_o |
float
|
U relative coordinate of the center. |
_v_rel_o |
float
|
V relative coordinate of the center. |
_pose_com |
PoseObjectPNP
|
Pose of the center of mass. |
_u_rel_com |
float
|
U relative coordinate of the COM. |
_v_rel_com |
float
|
V relative coordinate of the COM. |
Source code in robot_workspace/objects/object.py
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 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 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 | |
Functions¶
__init__(label, u_min, v_min, u_max, v_max, mask_8u, workspace, verbose=False)
¶
Initializes an Object instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
label
|
str
|
Label of the object (e.g., "chocolate bar"). |
required |
u_min
|
int
|
Upper-left corner u-coordinate of the bounding box (in pixels). |
required |
v_min
|
int
|
Upper-left corner v-coordinate of the bounding box (in pixels). |
required |
u_max
|
int
|
Lower-right corner u-coordinate of the bounding box (in pixels). |
required |
v_max
|
int
|
Lower-right corner v-coordinate of the bounding box (in pixels). |
required |
mask_8u
|
ndarray
|
Segmentation mask of the object (8-bit, uint8). |
required |
workspace
|
Workspace
|
Workspace instance where the object is located. |
required |
verbose
|
bool
|
If True, enables verbose logging. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the provided segmentation mask is not 8-bit unsigned, or if the workspace has no image shape. |
Source code in robot_workspace/objects/object.py
as_string_for_chat_window()
¶
Formats object details for display in a chat interface.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Chat-friendly object description. |
Source code in robot_workspace/objects/object.py
as_string_for_llm()
¶
Formats object details as a string for use with language models.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
String containing object information. |
Source code in robot_workspace/objects/object.py
as_string_for_llm_lbl()
¶
Formats object details in a line-by-line style, optimized for language model usage.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Detailed object information string. |
Source code in robot_workspace/objects/object.py
calc_width_height(pose_ul, pose_lr)
staticmethod
¶
Calculates the width and the height between two PoseObjects in meters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_ul
|
PoseObjectPNP
|
PoseObject in the upper left corner. |
required |
pose_lr
|
PoseObjectPNP
|
PoseObject in the lower right corner. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: (width, height) in meters. |
Source code in robot_workspace/objects/object.py
coordinate()
¶
from_dict(data, workspace)
classmethod
¶
Creates an Object instance from a dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary containing object data. |
required |
workspace
|
Workspace
|
Workspace instance. |
required |
Returns:
| Type | Description |
|---|---|
Object | None
|
Object | None: Reconstructed object instance or None if fails. |
Source code in robot_workspace/objects/object.py
from_json(json_str, workspace)
classmethod
¶
Creates an Object instance from a JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
json_str
|
str
|
JSON string containing object data. |
required |
workspace
|
Workspace
|
Workspace instance. |
required |
Returns:
| Type | Description |
|---|---|
Object | None
|
Object | None: Reconstructed object instance or None if fails. |
Source code in robot_workspace/objects/object.py
generate_object_id()
¶
Generates a unique ID for the object based on its properties.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Unique object identifier. |
Source code in robot_workspace/objects/object.py
get_workspace_id()
¶
Returns the ID of the workspace containing the object.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Workspace ID. |
gripper_rotation()
¶
height_m()
¶
label()
¶
largest_contour()
¶
pose_center()
¶
pose_com()
¶
set_pose_com(pose_com)
¶
Updates the object's center of mass pose and recalculates all dependent properties.
Handles both position changes and orientation changes (rotation around z-axis).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_com
|
PoseObjectPNP
|
New pose for the object's center of mass. |
required |
Source code in robot_workspace/objects/object.py
set_position(xy_coordinate)
¶
Legacy method kept for backwards compatibility.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
xy_coordinate
|
list[float]
|
[x, y] world coordinates in meters. |
required |
Source code in robot_workspace/objects/object.py
shape_m()
¶
size_m2()
¶
to_dict()
¶
Converts the Object instance to a dictionary that can be JSON serialized.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict[str, Any]: Dictionary representation of the object. |
Source code in robot_workspace/objects/object.py
to_json()
¶
Converts the Object instance to a JSON string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
JSON representation. |
u_rel_o()
¶
uv_rel_o()
¶
v_rel_o()
¶
verbose()
¶
width_m()
¶
workspace()
¶
x_center()
¶
x_com()
¶
xy_center()
¶
xy_com()
¶
y_center()
¶
Functions¶
robot_workspace.objects.objects
¶
Classes¶
Objects
¶
Bases: list[Object]
A class representing a list of Object instances.
Objects are typically stored in a workspace and represent physical entities detected by vision. This class provides several spatial query methods to find objects based on coordinates, labels, or size.
Source code in robot_workspace/objects/objects.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 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 | |
Functions¶
__init__(iterable=None, verbose=False)
¶
Initializes the Objects instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iterable
|
Iterable[Object]
|
An iterable of Object instances. Defaults to an empty list. |
None
|
verbose
|
bool
|
If True, enables verbose logging. |
False
|
Source code in robot_workspace/objects/objects.py
dict_list_to_objects(dict_list, workspace)
staticmethod
¶
Reconstructs an Objects collection from a list of dictionaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dict_list
|
list[dict[str, Any]]
|
List of object dictionaries. |
required |
workspace
|
Workspace
|
The workspace to associate with the objects. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Objects |
Objects
|
A collection of reconstructed objects. |
Source code in robot_workspace/objects/objects.py
get_detected_object(coordinate, label=None, serializable=False)
¶
Retrieves a detected object at or near a specified world coordinate, optionally filtering by label.
Checks for objects that are within a 2-centimeter radius of the specified coordinate. If multiple objects meet the criteria, the first one found is returned.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coordinate
|
list[float]
|
A 2D coordinate in world units [x, y]. |
required |
label
|
str
|
An optional filter for the object's label. |
None
|
serializable
|
bool
|
If True, returns a dictionary representation instead of an Object instance. |
False
|
Returns:
| Type | Description |
|---|---|
Object | dict[str, Any] | None
|
Object | dict[str, Any] | None: The first object detected near the given coordinate, or None if not found. |
Source code in robot_workspace/objects/objects.py
get_detected_objects(location=Location.NONE, coordinate=None, label=None)
¶
Returns a list of objects filtered by spatial location, coordinate, and label.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Location | str
|
Spatial filter. Values can be "left next to", "right next to", "above", "below", "close to", or Location enum equivalents. |
NONE
|
coordinate
|
list[float]
|
(x, y) coordinate in meters used for spatial filtering. Required if 'location' is not NONE. |
None
|
label
|
str
|
Filter by object label (substring match). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
Objects |
Objects
|
A collection of filtered objects. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If coordinate is missing but required for the specified location filter. |
Source code in robot_workspace/objects/objects.py
get_detected_objects_as_comma_separated_string()
¶
Returns the labels of all detected objects as a comma-separated string.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Comma-separated labels. |
Source code in robot_workspace/objects/objects.py
get_detected_objects_serializable(location=Location.NONE, coordinate=None, label=None)
¶
Similar to get_detected_objects but returns a list of dictionaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
location
|
Location | str
|
Spatial filter. |
NONE
|
coordinate
|
list[float]
|
Reference (x, y) coordinate. |
None
|
label
|
str
|
Filter by object label. |
None
|
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of dictionary representations of the filtered objects. |
Source code in robot_workspace/objects/objects.py
get_detected_objects_sorted(ascending=True, serializable=False)
¶
Returns objects sorted by their size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ascending
|
bool
|
Sorting order. Defaults to True. |
True
|
serializable
|
bool
|
If True, returns a list of dictionaries. |
False
|
Returns:
| Type | Description |
|---|---|
Objects | list[dict[str, Any]]
|
Objects | list[dict[str, Any]]: Sorted collection of objects. |
Source code in robot_workspace/objects/objects.py
get_largest_detected_object(serializable=False)
¶
Identifies the largest object by area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serializable
|
bool
|
If True, returns a dictionary instead of an Object. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[Object, float] | tuple[dict[str, Any], float]
|
(largest_object, area_m2). |
Source code in robot_workspace/objects/objects.py
get_nearest_detected_object(coordinate, label=None)
¶
Finds the object nearest to a specified coordinate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coordinate
|
list[float]
|
Target (x, y) coordinate. |
required |
label
|
str
|
If specified, only consider objects with this label. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[Object | None, float]
|
tuple[Object | None, float]: (nearest_object, distance_in_meters). |
Source code in robot_workspace/objects/objects.py
get_smallest_detected_object(serializable=False)
¶
Identifies the smallest object by area.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
serializable
|
bool
|
If True, returns a dictionary instead of an Object. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
tuple |
tuple[Object, float] | tuple[dict[str, Any], float]
|
(smallest_object, area_m2). |
Source code in robot_workspace/objects/objects.py
objects_to_dict_list(objects)
staticmethod
¶
Converts a list of Object instances to a list of dictionaries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
objects
|
list[Object]
|
List of Object instances. |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
list[dict[str, Any]]: List of dictionary representations. |
Source code in robot_workspace/objects/objects.py
verbose()
¶
Returns whether verbose logging is enabled.
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if verbose, else False. |
Functions¶
robot_workspace.objects.pose_object
¶
Classes¶
PoseObjectPNP
¶
Pose object which stores x, y, z, roll, pitch & yaw parameters.
Attributes:
| Name | Type | Description |
|---|---|---|
x |
float
|
X coordinate in meters. |
y |
float
|
Y coordinate in meters. |
z |
float
|
Z coordinate in meters. |
roll |
float
|
Roll orientation in radians. |
pitch |
float
|
Pitch orientation in radians. |
yaw |
float
|
Yaw orientation in radians. |
Source code in robot_workspace/objects/pose_object.py
15 16 17 18 19 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 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 | |
Attributes¶
quaternion
property
¶
Return the quaternion in a list [qx, qy, qz, qw].
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: Quaternion [qx, qy, qz, qw]. |
quaternion_pose
property
¶
Return the position and the quaternion in a list [x, y, z, qx, qy, qz, qw].
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: Position [x, y, z] + quaternion [qx, qy, qz, qw]. |
Functions¶
__init__(x=0.0, y=0.0, z=0.0, roll=0.0, pitch=0.0, yaw=0.0)
¶
Initializes a PoseObjectPNP instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
float
|
X coordinate in meters. |
0.0
|
y
|
float
|
Y coordinate in meters. |
0.0
|
z
|
float
|
Z coordinate in meters. |
0.0
|
roll
|
float
|
Roll orientation in radians. |
0.0
|
pitch
|
float
|
Pitch orientation in radians. |
0.0
|
yaw
|
float
|
Yaw orientation in radians. |
0.0
|
Source code in robot_workspace/objects/pose_object.py
approx_eq(other, eps_position=0.1, eps_orientation=0.1)
¶
Determines if two poses are approximately the same, accounting for angle periodicity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
PoseObjectPNP
|
Other pose object to compare with. |
required |
eps_position
|
float
|
Tolerance for position differences (in meters). |
0.1
|
eps_orientation
|
float
|
Tolerance for orientation differences (in radians). |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if poses are approximately the same, False otherwise. |
Source code in robot_workspace/objects/pose_object.py
approx_eq_xyz(other, eps=0.1)
¶
Compares the (x, y, z) coordinates of this pose object with another pose object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
PoseObjectPNP
|
The pose object to compare with. |
required |
eps
|
float
|
The allowable deviation for equality in each coordinate (default: 0.1). |
0.1
|
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the difference in x, y, and z coordinates between the two poses is less than the specified tolerance (eps), otherwise False. |
Source code in robot_workspace/objects/pose_object.py
convert_niryo_pose_object2pose_object(pose_object)
staticmethod
¶
Converts a PoseObject from Niryo class to a PoseObjectPNP object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_object
|
Any
|
PoseObject from Niryo. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
PoseObjectPNP |
PoseObjectPNP
|
The converted pose object. |
Source code in robot_workspace/objects/pose_object.py
convert_pose_object2niryo_pose_object(pose_object)
staticmethod
¶
Convert a PoseObjectPNP to a PoseObject from Niryo Robot.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pose_object
|
PoseObjectPNP
|
The pose object to convert. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
Any |
Any
|
Pose object as defined by Niryo. |
Source code in robot_workspace/objects/pose_object.py
copy_with_offsets(x_offset=0.0, y_offset=0.0, z_offset=0.0, roll_offset=0.0, pitch_offset=0.0, yaw_offset=0.0)
¶
Creates a new pose object by applying offsets to its position and orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_offset
|
float
|
Offset to apply to the x-coordinate (default: 0.0). |
0.0
|
y_offset
|
float
|
Offset to apply to the y-coordinate (default: 0.0). |
0.0
|
z_offset
|
float
|
Offset to apply to the z-coordinate (default: 0.0). |
0.0
|
roll_offset
|
float
|
Offset to apply to the roll orientation (default: 0.0). |
0.0
|
pitch_offset
|
float
|
Offset to apply to the pitch orientation (default: 0.0). |
0.0
|
yaw_offset
|
float
|
Offset to apply to the yaw orientation (default: 0.0). |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
PoseObjectPNP |
PoseObjectPNP
|
A new pose object with the offsets applied. |
Source code in robot_workspace/objects/pose_object.py
euler_to_quaternion(roll, pitch, yaw)
staticmethod
¶
Convert euler angles to quaternion.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
roll
|
float
|
Roll in radians. |
required |
pitch
|
float
|
Pitch in radians. |
required |
yaw
|
float
|
Yaw in radians. |
required |
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: Quaternion in a list [qx, qy, qz, qw]. |
Source code in robot_workspace/objects/pose_object.py
quaternion_to_euler_angle(qx, qy, qz, qw)
staticmethod
¶
Convert quaternion to euler angles.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
qx
|
float
|
Quaternion x. |
required |
qy
|
float
|
Quaternion y. |
required |
qz
|
float
|
Quaternion z. |
required |
qw
|
float
|
Quaternion w. |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float, float]
|
tuple[float, float, float]: Euler angles (roll, pitch, yaw) in radians. |
Source code in robot_workspace/objects/pose_object.py
to_list()
¶
Return a list [x, y, z, roll, pitch, yaw] corresponding to the pose's parameters.
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: A list of the pose's parameters. |
Source code in robot_workspace/objects/pose_object.py
to_transformation_matrix()
¶
Converts the pose into a 4x4 transformation matrix.
The transformation matrix represents the pose of an object in a 3D coordinate system. It combines translation and rotation into a single homogeneous transformation.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A 4x4 transformation matrix of type float, where: - The upper-left 3x3 submatrix represents the rotation. - The last column represents the translation. - The bottom row is [0, 0, 0, 1] for homogeneity. |
Source code in robot_workspace/objects/pose_object.py
xy_coordinate()
¶
Returns the (x, y) coordinates of the pose.
Returns:
| Type | Description |
|---|---|
list[float]
|
list[float]: [x, y] coordinates. |
Functions¶
robot_workspace.workspaces.workspace
¶
Classes¶
Workspace
¶
Bases: ABC
Abstract base class representing a robotic workspace.
A workspace defines a region where a robot can pick and place objects. It handles coordinate transformations between camera images and world coordinates.
Attributes:
| Name | Type | Description |
|---|---|---|
_id |
str
|
Unique identifier for the workspace. |
_verbose |
bool
|
If True, enables verbose logging. |
_logger |
Logger
|
Logger instance. |
_observation_pose |
PoseObjectPNP
|
Optimal pose for the camera to observe the workspace. |
_xy_ul_wc |
PoseObjectPNP
|
Upper-left corner in world coordinates. |
_xy_ll_wc |
PoseObjectPNP
|
Lower-left corner in world coordinates. |
_xy_ur_wc |
PoseObjectPNP
|
Upper-right corner in world coordinates. |
_xy_lr_wc |
PoseObjectPNP
|
Lower-right corner in world coordinates. |
_xy_center_wc |
PoseObjectPNP
|
Center of the workspace in world coordinates. |
_width_m |
float
|
Width of the workspace in meters. |
_height_m |
float
|
Height of the workspace in meters. |
_img_shape |
tuple[int, int, int]
|
Shape of the camera image (height, width, channels). |
Source code in robot_workspace/workspaces/workspace.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 | |
Functions¶
__init__(workspace_id, verbose=False)
¶
Initializes the workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
Unique ID of the workspace. |
required |
verbose
|
bool
|
Whether to enable verbose logging. |
False
|
Source code in robot_workspace/workspaces/workspace.py
height_m()
¶
id()
¶
img_shape()
¶
is_visible(camera_pose)
¶
Checks whether the workspace is visible from the given camera pose.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
camera_pose
|
PoseObjectPNP
|
The current pose of the camera. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the workspace is considered visible, False otherwise. |
Source code in robot_workspace/workspaces/workspace.py
observation_pose()
¶
set_img_shape(img_shape)
¶
Sets the image shape for the workspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
img_shape
|
tuple[int, int, int]
|
(height, width, channels). |
required |
transform_camera2world_coords(workspace_id, u_rel, v_rel, yaw=0.0)
abstractmethod
¶
Transforms relative image coordinates to world coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
ID of the workspace. |
required |
u_rel
|
float
|
Normalized horizontal coordinate [0, 1]. |
required |
v_rel
|
float
|
Normalized vertical coordinate [0, 1]. |
required |
yaw
|
float
|
Orientation of the object at the given point. |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
PoseObjectPNP |
PoseObjectPNP
|
Corresponding pose in world coordinates. |
Source code in robot_workspace/workspaces/workspace.py
verbose()
¶
width_m()
¶
xy_center_wc()
¶
xy_ll_wc()
¶
xy_lr_wc()
¶
xy_ul_wc()
¶
Functions¶
robot_workspace.workspaces.niryo_workspace
¶
Classes¶
NiryoWorkspace
¶
Bases: Workspace
Implementation of Workspace for the Niryo Ned2 robot.
This class provides specific coordinate transformations and poses for the Niryo Ned2 robotic arm and its mounted camera.
Source code in robot_workspace/workspaces/niryo_workspace.py
18 19 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 | |
Functions¶
__init__(workspace_id, environment, verbose=False, config=None)
¶
Initializes the NiryoWorkspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
Unique ID of the workspace. |
required |
environment
|
EnvironmentProtocol
|
Object providing robot environment access. |
required |
verbose
|
bool
|
Whether to enable verbose output. |
False
|
config
|
WorkspaceConfig
|
Optional workspace configuration. |
None
|
Source code in robot_workspace/workspaces/niryo_workspace.py
environment()
¶
from_config(config, environment, verbose=False)
classmethod
¶
Creates a NiryoWorkspace instance from a configuration object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
WorkspaceConfig
|
Configuration instance. |
required |
environment
|
EnvironmentProtocol
|
Environment object. |
required |
verbose
|
bool
|
Whether to enable verbose output. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
NiryoWorkspace |
NiryoWorkspace
|
The initialized workspace instance. |
Source code in robot_workspace/workspaces/niryo_workspace.py
transform_camera2world_coords(workspace_id, u_rel, v_rel, yaw=0.0)
¶
Transforms relative image coordinates to Niryo world coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
ID of the workspace. |
required |
u_rel
|
float
|
Normalized horizontal coordinate [0, 1]. |
required |
v_rel
|
float
|
Normalized vertical coordinate [0, 1]. |
required |
yaw
|
float
|
Orientation of the object. |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
PoseObjectPNP |
PoseObjectPNP
|
Corresponding pose in world coordinates. |
Source code in robot_workspace/workspaces/niryo_workspace.py
Functions¶
robot_workspace.workspaces.widowx_workspace
¶
Classes¶
WidowXWorkspace
¶
Bases: Workspace
Implementation of Workspace for the WidowX 250 6DOF robot.
The WidowX robot typically uses a third-person camera view rather than a gripper-mounted camera.
Source code in robot_workspace/workspaces/widowx_workspace.py
17 18 19 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 | |
Functions¶
__init__(workspace_id, environment, verbose=False, config=None)
¶
Initializes the WidowXWorkspace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
Unique ID of the workspace. |
required |
environment
|
EnvironmentProtocol
|
Object implementing EnvironmentProtocol. |
required |
verbose
|
bool
|
Whether to enable verbose output. |
False
|
config
|
WorkspaceConfig
|
Optional workspace configuration. |
None
|
Source code in robot_workspace/workspaces/widowx_workspace.py
environment()
¶
from_config(config, environment, verbose=False)
classmethod
¶
Creates a WidowXWorkspace from a configuration object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
WorkspaceConfig
|
Workspace configuration. |
required |
environment
|
EnvironmentProtocol
|
Environment object. |
required |
verbose
|
bool
|
Whether to enable verbose output. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
WidowXWorkspace |
WidowXWorkspace
|
The initialized workspace instance. |
Source code in robot_workspace/workspaces/widowx_workspace.py
transform_camera2world_coords(workspace_id, u_rel, v_rel, yaw=0.0)
¶
Transforms relative image coordinates to WidowX world coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
workspace_id
|
str
|
ID of the workspace. |
required |
u_rel
|
float
|
Normalized horizontal coordinate [0, 1]. |
required |
v_rel
|
float
|
Normalized vertical coordinate [0, 1]. |
required |
yaw
|
float
|
Orientation of the object. |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
PoseObjectPNP |
PoseObjectPNP
|
Corresponding pose in world coordinates. |