graspnetAPI.utils.dexnet.grasping.meshpy package

Submodules

graspnetAPI.utils.dexnet.grasping.meshpy.mesh module

Encapsulates mesh for grasping operations Authors: Jeff Mahler and Matt Matl

class graspnetAPI.utils.dexnet.grasping.meshpy.mesh.Mesh3D(vertices, triangles, normals=None, density=1.0, center_of_mass=None, trimesh=None, T_obj_world=RigidTransform(rotation=np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]), translation=np.array([0.0, 0.0, 0.0]), from_frame='obj', to_frame='world'))[source]

Bases: object

A triangular mesh for a three-dimensional shape representation.

verticesnumpy.ndarray of float

A #verts by 3 array, where each row contains an ordered [x,y,z] set that describes one vertex.

trianglesnumpy.ndarray of int

A #tris by 3 array, where each row contains indices of vertices in the vertices array that are part of the triangle.

normalsnumpy.ndarray of float

A #normals by 3 array, where each row contains a normalized vector. This list should contain one norm per vertex.

densityfloat

The density of the mesh.

center_of_massnumpy.ndarray of float

The 3D location of the mesh’s center of mass.

massfloat

The mass of the mesh (read-only).

inertianumpy.ndarray of float

The 3x3 inertial matrix of the mesh (read-only).

bb_centernumpy.ndarray of float

The 3D location of the center of the mesh’s minimal bounding box (read-only).

centroidnumpy.ndarray of float

The 3D location of the mesh’s vertex mean (read-only).

C_canonical = array([[0.01666667, 0.00833333, 0.00833333], [0.00833333, 0.01666667, 0.00833333], [0.00833333, 0.00833333, 0.01666667]])
OBJ_EXT = '.obj'
PROC_TAG = '_proc'
ScalingTypeDiag = 4
ScalingTypeMax = 2
ScalingTypeMed = 1
ScalingTypeMin = 0
ScalingTypeRelative = 3
property T_obj_world

Return pose.

property bb_center

numpy.ndarray of float : The 3D location of the center of the mesh’s minimal bounding box (read-only).

bounding_box()[source]

Returns the mesh’s bounding box corners.

tuple of numpy.ndarray of float

A 2-tuple of 3-ndarrays of floats. The first 3-array contains the vertex of the smallest corner of the bounding box, and the second 3-array contains the largest corner of the bounding box.

bounding_box_mesh()[source]

Returns the mesh bounding box as a mesh.

Mesh3D

A Mesh3D representation of the mesh’s bounding box.

property center_of_mass

numpy.ndarray of float : The 3D location of the mesh’s center of mass.

center_vertices()[source]

Center the mesh’s vertices on the mesh center of mass.

This shifts the mesh without rotating it so that the center of its bounding box is at the origin.

center_vertices_avg()[source]

Center the mesh’s vertices at the centroid.

This shifts the mesh without rotating it so that the centroid (mean) of all vertices is at the origin.

center_vertices_bb()[source]

Center the mesh’s vertices at the center of its bounding box.

This shifts the mesh without rotating it so that the center of its bounding box is at the origin.

property centroid

numpy.ndarray of float : The 3D location of the mesh’s vertex mean (read-only).

compute_vertex_normals()[source]

Get normals from triangles

convex_hull()[source]

Return a 3D mesh that represents the convex hull of the mesh.

copy()[source]

Return a copy of the mesh.

This method only copies the vertices and triangles of the mesh.

covariance()[source]

Return the total covariance of the mesh’s triangles.

float

The total covariance of the mesh’s triangles.

property density

float : The density of the mesh.

find_contact(origin, direction)[source]

Finds the contact location with the mesh, if it exists.

flip_normals()[source]

Flips the mesh normals.

flip_tri_orientation()[source]

Flips the orientation of all triangles.

get_T_surface_obj(T_obj_surface, delta=0.0)[source]

Gets the transformation that puts the object resting exactly on the z=delta plane

T_obj_surfaceRigidTransform

The RigidTransform by which the mesh is transformed.

deltafloat

Z-coordinate to rest the mesh on

This method copies the vertices and triangles of the mesh.

property inertia

numpy.ndarray of float : The 3x3 inertial matrix of the mesh (read-only).

property is_watertight
static load(filename, cache_dir, preproc_script=None)[source]

Load a mesh from a file.

If the mesh is not already in .obj format, this requires the installation of meshlab. Meshlab has a command called meshlabserver that is used to convert the file into a .obj format.

filenamestr

Path to mesh file.

cache_dirstr

A directory to store a converted .obj file in, if the file isn’t already in .obj format.

preproc_scriptstr

The path to an optional script to run before converting the mesh file to .obj if necessary.

