当前位置: 首页>>代码示例>>Python>>正文


Python TimerCallback.start方法代码示例

本文整理汇总了Python中ddapp.timercallback.TimerCallback.start方法的典型用法代码示例。如果您正苦于以下问题:Python TimerCallback.start方法的具体用法?Python TimerCallback.start怎么用?Python TimerCallback.start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ddapp.timercallback.TimerCallback的用法示例。


在下文中一共展示了TimerCallback.start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
def main():

    app = consoleapp.ConsoleApp()

    meshCollection = lcmobjectcollection.LCMObjectCollection('MESH_COLLECTION_COMMAND')
    affordanceCollection = lcmobjectcollection.LCMObjectCollection('AFFORDANCE_COLLECTION_COMMAND')

    meshCollection.sendEchoRequest()
    affordanceCollection.sendEchoRequest()

    def printCollection():
        print
        print '----------------------------------------------------'
        print datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        print '%d affordances' % len(affordanceCollection.collection)
        for desc in affordanceCollection.collection.values():
            print
            print 'name:', desc['Name']
            print 'type:', desc['classname']


    timer = TimerCallback(targetFps=0.2)
    timer.callback = printCollection
    timer.start()

    #app.showPythonConsole()
    app.start()
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:29,代码来源:affordanceServer.py

示例2: LCMForceDisplay

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
    class LCMForceDisplay(object):
        '''
        Displays foot force sensor signals in a status bar widget or label widget
        '''


        def onAtlasState(self,msg):
            self.l_foot_force_z = msg.force_torque.l_foot_force_z
            self.r_foot_force_z = msg.force_torque.r_foot_force_z

        def __init__(self, channel, statusBar=None):

            self.sub = lcmUtils.addSubscriber(channel, lcmdrc.atlas_state_t, self.onAtlasState)
            self.label = QtGui.QLabel('')
            statusBar.addPermanentWidget(self.label)

            self.timer = TimerCallback(targetFps=10)
            self.timer.callback = self.showRate
            self.timer.start()

            self.l_foot_force_z = 0
            self.r_foot_force_z = 0

        def __del__(self):
            lcmUtils.removeSubscriber(self.sub)

        def showRate(self):
            global leftInContact, rightInContact
            self.label.text = '%.2f | %.2f' % (self.l_foot_force_z,self.r_foot_force_z)
开发者ID:wxmerkt,项目名称:director,代码行数:31,代码来源:startup.py

示例3: showHandCloud

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
def showHandCloud(hand='left', view=None):

    view = view or app.getCurrentRenderView()
    if view is None:
        return

    assert hand in ('left', 'right')

    maps = om.findObjectByName('Map Server')
    assert maps is not None

    viewId = 52 if hand == 'left' else 53
    reader = maps.source.reader

    def getCurrentViewId():
        return reader.GetCurrentMapId(viewId)

    p = vtk.vtkPolyData()
    obj = showPolyData(p, '%s hand cloud' % hand, view=view, parent='sensors')
    obj.currentViewId = -1

    def updateCloud():
        currentViewId = getCurrentViewId()
        #print 'updateCloud: current view id:', currentViewId
        if currentViewId != obj.currentViewId:
            reader.GetDataForMapId(viewId, currentViewId, p)
            #print 'updated poly data.  %d points.' % p.GetNumberOfPoints()
            obj._renderAllViews()

    t = TimerCallback()
    t.targetFps = 1
    t.callback = updateCloud
    t.start()
    obj.updater = t
    return obj
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:37,代码来源:visualization.py

示例4: start

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
    def start(self):
        if self.reader is None:
            self.reader = drc.vtkMultisenseSource()
            self.reader.InitBotConfig(drcargs.args().config_file)
            self.reader.SetDistanceRange(0.25, 4.0)
            self.reader.Start()

        TimerCallback.start(self)
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:10,代码来源:perception.py

