Пример #1
0
                continue
            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))
Пример #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()
Пример #3
0
robotname = 'athlete'

world = WorldModel()
world.readFile(worldfile)

print "Showing robot in modal dialog box"
visualization.add("robot",world.robot(0))
visualization.add("ee",world.robot(0).link(11).getTransform())
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)
Пример #4
0
worldfile = "../../data/athlete_plane.xml"
robotname = "athlete"

world = WorldModel()
world.readFile(worldfile)

"""
#tests of visualization module interacting with the resource module
print "Showing robot in modal dialog box"
visualization.add("robot",world.robot(0))
visualization.add("ee",world.robot(0).link(11).getTransform())
visualization.dialog()
import time
"""

"""
#tests of visualization module interacting with the resource module
print "Showing threaded visualization"
visualization.show()
for i in range(3):
    visualization.lock()
    q = world.robot(0).getConfig()
    q[9] = 3.0
    world.robot(0).setConfig(q)
    visualization.unlock()
    time.sleep(1.0)
    if not visualization.shown():
        break
    visualization.lock()
    q = world.robot(0).getConfig()
    q[9] = -1.0
Пример #5
0
resource module."""

worldfile = "../../data/athlete_plane.xml"
robotname = 'athlete'

world = WorldModel()
world.readFile(worldfile)
"""
#tests of visualization module interacting with the resource module
print "Showing robot in modal dialog box"
visualization.add("robot",world.robot(0))
visualization.add("ee",world.robot(0).link(11).getTransform())
visualization.dialog()
import time
"""
"""
#tests of visualization module interacting with the resource module
print "Showing threaded visualization"
visualization.show()
for i in range(3):
    visualization.lock()
    q = world.robot(0).getConfig()
    q[9] = 3.0
    world.robot(0).setConfig(q)
    visualization.unlock()
    time.sleep(1.0)
    if not visualization.shown():
        break
    visualization.lock()
    q = world.robot(0).getConfig()
    q[9] = -1.0