Mesh3D

A 3D mesh object read from the file.

property mass

float : The mass of the mesh (read-only).

max_coords()[source]

Returns the maximum coordinates of the mesh.

numpy.ndarray of float

A 3-ndarray of floats that represents the minimal x, y, and z coordinates represented in the mesh.

merge(other_mesh)[source]

Combines this mesh with another mesh.

other_meshMesh3D

the mesh to combine with

Mesh3D

merged mesh

min_coords()[source]

Returns the minimum coordinates of the mesh.

numpy.ndarray of float

A 3-ndarray of floats that represents the minimal x, y, and z coordinates represented in the mesh.

normalize_vertices()[source]

Normalize the mesh’s orientation along its principal axes.

Transforms the vertices and normals of the mesh such that the origin of the resulting mesh’s coordinate frame is at the center of the bounding box and the principal axes (as determined from PCA) are aligned with the vertical Z, Y, and X axes in that order.

property normals

numpy.ndarray of float : A #normals by 3 array, where each row contains a normalized vector. This list should contain one norm per vertex.

property num_triangles

int: The number of total triangles

property num_vertices

int: The number of total vertices

principal_dims()[source]

Returns the maximal span of the mesh’s coordinates.

The maximal span is the maximum coordinate value minus the minimal coordinate value in each principal axis.

numpy.ndarray of float

A 3-ndarray of floats that represents the maximal x, y, and z spans of the mesh.

random_points(n_points)[source]

Generate uniformly random points on the surface of the mesh.

n_pointsint

The number of random points to generate.

numpy.ndarray of float

A n_points by 3 ndarray that contains the sampled 3D points.

ray_intersections(ray, point, distance)[source]

Returns a list containing the indices of the triangles that are intersected by the given ray emanating from the given point within some distance.

remove_bad_tris()[source]

Remove triangles with out-of-bounds vertices from the mesh.

remove_unreferenced_vertices()[source]

Remove any vertices that are not part of a triangular face.

This method will fail if any bad triangles are present, so run remove_bad_tris() first if you’re unsure if bad triangles are present.

bool

Returns True if vertices were removed, False otherwise.

rescale(scale_factor)[source]

Rescales the vertex coordinates by scale_factor.

scale_factorfloat

The desired scale factor for the mesh’s vertices.

rescale_dimension(scale, scaling_type=0)[source]

Rescales the vertex coordinates to scale using the given scaling_type.

scalefloat

The desired scaling factor of the selected dimension, if scaling_type is ScalingTypeMin, ScalingTypeMed, ScalingTypeMax, or ScalingTypeDiag. Otherwise, the overall scaling factor.

scaling_typeint

One of ScalingTypeMin, ScalingTypeMed, ScalingTypeMax, ScalingTypeRelative, or ScalingTypeDiag. ScalingTypeMin scales the smallest vertex extent (X, Y, or Z) by scale, ScalingTypeMed scales the median vertex extent, and ScalingTypeMax scales the maximum vertex extent. ScalingTypeDiag scales the bounding box diagonal (divided by three), and ScalingTypeRelative provides absolute scaling.

resting_pose(T_obj_world, eps=1e-10)[source]

Returns the stable pose that the mesh will rest on if it lands on an infinite planar worksurface quasi-statically in the given transformation (only the rotation is used).

T_obj_worldautolab_core.RigidTransform

transformation from object to table basis (z-axis upward) specifying the orientation of the mesh

epsfloat

numeric tolerance in cone projection solver

StablePose

stable pose specifying the face that the mesh will land on

scale_principal_eigenvalues(new_evals)[source]
stable_poses(min_prob=0.0)[source]

Computes all valid StablePose objects for the mesh.

min_probfloat

stable poses that are less likely than this threshold will be discarded

list of StablePose

A list of StablePose objects for the mesh.

subdivide(min_tri_length=inf)[source]

Return a copy of the mesh that has been subdivided by one iteration.

This method only copies the vertices and triangles of the mesh.

support(direction)[source]

Returns the support function in the given direction

directionnumpy.ndarray of float

A 3-ndarray of floats that is a unit vector in the direction of the desired support.

numpy.ndarray of float

A 3-ndarray of floats that represents the support.

surface_area()[source]

Return the surface area of the mesh.

float

The surface area of the mesh.

total_volume()[source]

Return the total volume of the mesh.

float

The total volume of the mesh.

transform(T)[source]

Return a copy of the mesh that has been transformed by T.

TRigidTransform

The RigidTransform by which the mesh is transformed.

This method only copies the vertices and triangles of the mesh.

tri_centers()[source]

Returns an array of the triangle centers as 3D points.

numpy.ndarray of numpy.ndarray of float