示例5: BlackoutMonitor

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class BlackoutMonitor(object):
    UPDATE_RATE = 5
    AVERAGE_N = 5
    def __init__(self, robotStateJointController, view, cameraview, mapServerSource):

        self.robotStateJointController = robotStateJointController
        self.view = view
        self.cameraview = cameraview
        self.mapServerSource = mapServerSource

        self.lastCameraMessageTime = 0
        self.lastScanBundleMessageTime = 0

        self.lastBlackoutLengths = []
        self.lastBlackoutLength = 0
        self.inBlackout = False
        self.averageBlackoutLength = 0.0

        self.txt = vis.updateText("DATA AGE: 0 sec", "Data Age Text", view=self.view)
        self.txt.addProperty('Show Avg Duration', False)
        self.txt.setProperty('Visible', False)

        self.updateTimer = TimerCallback(self.UPDATE_RATE)
        self.updateTimer.callback = self.update
        self.updateTimer.start()

    def update(self):
        self.lastCameraMessageTime = self.cameraview.imageManager.queue.getCurrentImageTime('CAMERA_LEFT')
        self.lastScanBundleMessageTime = self.mapServerSource.reader.GetLastScanBundleUTime()
        if self.robotStateJointController.lastRobotStateMessage:
            elapsedCam = max((self.robotStateJointController.lastRobotStateMessage.utime - self.lastCameraMessageTime) / (1000*1000), 0.0)
            elapsedScan = max((self.robotStateJointController.lastRobotStateMessage.utime - self.lastScanBundleMessageTime) / (1000*1000), 0.0)
            # can't be deleted, only hidden, so this is ok
            if (self.txt.getProperty('Visible')):
                if (self.txt.getProperty('Show Avg Duration')):
                    textstr = "CAM  AGE: %02d sec\nSCAN AGE: %02d sec    AVG: %02d sec" % (math.floor(elapsedCam), math.floor(elapsedScan), math.floor(self.averageBlackoutLength))
                else:
                    textstr = "CAM  AGE: %02d sec\nSCAN AGE: %02d sec" % (math.floor(elapsedCam), math.floor(elapsedScan))
                ssize = self.view.size
                self.txt.setProperty('Text', textstr)
                self.txt.setProperty('Position', [10, 10])

            # count out blackouts
            if elapsedCam > 1.0:
                self.inBlackout = True
                self.lastBlackoutLength = elapsedCam
            else:
                if (self.inBlackout):
                    # Don't count huge time jumps due to init
                    if (self.lastBlackoutLength < 100000):
                        self.lastBlackoutLengths.append(self.lastBlackoutLength)
                    if len(self.lastBlackoutLengths) > self.AVERAGE_N:
                        self.lastBlackoutLengths.pop(0)
                    if len(self.lastBlackoutLengths) > 0:
                        self.averageBlackoutLength = sum(self.lastBlackoutLengths) / float(len(self.lastBlackoutLengths))
                    self.inBlackout = False
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:58,代码来源:blackoutmonitor.py

示例6: KinectSource

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class KinectSource(TimerCallback):

    def __init__(self, view, _KinectQueue):
        self.view = view
        self.KinectQueue = _KinectQueue

        self.visible = True
        
        self.p = vtk.vtkPolyData()
        utime = KinectQueue.getPointCloudFromKinect(self.p)
        self.polyDataObj = vis.PolyDataItem('kinect source', shallowCopy(self.p), view)
        self.polyDataObj.actor.SetPickable(1)
        self.polyDataObj.initialized = False

        om.addToObjectModel(self.polyDataObj)

        self.queue = PythonQt.dd.ddBotImageQueue(lcmUtils.getGlobalLCMThread())
        self.queue.init(lcmUtils.getGlobalLCMThread(), drcargs.args().config_file)

        self.targetFps = 30
        self.timerCallback = TimerCallback(targetFps=self.targetFps)
        self.timerCallback.callback = self._updateSource
        #self.timerCallback.start()
        
    def start(self):
        self.timerCallback.start()

    def stop(self):
        self.timerCallback.stop()

    def setFPS(self, framerate):
        self.targetFps = framerate
        self.timerCallback.stop()
        self.timerCallback.targetFps = framerate
        self.timerCallback.start()

    def setVisible(self, visible):
        self.polyDataObj.setProperty('Visible', visible)

    def _updateSource(self):
        p = vtk.vtkPolyData()
        utime = self.KinectQueue.getPointCloudFromKinect(p)

        if not p.GetNumberOfPoints():
            return

        cameraToLocalFused = vtk.vtkTransform()
        self.queue.getTransform('KINECT_RGB', 'local', utime, cameraToLocalFused)
        p = filterUtils.transformPolyData(p,cameraToLocalFused)
        self.polyDataObj.setPolyData(p)

        if not self.polyDataObj.initialized:
            self.polyDataObj.setProperty('Color By', 'rgb_colors')
            self.polyDataObj.initialized = True
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:56,代码来源:kinectlcm.py

