示例#1
0
def from_obj(filename):
    mesh = threed.mesh_from_obj(filename)
    
    res = object_finder_msg.Mesh()
    
    components = []
    for mtl, x in itertools.groupby(zip(mesh.indices, mesh.materials), lambda (triangle, mtl): mtl):
        triangles = []
        for triangle, mtl_ in x:
            assert len(triangle) == 3
            assert mtl_ is mtl
            
            triangles.append(object_finder_msg.Triangle(
                corners=[Point(*mesh.vertices[vert_index]) for vert_index, tex_index, normal_index in triangle],
            ))
        
        components.append(object_finder_msg.Component(
            name=mtl.name,
            color=object_finder_msg.Color(
                r=mtl.Kd[0],
                g=mtl.Kd[1],
                b=mtl.Kd[2],
            ),
            triangles=triangles,
        ))
示例#2
0
                corners=[Point(*mesh.vertices[vert_index]) for vert_index, tex_index, normal_index in triangle],
            ))
        
        components.append(object_finder_msg.Component(
            name=mtl.name,
            color=object_finder_msg.Color(
                r=mtl.Kd[0],
                g=mtl.Kd[1],
                b=mtl.Kd[2],
            ),
            triangles=triangles,
        ))
    
    components.sort(key=lambda component: component.name)
    
    return object_finder_msg.Mesh(components=components)

targetdesc = object_finder_msg.TargetDesc(
    type=object_finder_msg.TargetDesc.TYPE_MESH,
    mesh=None,
    prior_distribution=PoseWithCovariance(
        pose=Pose(
            orientation=None, # set later
        ),
        covariance=[
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,
            0, 0, 0, 0, 0, 0,