An ndarray of 3-ndarrays of floats, where each 3-ndarray represents the 3D point at the center of the corresponding mesh triangle.

tri_normals(align_to_hull=False)[source]

Returns a list of the triangle normals.

align_to_hullbool

If true, we re-orient the normals to point outward from the mesh by using the convex hull.

numpy.ndarray of float

A #triangles by 3 array of floats, where each 3-ndarray represents the 3D normal vector of the corresponding triangle.

property triangles

numpy.ndarray of int : A #tris by 3 array, where each row contains indices of vertices in the vertices array that are part of the triangle.

property trimesh

Convert to trimesh.

update_tf(delta_T)[source]

Updates the mesh transformation.

property vertices

numpy.ndarray of float : A #verts by 3 array, where each row contains an ordered [x,y,z] set that describes one vertex.

visualize(color=0.5, 0.5, 0.5, style='surface', opacity=1.0)[source]

Plots visualization of mesh using MayaVI.

colortuple of float

3-tuple of floats in [0,1] to give the mesh’s color

stylestr

Either ‘surface’, which produces an opaque surface, or ‘wireframe’, which produces a wireframe.

opacityfloat

A value in [0,1] indicating the opacity of the mesh. Zero is transparent, one is opaque.

mayavi.modules.surface.Surface

The displayed surface.

graspnetAPI.utils.dexnet.grasping.meshpy.obj_file module

File for loading and saving meshes from .OBJ files Author: Jeff Mahler

class graspnetAPI.utils.dexnet.grasping.meshpy.obj_file.ObjFile(filepath)[source]

Bases: object

A Wavefront .obj file reader and writer.

filepathstr

The full path to the .obj file associated with this reader/writer.

property filepath

Returns the full path to the .obj file associated with this reader/writer.

str

The full path to the .obj file associated with this reader/writer.

read()[source]

Reads in the .obj file and returns a Mesh3D representation of that mesh.

Mesh3D

A Mesh3D created from the data in the .obj file.

write(mesh)[source]

Writes a Mesh3D object out to a .obj file format

meshMesh3D

The Mesh3D object to write to the .obj file.

Does not support material files or texture coordinates.

graspnetAPI.utils.dexnet.grasping.meshpy.sdf module

Definition of SDF Class Author: Sahaana Suri, Jeff Mahler, and Matt Matl

Currently assumes clean input

class graspnetAPI.utils.dexnet.grasping.meshpy.sdf.Sdf[source]

Bases: object

Abstract class for signed distance fields.

property center

Center of grid.

This basically transforms the world frame to grid center.

numpy.ndarray

center_world()[source]

Center of grid (basically transforms world frame to grid center)

property data

The SDF data.

numpy.ndarray of float

The 2- or 3-dimensional ndarray that holds the grid of signed distances.

property dimensions

SDF dimension information.

numpy.ndarray of int

The ndarray that contains the dimensions of the sdf.

property gradients

Gradients of the SDF.

list of numpy.ndarray of float

A list of ndarrays of the same dimension as the SDF. The arrays are in axis order and specify the gradients for that axis at each point.

is_out_of_bounds(coords)[source]

Returns True if coords is an out of bounds access.

coordsnumpy.ndarray of int

A 2- or 3-dimensional ndarray that indicates the desired coordinates in the grid.

bool

Are the coordinates in coords out of bounds?

on_surface(coords)[source]

Determines whether or not a point is on the object surface.

coordsnumpy.ndarray of int

A 2- or 3-dimensional ndarray that indicates the desired coordinates in the grid.

tuple of bool, float

Is the point on the object’s surface, and what is the signed distance at that point?

property origin

The location of the origin in the SDF grid.

numpy.ndarray of float

The 2- or 3-ndarray that contains the location of the origin of the mesh grid in real space.

property resolution

The grid resolution (how wide each grid cell is).

float

The width of each grid cell.

abstract surface_points()[source]

Returns the points on the surface.

tuple of numpy.ndarray of int, numpy.ndarray of float

The points on the surface and the signed distances at those points.

abstract transform(tf)[source]

Returns a new SDF transformed by similarity tf.

abstract transform_pt_grid_to_obj(x_grid, direction=False)[source]

Transforms points from grid frame to world frame

abstract transform_pt_obj_to_grid(x_world, direction=False)[source]

Transforms points from world frame to grid frame

transform_to_world()[source]

Returns an sdf object with center in the world frame of reference.

class graspnetAPI.utils.dexnet.grasping.meshpy.sdf.Sdf3D(sdf_data, origin, resolution, use_abs=False, T_sdf_world=RigidTransform(rotation=np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]), translation=np.array([0.0, 0.0, 0.0]), from_frame='sdf', to_frame='world'))[source]

