macro_particle_system
MacroParticleSystem
Bases: BaseSystem
Global system for modeling "macro" level particles, e.g.: dirt, dust, etc.
Source code in omnigibson/systems/macro_particle_system.py
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 |
|
add_particle(prim_path, idn=None, scale=None, position=None, orientation=None)
classmethod
Adds a particle to this system.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prim_path |
str
|
Absolute path to the newly created particle, minus the name for this particle |
required |
idn |
None or int
|
If specified, should be unique identifier to assign to this particle. If not, will automatically generate a new unique one |
None
|
scale |
None or 3-array
|
Relative (x,y,z) scale of the particle, if any. If not specified, will automatically be sampled based on cls.min_scale and cls.max_scale |
None
|
position |
None or 3-array
|
Global (x,y,z) position to set this particle to, if any |
None
|
orientation |
None or 4-array
|
Global (x,y,z,w) quaternion orientation to set this particle to, if any |
None
|
Returns:
Name | Type | Description |
---|---|---|
XFormPrim | Newly created particle instance, which is added internally as well |
Source code in omnigibson/systems/macro_particle_system.py
n_particles()
next_available_particle_idn()
Returns:
Name | Type | Description |
---|---|---|
int | the next available particle idn across all groups. |
Source code in omnigibson/systems/macro_particle_system.py
particle_idn2name(idn)
classmethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
idn |
int
|
Unique ID number assigned to the particle to grab the name for |
required |
Returns:
Name | Type | Description |
---|---|---|
str | Particle name corresponding to its unique id number |
Source code in omnigibson/systems/macro_particle_system.py
particle_idns()
Returns:
Name | Type | Description |
---|---|---|
set | idn of all the particles across all groups. |
particle_name2idn(name)
classmethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Particle name to grab its corresponding unique id number for |
required |
Returns:
Name | Type | Description |
---|---|---|
int | Unique ID assigned to the particle based on its name |
Source code in omnigibson/systems/macro_particle_system.py
particle_name_prefix()
Returns:
Name | Type | Description |
---|---|---|
str | Naming prefix used for all generated particles. This is coupled with the unique particle ID to generate the full particle name |
Source code in omnigibson/systems/macro_particle_system.py
remove_all_particles()
classmethod
Removes all particles and deletes them from the simulator
Source code in omnigibson/systems/macro_particle_system.py
remove_particle(name)
classmethod
Remove particle with name @name from both the simulator as well as internally
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the particle to remove |
required |
Source code in omnigibson/systems/macro_particle_system.py
set_particle_template_object(obj)
classmethod
Sets the template particle object that will be used for duplication purposes. Note that this automatically adds @obj itself to the ongoing array of particles!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
BasePrim
|
Object to serve as template |
required |
Source code in omnigibson/systems/macro_particle_system.py
set_scale_limits(minimum=None, maximum=None)
classmethod
Set the min and / or max scaling limits that will be uniformly sampled from when generating new particles
Parameters:
Name | Type | Description | Default |
---|---|---|---|
minimum |
None or 3-array
|
If specified, should be (x,y,z) minimum scaling factor to apply to generated particles |
None
|
maximum |
None or 3-array
|
If specified, should be (x,y,z) maximum scaling factor to apply to generated particles |
None
|
Source code in omnigibson/systems/macro_particle_system.py
VisualParticleSystem
Bases: MacroParticleSystem
Particle system class that additionally includes sampling utilities for placing particles on specific objects
Source code in omnigibson/systems/macro_particle_system.py
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 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 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 |
|
create(name, create_particle_template, min_scale=None, max_scale=None, **kwargs)
classmethod
Utility function to programmatically generate monolithic visual particle system classes.
Note: If using super() calls in any functions, we have to use slightly esoteric syntax in order to
accommodate this procedural method for using super calls
cf. https://stackoverflow.com/questions/22403897/what-does-it-mean-by-the-super-object-returned-is-unbound-in-python
Use: super(cls).get(cls).
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 the visual particles' relative scale. Else, defaults to 1 |
None
|
max_scale |
None or 3-array
|
If specified, sets the maximum bound for the visual particles' relative scale. Else, defaults to 1 |
None
|
create_particle_template |
function
|
Method for generating the visual particle template that will be duplicated when generating groups of particles. Expected signature: create_particle_template(prim_path: str, name: str) --> EntityPrim where @prim_path and @name are the parameters to assign to the generated EntityPrim. NOTE: The loaded particle template is expected to be a non-articulated, single-link object with a single visual mesh attached to its root link, since this will be the actual visual mesh used |
required |
**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 |
---|---|---|
VisualParticleSystem | Generated visual particle system class |
Source code in omnigibson/systems/macro_particle_system.py
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/macro_particle_system.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 |
np.array
|
(n_particles, 3) shaped array specifying per-particle (x,y,z) positions |
required |
orientations |
None or np.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 np.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 root link |
None
|
Source code in omnigibson/systems/macro_particle_system.py
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 |
|
generate_group_particles_on_object(group, max_samples, 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 |
int
|
Maximum number of particles to sample |
required |
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/macro_particle_system.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/macro_particle_system.py
get_particle_position_orientation(name)
classmethod
Compute particle's global 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 |
---|---|---|---|
name |
str
|
Name of the particle to compute global position and orientation for |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: (x,y,z) position in the world frame - 4-array: (x,y,z,w) quaternion orientation in the world frame |
Source code in omnigibson/systems/macro_particle_system.py
get_particles_position_orientation()
classmethod
Computes all particles' global positions and orientations that belong to this system
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 in the world frame - (n, 4)-array: per-particle (x,y,z,w) quaternion orientation in the world frame |
Source code in omnigibson/systems/macro_particle_system.py
groups()
Returns:
Type | Description |
---|---|
set of str: Current attachment particle group names |
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/macro_particle_system.py
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/macro_particle_system.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/macro_particle_system.py
remove_particle(name)
classmethod
Remove particle with name @name from both the simulator and internal state
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the particle to remove |
required |
Source code in omnigibson/systems/macro_particle_system.py
sample_scales(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/macro_particle_system.py
update_particle_scaling(group)
classmethod
Update particle scaling for group @group before generating group particles. Default is a no-op (i.e.: returns the current cls.min_scale, cls.max_scale)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
group |
str
|
Specific group for which to modify the particle scaling |
required |
Returns:
Type | Description |
---|---|
2-tuple: - 3-array: min scaling factor to set - 3-array: max scaling factor to set |