示例7: TriggerFingerPublisher

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class TriggerFingerPublisher():
	def __init__(self, lcmChannel):
		self.lcmChannel = lcmChannel
		self.reader = midi.MidiReader()
		self.timer = TimerCallback()
		self.timer.callback = self.tick
		self.msg = lcmdrc.trigger_finger_t()
	
	def startPublishing(self):	
		print 'Publishing on ' + self.lcmChannel
		self.timer.start()

	def publish(self):
		messages = self.reader.getMessages()
		
		for message in messages:
			channel = message[2]
			val = message[3] / 127.0
			if channel is 102:
				self.msg.slider1 = val
			elif channel is 103:
				self.msg.slider2 = val
			elif channel is 104:
				self.msg.slider3 = val
			elif channel is 105:
				self.msg.slider4 = val
			elif channel is 106:
				self.msg.knob1 = val
			elif channel is 107:
				self.msg.knob2 = val
			elif channel is 108:
				self.msg.knob3 = val
			elif channel is 109:
				self.msg.knob4 = val
			elif channel is 110:
				self.msg.knob5 = val
			elif channel is 111:
				self.msg.knob6 = val
			elif channel is 112:
				self.msg.knob7 = val
			elif channel is 113:
				self.msg.knob8 = val
		
		if len(messages) is not 0:
			self.msg.utime = getUtime()
			lcmUtils.publish(self.lcmChannel, self.msg)

	
	def tick(self):
		self.publish()
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:52,代码来源:triggerfinger.py

示例8: CommittedRobotPlanListener

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class CommittedRobotPlanListener(object):

    def __init__(self):
        self.sub = lcmUtils.addSubscriber('COMMITTED_ROBOT_PLAN', lcmdrc.robot_plan_t, self.onRobotPlan)
        lcmUtils.addSubscriber('COMMITTED_PLAN_PAUSE', lcmdrc.plan_control_t, self.onPause)
        self.animationTimer = None


    def onPause(self, msg):
        commandStream.stopStreaming()
        if self.animationTimer:
            self.animationTimer.stop()

    def onRobotPlan(self, msg):


        playback = planplayback.PlanPlayback()
        playback.interpolationMethod = 'pchip'
        poseTimes, poses = playback.getPlanPoses(msg)
        f = playback.getPoseInterpolator(poseTimes, poses)

        print 'received robot plan, %.2f seconds' % (poseTimes[-1] - poseTimes[0])

        commandStream.applyPlanDefaults()
        commandStream.startStreaming()

        timer = simpletimer.SimpleTimer()

        def setPose(pose):
            commandStream.setGoalPose(pose)

        def updateAnimation():

            tNow = timer.elapsed()

            if tNow > poseTimes[-1]:
                pose = poses[-1]
                setPose(pose)
                commandStream.applyDefaults()
                print 'plan ended.'
                return False

            pose = f(tNow)
            setPose(pose)

        self.animationTimer = TimerCallback()
        self.animationTimer.targetFps = 1000
        self.animationTimer.callback = updateAnimation
        self.animationTimer.start()
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:51,代码来源:testAtlasCommand.py

