コード例 #1
0
def adjustMeshPath(path_mesh_pkg,link):
    """
    Find the path of a mesh according to the link definition.
    Set the visual and collision element of the given link
    :param : path_mesh_pkg, absolute path of the package where the meshes should be located
    :param : link, dictionary key of the link we want to set visual and collision parameters

    :return : tempVisu, Visual element with the NAO visual geometrical shape for people who don't have the meshes
    :return : tempCol, Collision element with the NAO collision geometrical shape for people who don't have the meshes
    """
    global robot, SCALE, MESHPKG, MESH_VERSION
    tempVisu = None
    tempVisuMesh = None
    tempCol = None
    tempColMesh = None
    if robot.links[link].visual != None:
        try:
            meshname = str(LINKS_DICO.keys()[list(LINKS_DICO.values()).index(link)])
            if meshname.endswith('_link'):
                meshfile = meshname[0:-5]
            else:
                meshfile = meshname
        except:
            meshname = link
            meshfile = link
            pass
        if meshfile.endswith('_link'):
            meshfile = meshfile[0:-5]
        tempVisuMesh = ur.Visual(ur.Mesh('',(SCALE,SCALE,SCALE)))
        tempColMesh = ur.Collision(ur.Mesh('',(SCALE,SCALE,SCALE)))
        tempVisuMesh.origin = robot.links[link].visual.origin
        tempColMesh.origin = robot.links[link].visual.origin
        if os.path.isfile(os.path.join(path_mesh_pkg, 'meshes',MESH_VERSION, robot.links[link].visual.geometry.filename[robot.links[link].visual.geometry.filename.rfind("/")+1:])):
            tempVisuMesh.geometry.filename = os.path.join('package://', NAME + MESHPKG , 'meshes' , MESH_VERSION, robot.links[link].visual.geometry.filename[robot.links[link].visual.geometry.filename.rfind("/")+1:])
            tempColMesh.geometry.filename = tempVisuMesh.geometry.filename[0:-4] + COLLISION_SUFFIX
        else:
            tempVisuMesh.geometry.filename =  os.path.join('package://', NAME + MESHPKG , 'meshes' ,MESH_VERSION, meshfile + '.dae')
            tempColMesh.geometry.filename = tempVisuMesh.geometry.filename[0:-4] + COLLISION_SUFFIX

        if NAME=='nao':
            try:
                tempVisu = ur.Visual(VISU_DICO[meshname], ur.Material('LightGrey'),  dico.Nao_orig[meshname])
                tempCol = ur.Collision(VISU_DICO[meshname], dico.Nao_orig[meshname])
            except KeyError:
                tempVisu = None
                tempCol = None
        robot.links[link].visual = tempVisuMesh
        robot.links[link].collision = tempColMesh
    return (tempVisu,tempCol)
コード例 #2
0
def add_dummy_collision(list):
    """Add a Box collision tag to every links containing keyword in list."""
    global robot
    for string in list:
        for link in robot.links:
            if robot.links[link].name.find(string) != -1:
                robot.links[link].collision = ur.Collision(
                    ur.Box([0.01, 0.01, 0.005]),
                    ur.Pose((0, 0, 0), (0, 0, 0)))