sampling_utils
check_cuboid_empty(hit_normal, bottom_corner_positions, this_cuboid_dimensions, refusal_log)
Check whether the cuboid defined by @this_cuboid_dimensions and @bottom_corner_positions contains empty space or not
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hit_normal |
3 - array
|
(x,y,z) normal |
required |
bottom_corner_positions |
4, 3)-array
|
the positions defining the bottom corners of the cuboid being sampled |
required |
this_cuboid_dimensions |
3 - array
|
(x,y,z) size of the sampled cuboid |
required |
refusal_log |
list of str
|
Logging array for adding debug logs |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the cuboid is empty, else False |
Source code in omnigibson/utils/sampling_utils.py
check_distance_to_plane(points, plane_centroid, plane_normal, hit_to_plane_threshold, refusal_log)
Calculates whether points are within @hit_to_plane_threshold distance to plane defined by @plane_centroid and @plane_normal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points |
k, 3)-array
|
th.tensor of shape (k, 3) |
required |
plane_centroid |
3 - array
|
(x,y,z) points' centroid |
required |
plane_normal |
3 - array
|
(x,y,z) normal of the fitted plane |
required |
hit_to_plane_threshold |
float
|
Threshold distance to check between @points and plane |
required |
refusal_log |
dict
|
Debugging dictionary to add error messages to |
required |
Returns:
Type | Description |
---|---|
bool
|
True if all points are within @hit_to_plane_threshold distance to plane, otherwise False |
Source code in omnigibson/utils/sampling_utils.py
check_hit_max_angle_from_z_axis(hit_normal, max_angle_with_z_axis, refusal_log)
Check whether the normal @hit_normal deviates from the global z axis by more than @max_angle_with_z_axis
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hit_normal |
3 - array
|
Normal vector to check with respect to global z-axis |
required |
max_angle_with_z_axis |
float
|
Maximum acceptable angle between the global z-axis and @hit_normal |
required |
refusal_log |
list of str
|
Logging array for adding debug logs |
required |
Returns:
Type | Description |
---|---|
bool
|
True if the angle between @hit_normal and the global z-axis is less than @max_angle_with_z_axis, otherwise False |
Source code in omnigibson/utils/sampling_utils.py
check_normal_similarity(center_hit_normal, hit_normals, tolerance, refusal_log)
Check whether the normals from @hit_normals are within some @tolerance of @center_hit_normal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
center_hit_normal |
3 - array
|
normal of the center hit point |
required |
hit_normals |
n, 3)-array
|
normals of all the hit points |
required |
tolerance |
float
|
Acceptable deviation between the center hit normal and all normals |
required |
refusal_log |
dict
|
Dictionary to write debugging and log information to |
required |
Returns:
Type | Description |
---|---|
bool
|
Whether the normal similarity is acceptable or not |
Source code in omnigibson/utils/sampling_utils.py
check_rays_hit_object(cast_results, threshold, refusal_log, body_names=None)
Checks whether rays hit a specific object, as specified by a list of @body_names
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cast_results |
list of dict
|
Output from raycast_batch. |
required |
threshold |
float
|
Relative ratio in [0, 1] specifying proportion of rays from @cast_results are required to hit @body_names to count as the object being hit |
required |
refusal_log |
list of str
|
Logging array for adding debug logs |
required |
body_names |
None or list or set of str
|
absolute USD paths to rigid bodies to check for hit. If not specified, then any valid hit will be accepted |
None
|
Returns:
Type | Description |
---|---|
None or list of bool
|
Individual T/F for each ray -- whether it hit the object or not |
Source code in omnigibson/utils/sampling_utils.py
compute_ray_destination(axis, is_top, start_pos, aabb_min, aabb_max)
Compute the point on the AABB defined by @aabb_min and @aabb_max from shooting a ray at @start_pos in the direction defined by global axis @axis and @is_top
Parameters:
Name | Type | Description | Default |
---|---|---|---|
axis |
int
|
Which direction to compute the ray destination. Valid options are {0, 1, 2} -- the x, y, or z axes |
required |
is_top |
bool
|
Whether to shoot in the positive or negative @axis direction |
required |
aabb_min |
3 - array
|
(x,y,z) position defining the lower corner of the AABB |
required |
aabb_max |
3 - array
|
(x,y,z) position defining the upper corner of the AABB |
required |
Returns:
Type | Description |
---|---|
3 - array
|
computed (x,y,z) point on the AABB surface |
Source code in omnigibson/utils/sampling_utils.py
compute_rotation_from_grid_sample(two_d_grid, projected_hits, cuboid_centroid, this_cuboid_dimensions, hits, refusal_log)
Computes
Parameters:
Name | Type | Description | Default |
---|---|---|---|
two_d_grid |
(n, 2)
|
(x,y) raycast origin points in the local plane frame |
required |
projected_hits |
k,3)-array
|
Points' positions projected onto the plane generated |
required |
cuboid_centroid |
3 - array
|
(x,y,z) sampled position of the hit cuboid centroid in the global frame |
required |
this_cuboid_dimensions |
3 - array
|
(x,y,z) size of cuboid being sampled from the grid |
required |
hits |
list of bool
|
whether each point from @two_d_grid is a valid hit or not |
required |
refusal_log |
dict
|
Dictionary to write debugging and log information to |
required |
Returns:
Type | Description |
---|---|
None or Rotation
|
If successfully hit, returns relative rotation from two_d_grid to generated hit plane. Otherwise, returns None |
Source code in omnigibson/utils/sampling_utils.py
draw_debug_markers(hit_positions, radius=0.01)
Helper method to generate and place debug markers at @hit_positions
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hit_positions |
n, 3)-array
|
Desired positions to place markers at |
required |
radius |
float
|
Radius of the generated virtual marker |
0.01
|
Source code in omnigibson/utils/sampling_utils.py
fit_plane(points, refusal_log)
Fits a plane to the given 3D points. Copied from https://stackoverflow.com/a/18968498
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points |
k, 3)-array
|
th.tensor of shape (k, 3) |
required |
refusal_log |
dict
|
Debugging dictionary to add error messages to |
required |
Returns:
Type | Description |
---|---|
2 - tuple
|
|
Source code in omnigibson/utils/sampling_utils.py
get_distance_to_plane(points, plane_centroid, plane_normal)
Computes distance from @points to plane defined by @plane_centroid and @plane_normal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points |
k, 3)-array
|
th.tensor of shape (k, 3) |
required |
plane_centroid |
3 - array
|
(x,y,z) points' centroid |
required |
plane_normal |
3 - array
|
(x,y,z) normal of the fitted plane |
required |
Returns:
Type | Description |
---|---|
k - array
|
Absolute distances from each point to the plane |
Source code in omnigibson/utils/sampling_utils.py
get_parallel_rays(source, destination, offset, new_ray_per_horizontal_distance)
Given an input ray described by a source and a destination, sample parallel rays around it as the center.
The parallel rays start at the corners of a square of edge length offset
centered on source
, with the square
orthogonal to the ray direction. That is, the cast rays are the height edges of a square-base cuboid with bases
centered on source
and destination
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
3 - array
|
(x,y,z) source of the ray to sample parallel rays of. |
required |
destination |
3 - array
|
Source of the ray to sample parallel rays of. |
required |
offset |
float
|
Orthogonal distance of parallel rays from input ray. |
required |
new_ray_per_horizontal_distance |
float
|
Step in offset beyond which an additional split will be applied in the parallel ray grid (which at minimum is 3x3 at the AABB corners & center). |
required |
Returns:
Type | Description |
---|---|
3 - tuple
|
|
Source code in omnigibson/utils/sampling_utils.py
get_projection_onto_plane(points, plane_centroid, plane_normal)
Computes @points' projection onto the plane defined by @plane_centroid and @plane_normal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
points |
k, 3)-array
|
th.tensor of shape (k, 3) |
required |
plane_centroid |
3 - array
|
(x,y,z) points' centroid |
required |
plane_normal |
3 - array
|
(x,y,z) normal of the fitted plane |
required |
Returns:
Type | Description |
---|---|
k,3)-array
|
Points' positions projected onto the plane |
Source code in omnigibson/utils/sampling_utils.py
raytest(start_point, end_point, only_closest=True, ignore_bodies=None, ignore_collisions=None, callback=None)
Computes raytest collision for ray cast from @start_point to @end_point
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_point |
3 - array
|
(x,y,z) global start location of the ray |
required |
end_point |
3 - array
|
(x,y,z) global end location of the ray |
required |
only_closest |
bool
|
Whether we report the first (closest) hit from the ray or grab all hits |
True
|
ignore_bodies |
None or list of str
|
If specified, specifies absolute USD paths to rigid bodies whose collisions should be ignored |
None
|
ignore_collisions |
None or list of str
|
If specified, specifies absolute USD paths to collision geoms whose collisions should be ignored |
None
|
callback |
None or function
|
If specified and @only_closest is False, the custom callback to use per-hit. This can be efficient if raytests are meant to terminate early. If None, no custom callback will be used. Expected signature is callback(hit) -> bool, which returns True if the raycast should continue or not |
None
|
Returns:
Type | Description |
---|---|
dict or list of dict
|
Results for this raytest. If @only_closest=True, then we only return the information from the closest hit. Otherwise, we return an (unordered) list of information for all hits encountered. Each dict is composed of: "hit" (bool): Whether an object was hit or not "position" (3-array): Location of the hit position "normal" (3-array): normal vector of the face hit "distance" (float): distance from @start_point the hit occurred "collision" (str): absolute USD path to the collision body hit "rigidBody" (str): absolute USD path to the associated rigid body hit Note that only "hit" = False exists in the dict if no hit was found |
Source code in omnigibson/utils/sampling_utils.py
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 |
|
raytest_batch(start_points, end_points, only_closest=True, ignore_bodies=None, ignore_collisions=None, callback=None)
Computes raytest collisions for a set of rays cast from @start_points to @end_points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
start_points |
list of 3-array
|
Array of start locations to cast rays, where each is (x,y,z) global start location of the ray |
required |
end_points |
list of 3-array
|
Array of end locations to cast rays, where each is (x,y,z) global end location of the ray |
required |
only_closest |
bool
|
Whether we report the first (closest) hit from the ray or grab all hits |
True
|
ignore_bodies |
None or list of str
|
If specified, specifies absolute USD paths to rigid bodies whose collisions should be ignored |
None
|
ignore_collisions |
None or list of str
|
If specified, specifies absolute USD paths to collision geoms whose collisions should be ignored |
None
|
callback |
None or function
|
If specified and @only_closest is False, the custom callback to use per-hit. This can be efficient if raytests are meant to terminate early. If None, no custom callback will be used. Expected signature is callback(hit) -> bool, which returns True if the raycast should continue or not |
None
|
Returns:
Type | Description |
---|---|
list of dict or list of list of dict
|
Results for all rays, where each entry corresponds to the result for the ith ray cast. If @only_closest=True, each entry in the list is the closest hit. Otherwise, each entry is its own (unordered) list of hits for that ray. Each dict is composed of: "hit" (bool): Whether an object was hit or not "position" (3-array): Location of the hit position "normal" (3-array): normal vector of the face hit "distance" (float): distance from @start_point the hit occurred "collision" (str): absolute USD path to the collision body hit "rigidBody" (str): absolute USD path to the associated rigid body hit Note that only "hit" = False exists in the dict if no hit was found |
Source code in omnigibson/utils/sampling_utils.py
sample_cuboid_on_object(obj, start_points, end_points, cuboid_dimensions, ignore_objs=None, new_ray_per_horizontal_distance=None, hit_proportion=None, max_angle_with_z_axis=None, parallel_ray_normal_angle_tolerance=None, hit_to_plane_threshold=None, cuboid_bottom_padding=None, undo_cuboid_bottom_padding=True, verify_cuboid_empty=True, refuse_downwards=False)
Samples points on an object's surface using ray casting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
DatasetObject
|
The object to sample points on. |
required |
start_points |
n, s, 3)-array
|
(num_samples, max_sampling_attempts, 3) shaped array representing the start points for raycasting defined in the world frame |
required |
end_points |
n, s, 3)-array
|
(num_samples, max_sampling_attempts, 3) shaped array representing the end points for raycasting defined in the world frame |
required |
cuboid_dimensions |
n, 3)-array
|
Float sequence of len 3, the size of the empty cuboid we are trying to sample. Can also provide list of cuboid dimension triplets in which case each i'th sample will be sampled using the i'th triplet. Alternatively, cuboid_dimensions can be set to be all zeros if the user just want to sample points (instead of cuboids) for significantly better performance. This applies when the user wants to sample very small particles. |
required |
ignore_objs |
None or list of EntityPrim
|
If @obj is None, this can be used to filter objects when checking for valid cuboid locations. Any sampled rays that hit an object in @ignore_objs will be ignored. If None, no filtering will be used |
None
|
new_ray_per_horizontal_distance |
float
|
per this distance of the cuboid dimension, increase the grid size of the parallel ray-testing by 1. This controls how fine-grained the grid ray-casting should be with respect to the size of the sampled cuboid. |
None
|
hit_proportion |
float
|
the minimum percentage of the hits required across the grid. |
None
|
max_angle_with_z_axis |
float
|
maximum angle between hit normal and positive Z axis allowed. Can be used to disallow downward-facing hits when refuse_downwards=True. |
None
|
parallel_ray_normal_angle_tolerance |
float
|
maximum angle difference between the normal of the center hit and the normal of other hits allowed. |
None
|
hit_to_plane_threshold |
float
|
how far any given hit position can be from the least-squares fit plane to all of the hit positions before the sample is rejected. |
None
|
cuboid_bottom_padding |
float
|
additional padding applied to the bottom of the cuboid. This is needed for the emptiness check (@check_cuboid_empty) within the cuboid. un_padding=True can be set if the user wants to remove the padding after the emptiness check. |
None
|
undo_cuboid_bottom_padding |
bool
|
Whether the bottom padding that's applied to the cuboid should be removed before return. Useful when the cuboid needs to be flush with the surface for whatever reason. Note that the padding will still be applied initially (since it's not possible to do the cuboid emptiness check without doing this - otherwise the rays will hit the sampled-on object), so the emptiness check still checks a padded cuboid. This flag will simply make the sampler undo the padding prior to returning. |
True
|
verify_cuboid_empty |
bool
|
Whether to filter out sampled cuboid locations that are not collision-free. Note that this check will only potentially occur if nonzero cuboid dimensions are specified. |
True
|
refuse_downwards |
bool
|
whether downward-facing hits (as defined by max_angle_with_z_axis) are allowed. |
False
|
Returns:
Type | Description |
---|---|
list of tuple
|
list of length num_samples elements where each element is a tuple in the form of (cuboid_centroid, cuboid_up_vector, cuboid_rotation, {refusal_reason: [refusal_details...]}). Cuboid positions are set to None when no successful sampling happens within the max number of attempts. Refusal details are only filled if the m.DEBUG_SAMPLING flag is globally set to True. |
Source code in omnigibson/utils/sampling_utils.py
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 |
|
sample_cuboid_on_object_full_grid_topdown(obj, ray_spacing, cuboid_dimensions, new_ray_per_horizontal_distance=None, hit_proportion=None, aabb_offset=None, aabb_offset_fraction=None, max_angle_with_z_axis=None, parallel_ray_normal_angle_tolerance=None, hit_to_plane_threshold=None, cuboid_bottom_padding=None, undo_cuboid_bottom_padding=True, verify_cuboid_empty=True, refuse_downwards=False)
Samples points on an object's surface using ray casting. Rays are sampled with a dense grid from top down.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
DatasetObject
|
The object to sample points on. |
required |
ray_spacing |
float
|
spacing between the rays, or equivalently, size of the grid cell, when sampling the start and end points. This implicitly determines the number of cuboids that will be sampled. |
required |
cuboid_dimensions |
n, 3)-array
|
Float sequence of len 3, the size of the empty cuboid we are trying to sample. Can also provide list of cuboid dimension triplets in which case each i'th sample will be sampled using the i'th triplet. Alternatively, cuboid_dimensions can be set to be all zeros if the user just want to sample points (instead of cuboids) for significantly better performance. This applies when the user wants to sample very small particles. |
required |
new_ray_per_horizontal_distance |
float
|
per this distance of the cuboid dimension, increase the grid size of the parallel ray-testing by 1. This controls how fine-grained the grid ray-casting should be with respect to the size of the sampled cuboid. |
None
|
hit_proportion |
float
|
the minimum percentage of the hits required across the grid. |
None
|
aabb_offset |
None or float or 3 - array
|
padding for AABB to initiate ray-testing, in absolute units. If specified, will override @aabb_offset_fraction |
None
|
aabb_offset_fraction |
float or 3 - array
|
padding for AABB to initiate ray-testing, as a fraction of overall AABB. |
None
|
max_angle_with_z_axis |
float
|
maximum angle between hit normal and positive Z axis allowed. Can be used to disallow downward-facing hits when refuse_downwards=True. |
None
|
parallel_ray_normal_angle_tolerance |
float
|
maximum angle difference between the normal of the center hit and the normal of other hits allowed. |
None
|
hit_to_plane_threshold |
float
|
how far any given hit position can be from the least-squares fit plane to all of the hit positions before the sample is rejected. |
None
|
cuboid_bottom_padding |
float
|
additional padding applied to the bottom of the cuboid. This is needed for the emptiness check (@check_cuboid_empty) within the cuboid. un_padding=True can be set if the user wants to remove the padding after the emptiness check. |
None
|
undo_cuboid_bottom_padding |
bool
|
Whether the bottom padding that's applied to the cuboid should be removed before return. Useful when the cuboid needs to be flush with the surface for whatever reason. Note that the padding will still be applied initially (since it's not possible to do the cuboid emptiness check without doing this - otherwise the rays will hit the sampled-on object), so the emptiness check still checks a padded cuboid. This flag will simply make the sampler undo the padding prior to returning. |
True
|
verify_cuboid_empty |
bool
|
Whether to filter out sampled cuboid locations that are not collision-free. Note that this check will only potentially occur if nonzero cuboid dimensions are specified. |
True
|
refuse_downwards |
bool
|
whether downward-facing hits (as defined by max_angle_with_z_axis) are allowed. |
False
|
Returns:
Type | Description |
---|---|
list of tuple
|
list of length num_samples elements where each element is a tuple in the form of (cuboid_centroid, cuboid_up_vector, cuboid_rotation, {refusal_reason: [refusal_details...]}). Cuboid positions are set to None when no successful sampling happens within the max number of attempts. Refusal details are only filled if the m.DEBUG_SAMPLING flag is globally set to True. |
Source code in omnigibson/utils/sampling_utils.py
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 |
|
sample_cuboid_on_object_symmetric_bimodal_distribution(obj, num_samples, cuboid_dimensions, bimodal_mean_fraction, bimodal_stdev_fraction, axis_probabilities, new_ray_per_horizontal_distance=None, hit_proportion=None, aabb_offset=None, aabb_offset_fraction=None, max_sampling_attempts=None, max_angle_with_z_axis=None, parallel_ray_normal_angle_tolerance=None, hit_to_plane_threshold=None, cuboid_bottom_padding=None, undo_cuboid_bottom_padding=True, verify_cuboid_empty=True, refuse_downwards=False)
Samples points on an object's surface using ray casting. Rays are sampled with a symmetric bimodal distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
DatasetObject
|
The object to sample points on. |
required |
num_samples |
int
|
the number of points to try to sample. |
required |
cuboid_dimensions |
n, 3)-array
|
Float sequence of len 3, the size of the empty cuboid we are trying to sample. Can also provide list of cuboid dimension triplets in which case each i'th sample will be sampled using the i'th triplet. Alternatively, cuboid_dimensions can be set to be all zeros if the user just want to sample points (instead of cuboids) for significantly better performance. This applies when the user wants to sample very small particles. |
required |
bimodal_mean_fraction |
float
|
the mean of one side of the symmetric bimodal distribution as a fraction of the min-max range. |
required |
bimodal_stdev_fraction |
float
|
the standard deviation of one side of the symmetric bimodal distribution as a fraction of the min-max range. |
required |
axis_probabilities |
3 - array
|
the probability of ray casting along each axis. |
required |
new_ray_per_horizontal_distance |
float
|
per this distance of the cuboid dimension, increase the grid size of the parallel ray-testing by 1. This controls how fine-grained the grid ray-casting should be with respect to the size of the sampled cuboid. |
None
|
hit_proportion |
float
|
the minimum percentage of the hits required across the grid. |
None
|
aabb_offset |
None or float or 3 - array
|
padding for AABB to initiate ray-testing, in absolute units. If specified, will override @aabb_offset_fraction |
None
|
aabb_offset_fraction |
float or 3 - array
|
padding for AABB to initiate ray-testing, as a fraction of overall AABB. |
None
|
max_sampling_attempts |
int
|
how many times sampling will be attempted for each requested point. |
None
|
max_angle_with_z_axis |
float
|
maximum angle between hit normal and positive Z axis allowed. Can be used to disallow downward-facing hits when refuse_downwards=True. |
None
|
parallel_ray_normal_angle_tolerance |
float
|
maximum angle difference between the normal of the center hit and the normal of other hits allowed. |
None
|
hit_to_plane_threshold |
float
|
how far any given hit position can be from the least-squares fit plane to all of the hit positions before the sample is rejected. |
None
|
cuboid_bottom_padding |
float
|
additional padding applied to the bottom of the cuboid. This is needed for the emptiness check (@check_cuboid_empty) within the cuboid. un_padding=True can be set if the user wants to remove the padding after the emptiness check. |
None
|
undo_cuboid_bottom_padding |
bool
|
Whether the bottom padding that's applied to the cuboid should be removed before return. Useful when the cuboid needs to be flush with the surface for whatever reason. Note that the padding will still be applied initially (since it's not possible to do the cuboid emptiness check without doing this - otherwise the rays will hit the sampled-on object), so the emptiness check still checks a padded cuboid. This flag will simply make the sampler undo the padding prior to returning. |
True
|
verify_cuboid_empty |
bool
|
Whether to filter out sampled cuboid locations that are not collision-free. Note that this check will only potentially occur if nonzero cuboid dimensions are specified. |
True
|
refuse_downwards |
bool
|
whether downward-facing hits (as defined by max_angle_with_z_axis) are allowed. |
False
|
Returns:
Type | Description |
---|---|
list of tuple
|
list of length num_samples elements where each element is a tuple in the form of (cuboid_centroid, cuboid_up_vector, cuboid_rotation, {refusal_reason: [refusal_details...]}). Cuboid positions are set to None when no successful sampling happens within the max number of attempts. Refusal details are only filled if the m.DEBUG_SAMPLING flag is globally set to True. |
Source code in omnigibson/utils/sampling_utils.py
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 |
|
sample_origin_positions(mins, maxes, count, bimodal_mean_fraction, bimodal_stdev_fraction, axis_probabilities)
Sample ray casting origin positions with a given distribution.
The way the sampling works is that for each particle, it will sample two coordinates uniformly and one using a symmetric, bimodal truncated normal distribution. This way, the particles will mostly be close to the faces of the AABB (given a correctly parameterized bimodal truncated normal) and will be spread across each face, but there will still be a small number of particles spawned inside the object if it has an interior.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
mins |
3 - array
|
the minimum coordinate along each axis. |
required |
maxes |
3 - array
|
the maximum coordinate along each axis. |
required |
count |
int
|
Number of origins to sample. |
required |
bimodal_mean_fraction |
float
|
the mean of one side of the symmetric bimodal distribution as a fraction of the min-max range. |
required |
bimodal_stdev_fraction |
float
|
the standard deviation of one side of the symmetric bimodal distribution as a fraction of the min-max range. |
required |
axis_probabilities |
3 - array
|
the probability of ray casting along each axis. |
required |
Returns:
Type | Description |
---|---|
list
|
List where each element is (ray cast axis index, bool whether the axis was sampled from the top side, [x, y, z]) tuples. |
Source code in omnigibson/utils/sampling_utils.py
sample_raytest_start_end_full_grid_topdown(obj, ray_spacing, aabb_offset=None, aabb_offset_fraction=None)
Sample the start points and end points around a given object by a dense grid from top down.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
obj |
DatasetObject
|
The object to sample points on. |
required |
ray_spacing |
float
|
spacing between the rays, or equivalently, size of the grid cell |
required |
aabb_offset |
None or float or 3 - array
|
padding for AABB to initiate ray-testing, in absolute units. If specified, will override @aabb_offset_fraction |
None
|
aabb_offset_fraction |
float or 3 - array
|
padding for AABB to initiate ray-testing, as a fraction of overall AABB. |
None
|
Returns:
Type | Description |
---|---|
2 - tuple
|
|
Source code in omnigibson/utils/sampling_utils.py
sample_raytest_start_end_symmetric_bimodal_distribution(obj, num_samples, bimodal_mean_fraction, bimodal_stdev_fraction, axis_probabilities, aabb_offset=None, aabb_offset_fraction=None, max_sampling_attempts=None)
Sample the start points and end points around a given object by a symmetric bimodal distribution
obj (DatasetObject): The object to sample points on. num_samples (int): the number of points to try to sample. bimodal_mean_fraction (float): the mean of one side of the symmetric bimodal distribution as a fraction of the min-max range. bimodal_stdev_fraction (float): the standard deviation of one side of the symmetric bimodal distribution as a fraction of the min-max range. axis_probabilities (3-array): probability of ray casting along each axis. aabb_offset (None or float or 3-array): padding for AABB to initiate ray-testing, in absolute units. If specified, will override @aabb_offset_fraction aabb_offset_fraction (float or 3-array): padding for AABB to initiate ray-testing, as a fraction of overall AABB. max_sampling_attempts (int): how many times sampling will be attempted for each requested point.
Returns:
Type | Description |
---|---|
2 - tuple
|
|