in tacto/sensor.py [0:0]
def add_object(self, urdf_fn, obj_id, globalScaling=1.0):
# Load urdf file by urdfpy
robot = URDF.load(urdf_fn)
for link_id, link in enumerate(robot.links):
if len(link.visuals) == 0:
continue
link_id = link_id - 1
# Get each links
visual = link.visuals[0]
obj_trimesh = visual.geometry.meshes[0]
# Set mesh color to default (remove texture)
obj_trimesh.visual = trimesh.visual.ColorVisuals()
# Set initial origin (pybullet pose already considered initial origin position, not orientation)
pose = visual.origin
# Scale if it is mesh object (e.g. STL, OBJ file)
mesh = visual.geometry.mesh
if mesh is not None and mesh.scale is not None:
S = np.eye(4, dtype=np.float64)
S[:3, :3] = np.diag(mesh.scale)
pose = pose.dot(S)
# Apply interial origin if applicable
inertial = link.inertial
if inertial is not None and inertial.origin is not None:
pose = np.linalg.inv(inertial.origin).dot(pose)
# Set global scaling
pose = np.diag([globalScaling] * 3 + [1]).dot(pose)
obj_trimesh = obj_trimesh.apply_transform(pose)
obj_name = "{}_{}".format(obj_id, link_id)
self.objects[obj_name] = Link(obj_id, link_id, self.cid)
position, orientation = self.objects[obj_name].get_pose()
# Add object in pyrender
self.renderer.add_object(
obj_trimesh,
obj_name,
position=position, # [-0.015, 0, 0.0235],
orientation=orientation, # [0, 0, 0],
)