Link
This module contains dataclasses for creating a link in a URDF robot model.
Dataclass
- Origin: Represents the origin of a link in the robot model.
- Axis: Represents the axis of a link in the robot model.
- Inertia: Represents the inertia properties of a link in the robot model.
- Material: Represents the material properties of a link in the robot model.
- InertialLink: Represents the inertial properties of a link in the robot model.
- VisualLink: Represents the visual properties of a link in the robot model.
- CollisionLink: Represents the collision properties of a link in the robot model.
- Link: Represents a link in the robot model.
Enum
- Colors: Enumerates the possible colors for a link in the robot model.
Axis
dataclass
¶
Represents the axis of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
xyz |
tuple[float, float, float]
|
The x, y, z coordinates of the axis. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the axis to an XML element. |
Examples:
>>> axis = Axis(xyz=(1.0, 0.0, 0.0))
>>> axis.to_xml()
<Element 'axis' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_xml(xml)
classmethod
¶
Create an axis from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the axis from. |
required |
Returns:
Type | Description |
---|---|
Axis
|
The axis created from the XML element. |
Examples:
>>> xml = ET.Element('axis')
>>> Axis.from_xml(xml)
Axis(xyz=(0.0, 0.0, 0.0))
Source code in onshape_robotics_toolkit\models\link.py
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
|
to_mjcf(root)
¶
Convert the axis to an MuJoCo compatible XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Element
|
The root element to append the axis to. |
required |
Returns:
Type | Description |
---|---|
None
|
The XML element representing the axis. |
Examples:
>>> axis = Axis(xyz=(1.0, 0.0, 0.0))
>>> axis.to_mjcf()
<Element 'axis' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
to_xml(root=None)
¶
Convert the axis to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the axis to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the axis. |
Examples:
>>> axis = Axis(xyz=(1.0, 0.0, 0.0))
>>> axis.to_xml()
<Element 'axis' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
CollisionLink
dataclass
¶
Represents the collision properties of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
origin |
Origin
|
The origin of the link. |
geometry |
BaseGeometry
|
The geometry of the link. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the collision properties to an XML element. |
Examples:
>>> collision = CollisionLink(origin=Origin(...), geometry=BoxGeometry(...))
>>> collision.to_xml()
<Element 'collision' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_xml(xml)
classmethod
¶
Create a collision link from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the collision link from. |
required |
Returns:
Type | Description |
---|---|
CollisionLink
|
The collision link created from the XML element. |
Examples:
>>> xml = ET.Element('collision')
>>> CollisionLink.from_xml(xml)
CollisionLink(name='collision', origin=None, geometry=None)
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
to_mjcf(root)
¶
Convert the collision properties to an MuJoCo compatible XML element.
Example XML:
<geom name="Assembly-2-1-SUB-Part-5-1-collision"
pos="0.0994445 -0.000366963 0.0171076"
quat="-0.92388 -4.28774e-08 0.382683 0"
type="mesh"
rgba="1 0.5 0 1"
mesh="Assembly-2-1-SUB-Part-5-1"
contype="1"
conaffinity="0"
density="0"
group="1"/>
Returns:
Type | Description |
---|---|
None
|
The XML element representing the collision properties. |
Examples:
>>> collision = CollisionLink(origin=Origin(...), geometry=BoxGeometry(...))
>>> collision.to_mjcf()
<Element 'collision' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
to_xml(root=None)
¶
Convert the collision properties to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the collision properties to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the collision properties. |
Examples:
>>> collision = CollisionLink(origin=Origin(...), geometry=BoxGeometry(...))
>>> collision.to_xml()
<Element 'collision' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 |
|
transform(transformation_matrix)
¶
Apply a transformation to the visual link's origin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformation_matrix
|
ndarray
|
A 4x4 transformation matrix (homogeneous). |
required |
Source code in onshape_robotics_toolkit\models\link.py
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 |
|
Colors
¶
Bases: tuple[float, float, float]
, Enum
Enumerates the possible colors in RGBA format for a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
RED |
tuple[float, float, float]
|
Color red. |
GREEN |
tuple[float, float, float]
|
Color green. |
BLUE |
tuple[float, float, float]
|
Color blue. |
YELLOW |
tuple[float, float, float]
|
Color yellow. |
CYAN |
tuple[float, float, float]
|
Color cyan. |
MAGENTA |
tuple[float, float, float]
|
Color magenta. |
WHITE |
tuple[float, float, float]
|
Color white. |
BLACK |
tuple[float, float, float]
|
Color black. |
ORANGE |
tuple[float, float, float]
|
Color orange. |
PINK |
tuple[float, float, float]
|
Color pink. |
Examples:
>>> Colors.RED
<Colors.RED: (1.0, 0.0, 0.0)>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
Inertia
dataclass
¶
Represents the inertia tensor of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
ixx |
float
|
The inertia tensor element Ixx. |
iyy |
float
|
The inertia tensor element Iyy. |
izz |
float
|
The inertia tensor element Izz. |
ixy |
float
|
The inertia tensor element Ixy. |
ixz |
float
|
The inertia tensor element Ixz. |
iyz |
float
|
The inertia tensor element Iyz. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the inertia tensor to an XML element. |
Examples:
>>> inertia = Inertia(ixx=1.0, iyy=2.0, izz=3.0, ixy=0.0, ixz=0.0, iyz=0.0)
>>> inertia.to_xml()
<Element 'inertia' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_xml(xml)
classmethod
¶
Create an inertia tensor from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the inertia tensor from. |
required |
Returns:
Type | Description |
---|---|
Inertia
|
The inertia tensor created from the XML element. |
Examples:
>>> xml = ET.Element('inertia')
>>> Inertia.from_xml(xml)
Inertia(ixx=0.0, iyy=0.0, izz=0.0, ixy=0.0, ixz=0.0, iyz=0.0)
Source code in onshape_robotics_toolkit\models\link.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 |
|
to_mjcf(root)
¶
Convert the inertia tensor to an MuJoCo compatible XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Element
|
The root element to append the inertia tensor to. |
required |
Returns:
Type | Description |
---|---|
None
|
The XML element representing the inertia tensor. |
Examples:
>>> inertia = Inertia(ixx=1.0, iyy=2.0, izz=3.0, ixy=0.0, ixz=0.0, iyz=0.0)
>>> inertia.to_mjcf()
<Element 'inertia' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
|
to_xml(root=None)
¶
Convert the inertia tensor to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the inertia tensor to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the inertia tensor. |
Examples:
>>> inertia = Inertia(ixx=1.0, iyy=2.0, izz=3.0, ixy=0.0, ixz=0.0, iyz=0.0)
>>> inertia.to_xml()
<Element 'inertia' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
|
zero_inertia()
classmethod
¶
Create an inertia tensor with zero values.
Returns:
Type | Description |
---|---|
Inertia
|
The inertia tensor with zero values. |
Examples:
>>> Inertia.zero_inertia()
Inertia(ixx=0.0, iyy=0.0, izz=0.0, ixy=0.0, ixz=0.0, iyz=0.0)
Source code in onshape_robotics_toolkit\models\link.py
417 418 419 420 421 422 423 424 425 426 427 428 429 |
|
InertialLink
dataclass
¶
Represents the inertial properties of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
mass |
float
|
The mass of the link. |
inertia |
Inertia
|
The inertia properties of the link. |
origin |
Origin
|
The origin of the link. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the inertial properties to an XML element. |
Examples:
>>> inertial = InertialLink(mass=1.0, inertia=Inertia(...), origin=Origin(...))
>>> inertial.to_xml()
<Element 'inertial' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_xml(xml)
classmethod
¶
Create inertial properties from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the inertial properties from. |
required |
Returns:
Type | Description |
---|---|
InertialLink
|
The inertial properties created from the XML element. |
Examples:
>>> xml = ET.Element('inertial')
>>> InertialLink.from_xml(xml)
InertialLink(mass=0.0, inertia=None, origin=None)
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
to_mjcf(root)
¶
Convert the inertial properties to an MuJoCo compatible XML element.
Example XML:
<inertial pos="0 0 -0.0075" euler="0.5 0.5 -0.5" mass="0.624"
diaginertia="0.073541512 0.07356916 0.073543931" />
Source code in onshape_robotics_toolkit\models\link.py
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
|
to_xml(root=None)
¶
Convert the inertial properties to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the inertial properties to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the inertial properties. |
Examples:
>>> inertial = InertialLink(mass=1.0, inertia=Inertia(...), origin=Origin(...))
>>> inertial.to_xml()
<Element 'inertial' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 |
|
Link
dataclass
¶
Represents a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the link. |
visual |
VisualLink
|
The visual properties of the link. |
collision |
CollisionLink
|
The collision properties of the link. |
inertial |
InertialLink
|
The inertial properties of the link. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the link to an XML element. |
Class Methods
from_xml: Creates a link from an XML element.
Examples:
>>> link = Link(name="link", visual=VisualLink(...), collision=CollisionLink(...), inertial=InertialLink(...))
>>> link.to_xml()
<Element 'link' at 0x7f8b3c0b4c70>
>>> part = Part(...)
>>> Link.from_part(part)
Link(name='partId', visual=None, collision=None, inertial=None)
Source code in onshape_robotics_toolkit\models\link.py
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 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
|
from_xml(xml)
classmethod
¶
Create a link from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the link from. |
required |
Returns:
Type | Description |
---|---|
Link
|
The link created from the XML element. |
Examples:
>>> xml = ET.Element('link')
>>> Link.from_xml(xml)
Link(name='link', visual=None, collision=None, inertial=None)
Source code in onshape_robotics_toolkit\models\link.py
995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 |
|
to_mjcf(root=None)
¶
Convert the link to an MuJoCo compatible XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the link to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the link. |
Examples:
>>> link = Link(
... name="link",
... visual=VisualLink(...),
... collision=CollisionLink(...),
... inertial=InertialLink(...),
... )
>>> link.to_mjcf()
<Element 'link' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
to_xml(root=None)
¶
Convert the link to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the link to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the link. |
Examples:
>>> link = Link(
... name="link",
... visual=VisualLink(...),
... collision=CollisionLink(...),
... inertial=InertialLink(...),
... )
>>> link.to_xml()
<Element 'link' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
Material
dataclass
¶
Represents the material properties of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the material. |
color |
tuple[float, float, float, float]
|
The color of the material in RGBA format. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the material properties to an XML element. |
Class Methods
from_color: Creates a material from a color.
Examples:
>>> material = Material(name="material", color=(1.0, 0.0, 0.0, 1.0))
>>> material.to_xml()
<Element 'material' at 0x7f8b3c0b4c70>
>>> Material.from_color(name="material", color=Colors.RED)
Material(name='material', color=(1.0, 0.0, 0.0, 1.0))
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_color(name, color)
classmethod
¶
Create a material from a color.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the material. |
required |
color
|
Colors
|
The color of the material. |
required |
Returns:
Type | Description |
---|---|
Material
|
The material created from the color. |
Examples:
>>> Material.from_color(name="material", color=Colors.RED)
Material(name='material', color=(1.0, 0.0, 0.0, 1.0))
Source code in onshape_robotics_toolkit\models\link.py
519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
|
from_xml(xml)
classmethod
¶
Create a material from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the material from. |
required |
Returns:
Type | Description |
---|---|
Material
|
The material created from the XML element. |
Examples:
>>> xml = ET.Element('material')
>>> Material.from_xml(xml)
Material(name='material', color=(1.0, 0.0, 0.0, 1.0))
Source code in onshape_robotics_toolkit\models\link.py
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 |
|
to_mjcf(root)
¶
Convert the material properties to an MuJoCo compatible XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Element
|
The root element to append the material properties to. |
required |
Returns:
Type | Description |
---|---|
None
|
The XML element representing the material properties. |
Examples:
>>> material = Material(name="material", color=(1.0, 0.0, 0.0, 1.0))
>>> material.to_mjcf()
<Element 'material' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 |
|
to_xml(root=None)
¶
Convert the material properties to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the material properties to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the material properties. |
Examples:
>>> material = Material(name="material", color=(1.0, 0.0, 0.0, 1.0))
>>> material.to_xml()
<Element 'material' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
Origin
dataclass
¶
Represents the origin of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
xyz |
tuple[float, float, float]
|
The x, y, z coordinates of the origin. |
rpy |
tuple[float, float, float]
|
The roll, pitch, yaw angles of the origin. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the origin to an XML element. |
Class Methods
from_matrix: Creates an origin from a transformation matrix. zero_origin: Creates an origin at the origin (0, 0, 0) with no rotation.
Examples:
>>> origin = Origin(xyz=(1.0, 2.0, 3.0), rpy=(0.0, 0.0, 0.0))
>>> origin.to_xml()
<Element 'origin' at 0x7f8b3c0b4c70>
>>> matrix = np.matrix([
... [1, 0, 0, 0],
... [0, 1, 0, 0],
... [0, 0, 1, 0],
... [0, 0, 0, 1],
... ])
>>> Origin.from_matrix(matrix)
Origin(xyz=(0.0, 0.0, 0.0), rpy=(0.0, 0.0, 0.0))
>>> Origin.zero_origin()
Origin(xyz=(0.0, 0.0, 0.0), rpy=(0.0, 0.0, 0.0))
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_matrix(matrix)
classmethod
¶
Create an origin from a transformation matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
matrix
|
The transformation matrix. |
required |
Returns:
Type | Description |
---|---|
Origin
|
The origin created from the transformation matrix. |
Examples:
>>> matrix = np.matrix([
... [1, 0, 0, 0],
... [0, 1, 0, 0],
... [0, 0, 1, 0],
... [0, 0, 0, 1],
... ])
>>> Origin.from_matrix(matrix)
Origin(xyz=(0.0, 0.0, 0.0), rpy=(0.0, 0.0, 0.0))
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_xml(xml)
classmethod
¶
Create an origin from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the origin from. |
required |
Returns:
Type | Description |
---|---|
Origin
|
The origin created from the XML element. |
Examples:
>>> xml = ET.Element('origin')
>>> Origin.from_xml(xml)
Origin(xyz=(0.0, 0.0, 0.0), rpy=(0.0, 0.0, 0.0))
Source code in onshape_robotics_toolkit\models\link.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
|
quat(sequence='xyz')
¶
Convert the origin to a quaternion.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sequence
|
str
|
The sequence of the Euler angles. |
'xyz'
|
Returns:
Type | Description |
---|---|
str
|
The quaternion representing the origin. |
Source code in onshape_robotics_toolkit\models\link.py
189 190 191 192 193 194 195 196 197 198 199 |
|
to_mjcf(root)
¶
Convert the origin to an MuJoCo compatible XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Element
|
The root element to append the origin to. |
required |
Returns:
Type | Description |
---|---|
None
|
The XML element representing the origin. |
Examples:
>>> origin = Origin(xyz=(1.0, 2.0, 3.0), rpy=(0.0, 0.0, 0.0))
>>> origin.to_mjcf()
<Element 'origin' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
to_xml(root=None)
¶
Convert the origin to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the origin to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the origin. |
Examples:
>>> origin = Origin(xyz=(1.0, 2.0, 3.0), rpy=(0.0, 0.0, 0.0))
>>> origin.to_xml()
<Element 'origin' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
transform(matrix, inplace=False)
¶
Apply a transformation matrix to the origin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix
|
matrix
|
The transformation matrix to apply to the origin. |
required |
inplace
|
bool
|
Whether to apply the transformation in place. |
False
|
Returns:
Type | Description |
---|---|
Union[Origin, None]
|
The origin with the transformation applied. |
Examples:
>>> origin = Origin(xyz=(1.0, 2.0, 3.0), rpy=(0.0, 0.0, 0.0))
>>> matrix = np.eye(4)
>>> origin.transform(matrix)
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
zero_origin()
classmethod
¶
Create an origin at the origin (0, 0, 0) with no rotation.
Returns:
Type | Description |
---|---|
Origin
|
The origin at the origin (0, 0, 0) with no rotation. |
Examples:
>>> Origin.zero_origin()
Origin(xyz=(0.0, 0.0, 0.0), rpy=(0.0, 0.0, 0.0))
Source code in onshape_robotics_toolkit\models\link.py
229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
|
VisualLink
dataclass
¶
Represents the visual properties of a link in the robot model.
Attributes:
Name | Type | Description |
---|---|---|
origin |
Origin
|
The origin of the link. |
geometry |
BaseGeometry
|
The geometry of the link. |
material |
Material
|
The material properties of the link. |
Methods:
Name | Description |
---|---|
to_xml |
Converts the visual properties to an XML element. |
Examples:
>>> visual = VisualLink(origin=Origin(...), geometry=BoxGeometry(...), material=Material(...))
>>> visual.to_xml()
<Element 'visual' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
from_xml(xml)
classmethod
¶
Create a visual link from an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xml
|
Element
|
The XML element to create the visual link from. |
required |
Returns:
Type | Description |
---|---|
VisualLink
|
The visual link created from the XML element. |
Examples:
>>> xml = ET.Element('visual')
>>> VisualLink.from_xml(xml)
VisualLink(name='visual', origin=None, geometry=None, material=None)
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
to_mjcf(root)
¶
Convert the visual properties to an MuJoCo compatible XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Element
|
The root element to append the visual properties to. |
required |
Returns:
Type | Description |
---|---|
None
|
The XML element representing the visual properties. |
Examples:
>>> visual = VisualLink(origin=Origin(...), geometry=BoxGeometry(...), material=Material(...))
>>> visual.to_mjcf()
<Element 'visual' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
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 |
|
to_xml(root=None)
¶
Convert the visual properties to an XML element.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root
|
Optional[Element]
|
The root element to append the visual properties to. |
None
|
Returns:
Type | Description |
---|---|
Element
|
The XML element representing the visual properties. |
Examples:
>>> visual = VisualLink(origin=Origin(...), geometry=BoxGeometry(...), material=Material(...))
>>> visual.to_xml()
<Element 'visual' at 0x7f8b3c0b4c70>
Source code in onshape_robotics_toolkit\models\link.py
681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
|
transform(transformation_matrix)
¶
Apply a transformation to the visual link's origin.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
transformation_matrix
|
ndarray
|
A 4x4 transformation matrix (homogeneous). |
required |
Source code in onshape_robotics_toolkit\models\link.py
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
|