system_base
BaseSystem
Bases: SerializableNonInstance
, UniquelyNamedNonInstance
Base class for all systems. These are non-instance objects that should be used globally for a given environment. This is useful for items in a scene that are non-discrete / cannot be distinguished into individual instances, e.g.: water, particles, etc. While we keep the python convention of the system class name being camel case (e.g. StrawberrySmoothie), we adopt the snake case for the system registry to unify with the category of BaseObject. For example, get_system("strawberry_smoothie") will return the StrawberrySmoothie class.
Source code in omnigibson/systems/system_base.py
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 |
|
clear()
classmethod
Clears this system, so that it may possibly be re-initialized. Useful for, e.g., when loading from a new scene during the same sim instance
create(name, min_scale=None, max_scale=None, **kwargs)
classmethod
Helper function to programmatically generate systems
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the visual particles, in snake case. |
required |
min_scale |
None or 3 - array
|
If specified, sets the minumum bound for particles' relative scale. Else, defaults to 1 |
None
|
max_scale |
None or 3 - array
|
If specified, sets the maximum bound for particles' relative scale. Else, defaults to 1 |
None
|
**kwargs |
any
|
keyword-mapped parameters to override / set in the child class, where the keys represent the class attribute to modify and the values represent the functions / value to set (Note: These values should have either @classproperty or @classmethod decorators!) |
{}
|
Returns:
Name | Type | Description |
---|---|---|
BaseSystem |
Generated system class given input arguments |
Source code in omnigibson/systems/system_base.py
generate_particles(positions, orientations=None, scales=None, **kwargs)
classmethod
Generates new particles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
positions |
array
|
(n_particles, 3) shaped array specifying per-particle (x,y,z) positions |
required |
orientations |
None or array
|
(n_particles, 4) shaped array specifying per-particle (x,y,z,w) quaternion orientations. If not specified, all will be set to canonical orientation (0, 0, 0, 1) |
None
|
scales |
None or array
|
(n_particles, 3) shaped array specifying per-particle (x,y,z) scales. If not specified, will be uniformly randomly sampled from (cls.min_scale, cls.max_scale) |
None
|
**kwargs |
dict
|
Any additional keyword-specific arguments required by subclass implementation |
{}
|
Source code in omnigibson/systems/system_base.py
get_active_systems()
classmethod
Returns:
Name | Type | Description |
---|---|---|
dict |
Mapping from system name to system for all systems that are subclasses of this system AND active (initialized) |
Source code in omnigibson/systems/system_base.py
get_particle_local_pose(idx)
classmethod
Compute particle's position and orientation in the particle's parent frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
int
|
Index of the particle to compute position and orientation for. Note: this is equivalent to grabbing the corresponding idx'th entry from @get_particles_local_pose() |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: (x,y,z) position - 4-array: (x,y,z,w) quaternion orientation |
Source code in omnigibson/systems/system_base.py
get_particle_position_orientation(idx)
classmethod
Compute particle's position and orientation. This automatically takes into account the relative pose w.r.t. its parent link and the global pose of that parent link.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
int
|
Index of the particle to compute position and orientation for. Note: this is equivalent to grabbing the corresponding idx'th entry from @get_particles_position_orientation() |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: (x,y,z) position - 4-array: (x,y,z,w) quaternion orientation |
Source code in omnigibson/systems/system_base.py
get_particles_local_pose()
classmethod
Computes all particles' positions and orientations that belong to this system in the particles' parent frames
Returns:
Type | Description |
---|---|
2-tuple: - (n, 3)-array: per-particle (x,y,z) position - (n, 4)-array: per-particle (x,y,z,w) quaternion orientation |
Source code in omnigibson/systems/system_base.py
get_particles_position_orientation()
classmethod
Computes all particles' positions and orientations that belong to this system in the world frame
Note: This is more optimized than doing a for loop with self.get_particle_position_orientation()
Returns:
Type | Description |
---|---|
2-tuple: - (n, 3)-array: per-particle (x,y,z) position - (n, 4)-array: per-particle (x,y,z,w) quaternion orientation |
Source code in omnigibson/systems/system_base.py
initialize()
classmethod
Initializes this system
Source code in omnigibson/systems/system_base.py
material()
Returns:
Type | Description |
---|---|
None or MaterialPrim: Material belonging to this system, if there is any |
n_particles()
prim_path()
remove_all_particles()
classmethod
remove_particles(idxs, **kwargs)
classmethod
Removes pre-existing particles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idxs |
array
|
(n_particles,) shaped array specifying IDs of particles to delete |
required |
**kwargs |
dict
|
Any additional keyword-specific arguments required by subclass implementation |
{}
|
Source code in omnigibson/systems/system_base.py
reset()
classmethod
sample_scales(n)
classmethod
Samples scales uniformly based on @cls.min_scale and @cls.max_scale
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Number of scales to sample |
required |
Returns:
Type | Description |
---|---|
(n, 3) array: Array of sampled scales |
Source code in omnigibson/systems/system_base.py
set_particle_local_pose(idx, position=None, orientation=None)
classmethod
Sets particle's position and orientation in the particle's parent frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
int
|
Index of the particle to set position and orientation for. Note: this is equivalent to setting the corresponding idx'th entry from @set_particles_local_pose() |
required |
position |
3 - array
|
particle (x,y,z) position |
None
|
orientation |
4 - array
|
particle (x,y,z,w) quaternion orientation |
None
|
Source code in omnigibson/systems/system_base.py
set_particle_position_orientation(idx, position=None, orientation=None)
classmethod
Sets particle's position and orientation. This automatically takes into account the relative pose w.r.t. its parent link and the global pose of that parent link.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idx |
int
|
Index of the particle to set position and orientation for. Note: this is equivalent to setting the corresponding idx'th entry from @set_particles_position_orientation() |
required |
position |
3 - array
|
particle (x,y,z) position |
None
|
orientation |
4 - array
|
particle (x,y,z,w) quaternion orientation |
None
|
Source code in omnigibson/systems/system_base.py
set_particles_local_pose(positions=None, orientations=None)
classmethod
Sets all particles' positions and orientations that belong to this system in the particles' parent frames
Parameters:
Name | Type | Description | Default |
---|---|---|---|
positions |
n - array
|
(n, 3) per-particle (x,y,z) position |
None
|
orientations |
n - array
|
(n, 4) per-particle (x,y,z,w) quaternion orientation |
None
|
Source code in omnigibson/systems/system_base.py
set_particles_position_orientation(positions=None, orientations=None)
classmethod
Sets all particles' positions and orientations that belong to this system in the world frame
Note: This is more optimized than doing a for loop with self.set_particle_position_orientation()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
positions |
n - array
|
(n, 3) per-particle (x,y,z) position |
None
|
orientations |
n - array
|
(n, 4) per-particle (x,y,z,w) quaternion orientation |
None
|
Source code in omnigibson/systems/system_base.py
update()
classmethod
PhysicalParticleSystem
Bases: BaseSystem
System whose generated particles are subject to physics
Source code in omnigibson/systems/system_base.py
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 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 |
|
check_in_contact(positions)
classmethod
Checks whether each particle specified by @particle_positions are in contact with any rigid body.
NOTE: This is a rough proxy for contact, given @positions. Should not be taken as ground truth. This is because for efficiency and underlying physics reasons, it's easier to treat particles as spheres for fast checking. For particles directly spawned from Omniverse's underlying ParticleSystem API, it is a rough proxy semantically, though it is accurate in sim-physics since all spawned particles interact as spheres. For particles spawned manually as rigid bodies, it is a rough proxy both semantically and physically, as the object physically interacts with its non-uniform geometry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
positions |
array
|
(n_particles, 3) shaped array specifying per-particle (x,y,z) positions |
required |
Returns:
Type | Description |
---|---|
n-array: (n_particles,) boolean array, True if in contact, otherwise False |
Source code in omnigibson/systems/system_base.py
generate_particles_from_link(obj, link, use_visual_meshes=True, mesh_name_prefixes=None, check_contact=True, sampling_distance=None, max_samples=None, **kwargs)
classmethod
Generates a new particle instancer with unique identification number @idn, with particles sampled from the mesh located at @mesh_prim_path, and registers it internally. This will also check for collision with other rigid objects before spawning in individual particles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
EntityPrim
|
Object whose @link's visual meshes will be converted into sampled particles |
required |
link |
RigidPrim
|
@obj's link whose visual meshes will be converted into sampled particles |
required |
use_visual_meshes |
bool
|
Whether to use visual meshes of the link to generate particles |
True
|
mesh_name_prefixes |
None or str
|
If specified, specifies the substring that must exist in @link's mesh names in order for that mesh to be included in the particle generator function. If None, no filtering will be used. |
None
|
check_contact |
bool
|
If True, will only spawn in particles that do not collide with other rigid bodies |
True
|
sampling_distance |
None or float
|
If specified, sets the distance between sampled particles. If None, a simulator autocomputed value will be used |
None
|
max_samples |
None or int
|
If specified, maximum number of particles to sample |
None
|
**kwargs |
dict
|
Any additional keyword-mapped arguments required by subclass implementation |
{}
|
Source code in omnigibson/systems/system_base.py
generate_particles_on_object(obj, sampling_distance=None, max_samples=None, min_samples_for_success=1, **kwargs)
classmethod
Generates @n_particles new particle objects and samples their locations on the top surface of object @obj
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
BaseObject
|
Object on which to generate a particle instancer with sampled particles on the object's top surface |
required |
sampling_distance |
None or float
|
If specified, sets the distance between sampled particles. If None, a simulator autocomputed value will be used |
None
|
max_samples |
None or int
|
If specified, maximum number of particles to sample |
None
|
min_samples_for_success |
int
|
Minimum number of particles required to be sampled successfully in order for this generation process to be considered successful |
1
|
**kwargs |
dict
|
Any additional keyword-mapped arguments required by subclass implementation |
{}
|
Returns:
Name | Type | Description |
---|---|---|
bool |
True if enough particles were generated successfully (number of successfully sampled points >= min_samples_for_success), otherwise False |
Source code in omnigibson/systems/system_base.py
particle_contact_radius()
Returns:
Name | Type | Description |
---|---|---|
float |
Contact radius for the particles to be generated, for the purpose of estimating contacts |
particle_density()
particle_particle_rest_distance()
Returns:
Type | Description |
---|---|
The minimum distance between individual particles at rest |
particle_radius()
Returns:
Name | Type | Description |
---|---|---|
float |
Radius for the particles to be generated, for the purpose of sampling |
VisualParticleSystem
Bases: BaseSystem
Particle system class for generating particles not subject to physics, and are attached to individual objects
Source code in omnigibson/systems/system_base.py
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 |
|
create_attachment_group(obj)
classmethod
Creates an attachment group internally for object @obj. Note that this does NOT automatically generate particles for this object (should call generate_group_particles(...) ).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
BaseObject
|
Object for which a new particle attachment group will be created for |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Name of the attachment group to use when executing commands from this class on that specific attachment group |
Source code in omnigibson/systems/system_base.py
generate_group_particles(group, positions, orientations=None, scales=None, link_prim_paths=None)
classmethod
Generates new particle objects within group @group at the specified pose (@positions, @orientations) with corresponding scales @scales.
Assumes positions are the exact contact point on @group object's surface. If cls._CLIP_INTO_OBJECTS
is not True, then the positions will be offset away from the object by half of its bbox
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Object on which to sample particle locations |
required |
positions |
array
|
(n_particles, 3) shaped array specifying per-particle (x,y,z) positions |
required |
orientations |
None or array
|
(n_particles, 4) shaped array specifying per-particle (x,y,z,w) quaternion orientations. If not specified, all will be set to canonical orientation (0, 0, 0, 1) |
None
|
scales |
None or array
|
(n_particles, 3) shaped array specifying per-particle (x,y,z) scaling in its local frame. If not specified, all we randomly sampled based on @cls.min_scale and @cls.max_scale |
None
|
link_prim_paths |
None or list of str
|
Determines which link each generated particle will be attached to. If not specified, all will be attached to the group object's prim, NOT a link |
None
|
Source code in omnigibson/systems/system_base.py
generate_group_particles_on_object(group, max_samples=None, min_samples_for_success=1)
classmethod
Generates @max_samples new particle objects and samples their locations on the surface of object @obj. Note that if any particles are in the group already, they will be removed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Object on which to sample particle locations |
required |
max_samples |
None or int
|
If specified, maximum number of particles to sample |
None
|
min_samples_for_success |
int
|
Minimum number of particles required to be sampled successfully in order for this generation process to be considered successful |
1
|
Returns:
Name | Type | Description |
---|---|---|
bool |
True if enough particles were generated successfully (number of successfully sampled points >= min_samples_for_success), otherwise False |
Source code in omnigibson/systems/system_base.py
get_group_name(obj)
classmethod
Grabs the corresponding group name for object @obj
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
BaseObject
|
Object for which its procedurally generated particle attachment name should be grabbed |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Name of the attachment group to use when executing commands from this class on that specific attachment group |
Source code in omnigibson/systems/system_base.py
get_group_particles_local_pose(group)
classmethod
Computes all particles' positions and orientations that belong to @group in the particles' parent frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Group name whose particle positions and orientations should be computed |
required |
Returns:
Type | Description |
---|---|
2-tuple: - (n, 3)-array: per-particle (x,y,z) position - (n, 4)-array: per-particle (x,y,z,w) quaternion orientation |
Source code in omnigibson/systems/system_base.py
get_group_particles_position_orientation(group)
classmethod
Computes all particles' positions and orientations that belong to @group
Note: This is more optimized than doing a for loop with self.get_particle_position_orientation()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Group name whose particle positions and orientations should be computed |
required |
Returns:
Type | Description |
---|---|
2-tuple: - (n, 3)-array: per-particle (x,y,z) position - (n, 4)-array: per-particle (x,y,z,w) quaternion orientation |
Source code in omnigibson/systems/system_base.py
groups()
num_group_particles(group)
classmethod
Gets the number of particles for the given group in the simulator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Name of the attachment group to remove all particles from. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
Number of particles allocated to this group in the scene. Note that if @group does not exist, this will return 0 |
Source code in omnigibson/systems/system_base.py
particle_object()
Returns:
Name | Type | Description |
---|---|---|
XFormPrim |
Particle object to be used as a template for duplication |
remove_all_group_particles(group)
classmethod
Remove particle with name @name from both the simulator as well as internally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Name of the attachment group to remove all particles from |
required |
Source code in omnigibson/systems/system_base.py
remove_attachment_group(group)
classmethod
Removes an attachment group internally for object @obj. Note that this will automatically remove any particles currently assigned to that group
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Name of the attachment group to remove |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
Name of the attachment group to use when executing commands from this class on that specific attachment group |
Source code in omnigibson/systems/system_base.py
sample_scales_by_group(group, n)
classmethod
Samples @n particle scales for group @group.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Specific group for which to sample scales |
required |
n |
int
|
Number of scales to sample |
required |
Returns:
Type | Description |
---|---|
(n, 3) array: Array of sampled scales |
Source code in omnigibson/systems/system_base.py
scale_relative_to_parent()
Returns:
Name | Type | Description |
---|---|---|
bool |
Whether or not particles should be scaled relative to the group's parent object. NOTE: If True, this will OVERRIDE cls.min_scale and cls.max_scale when sampling particles! |
Source code in omnigibson/systems/system_base.py
set_group_particles_local_pose(group, positions=None, orientations=None)
classmethod
Sets all particles' positions and orientations that belong to @group in the particles' parent frame
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Group name whose particle positions and orientations should be computed |
required |
positions |
n - array
|
(n, 3) per-particle (x,y,z) position |
None
|
orientations |
n - array
|
(n, 4) per-particle (x,y,z,w) quaternion orientation |
None
|
Source code in omnigibson/systems/system_base.py
set_group_particles_position_orientation(group, positions=None, orientations=None)
classmethod
Sets all particles' positions and orientations that belong to @group
Note: This is more optimized than doing a for loop with self.set_particle_position_orientation()
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Group name whose particle positions and orientations should be computed |
required |
positions |
n - array
|
(n, 3) per-particle (x,y,z) position |
None
|
orientations |
n - array
|
(n, 4) per-particle (x,y,z,w) quaternion orientation |
None
|