Ejemplo n.º 1
0
def edit_template(world):
    """Shows how to pop up a visualization window with a world in which the robot configuration and a transform can be edited"""
    #add the world to the visualizer
    vis.add("world",world)
    xform = se3.identity()
    vis.add("transform",xform)
    robotPath = ("world",world.robot(0).getName())  #compound item reference: refers to robot 0 in the world
    vis.edit(robotPath)   
    vis.edit("transform")

    #This prints how to get references to items in the visualizer
    print("Visualization items:")
    vis.listItems(indent=2)

    vis.setWindowTitle("Visualization editing test")
    if not MULTITHREADED:
        vis.loop(setup=vis.show)
    else:
        vis.show()
        while vis.shown():
            vis.lock()
            #TODO: you may modify the world here.
            vis.unlock()
            time.sleep(0.01)
    print("Resulting configuration",vis.getItemConfig(robotPath))
    print("Resulting transform (config)",vis.getItemConfig("transform"))  # this is a vector describing the item parameters
    xform = list(xform)  #convert se3 element from tuple to list
    config.setConfig(xform,vis.getItemConfig("transform"))
    print("Resulting transform (se3)",xform)
    #quit the visualization thread nicely
    vis.kill()
Ejemplo n.º 2
0
    #creates a world and loads all the items on the command line
    world = WorldModel()
    for fn in sys.argv[1:]:
        res = world.readFile(fn)
        if not res:
            raise RuntimeError("Unable to load model "+fn)

    robot = world.robot(0)
    endeffectors = [robot.numLinks()-1]
    #(res,val) = editors.run(editors.SelectionEditor("endeffectors",endeffectors,description="End effector links",world=world,robot=robot))
    #if res:
    #    print "Return value",val
    #    endeffectors = val

    vis.add("world",world)
    vis.listItems()
    vis.setColor(("world",world.robot(0).getName()),1,1,0,1)
    coordinates.setRobotModel(robot)
    eenames = [robot.link(e).getName() for e in endeffectors]
    eeobjectives = []
    for e in endeffectors:
        f = coordinates.frame(robot.link(e).getName())
        fw = coordinates.addFrame(robot.link(e).getName()+"_tgt",robot.link(e).getTransform())
        assert f != None
        vis.add("ee_"+robot.link(e).getName(),fw)
        vis.edit("ee_"+robot.link(e).getName())
        obj = coordinates.ik_fixed_objective(f)
        eeobjectives.append(obj)

    #this tests the cartesian interpolation stuff
    print "***** BEGINNING CARTESIAN INTERPOLATION TEST *****"
Ejemplo n.º 3
0
    vp = vis.getViewport()
    vp.w, vp.h = 1500, 1100
    vis.setViewport(vp)

    ## Create robot object. Change the class to the desired robot.
    ## Also, make sure the robot class corresponds to the robot in simpleWorld.xml file

    robot = unicycle(world.robot(0), "unicycle", vis)
    robot.setAltitude(0.1)

    ## Display the world coordinate system
    vis.add("WCS", [so3.identity(), [0, 0, 0]])
    vis.setAttribute("WCS", "size", 12)

    print "Visualization items:"
    vis.listItems(indent=2)
    #vis.autoFitCamera()
    vis.addText("textCol", "No collision")
    vis.setAttribute("textCol", "size", 24)
    collisionFlag = False
    collisionChecker = collide.WorldCollider(world)

    ## On-screen text display
    vis.addText("textConfig", "Robot configuration: ")
    vis.setAttribute("textConfig", "size", 24)
    vis.addText("textbottom", "WCS: X-axis Red, Y-axis Green, Z-axis Blue",
                (20, -30))

    print "Starting visualization window#..."

    ## Run the visualizer, which runs in a separate thread