Example #1
0
            q[i] = qmin[i]
            traj.milestones.append(q)

            traj.times.append(len(traj.times) * 0.5)
            q[i] = qmax[i]
            traj.milestones.append(q)

        save, traj.milestones = resource.edit("trajectory",
                                              traj.milestones,
                                              world=world)
        visualization.animate("robot", traj)

    visualization.show()

    iteration = 0
    while visualization.shown():
        #visualization.lock()
        #can modify the visualization here
        #visualization.unlock()
        #time.sleep(0.01)
        #animationTime = visualization.animationTime()
        iteration += 1

    if len(sys.argv) > 1:
        visualization.animate("robot", None)
        sim = Simulator(world)
        sim.simulate(0)
        trajectory.execute_path(traj.milestones, sim.controller(0))
        #for some tricky Qt reason, need to sleep before showing a window again
        #Perhaps the event loop must complete some extra cycles?
        time.sleep(0.01)
Example #2
0
if __name__ == "__main__":
    print "visplugin.py: This example demonstrates how to simulate a world and read user input using the visualization framework"
    if len(sys.argv)<=1:
        print "USAGE: visplugin.py [world_file]"
        exit()

    world = WorldModel()
    for fn in sys.argv[1:]:
        res = world.readFile(fn)
        if not res:
            raise RuntimeError("Unable to load model "+fn)

    print "Press 'q' to exit"
    #the plugin is used to get interactivity with the visualizer... if you
    #don't care about interactivity, you may leave it out.  See vistemplate.py for
    #an example of this
    plugin = MyGLPlugin(world)
    visualization.setPlugin(plugin)
    #add the world to the visualizer
    visualization.add("world",world)
    #run the visualizer in a separate thread
    visualization.show()
    while visualization.shown() and not plugin.quit:
        visualization.lock()
        #TODO: you may modify the world here
        visualization.unlock()
        #changes to the visualization must be done outside the lock
        time.sleep(0.01)
    print "Ending visualization."
    visualization.kill()
Example #3
0
            traj.times.append(len(traj.times)*0.5)
            q = q0[:]
            q[i] = qmin[i]
            traj.milestones.append(q)
            
            traj.times.append(len(traj.times)*0.5)
            q[i] = qmax[i]
            traj.milestones.append(q)

        save,traj.milestones = resource.edit("trajectory",traj.milestones,world=world)
        visualization.animate("robot",traj)
    
    visualization.show()
    
    iteration = 0
    while visualization.shown():
        #visualization.lock()
        #can modify the visualization here
        #visualization.unlock()
        #time.sleep(0.01)
        #animationTime = visualization.animationTime()
        iteration += 1

    if len(sys.argv)>1:
        visualization.animate("robot",None)
        sim = Simulator(world)
        sim.simulate(0)
        trajectory.execute_path(traj.milestones,sim.controller(0))
        #for some tricky Qt reason, need to sleep before showing a window again
        #Perhaps the event loop must complete some extra cycles?
        time.sleep(0.01)
Example #4
0
    print "visplugin.py: This example demonstrates how to simulate a world and read user input using the klampt.visualization framework"
    if len(sys.argv)<=1:
        print "USAGE: visplugin.py [world_file]"
        exit()

    world = WorldModel()
    for fn in sys.argv[1:]:
        res = world.readFile(fn)
        if not res:
            raise RuntimeError("Unable to load model "+fn)
    world.enableInitCollisions(True)

    print "Press 'q' to exit"
    #the plugin is used to get interactivity with the visualizer... if you
    #don't care about interactivity, you may leave it out.  See vistemplate.py for
    #an example of this
    plugin = MyGLPlugin(world)
    visualization.setPlugin(plugin)
    #add the world to the visualizer
    visualization.add("world",world)
    #run the visualizer in a separate thread
    visualization.show()
    while visualization.shown() and not plugin.quit:
        visualization.lock()
        #TODO: you may modify the world here
        visualization.unlock()
        #changes to the visualization must be done outside the lock
        time.sleep(0.01)
    print "Ending visualization."
    visualization.kill()
Example #5
0
visualization.dialog()

import threading
import time

print "Showing threaded visualization"
lock = threading.Lock()
visualization.show(lock)
for i in range(3):
    lock.acquire()
    q = world.robot(0).getConfig()
    q[9] = 3.0
    world.robot(0).setConfig(q)
    lock.release()
    time.sleep(1.0)
    if not visualization.shown():
        break
    lock.acquire()
    q = world.robot(0).getConfig()
    q[9] = -1.0
    world.robot(0).setConfig(q)
    lock.release()
    time.sleep(1.0)
    if not visualization.shown():
        break
visualization.show(False)

#look in resources/athlete/
resource.setDirectory('resources/'+robotname)

config = resource.get("resourcetest1.config",description="First config, always edited",doedit=True,editor='visual',world=world)