コード例 #1
0
ファイル: glrobotprogram.py プロジェクト: whutddk/Klampt
    def __init__(self, world):
        """Arguments:
        - world: a RobotWorld instance.
        """
        GLPluginInterface.__init__(self)
        self.world = world
        #Put your initialization code here
        #the current example creates a collision class, simulator,
        #simulation flag, and screenshot flags
        self.collider = collide.WorldCollider(world)
        self.sim = SimpleSimulator(world)
        self.simulate = False
        self.dt = 0.02

        #turn this on to draw contact points
        self.drawContacts = False

        #turn this on to draw sensors
        self.drawSensors = False

        #turn this on to save screenshots
        self.saveScreenshots = False
        self.nextScreenshotTime = 0
        self.screenshotCount = 0
        self.verbose = 0

        self.htmlSharePath = None

        def toggle_simulate():
            self.simulate = not self.simulate
            print "Simulating:", self.simulate

        def toggle_movie_mode():
            self.saveScreenshots = not self.saveScreenshots
            print "Movie mode:", self.saveScreenshots

        def toggle_draw_contacts():
            self.drawContacts = not self.drawContacts
            if self.drawContacts:
                self.sim.enableContactFeedbackAll()

        def toggle_draw_sensors():
            if self.drawSensors == False:
                self.drawSensors = True
            elif self.drawSensors == True:
                self.drawSensors = 'full'
            else:
                self.drawSensors = False

        def single_step():
            print "Advancing by 0.01s"
            self.simStep(0.01)

        self.add_action(toggle_simulate, 'Toggle simulation', 's')
        self.add_action(single_step, 'Step simulation', ' ')
        #self.add_action(toggle_movie_mode,'Toggle movie mode','m')
        self.add_action(self.sim.toggleLogging, 'Toggle simulation logging',
                        'l')
        self.add_action(toggle_draw_contacts, 'Toggle draw contacts', 'c')
        self.add_action(toggle_draw_sensors, 'Toggle draw sensors', 'v')
コード例 #2
0
ファイル: glcommon.py プロジェクト: kunlqt/Klampt
    def __init__(self):
        from ..robotsim import WidgetSet

        GLPluginInterface.__init__(self)
        self.klamptwidgetbutton = 2
        self.klamptwidgetmaster = WidgetSet()
        self.klamptwidgetdragging = False
コード例 #3
0
ファイル: glcommon.py プロジェクト: krishauser/Klampt
    def __init__(self):
        from ..robotsim import WidgetSet

        GLPluginInterface.__init__(self)
        self.klamptwidgetbutton = 2
        self.klamptwidgetmaster = WidgetSet()
        self.klamptwidgetdragging = False
コード例 #4
0
ファイル: glrobotprogram.py プロジェクト: krishauser/Klampt
 def __init__(self,world):
     """Args:
         world (WorldModel): the world to draw
     """
     GLPluginInterface.__init__(self)
     self.world = world
     #Put your initialization code here
     #the current example creates a collision class, simulator, 
     #simulation flag, and screenshot flags
     self.collider = collide.WorldCollider(world)
コード例 #5
0
ファイル: glrobotprogram.py プロジェクト: xyyeh/Klampt
 def __init__(self, world):
     """Args:
         world (WorldModel): the world to draw
     """
     GLPluginInterface.__init__(self)
     self.world = world
     #Put your initialization code here
     #the current example creates a collision class, simulator,
     #simulation flag, and screenshot flags
     self.collider = collide.WorldCollider(world)
コード例 #6
0
ファイル: glrobotprogram.py プロジェクト: krishauser/Klampt
 def motionfunc(self,x,y,dx,dy):
     return GLPluginInterface.motionfunc(self,x,y,dx,dy)