示例9: SpindleSpinChecker

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class SpindleSpinChecker(object):

    def __init__(self, spindleMonitor):

        self.spindleMonitor = spindleMonitor
        self.timer = TimerCallback(targetFps=3)
        self.timer.callback = self.update
        self.warningButton = None
        self.action = None

    def update(self):        
        if abs(self.spindleMonitor.getAverageSpindleVelocity()) < 0.2:
            self.notifyUserStatusBar()
        else:
            self.clearStatusBarWarning()

    def start(self):
        self.action.checked = True
        self.timer.start()

    def stop(self):
        self.action.checked = False
        self.timer.stop()

    def setupMenuAction(self):
        self.action = app.addMenuAction('Tools', 'Spindle Stuck Warning')
        self.action.setCheckable(True)
        self.action.checked = self.timer.isActive()
        self.action.connect('triggered()', self.onActionChanged)

    def onActionChanged(self):
        if self.action.checked:
            self.start()
        else:
            self.stop()

    def clearStatusBarWarning(self):
        if self.warningButton:
            self.warningButton.deleteLater()
            self.warningButton = None

    def notifyUserStatusBar(self):
        if self.warningButton:
            return
        self.warningButton = QtGui.QPushButton('Spindle Stuck Warning')
        self.warningButton.setStyleSheet("background-color:red")
        app.getMainWindow().statusBar().insertPermanentWidget(0, self.warningButton)
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:49,代码来源:multisensepanel.py

示例10: ImageWidget

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class ImageWidget(object):

    def __init__(self, imageManager, imageName, view):
        self.view = view
        self.imageManager = imageManager
        self.imageName = imageName

        self.updateUtime = 0
        self.initialized = False

        self.imageWidget = vtk.vtkLogoWidget()
        rep = self.imageWidget.GetRepresentation()
        rep.GetImageProperty().SetOpacity(1.0)
        self.imageWidget.SetInteractor(self.view.renderWindow().GetInteractor())

        self.flip = vtk.vtkImageFlip()
        self.flip.SetFilteredAxis(1)
        self.flip.SetInput(imageManager.getImage(imageName))
        rep.SetImage(self.flip.GetOutput())

        self.timerCallback = TimerCallback()
        self.timerCallback.targetFps = 60
        self.timerCallback.callback = self.updateView
        self.timerCallback.start()


    def hide(self):
        self.imageWidget.Off()

    def show(self):
        self.imageWidget.On()

    def updateView(self):

        if not self.view.isVisible():
            return

        currentUtime = self.imageManager.updateImage(self.imageName)
        if currentUtime != self.updateUtime:
            if not self.initialized:
                self.show()
                self.initialized = True

            self.updateUtime = currentUtime
            self.flip.Update()
            self.view.render()
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:48,代码来源:cameraview.py

示例11: ControllerRateLabel

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
    class ControllerRateLabel(object):
        '''
        Displays a controller frequency in the status bar
        '''

        def __init__(self, atlasDriver, statusBar):
            self.atlasDriver = atlasDriver
            self.label = QtGui.QLabel('')
            statusBar.addPermanentWidget(self.label)

            self.timer = TimerCallback(targetFps=1)
            self.timer.callback = self.showRate
            self.timer.start()

        def showRate(self):
            rate = self.atlasDriver.getControllerRate()
            rate = 'unknown' if rate is None else '%d hz' % rate
            self.label.text = 'Controller rate: %s' % rate
开发者ID:wxmerkt,项目名称:director,代码行数:20,代码来源:startup.py

示例12: FrameVisualizationPanel

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class FrameVisualizationPanel(object):

    def __init__(self, view):

        self.view = view

        loader = QtUiTools.QUiLoader()
        uifile = QtCore.QFile(':/ui/ddFrameVisualization.ui')
        assert uifile.open(uifile.ReadOnly)


        self.widget = loader.load(uifile)
        self.ui = WidgetDict(self.widget.children())

        self.botFrameUpdater = BotFrameUpdater(self.ui.botFramesListWidget)

        robotModel = om.findObjectByName('robot state model')
        self.linkFrameUpdater = LinkFrameUpdater(robotModel, self.ui.linkFramesListWidget)

        self.eventFilter = PythonQt.dd.ddPythonEventFilter()
        self.ui.scrollArea.installEventFilter(self.eventFilter)
        self.eventFilter.addFilteredEventType(QtCore.QEvent.Resize)
        self.eventFilter.connect('handleEvent(QObject*, QEvent*)', self.onEvent)

        PythonQt.dd.ddGroupBoxHider(self.ui.botFramesGroup)
        PythonQt.dd.ddGroupBoxHider(self.ui.linkFramesGroup)

        self.updateTimer = TimerCallback(targetFps=60)
        self.updateTimer.callback = self.updateFrames
        self.updateTimer.start()

    def onEvent(self, obj, event):
        minSize = self.ui.scrollArea.widget().minimumSizeHint.width() + self.ui.scrollArea.verticalScrollBar().width
        self.ui.scrollArea.setMinimumWidth(minSize)

    def updateFrames(self):
        self.botFrameUpdater.updateFrames()

    def getNameFilter(self):
        return str(self.ui.botFramesFilterEdit.text)

    def onNameFilterChanged(self):
        filter = self.getNameFilter()
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:45,代码来源:framevisualization.py