Bases: graspnetAPI.utils.dexnet.grasping.meshpy.sdf.Sdf

curvature(coords, delta=0.001)[source]

Returns an approximation to the local SDF curvature (Hessian) at the given coordinate in grid basis.

coordsnumpy 3-vector

the grid coordinates at which to get the curvature

delta : Returns ——- curvature : 3x3 ndarray of the curvature at the surface points

static find_zero_crossing_linear(x1, y1, x2, y2)[source]

Find zero crossing using linear approximation

static find_zero_crossing_quadratic(x1, y1, x2, y2, x3, y3, eps=1.0)[source]

Find zero crossing using quadratic approximation along 1d line

gradient(coords)[source]

Returns the SDF gradient at the given coordinates, interpolating if necessary

coordsnumpy.ndarray of int

A 3-dimensional ndarray that indicates the desired coordinates in the grid.

float

The gradient at the given coords (interpolated).

IndexError

If the coords vector does not have three entries.

max_coords_x = [1, 4, 6, 7]
max_coords_y = [2, 4, 5, 7]
max_coords_z = [3, 5, 6, 7]
min_coords_x = [0, 2, 3, 5]
min_coords_y = [0, 1, 3, 6]
min_coords_z = [0, 1, 2, 4]
num_interpolants = 8
rescale(scale)[source]

Rescale an SDF by a given scale factor.

scalefloat

the amount to scale the SDF

Sdf3D

new sdf with given scale

surface_normal(coords, delta=1.5)[source]

Returns the sdf surface normal at the given coordinates by computing the tangent plane using SDF interpolation.

coordsnumpy.ndarray of int

A 3-dimensional ndarray that indicates the desired coordinates in the grid.

deltafloat

A radius for collecting surface points near the target coords for calculating the surface normal.

numpy.ndarray of float

The 3-dimensional ndarray that represents the surface normal.

IndexError

If the coords vector does not have three entries.

surface_points(grid_basis=True)[source]

Returns the points on the surface.

grid_basisbool

If False, the surface points are transformed to the world frame. If True (default), the surface points are left in grid coordinates.

tuple of numpy.ndarray of int, numpy.ndarray of float

The points on the surface and the signed distances at those points.

transform(delta_T)[source]

Creates a new SDF with a given pose with respect to world coordinates.

delta_Tautolab_core.RigidTransform

transform from cur sdf to transformed sdf coords

transform_dense(delta_T, detailed=False)[source]

Transform the grid by pose T and scale with canonical reference frame at the SDF center with axis alignment.

delta_TSimilarityTransform

the transformation from the current frame of reference to the new frame of reference

detailedbool

whether or not to use interpolation

Sdf3D

new sdf with grid warped by T

transform_pt_grid_to_obj(x_grid, direction=False)[source]

Converts a point in grid coords to the world basis. If direction then don’t translate.

x_gridnumpy 3xN ndarray or numeric scalar

points to transform from grid basis to sdf basis in meters

direction : bool Returns ——- x_sdf : numpy 3xN ndarray

points in sdf basis (meters)

transform_pt_obj_to_grid(x_sdf, direction=False)[source]

Converts a point in sdf coords to the grid basis. If direction then don’t translate.

x_sdfnumpy 3xN ndarray or numeric scalar

points to transform from sdf basis in meters to grid basis

direction : bool Returns ——- x_grid : numpy 3xN ndarray or scalar

points in grid basis

graspnetAPI.utils.dexnet.grasping.meshpy.sdf_file module

Reads and writes sdfs to file Author: Jeff Mahler

class graspnetAPI.utils.dexnet.grasping.meshpy.sdf_file.SdfFile(filepath)[source]

Bases: object

A Signed Distance Field .sdf file reader and writer.

filepathstr

The full path to the .sdf or .csv file associated with this reader/writer.

property filepath

Returns the full path to the file associated with this reader/writer.

str

The full path to the file associated with this reader/writer.

read()[source]

Reads in the SDF file and returns a Sdf object.

Sdf

A Sdf created from the data in the file.

write(sdf)[source]

Writes an SDF to a file.

sdfSdf

An Sdf object to write out.

This is not currently implemented or supported.

graspnetAPI.utils.dexnet.grasping.meshpy.stable_pose module

A basic struct-like Stable Pose class to make accessing pose probability and rotation matrix easier

Author: Matt Matl and Nikhil Sharma

class graspnetAPI.utils.dexnet.grasping.meshpy.stable_pose.StablePose(p, r, x0, face=None, stp_id=- 1)[source]

Bases: object

A representation of a mesh’s stable pose.

pfloat

Probability associated with this stable pose.