コード例 #7
0
ファイル: glrobotprogram.py プロジェクト: krishauser/Klampt
 def mousefunc(self,button,state,x,y):
     #Put your mouse handler here
     #the current example prints out the list of objects clicked whenever
     #you right click
     if self.verbose: print "mouse",button,state,x,y
     return GLPluginInterface.mousefunc(self,button,state,x,y)
コード例 #8
0
ファイル: glrobotprogram.py プロジェクト: whutddk/Klampt
 def initialize(self):
     #match window refresh rate
     self.dt = self.window.program.dt
     return GLPluginInterface.initialize(self)
コード例 #9
0
ファイル: glrobotprogram.py プロジェクト: whutddk/Klampt
 def motionfunc(self, x, y, dx, dy):
     return GLPluginInterface.motionfunc(self, x, y, dx, dy)
コード例 #10
0
ファイル: glrobotprogram.py プロジェクト: whutddk/Klampt
 def mousefunc(self, button, state, x, y):
     #Put your mouse handler here
     #the current example prints out the list of objects clicked whenever
     #you right click
     if self.verbose: print "mouse", button, state, x, y
     return GLPluginInterface.mousefunc(self, button, state, x, y)
コード例 #11
0
ファイル: glrobotprogram.py プロジェクト: gbyfbi/Klampt
    def __init__(self, world):
        """Arguments:
        - world: a RobotWorld instance.
        """
        GLPluginInterface.__init__(self)
        self.world = world
        #Put your initialization code here
        #the current example creates a collision class, simulator,
        #simulation flag, and screenshot flags
        self.collider = collide.WorldCollider(world)
        self.sim = SimpleSimulator(world)
        self.simulate = False
        self.dt = 0.02

        #turn this on to draw contact points
        self.drawContacts = False

        #turn this on to draw sensors
        self.drawSensors = False

        #turn this on to save screenshots
        self.saveScreenshots = False
        self.nextScreenshotTime = 0
        self.screenshotCount = 0
        self.verbose = 0

        self.htmlSharePath = None

        def toggle_simulate():
            self.simulate = not self.simulate
            print "Simulating:", self.simulate

        def toggle_movie_mode():
            self.saveScreenshots = not self.saveScreenshots
            print "Movie mode:", self.saveScreenshots

        def toggle_draw_contacts():
            self.drawContacts = not self.drawContacts
            if self.drawContacts:
                self.sim.enableContactFeedbackAll()

        def toggle_draw_sensors():
            if self.drawSensors == False:
                self.drawSensors = True
            elif self.drawSensors == True:
                self.drawSensors = 'full'
            else:
                self.drawSensors = False

        def share_path():
            from ..io import html
            if self.htmlSharePath is None:
                self.htmlSharePath = html.HTMLSharePath(
                    filename="simulation_path.html",
                    name="Klamp't Simulation Path")
                #20FPS is sufficient...
                self.htmlSharePath.dt = 0.05
                self.htmlSharePath.start(self.sim)
            else:
                try:
                    from PyQt4.QtGui import QFileDialog
                    patterns = "HTML files (*.html)"
                    fn = QFileDialog.getSaveFileName(
                        None, "Save path HTML file to...",
                        self.htmlSharePath.fn, patterns)
                    if fn:
                        self.htmlSharePath.fn = fn
                    else:
                        return
                except ImportError:
                    pass
                self.htmlSharePath.end()

        def single_step():
            print "Advancing by 0.01s"
            self.simStep(0.01)

        self.add_action(toggle_simulate, 'Toggle simulation', 's')
        self.add_action(single_step, 'Step simulation', ' ')
        self.add_action(toggle_movie_mode, 'Toggle movie mode', 'm')
        self.add_action(self.sim.toggleLogging, 'Toggle simulation logging',
                        'l')
        self.add_action(toggle_draw_contacts, 'Toggle draw contacts', 'c')
        self.add_action(toggle_draw_sensors, 'Toggle draw sensors', 'v')
        self.add_action(share_path, 'Begin/finalize logging path to HTML', 'w')