ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
pyassimp apparently reads 3D file formats like ply
and stl
, and there is a usage example in the MoveIt planning scene interface that is probably helpful:
def makeMesh(self, name, pose, filename):
if not use_pyassimp:
rospy.logerr('pyassimp is broken on your platform, cannot load meshes')
return
scene = pyassimp.load(filename)
if not scene.meshes:
rospy.logerr('Unable to load mesh')
return
mesh = Mesh()
for face in scene.meshes[0].faces:
triangle = MeshTriangle()
if len(face.indices) == 3:
triangle.vertex_indices = [face.indices[0],
face.indices[1],
face.indices[2]]
mesh.triangles.append(triangle)
for vertex in scene.meshes[0].vertices:
point = Point()
point.x = vertex[0]
point.y = vertex[1]
point.z = vertex[2]
mesh.vertices.append(point)
pyassimp.release(scene)
o = CollisionObject()
o.header.stamp = rospy.Time.now()
o.header.frame_id = self._fixed_frame
o.id = name
o.meshes.append(mesh)
o.mesh_poses.append(pose)
o.operation = o.ADD
return o