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 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 __init__(self, spindleMonitor): self.spindleMonitor = spindleMonitor self.timer = TimerCallback(targetFps=3) self.timer.callback = self.update self.warningButton = None self.action = None
def _initTaskPanel(self): self.lastStatusMessage = '' self.nextStepTask = None self.completedTasks = [] self.taskQueue = atq.AsyncTaskQueue() self.taskQueue.connectQueueStarted(self.onQueueStarted) self.taskQueue.connectQueueStopped(self.onQueueStopped) self.taskQueue.connectTaskStarted(self.onTaskStarted) self.taskQueue.connectTaskEnded(self.onTaskEnded) self.taskQueue.connectTaskPaused(self.onTaskPaused) self.taskQueue.connectTaskFailed(self.onTaskFailed) self.taskQueue.connectTaskException(self.onTaskException) self.timer = TimerCallback(targetFps=2) self.timer.callback = self.updateTaskStatus self.timer.start() self.taskTree = tmw.TaskTree() self.ui.taskFrame.layout().insertWidget(0, self.taskTree.treeWidget) l = QtGui.QVBoxLayout(self.ui.taskPropertiesGroupBox) l.addWidget(self.taskTree.propertiesPanel) PythonQt.dd.ddGroupBoxHider(self.ui.taskPropertiesGroupBox) self.ui.taskStepButton.connect('clicked()', self.onStep) self.ui.taskContinueButton.connect('clicked()', self.onContinue) self.ui.taskPauseButton.connect('clicked()', self.onPause) self.ui.promptAcceptButton.connect('clicked()', self.onAcceptPrompt) self.ui.promptRejectButton.connect('clicked()', self.onRejectPrompt) self.clearPrompt() self.updateTaskButtons()
def __init__(self): self.timer = TimerCallback(targetFps=10) #self.timer.disableScheduledTimer() self.app = ConsoleApp() self.robotModel, self.jointController = roboturdf.loadRobotModel( 'robot model') self.fpsCounter = simpletimer.FPSCounter() self.drakePoseJointNames = robotstate.getDrakePoseJointNames() self.fpsCounter.printToConsole = True self.timer.callback = self._tick self._initialized = False self.publishChannel = 'JOINT_POSITION_GOAL' # self.lastCommandMessage = newAtlasCommandMessageAtZero() self._numPositions = len(robotstate.getDrakePoseJointNames()) self._previousElapsedTime = 100 self._baseFlag = 0 self.jointLimitsMin = np.array([ self.robotModel.model.getJointLimits(jointName)[0] for jointName in robotstate.getDrakePoseJointNames() ]) self.jointLimitsMax = np.array([ self.robotModel.model.getJointLimits(jointName)[1] for jointName in robotstate.getDrakePoseJointNames() ]) self.useControllerFlag = False self.drivingGainsFlag = False self.applyDefaults()
def __init__(self, frameProvider): vis.PolyDataItem.__init__(self, 'spindle axis', vtk.vtkPolyData(), view=None) self.frameProvider = frameProvider self.timer = TimerCallback() self.timer.callback = self.update self.setProperty('Color', QtGui.QColor(0, 255, 0)) self.setProperty('Visible', False)
def launchViewer(self): playButtonFps = 1.0/self.options['Sim']['dt'] print "playButtonFPS", playButtonFps self.playTimer = TimerCallback(targetFps=playButtonFps) self.playTimer.callback = self.playTimerCallback panel = QtGui.QWidget() l = QtGui.QHBoxLayout(panel) playButton = QtGui.QPushButton('Play/Pause') playButton.connect('clicked()', self.onPlayButton) l.addWidget(playButton) w = QtGui.QWidget() l = QtGui.QVBoxLayout(w) l.addWidget(self.view) l.addWidget(panel) w.showMaximized() self.carFrame.connectFrameModified(self.updateDrawIntersection) self.updateDrawIntersection(self.carFrame) applogic.resetCamera(viewDirection=[0.2,0,-1]) self.view.showMaximized() self.view.raise_() self.app.start()
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 onRobotPlan(self, msg): playback = planplayback.PlanPlayback() playback.interpolationMethod = 'pchip' poseTimes, poses = playback.getPlanPoses(msg) f = playback.getPoseInterpolator(poseTimes, poses) jointController = self.robotSystem.teleopJointController timer = simpletimer.SimpleTimer() def setPose(pose): jointController.setPose('plan_playback', pose) self.jointTeleopPanel.endPose = pose self.jointTeleopPanel.updateSliders() commandStream.setGoalPose(pose) def updateAnimation(): tNow = timer.elapsed() if tNow > poseTimes[-1]: pose = poses[-1] setPose(pose) return False pose = f(tNow) setPose(pose) self.animationTimer = TimerCallback() self.animationTimer.targetFps = 60 self.animationTimer.callback = updateAnimation self.animationTimer.start()
def __init__(self, view, affordanceManager, ikServer, jointController, raycastDriver): self.view = view self.affordanceManager = affordanceManager self.ikServer = ikServer self.jointController = jointController self.raycastDriver = raycastDriver loader = QtUiTools.QUiLoader() uifile = QtCore.QFile(':/ui/ddAffordancePanel.ui') assert uifile.open(uifile.ReadOnly) self.widget = loader.load(uifile) self.ui = WidgetDict(self.widget.children()) self.ui.affordanceListWidget.hide() self.ui.spawnBoxButton.connect('clicked()', self.onSpawnBox) self.ui.spawnSphereButton.connect('clicked()', self.onSpawnSphere) self.ui.spawnCylinderButton.connect('clicked()', self.onSpawnCylinder) self.ui.spawnCapsuleButton.connect('clicked()', self.onSpawnCapsule) self.ui.spawnRingButton.connect('clicked()', self.onSpawnRing) self.ui.spawnMeshButton.connect('clicked()', self.onSpawnMesh) self.ui.getRaycastTerrainButton.connect('clicked()', self.onGetRaycastTerrain) 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) self.updateTimer = TimerCallback(targetFps=30) self.updateTimer.callback = self.updatePanel self.updateTimer.start()
def __init__(self, planPlayback, playbackRobotModel, playbackJointController, robotStateModel, robotStateJointController, manipPlanner): self.planPlayback = planPlayback self.playbackRobotModel = playbackRobotModel self.playbackJointController = playbackJointController self.robotStateModel = robotStateModel self.robotStateJointController = robotStateJointController self.manipPlanner = manipPlanner manipPlanner.connectPlanCommitted(self.onPlanCommitted) manipPlanner.connectUseSupports(self.updateButtonColor) self.autoPlay = True self.useOperationColors() self.planFramesObj = None self.plan = None self.poseInterpolator = None self.startTime = 0.0 self.endTime = 1.0 self.animationTimer = TimerCallback() self.animationTimer.targetFps = 60 self.animationTimer.callback = self.updateAnimation self.animationClock = SimpleTimer() loader = QtUiTools.QUiLoader() uifile = QtCore.QFile(':/ui/ddPlaybackPanel.ui') assert uifile.open(uifile.ReadOnly) self.widget = loader.load(uifile) uifile.close() self.ui = WidgetDict(self.widget.children()) self.ui.viewModeCombo.connect('currentIndexChanged(const QString&)', self.viewModeChanged) self.ui.playbackSpeedCombo.connect( 'currentIndexChanged(const QString&)', self.playbackSpeedChanged) self.ui.interpolationCombo.connect( 'currentIndexChanged(const QString&)', self.interpolationChanged) self.ui.samplesSpinBox.connect('valueChanged(int)', self.numberOfSamplesChanged) self.ui.playbackSlider.connect('valueChanged(int)', self.playbackSliderValueChanged) self.ui.animateButton.connect('clicked()', self.animateClicked) self.ui.hideButton.connect('clicked()', self.hideClicked) self.ui.executeButton.connect('clicked()', self.executeClicked) self.ui.executeButton.setShortcut(QtGui.QKeySequence('Ctrl+Return')) self.ui.stopButton.connect('clicked()', self.stopClicked) self.ui.executeButton.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.ui.executeButton.connect( 'customContextMenuRequested(const QPoint&)', self.showExecuteContextMenu) self.setPlan(None) self.hideClicked()
def startApplication(enableQuitTimer=False): appInstance = QtGui.QApplication.instance() if enableQuitTimer: quitTimer = TimerCallback() quitTimer.callback = appInstance.quit quitTimer.singleShot(0.1) appInstance.exec_()
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 playPoses(self, poseTimes, poses, jointController): f = self.getPoseInterpolator(poseTimes, poses) timer = SimpleTimer() def updateAnimation(): tNow = timer.elapsed() * self.playbackSpeed if tNow > poseTimes[-1]: pose = poses[-1] jointController.setPose('plan_playback', pose) if self.animationCallback: self.animationCallback() return False pose = f(tNow) jointController.setPose('plan_playback', pose) if self.animationCallback: self.animationCallback() self.animationTimer = TimerCallback() self.animationTimer.targetFps = 60 self.animationTimer.callback = updateAnimation self.animationTimer.start() updateAnimation()
def setupPlayback(self): self.timer = TimerCallback(targetFps=30) self.timer.callback = self.tick playButtonFps = 1.0 / self.dt print "playButtonFPS", playButtonFps self.playTimer = TimerCallback(targetFps=playButtonFps) self.playTimer.callback = self.playTimerCallback self.sliderMovedByPlayTimer = False panel = QtGui.QWidget() l = QtGui.QHBoxLayout(panel) playButton = QtGui.QPushButton('Play/Pause') playButton.connect('clicked()', self.onPlayButton) slider = QtGui.QSlider(QtCore.Qt.Horizontal) slider.connect('valueChanged(int)', self.onSliderChanged) self.sliderMax = self.numTimesteps slider.setMaximum(self.sliderMax) self.slider = slider l.addWidget(playButton) l.addWidget(slider) w = QtGui.QWidget() l = QtGui.QVBoxLayout(w) l.addWidget(self.view) l.addWidget(panel) w.showMaximized() self.frame.connectFrameModified(self.updateDrawIntersection) self.updateDrawIntersection(self.frame) applogic.resetCamera(viewDirection=[0.2, 0, -1]) self.view.showMaximized() self.view.raise_() panel = screengrabberpanel.ScreenGrabberPanel(self.view) panel.widget.show() elapsed = time.time() - self.startSimTime simRate = self.counter / elapsed print "Total run time", elapsed print "Ticks (Hz)", simRate print "Number of steps taken", self.counter self.app.start()
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 __init__(self, affordanceManager, imageView): self.affordanceManager = affordanceManager self.prependImageName = False self.projectFootsteps = False self.projectAffordances = True self.extraObjects = [] self.imageView = imageView self.imageQueue = imageView.imageManager.queue self.timer = TimerCallback(targetFps=10) self.timer.callback = self.update
def __init__(self, view): self.collection = lcmobjectcollection.LCMObjectCollection( channel='AFFORDANCE_COLLECTION_COMMAND') self.collection.connectDescriptionUpdated(self._onDescriptionUpdated) self.collection.connectDescriptionRemoved(self._onDescriptionRemoved) self.view = view self.notifyFrequency = 30 # throttle lcm messages per second sent for affordance updates self._ignoreChanges = False self._pendingUpdates = set() self.timer = TimerCallback() self.timer.callback = self._notifyPendingUpdates
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 __init__(self, driver): self.driver = driver loader = QtUiTools.QUiLoader() uifile = QtCore.QFile(':/ui/ddAtlasDriverPanel.ui') assert uifile.open(uifile.ReadOnly) self.widget = loader.load(uifile) self.widget.setWindowTitle('Atlas Driver Panel') self.ui = WidgetDict(self.widget.children()) # Main Panel self.ui.calibrateEncodersButton.connect('clicked()', self.onCalibrateEncoders) self.ui.prepButton.connect('clicked()', self.onPrep) self.ui.combinedStandButton.connect('clicked()', self.onCombinedStand) self.ui.stopButton.connect('clicked()', self.onStop) self.ui.freezeButton.connect('clicked()', self.onFreeze) self.ui.calibrateNullBiasButton.connect('clicked()', self.onCalibrateNullBias) self.ui.calibrateElectricArmsButton.connect( 'clicked()', self.onCalibrateElectricArms) self.ui.initNavButton.connect('clicked()', self.onInitNav) self.ui.standButton.connect('clicked()', self.onStand) self.ui.mitStandButton.connect('clicked()', self.onMITStand) self.ui.userButton.connect('clicked()', self.onUser) self.ui.manipButton.connect('clicked()', self.onManip) self.ui.recoveryOnButton.connect('clicked()', self.driver.sendRecoveryEnable) self.ui.recoveryOffButton.connect('clicked()', self.driver.sendRecoveryDisable) self.ui.bracingOnButton.connect('clicked()', self.driver.sendBracingEnable) self.ui.bracingOffButton.connect('clicked()', self.driver.sendBracingDisable) for psi in [1000, 1500, 2000, 2400, 2650]: self.ui.__dict__['setPressure' + str(psi) + 'Button'].connect( 'clicked()', partial(self.driver.sendDesiredPumpPsi, psi)) self.ui.sendCustomPressureButton.connect('clicked()', self.sendCustomPressure) self.setupElectricArmCheckBoxes() PythonQt.dd.ddGroupBoxHider(self.ui.calibrationGroupBox) PythonQt.dd.ddGroupBoxHider(self.ui.pumpStatusGroupBox) PythonQt.dd.ddGroupBoxHider(self.ui.electricArmStatusGroupBox) self.updateTimer = TimerCallback(targetFps=5) self.updateTimer.callback = self.updatePanel self.updateTimer.start() self.updatePanel()
def __init__(self): self.tasks = [] self.generators = [] self.timer = TimerCallback(targetFps=10) self.timer.callback = self.callbackLoop self.callbacks = callbacks.CallbackRegistry([self.QUEUE_STARTED_SIGNAL, self.QUEUE_STOPPED_SIGNAL, self.TASK_STARTED_SIGNAL, self.TASK_ENDED_SIGNAL, self.TASK_PAUSED_SIGNAL, self.TASK_FAILED_SIGNAL, self.TASK_EXCEPTION_SIGNAL]) self.currentTask = None self.isRunning = False
def __init__(self): self.sub = lcmUtils.addSubscriber('JOINT_POSITION_GOAL', lcmdrc.robot_state_t, self.onJointPositionGoal) self.sub = lcmUtils.addSubscriber('SINGLE_JOINT_POSITION_GOAL', lcmdrc.joint_position_goal_t, self.onSingleJointPositionGoal) lcmUtils.addSubscriber('COMMITTED_PLAN_PAUSE', lcmdrc.plan_control_t, self.onPause) self.debug = False if self.debug: self.app = ConsoleApp() self.view = self.app.createView() self.robotModel, self.jointController = roboturdf.loadRobotModel('robot model', self.view) self.jointController.setPose('ATLAS_COMMAND', commandStream._currentCommandedPose) self.view.show() self.timer = TimerCallback(targetFps=30) self.timer.callback = self.onDebug
def __init__(self): app.setupPackagePaths() self.setupUi() app.toggleCameraTerrainMode(self.view) self.resetCamera() self.drakeVis = drakevisualizer.DrakeVisualizer(self.view) vis.showGrid(self.view, color=[0, 0, 0], parent=None) self.timer = TimerCallback() self.timer.callback = self.update self.timer.targetFps = 60
def initView(self, view): self.view = view or app.getViewManager().createView( self.viewName, 'VTK View') self.view.installImageInteractor() self.interactorStyle = self.view.renderWindow().GetInteractor( ).GetInteractorStyle() self.interactorStyle.AddObserver('SelectionChangedEvent', self.onRubberBandPick) self.imageActor = vtk.vtkImageActor() self.imageActor.SetInput(self.getImage()) self.imageActor.SetVisibility(False) self.view.renderer().AddActor(self.imageActor) self.timerCallback = TimerCallback() self.timerCallback.targetFps = 60 self.timerCallback.callback = self.updateView self.timerCallback.start()
def __init__(self, statusBar=None): self.manager = lcmUtils.LCMLoggerManager() self.statusBar = statusBar self.lastActiveLogFile = None self.numProcesses = 0 self.numLogFiles = 0 self.userTag = '' self.button = QtGui.QPushButton('') self.button.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.button.connect('customContextMenuRequested(const QPoint&)', self.showContextMenu) self.button.connect('clicked()', self.onClick) self.timer = TimerCallback(targetFps=0.25) self.timer.callback = self.updateState self.timer.start()
def __init__(self): self.timer = TimerCallback(targetFps=10) self.timer.callback = self.tick self.stop = self.timer.stop self.reader = None self.initReader() self.inputs = { 'slider': [0, 8, True], 'dial': [16, 8, True], 'r_button': [64, 8, False], 'm_button': [48, 8, False], 's_button': [32, 8, False], 'track_left': [58, 1, False], 'track_right': [59, 1, False], 'cycle': [46, 1, False], 'marker_set': [60, 1, False], 'marker_left': [61, 1, False], 'marker_right': [62, 1, False], 'rewind': [43, 1, False], 'fastforward': [44, 1, False], 'stop': [42, 1, False], 'play': [41, 1, False], 'record': [45, 1, False], } signalNames = [] for inputName, inputDescription in self.inputs.iteritems(): channelStart, numChannels, isContinuous = inputDescription for i in xrange(numChannels): channelId = '' if numChannels == 1 else '_%d' % i if isContinuous: signalNames.append('%s%s_value_changed' % (inputName, channelId)) else: signalNames.append('%s%s_pressed' % (inputName, channelId)) signalNames.append('%s%s_released' % (inputName, channelId)) self.callbacks = callbacks.CallbackRegistry(signalNames)
def __init__(self, multisenseDriver, neckDriver): self.multisenseDriver = multisenseDriver self.neckDriver = neckDriver self.neckPitchChanged = False self.multisenseChanged = False loader = QtUiTools.QUiLoader() uifile = QtCore.QFile(':/ui/ddMultisense.ui') assert uifile.open(uifile.ReadOnly) self.widget = loader.load(uifile) self.ui = WidgetDict(self.widget.children()) self.updateTimer = TimerCallback(targetFps=2) self.updateTimer.callback = self.updatePanel self.updateTimer.start() self.widget.headCamGainSpinner.setEnabled(False) self.widget.headCamExposureSpinner.setEnabled(False) #connect the callbacks self.widget.neckPitchSpinner.valueChanged.connect(self.neckPitchChange) self.widget.spinRateSpinner.valueChanged.connect(self.spinRateChange) self.widget.scanDurationSpinner.valueChanged.connect( self.scanDurationChange) self.widget.headCamFpsSpinner.valueChanged.connect( self.headCamFpsChange) self.widget.headCamGainSpinner.valueChanged.connect( self.headCamGainChange) self.widget.headCamExposureSpinner.valueChanged.connect( self.headCamExposureChange) self.widget.headAutoGainCheck.clicked.connect( self.headCamAutoGainChange) self.widget.ledOnCheck.clicked.connect(self.ledOnCheckChange) self.widget.ledBrightnessSpinner.valueChanged.connect( self.ledBrightnessChange) self.widget.sendButton.clicked.connect(self.sendButtonClicked) self.updatePanel()
def __init__(self, imageManager, view=None): self.imageManager = imageManager self.updateUtimes = {} self.sphereObjects = {} self.sphereImages = [ 'CAMERA_LEFT', 'CAMERACHEST_RIGHT', 'CAMERACHEST_LEFT' ] for name in self.sphereImages: imageManager.addImage(name) self.updateUtimes[name] = 0 self.initView(view) self.initEventFilter() self.rayCallback = rayDebug self.timerCallback = TimerCallback() self.timerCallback.targetFps = 60 self.timerCallback.callback = self.updateView self.timerCallback.start()
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
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()