MCPcopy Create free account
hub / github.com/BerkeleyAutomation/meshrender / __init__

Method __init__

meshrender/scene_object.py:83–125  ·  view source on GitHub ↗

Initialize a scene object with the given mesh, pose, and material. Parameters ---------- mesh : trimesh.Trimesh A mesh representing the object's geometry. poses : list of autolab_core.RigidTransform A set of poses, one for each instance of the

(self, mesh, poses=None, raw_pose_data=None, colors=None,
                 T_obj_world=None,
                 material=None,
                 enabled=True)

Source from the content-addressed store, hash-verified

81 """A scene object which consists as a set of identical objects.
82 """
83 def __init__(self, mesh, poses=None, raw_pose_data=None, colors=None,
84 T_obj_world=None,
85 material=None,
86 enabled=True):
87 """Initialize a scene object with the given mesh, pose, and material.
88
89 Parameters
90 ----------
91 mesh : trimesh.Trimesh
92 A mesh representing the object's geometry.
93 poses : list of autolab_core.RigidTransform
94 A set of poses, one for each instance of the scene object,
95 relative to the full object's origin.
96 raw_pose_data : (4*n,4) float or None
97 A numpy array containing raw pose data, where each row is a column of a point's
98 homogenous transform matrix. If not present, poses must be present.
99 colors : (n,3) float or None
100 A set of colors for each instanced object. If None, the color specified in material
101 properties is used for all instances.
102 T_obj_world : autolab_core.RigidTransform
103 A rigid transformation from the object's frame to the world frame.
104 material : MaterialProperties
105 A set of material properties for the object.
106 enabled : bool
107 If False, the object will not be rendered.
108 """
109
110 super(InstancedSceneObject, self).__init__(mesh, T_obj_world, material, enabled)
111 self._poses = poses
112 self._raw_pose_data = raw_pose_data
113
114 if self._raw_pose_data is None:
115 if self._poses is None:
116 raise ValueError('Either poses or raw_pose_data must be specified')
117 self._raw_pose_data = np.zeros((4*len(self._poses), 4))
118 for i, pose in enumerate(self._poses):
119 self._raw_pose_data[i*4:(i+1)*4,:] = pose.matrix.T
120
121 self._n_instances = self._raw_pose_data.shape[0] // 4
122
123 self._colors = colors
124 if self._colors is None:
125 self._colors = np.tile(material.color, (self._n_instances,1))
126
127 @property
128 def poses(self):

Callers

nothing calls this directly

Calls 1

__init__Method · 0.45

Tested by

no test coverage detected