示例13: AffordanceTextureUpdater

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class AffordanceTextureUpdater(object):

    def __init__(self, affordanceManager):
        self.affordanceManager = affordanceManager
        self.timer = TimerCallback(targetFps=10)
        self.timer.callback = self.updateTextures
        self.timer.start()

    def updateTexture(self, obj):
        if obj.getProperty('Camera Texture Enabled'):
            cameraview.applyCameraTexture(obj, cameraview.imageManager)
        else:
            cameraview.disableCameraTexture(obj)
        obj._renderAllViews()

    def updateTextures(self):

        for aff in affordanceManager.getAffordances():
            self.updateTexture(aff)
开发者ID:wxmerkt,项目名称:director,代码行数:21,代码来源:startup.py

示例14: startSwarmVisualization

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
def startSwarmVisualization():
    global timerCallback, nav_data, nav_cloud
    nav_cloud = vtknp.getVtkPolyDataFromNumpyPoints(nav_data)
    nav_cloud_obj = vis.showPolyData(shallowCopy(nav_cloud), 'nav data')

    nav_cloud_obj.initialized = False

    def updateSwarm():
      global nav_cloud

      if not nav_cloud_obj.initialized:
         nav_cloud_obj.mapper.SetColorModeToMapScalars()
         nav_cloud_obj.initialized = True

      #print nav_data.shape[0], nav_cloud.GetNumberOfPoints()
      nav_cloud = vtknp.getVtkPolyDataFromNumpyPoints(nav_data)
      nav_cloud_obj.setPolyData(shallowCopy(nav_cloud))
      #print nav_cloud_obj.polyData.GetNumberOfPoints()

    timerCallback = TimerCallback(targetFps=30)
    timerCallback.callback = updateSwarm
    timerCallback.start()
开发者ID:nicrip,项目名称:moos-ivp-swarm,代码行数:24,代码来源:swarm_visualize.py

示例15: PointerTracker

# 需要导入模块: from ddapp.timercallback import TimerCallback [as 别名]
# 或者: from ddapp.timercallback.TimerCallback import start [as 别名]
class PointerTracker(object):
    '''
    See segmentation.estimatePointerTip() documentation.
    '''
    def __init__(self, robotModel, stereoPointCloudItem):
        self.robotModel = robotModel
        self.stereoPointCloudItem = stereoPointCloudItem
        self.timer = TimerCallback(targetFps=5)
        self.timer.callback = self.updateFit

    def start(self):
        self.timer.start()

    def stop(self):
        self.timer.stop()

    def cleanup(self):
        om.removeFromObjectModel(om.findObjectByName('segmentation'))

    def updateFit(self, polyData=None):

        #if not self.stereoPointCloudItem.getProperty('Visible'):
        #    return

        if not polyData:
            self.stereoPointCloudItem.update()
            polyData = self.stereoPointCloudItem.polyData

        if not polyData or not polyData.GetNumberOfPoints():
            self.cleanup()
            return

        self.tipPosition = segmentation.estimatePointerTip(self.robotModel, polyData)
        if self.tipPosition is None:
            self.cleanup()

    def getPointerTip(self):
        return self.tipPosition
开发者ID:mlab-upenn,项目名称:arch-apex,代码行数:40,代码来源:trackers.py


注:本文中的ddapp.timercallback.TimerCallback.start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。