rnumpy.ndarray of :obj`numpy.ndarray` of float

3x3 rotation matrix that rotates the mesh into the stable pose from standardized coordinates.

x0numpy.ndarray of float

3D point in the mesh that is resting on the table.

facenumpy.ndarray

3D vector of indices corresponding to vertices forming the resting face

stp_idstr

A string identifier for the stable pose

T_obj_tableRigidTransform

A RigidTransform representation of the pose’s rotation matrix.

property T_obj_table
property T_obj_world

Module contents

class graspnetAPI.utils.dexnet.grasping.meshpy.Mesh3D(vertices, triangles, normals=None, density=1.0, center_of_mass=None, trimesh=None, T_obj_world=RigidTransform(rotation=np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]), translation=np.array([0.0, 0.0, 0.0]), from_frame='obj', to_frame='world'))[source]

Bases: object

A triangular mesh for a three-dimensional shape representation.

verticesnumpy.ndarray of float

A #verts by 3 array, where each row contains an ordered [x,y,z] set that describes one vertex.

trianglesnumpy.ndarray of int

A #tris by 3 array, where each row contains indices of vertices in the vertices array that are part of the triangle.

normalsnumpy.ndarray of float

A #normals by 3 array, where each row contains a normalized vector. This list should contain one norm per vertex.

densityfloat

The density of the mesh.

center_of_massnumpy.ndarray of float

The 3D location of the mesh’s center of mass.

massfloat

The mass of the mesh (read-only).

inertianumpy.ndarray of float

The 3x3 inertial matrix of the mesh (read-only).

bb_centernumpy.ndarray of float

The 3D location of the center of the mesh’s minimal bounding box (read-only).

centroidnumpy.ndarray of float

The 3D location of the mesh’s vertex mean (read-only).

C_canonical = array([[0.01666667, 0.00833333, 0.00833333], [0.00833333, 0.01666667, 0.00833333], [0.00833333, 0.00833333, 0.01666667]])
OBJ_EXT = '.obj'
PROC_TAG = '_proc'
ScalingTypeDiag = 4
ScalingTypeMax = 2
ScalingTypeMed = 1
ScalingTypeMin = 0
ScalingTypeRelative = 3
property T_obj_world

Return pose.

property bb_center

numpy.ndarray of float : The 3D location of the center of the mesh’s minimal bounding box (read-only).

bounding_box()[source]

Returns the mesh’s bounding box corners.

tuple of numpy.ndarray of float

A 2-tuple of 3-ndarrays of floats. The first 3-array contains the vertex of the smallest corner of the bounding box, and the second 3-array contains the largest corner of the bounding box.

bounding_box_mesh()[source]

Returns the mesh bounding box as a mesh.

Mesh3D

A Mesh3D representation of the mesh’s bounding box.

property center_of_mass

numpy.ndarray of float : The 3D location of the mesh’s center of mass.

center_vertices()[source]

Center the mesh’s vertices on the mesh center of mass.

This shifts the mesh without rotating it so that the center of its bounding box is at the origin.

center_vertices_avg()[source]

Center the mesh’s vertices at the centroid.

This shifts the mesh without rotating it so that the centroid (mean) of all vertices is at the origin.

center_vertices_bb()[source]

Center the mesh’s vertices at the center of its bounding box.

This shifts the mesh without rotating it so that the center of its bounding box is at the origin.

property centroid

numpy.ndarray of float : The 3D location of the mesh’s vertex mean (read-only).

compute_vertex_normals()[source]

Get normals from triangles

convex_hull()[source]

Return a 3D mesh that represents the convex hull of the mesh.

copy()[source]

Return a copy of the mesh.

This method only copies the vertices and triangles of the mesh.

covariance()[source]

Return the total covariance of the mesh’s triangles.

float

The total covariance of the mesh’s triangles.

property density

float : The density of the mesh.

find_contact(origin, direction)[source]

Finds the contact location with the mesh, if it exists.

flip_normals()[source]

Flips the mesh normals.

flip_tri_orientation()[source]

Flips the orientation of all triangles.

get_T_surface_obj(T_obj_surface, delta=0.0)[source]

Gets the transformation that puts the object resting exactly on the z=delta plane

T_obj_surfaceRigidTransform

The RigidTransform by which the mesh is transformed.

deltafloat

Z-coordinate to rest the mesh on

This method copies the vertices and triangles of the mesh.

property inertia

numpy.ndarray of float : The 3x3 inertial matrix of the mesh (read-only).

property is_watertight
static load(filename, cache_dir, preproc_script=None)[source]

Load a mesh from a file.

If the mesh is not already in .obj format, this requires the installation of meshlab. Meshlab has a command called meshlabserver that is used to convert the file into a .obj format.

