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
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()
def startApplication(enableQuitTimer=False): appInstance = QtGui.QApplication.instance() if enableQuitTimer: quitTimer = TimerCallback() quitTimer.callback = appInstance.quit quitTimer.singleShot(0.1) appInstance.exec_()
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()
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()
def startQuitTimer(timeoutInSeconds): quitTimer = TimerCallback() quitTimer.callback = ConsoleApp.quit quitTimer.singleShot(timeoutInSeconds)
######################### numRays = 20 rayLength = 5 angleMin = -np.pi/2 angleMax = np.pi/2 angleGrid = np.linspace(angleMin, angleMax, numRays) rays = np.zeros((3,numRays)) rays[0,:] = np.cos(angleGrid) rays[1,:] = np.sin(angleGrid) timer = TimerCallback(targetFps=30) timer.callback = tick playTimer = TimerCallback(targetFps=30) playTimer.callback = tick3 app = ConsoleApp() view = app.createView() panel = QtGui.QWidget()
ql.setMinimum(min) ql.setOrientation(QtCore.Qt.Vertical) return ql statusLabel = spawnBasicLabel() l.addWidget(wrapInVTitledItem("Behavior", [statusLabel])) def statusUpdate(): behavior = atlasDriver.getCurrentBehaviorName() statusLabel.setText(behavior) if (behavior != "user"): statusLabel.setStyleSheet(LABEL_DEFAULT_STYLE_SHEET + "background-color:red; color:white") else: statusLabel.setStyleSheet(LABEL_DEFAULT_STYLE_SHEET + "background-color:white; color:black") statusTimer = TimerCallback(targetFps=FPS) statusTimer.callback = statusUpdate statusTimer.start() controllerLabel = spawnBasicLabel() l.addWidget(wrapInVTitledItem("Controller", [controllerLabel])) def controllerUpdate(): status = atlasDriver.getControllerStatus() if not status: status = "Unknown" if len(status) > 6: status = status[0:6] rate = atlasDriver.getControllerRate() if not rate: rate = 0.0 controllerLabel.setText("%s\n%06.1fhz" % (status, rate)) if (rate < 500):
global playTime playTime = time.time() ######################### numRays = 20 rayLength = 5 angleMin = -np.pi / 2 angleMax = np.pi / 2 angleGrid = np.linspace(angleMin, angleMax, numRays) rays = np.zeros((3, numRays)) rays[0, :] = np.cos(angleGrid) rays[1, :] = np.sin(angleGrid) timer = TimerCallback(targetFps=30) timer.callback = tick playTimer = TimerCallback(targetFps=30) playTimer.callback = tick3 app = ConsoleApp() view = app.createView() panel = QtGui.QWidget() l = QtGui.QHBoxLayout(panel) playButton = QtGui.QPushButton('Play') playButton.connect('clicked()', onPlayButton) slider = QtGui.QSlider(QtCore.Qt.Horizontal) slider.connect('valueChanged(int)', onSliderChanged)
l.addWidget(wrapInVTitledItem("Behavior", [statusLabel])) def statusUpdate(): behavior = atlasDriver.getCurrentBehaviorName() statusLabel.setText(behavior) if (behavior != "user"): statusLabel.setStyleSheet(LABEL_DEFAULT_STYLE_SHEET + "background-color:red; color:white") else: statusLabel.setStyleSheet(LABEL_DEFAULT_STYLE_SHEET + "background-color:white; color:black") statusTimer = TimerCallback(targetFps=FPS) statusTimer.callback = statusUpdate statusTimer.start() controllerLabel = spawnBasicLabel() l.addWidget(wrapInVTitledItem("Controller", [controllerLabel])) def controllerUpdate(): status = atlasDriver.getControllerStatus() if not status: status = "Unknown" if len(status) > 6: status = status[0:6] rate = atlasDriver.getControllerRate() if not rate: rate = 0.0