本文整理汇总了Python中director.timercallback.TimerCallback.isActive方法的典型用法代码示例。如果您正苦于以下问题:Python TimerCallback.isActive方法的具体用法?Python TimerCallback.isActive怎么用?Python TimerCallback.isActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类director.timercallback.TimerCallback
的用法示例。
在下文中一共展示了TimerCallback.isActive方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SpindleSpinChecker
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import isActive [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)
示例2: Simulator
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import isActive [as 别名]
#.........这里部分代码省略.........
if value == self.Sensor.rayLength:
current_gap_width += 1
# else terminate counting for this gap
else:
if current_gap_width > biggest_gap_width:
biggest_gap_width = current_gap_width
biggest_gap_start_index = current_gap_start_index
current_gap_width = 0
current_gap_start_index = index + 1
if current_gap_width > biggest_gap_width:
biggest_gap_width = current_gap_width
biggest_gap_start_index = current_gap_start_index
middle_index_of_gap = biggest_gap_start_index + biggest_gap_width / 2
return self.polygon_initial_raycastLocations[middle_index_of_gap, :]
def onDrawActionSetButton(self):
print "drawing action set"
# self.ActionSet.computeFinalPositions(self.XVelocity_drawing,self.YVelocity_drawing)
self.ActionSet.computeAllPositions(self.XVelocity_drawing, self.YVelocity_drawing)
# self.ActionSet.drawActionSetFinal()
self.ActionSet.drawActionSetFull()
def onRunSimButton(self):
self.runBatchSimulation()
self.saveToFile("latest")
def onPlayButton(self):
if self.playTimer.isActive():
self.onPauseButton()
return
print "play"
self.playTimer.start()
self.playTime = time.time()
def onPauseButton(self):
print "pause"
self.playTimer.stop()
def saveToFile(self, filename):
# should also save the run data if it is available, i.e. stateOverTime, rewardOverTime
filename = "data/" + filename + ".out"
my_shelf = shelve.open(filename, "n")
my_shelf["options"] = self.options
my_shelf["simulationData"] = self.simulationData
my_shelf["stateOverTime"] = self.stateOverTime
my_shelf["raycastData"] = self.raycastData
my_shelf["controlInputData"] = self.controlInputData
my_shelf["numTimesteps"] = self.numTimesteps
my_shelf["idxDict"] = self.idxDict
my_shelf["counter"] = self.counter
my_shelf.close()
def run(self, launchApp=True):
self.counter = 1
示例3: AtlasCommandStream
# 需要导入模块: from director.timercallback import TimerCallback [as 别名]
# 或者: from director.timercallback.TimerCallback import isActive [as 别名]
class AtlasCommandStream(object):
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 initialize(self, currentRobotPose):
assert not self._initialized
self._currentCommandedPose = np.array(currentRobotPose)
self._previousCommandedPose = np.array(currentRobotPose)
self._goalPose = np.array(currentRobotPose)
self._initialized = True
def useController(self):
self.useControllerFlag = True
self.publishChannel = 'QP_CONTROLLER_INPUT'
def setKp(self, Kp, jointName=None):
if jointName is None:
self._Kp = Kp*np.ones(self._numPositions)
else:
idx = robotstate.getDrakePoseJointNames().index(jointName)
self._maxSpeed[idx] = Kp
self.updateKd()
def setMaxSpeed(self, speed, jointName=None):
if jointName is None:
self._maxSpeed = np.deg2rad(speed)*np.ones(self._numPositions)
else:
idx = robotstate.getDrakePoseJointNames().index(jointName)
self._maxSpeed[idx] = np.deg2rad(speed)
def updateKd(self):
self._dampingRatio = 1;
self._Kd = 2*self._dampingRatio*np.sqrt(self._Kp)
def applyDefaults(self):
self.setKp(10)
self.setMaxSpeed(10)
if self.drivingGainsFlag:
self.setMaxSpeed(70,'l_arm_lwy')
self.setKp(50,'l_arm_lwy')
self.setMaxSpeed(100,'l_leg_aky')
self.setKp(100,'l_leg_aky')
def applyDrivingDefaults(self):
self.drivingGainsFlag = True
self.applyDefaults()
def applyPlanDefaults(self):
self.setKp(10)
self.setMaxSpeed(60)
def startStreaming(self):
assert self._initialized
if not self.timer.isActive():
self.timer.start()
def stopStreaming(self):
self.timer.stop()
def setGoalPose(self, pose):
self._goalPose = self.clipPoseToJointLimits(pose)
def setIndividualJointGoalPose(self, pose, jointName):
jointIdx = self.drakePoseJointNames.index(jointName)
self._goalPose[jointIdx] = pose
def clipPoseToJointLimits(self,pose):
pose = np.array(pose)
pose = np.clip(pose, self.jointLimitsMin, self.jointLimitsMax)
return pose
def waitForRobotState(self):
msg = lcmUtils.captureMessage('EST_ROBOT_STATE', lcmbotcore.robot_state_t)
pose = robotstate.convertStateMessageToDrakePose(msg)
pose[:6] = np.zeros(6)
self.initialize(pose)
def _updateAndSendCommandMessage(self):
self._currentCommandedPose = self.clipPoseToJointLimits(self._currentCommandedPose)
#.........这里部分代码省略.........