filenamestr

Path to mesh file.

cache_dirstr

A directory to store a converted .obj file in, if the file isn’t already in .obj format.

preproc_scriptstr

The path to an optional script to run before converting the mesh file to .obj if necessary.

Mesh3D

A 3D mesh object read from the file.

property mass

float : The mass of the mesh (read-only).

max_coords()[source]

Returns the maximum coordinates of the mesh.

numpy.ndarray of float

A 3-ndarray of floats that represents the minimal x, y, and z coordinates represented in the mesh.

merge(other_mesh)[source]

Combines this mesh with another mesh.

other_meshMesh3D

the mesh to combine with

Mesh3D

merged mesh

min_coords()[source]

Returns the minimum coordinates of the mesh.

numpy.ndarray of float

A 3-ndarray of floats that represents the minimal x, y, and z coordinates represented in the mesh.

normalize_vertices()[source]

Normalize the mesh’s orientation along its principal axes.

Transforms the vertices and normals of the mesh such that the origin of the resulting mesh’s coordinate frame is at the center of the bounding box and the principal axes (as determined from PCA) are aligned with the vertical Z, Y, and X axes in that order.

property normals

numpy.ndarray of float : A #normals by 3 array, where each row contains a normalized vector. This list should contain one norm per vertex.

property num_triangles

int: The number of total triangles

property num_vertices

int: The number of total vertices

principal_dims()[source]

Returns the maximal span of the mesh’s coordinates.

The maximal span is the maximum coordinate value minus the minimal coordinate value in each principal axis.

numpy.ndarray of float

A 3-ndarray of floats that represents the maximal x, y, and z spans of the mesh.

random_points(n_points)[source]

Generate uniformly random points on the surface of the mesh.

n_pointsint

The number of random points to generate.

numpy.ndarray of float

A n_points by 3 ndarray that contains the sampled 3D points.

ray_intersections(ray, point, distance)[source]

Returns a list containing the indices of the triangles that are intersected by the given ray emanating from the given point within some distance.

remove_bad_tris()[source]

Remove triangles with out-of-bounds vertices from the mesh.

remove_unreferenced_vertices()[source]

Remove any vertices that are not part of a triangular face.

This method will fail if any bad triangles are present, so run remove_bad_tris() first if you’re unsure if bad triangles are present.

bool

Returns True if vertices were removed, False otherwise.

rescale(scale_factor)[source]

Rescales the vertex coordinates by scale_factor.

scale_factorfloat

The desired scale factor for the mesh’s vertices.

rescale_dimension(scale, scaling_type=0)[source]

Rescales the vertex coordinates to scale using the given scaling_type.

scalefloat

The desired scaling factor of the selected dimension, if scaling_type is ScalingTypeMin, ScalingTypeMed, ScalingTypeMax, or ScalingTypeDiag. Otherwise, the overall scaling factor.

scaling_typeint

One of ScalingTypeMin, ScalingTypeMed, ScalingTypeMax, ScalingTypeRelative, or ScalingTypeDiag. ScalingTypeMin scales the smallest vertex extent (X, Y, or Z) by scale, ScalingTypeMed scales the median vertex extent, and ScalingTypeMax scales the maximum vertex extent. ScalingTypeDiag scales the bounding box diagonal (divided by three), and ScalingTypeRelative provides absolute scaling.

resting_pose(T_obj_world, eps=1e-10)[source]

Returns the stable pose that the mesh will rest on if it lands on an infinite planar worksurface quasi-statically in the given transformation (only the rotation is used).

T_obj_worldautolab_core.RigidTransform

transformation from object to table basis (z-axis upward) specifying the orientation of the mesh

epsfloat

numeric tolerance in cone projection solver

StablePose

stable pose specifying the face that the mesh will land on

scale_principal_eigenvalues(new_evals)[source]
stable_poses(min_prob=0.0)[source]

Computes all valid StablePose objects for the mesh.

min_probfloat

stable poses that are less likely than this threshold will be discarded

list of StablePose

A list of StablePose objects for the mesh.

subdivide(min_tri_length=inf)[source]

Return a copy of the mesh that has been subdivided by one iteration.

This method only copies the vertices and triangles of the mesh.

support(direction)[source]

Returns the support function in the given direction

directionnumpy.ndarray of float

A 3-ndarray of floats that is a unit vector in the direction of the desired support.

numpy.ndarray of float

A 3-ndarray of floats that represents the support.

surface_area()[source]

Return the surface area of the mesh.

float

The surface area of the mesh.

total_volume()[source]

Return the total volume of the mesh.

float

The total volume of the mesh.

transform(T)[source]

