skrobot.sdf.GridSDF

class skrobot.sdf.GridSDF(sdf_data, origin, resolution, fill_value=inf, coords=None, use_abs=False)[source]

SDF using precopmuted signed distances for gridded points.

Methods

__call__(points_obj)[source]

Compute signed distances of input points to the implicit surface.

Parameters:

points_obj (numpy.ndarray[float](n_point, 3)) – 2 dim point array w.r.t. object coordinate.

Returns:

signed_distances – 1 dim (n_point,) array of signed distance.

Return type:

numpy.ndarray[float]

static from_file(filepath, **kwargs)[source]

Return GridSDF instance from a .sdf file.

Parameters:

filepath (str or pathlib.Path) – path of .sdf file

Returns:

sdf_instance – instance of sdf

Return type:

skrobot.esdf.GridSDF

static from_objfile(obj_filepath, dim_grid=100, padding_grid=5, **kwargs)[source]

Return GridSDF instance from an .obj file.

In the initial call of this method for an .obj file, the pre-process takes some time to converting it to a .sdf file. However, because a cache of .sdf file is created in the initial call, there is no overhead from the next call for the same .obj file.

Parameters:
  • obj_filepath (str or pathlib.Path) – path of objfile

  • dim_grid (int) – dim of sdf

  • padding_grid (int) – number of padding

Returns:

sdf_instance – instance of sdf

Return type:

skrobot.sdf.GridSDF

is_out_of_bounds(points_obj)[source]

check if the the input points is out of bounds

This method checks if the the input points is out of bounds of RegularGridInterpolator.

Parameters:

points_obj (numpy.ndarray[float](n_points, 3)) – points w.r.t. object to be checked.

Returns:

is_out_arr – If points is out of the interpolator’s boundary, the correspoinding element of is_out_arr is True

Return type:

numpy.ndarray[bool](n_points,)

on_surface(points_obj)[source]

Check if points are on the surface.

Parameters:

points_obj (numpy.ndarray[float](n_point, 3)) – 2 dim point array w.r.t. an object coordinate.

Returns:

  • logicals (numpy.ndarray[bool](n_point,)) – boolean vector of the on-surface predicate for points_obj.

  • sd_vals (numpy.ndarray[float](n_point,)) – signed distances corresponding to logicals.

surface_points(n_sample=1000)[source]

Sample points from the implicit surface of the sdf.

Parameters:

n_sample (int) – number of sample points.

Returns:

  • points_obj (numpy.ndarray[float](n_point, 3)) – sampled points w.r.t object coordinate.

  • dists (numpy.ndarray[float](n_point,)) – signed distances corresponding to points_obj.

__eq__(value, /)

Return self==value.

__ne__(value, /)

Return self!=value.

__lt__(value, /)

Return self<value.

__le__(value, /)

Return self<=value.

__gt__(value, /)

Return self>value.

__ge__(value, /)

Return self>=value.