示例#1
0
        def __call__(self):
            vis.lock()
            #TODO: you may modify the world here.  This line tests a sin wave.
            pt[2] = 1 + math.sin(self.iteration*0.03)
            vis.unlock()
            #changes to the visualization with vis.X functions can done outside the lock
            if (self.iteration % 100) == 0:
                if (self.iteration / 100)%2 == 0:
                    vis.hide("some blinking transform")
                    vis.addText("text4","The transform was hidden")
                    vis.logPlotEvent('plot','hide')
                else:
                    vis.hide("some blinking transform",False)
                    vis.addText("text4","The transform was shown")
                    vis.logPlotEvent('plot','show')
            #this is another way of changing the point's data without needing a lock/unlock
            #vis.add("some point",[2,5,1 + math.sin(iteration*0.03)],keepAppearance=True)
            #or
            #vis.setItemConfig("some point",[2,5,1 + math.sin(iteration*0.03)])

            if self.iteration == 200:
                vis.addText("text2","Going to hide the text for a second...")
            if self.iteration == 400:
                #use this to remove text
                vis.clearText()
            if self.iteration == 500:
                vis.addText("text2","Text added back again")
                vis.setColor("text2",1,0,0)
            self.iteration += 1
    def run(self):
        while vis.shown():
            vis.lock()

            vis.unlock()
            # changes to the visualization must be done outside the lock
        vis.clearText()
        print "Ending klampt.vis visualization."
示例#3
0
def multiwindow_template(world):
    """Tests multiple windows and views."""
    vis.add("world", world)
    vp = vis.getViewport()
    vp.w, vp.h = 400, 600
    vis.setViewport(vp)
    vis.addText("label1", "This is Window 1", (20, 20))
    vis.setWindowTitle("Window 1")
    vis.show()
    id1 = vis.getWindow()
    print("First window ID:", id1)

    id2 = vis.createWindow("Window 2")
    vis.add("Lone point", [0, 0, 0])
    vis.setViewport(vp)
    vis.addText("label1", "This is Window 2", (20, 20))
    print("Second window ID:", vis.getWindow())
    vis.setWindow(id2)
    vis.spin(float('inf'))

    #restore back to 1 window, clear the text
    vis.setWindow(id1)
    vis.clearText()

    vp = vis.getViewport()
    vp.w, vp.h = 800, 800
    vis.setViewport(vp)

    vis.setWindowTitle("vis.spin test: will close in 5 seconds...")
    vis.spin(5.0)

    #Now testing ability to re-launch windows
    vis.setWindowTitle("Shown again.  Close me to proceed.")
    vis.spin(float('inf'))

    vis.setWindowTitle("Dialog test. Close me to proceed.")
    vp = vis.getViewport()
    vp.w, vp.h = 400, 600
    vis.setViewport(vp)
    vis.dialog()

    vp.w, vp.h = 640, 480
    vis.setViewport(vp)
    for i in range(3):
        widgets = GLWidgetPlugin()
        widgets.addWidget(RobotPoser(world.robot(0)))
        vis.addPlugin(widgets)
    vis.setWindowTitle("Split screen test")
    vis.spin(float('inf'))

    vis.setPlugin(None)
    vis.setWindowTitle("Back to normal. Close me to quit.")
    vis.dialog()
    vis.kill()
示例#4
0
            print(i.printNode())

        vis.lock()
        vis.add("Initial", [source[0], source[1], 0.02])
        vis.setAttribute("Initial", "size", 14)
        vis.setColor("Initial", 0, 0.4470, 0.7410)
        vis.add("Goal", [goal[0], goal[1], 0.02])
        vis.setAttribute("Goal", "size", 14)
        vis.setColor("Goal", 0.8500, 0.3250, 0.0980)
        vis.unlock()

        vis.show()
        time.sleep(15)
        vis.lock()
        robot.setConfig(waypoints[0].point)
        vis.unlock()
        for i in range(len(waypoints) - 1):
            prWaypnt = waypoints[i + 1]

            for j in range(prWaypnt.t - 1):
                vis.lock()
                robot.velControlKin(prWaypnt.u1 * u1, prWaypnt.u2 * u2, dt)
                vis.unlock()
                time.sleep(dt)

    time.sleep(15)
    vis.clearText()

    print "Ending klampt.vis visualization."
    vis.kill()
示例#5
0
 def endEnv(self):
     vis.clearText()
     print "Ending klampt.vis visualization."
     vis.kill()