Return a copy of the mesh that has been transformed by T.

TRigidTransform

The RigidTransform by which the mesh is transformed.

This method only copies the vertices and triangles of the mesh.

tri_centers()[source]

Returns an array of the triangle centers as 3D points.

numpy.ndarray of numpy.ndarray of float

An ndarray of 3-ndarrays of floats, where each 3-ndarray represents the 3D point at the center of the corresponding mesh triangle.

tri_normals(align_to_hull=False)[source]

Returns a list of the triangle normals.

align_to_hullbool

If true, we re-orient the normals to point outward from the mesh by using the convex hull.

numpy.ndarray of float

A #triangles by 3 array of floats, where each 3-ndarray represents the 3D normal vector of the corresponding triangle.

property triangles

numpy.ndarray of int : A #tris by 3 array, where each row contains indices of vertices in the vertices array that are part of the triangle.

property trimesh

Convert to trimesh.

update_tf(delta_T)[source]

Updates the mesh transformation.

property vertices

numpy.ndarray of float : A #verts by 3 array, where each row contains an ordered [x,y,z] set that describes one vertex.

visualize(color=0.5, 0.5, 0.5, style='surface', opacity=1.0)[source]

Plots visualization of mesh using MayaVI.

colortuple of float

3-tuple of floats in [0,1] to give the mesh’s color

stylestr

Either ‘surface’, which produces an opaque surface, or ‘wireframe’, which produces a wireframe.

opacityfloat

A value in [0,1] indicating the opacity of the mesh. Zero is transparent, one is opaque.

mayavi.modules.surface.Surface

The displayed surface.

class graspnetAPI.utils.dexnet.grasping.meshpy.ObjFile(filepath)[source]

Bases: object

A Wavefront .obj file reader and writer.

filepathstr

The full path to the .obj file associated with this reader/writer.

property filepath

Returns the full path to the .obj file associated with this reader/writer.

str

The full path to the .obj file associated with this reader/writer.

read()[source]

Reads in the .obj file and returns a Mesh3D representation of that mesh.

Mesh3D

A Mesh3D created from the data in the .obj file.

write(mesh)[source]

Writes a Mesh3D object out to a .obj file format

meshMesh3D

The Mesh3D object to write to the .obj file.

Does not support material files or texture coordinates.

class graspnetAPI.utils.dexnet.grasping.meshpy.Sdf[source]

Bases: object

Abstract class for signed distance fields.

property center

Center of grid.

This basically transforms the world frame to grid center.

numpy.ndarray

center_world()[source]

Center of grid (basically transforms world frame to grid center)

property data

The SDF data.

numpy.ndarray of float

The 2- or 3-dimensional ndarray that holds the grid of signed distances.

property dimensions

SDF dimension information.

numpy.ndarray of int

The ndarray that contains the dimensions of the sdf.

property gradients

Gradients of the SDF.

list of numpy.ndarray of float

A list of ndarrays of the same dimension as the SDF. The arrays are in axis order and specify the gradients for that axis at each point.

is_out_of_bounds(coords)[source]

Returns True if coords is an out of bounds access.

coordsnumpy.ndarray of int

A 2- or 3-dimensional ndarray that indicates the desired coordinates in the grid.

bool

Are the coordinates in coords out of bounds?

on_surface(coords)[source]

Determines whether or not a point is on the object surface.

coordsnumpy.ndarray of int

A 2- or 3-dimensional ndarray that indicates the desired coordinates in the grid.

tuple of bool, float

Is the point on the object’s surface, and what is the signed distance at that point?

property origin

The location of the origin in the SDF grid.

numpy.ndarray of float

The 2- or 3-ndarray that contains the location of the origin of the mesh grid in real space.

property resolution

The grid resolution (how wide each grid cell is).

float

The width of each grid cell.

abstract surface_points()[source]

Returns the points on the surface.

tuple of numpy.ndarray of int, numpy.ndarray of float

The points on the surface and the signed distances at those points.

abstract transform(tf)[source]

Returns a new SDF transformed by similarity tf.

abstract transform_pt_grid_to_obj(x_grid, direction=False)[source]

Transforms points from grid frame to world frame

abstract transform_pt_obj_to_grid(x_world, direction=False)[source]

Transforms points from world frame to grid frame

transform_to_world()[source]

Returns an sdf object with center in the world frame of reference.

class graspnetAPI.utils.dexnet.grasping.meshpy.Sdf3D(sdf_data, origin, resolution, use_abs=False, T_sdf_world=RigidTransform(rotation=np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]), translation=np.array([0.0, 0.0, 0.0]), from_frame='sdf', to_frame='world'))[source]

Bases: graspnetAPI.utils.dexnet.grasping.meshpy.sdf.Sdf

curvature(coords, delta=0.001)[source]

Returns an approximation to the local SDF curvature (Hessian) at the given coordinate in grid basis.

coordsnumpy 3-vector

the grid coordinates at which to get the curvature

delta : Returns ——- curvature : 3x3 ndarray of the curvature at the surface points

static find_zero_crossing_linear(x1, y1, x2, y2)[source]

Find zero crossing using linear approximation

static find_zero_crossing_quadratic(x1, y1, x2, y2, x3, y3, eps=1.0)[source]

Find zero crossing using quadratic approximation along 1d line

gradient(coords)[source]

Returns the SDF gradient at the given coordinates, interpolating if necessary

coordsnumpy.ndarray of int

A 3-dimensional ndarray that indicates the desired coordinates in the grid.

float

The gradient at the given coords (interpolated).

IndexError

If the coords vector does not have three entries.

max_coords_x = [1, 4, 6, 7]
max_coords_y = [2, 4, 5, 7]
max_coords_z = [3, 5, 6, 7]
min_coords_x = [0, 2, 3, 5]
min_coords_y = [0, 1, 3, 6]
min_coords_z = [0, 1, 2, 4]
num_interpolants = 8
rescale(scale)[source]

Rescale an SDF by a given scale factor.

scalefloat

the amount to scale the SDF

Sdf3D

new sdf with given scale

surface_normal(coords, delta=1.5)[source]

Returns the sdf surface normal at the given coordinates by computing the tangent plane using SDF interpolation.

coordsnumpy.ndarray of int

A 3-dimensional ndarray that indicates the desired coordinates in the grid.

deltafloat

A radius for collecting surface points near the target coords for calculating the surface normal.

numpy.ndarray of float

The 3-dimensional ndarray that represents the surface normal.

IndexError

If the coords vector does not have three entries.

surface_points(grid_basis=True)[source]

Returns the points on the surface.

grid_basisbool

If False, the surface points are transformed to the world frame. If True (default), the surface points are left in grid coordinates.

tuple of numpy.ndarray of int, numpy.ndarray of float

The points on the surface and the signed distances at those points.

transform(delta_T)[source]

Creates a new SDF with a given pose with respect to world coordinates.

delta_Tautolab_core.RigidTransform

transform from cur sdf to transformed sdf coords

transform_dense(delta_T, detailed=False)[source]

Transform the grid by pose T and scale with canonical reference frame at the SDF center with axis alignment.

delta_TSimilarityTransform

the transformation from the current frame of reference to the new frame of reference

detailedbool

whether or not to use interpolation

Sdf3D

new sdf with grid warped by T

transform_pt_grid_to_obj(x_grid, direction=False)[source]

Converts a point in grid coords to the world basis. If direction then don’t translate.

x_gridnumpy 3xN ndarray or numeric scalar

points to transform from grid basis to sdf basis in meters

direction : bool Returns ——- x_sdf : numpy 3xN ndarray

points in sdf basis (meters)

transform_pt_obj_to_grid(x_sdf, direction=False)[source]

Converts a point in sdf coords to the grid basis. If direction then don’t translate.

x_sdfnumpy 3xN ndarray or numeric scalar

points to transform from sdf basis in meters to grid basis

direction : bool Returns ——- x_grid : numpy 3xN ndarray or scalar

points in grid basis

class graspnetAPI.utils.dexnet.grasping.meshpy.SdfFile(filepath)[source]

Bases: object

A Signed Distance Field .sdf file reader and writer.

filepathstr

The full path to the .sdf or .csv file associated with this reader/writer.

property filepath

Returns the full path to the file associated with this reader/writer.

str

The full path to the file associated with this reader/writer.

read()[source]

Reads in the SDF file and returns a Sdf object.

Sdf

A Sdf created from the data in the file.

write(sdf)[source]

Writes an SDF to a file.

sdfSdf

An Sdf object to write out.

This is not currently implemented or supported.

class graspnetAPI.utils.dexnet.grasping.meshpy.StablePose(p, r, x0, face=None, stp_id=- 1)[source]

Bases: object

A representation of a mesh’s stable pose.

pfloat

Probability associated with this stable pose.

rnumpy.ndarray of :obj`numpy.ndarray` of float

3x3 rotation matrix that rotates the mesh into the stable pose from standardized coordinates.

x0numpy.ndarray of float

3D point in the mesh that is resting on the table.

facenumpy.ndarray

3D vector of indices corresponding to vertices forming the resting face

stp_idstr

A string identifier for the stable pose

T_obj_tableRigidTransform

A RigidTransform representation of the pose’s rotation matrix.

property T_obj_table
property T_obj_world