def testTimeout(self): """ Make sure that the timeout works properly """ # Restart with a working timer self.machine.stop() self.machine.start(target.FindAttempt) # Make sure the timer has the correct value self.assertEquals(self.machine.currentState()._timeout, TestFindAttempt.TIMEOUT) # For Recover self.ai.data['lastTargetEvent'] = vision.TargetEvent() # Release timer self.releaseTimer(state.FindAttempt.TIMEOUT) # Test that the timeout worked properly self.assertCurrentState(target.Recover) self.assert_(self.visionSystem.targetDetector)
def update(self, timestep): if not self._sendEvents: return self._currentTime += timestep sinVal = math.sin(self._currentTime) eventLight = vision.RedLightEvent(sinVal, sinVal) eventTarget = vision.TargetEvent(sinVal, sinVal * -1, sinVal * -2, sinVal * -3) eventBarbedWire = vision.BarbedWireEvent(sinVal, sinVal * -1, sinVal * -2, sinVal * -3, sinVal * -4, sinVal * -5) if sinVal >= 0: self.publish(vision.EventType.LIGHT_FOUND, eventLight) self.publish(vision.EventType.TARGET_LOST, eventTarget) self.publish(vision.EventType.BARBED_WIRE_FOUND, eventBarbedWire) else: self.publish(vision.EventType.LIGHT_LOST, eventLight) self.publish(vision.EventType.TARGET_FOUND, eventTarget) self.publish(vision.EventType.BARBED_WIRE_LOST, eventBarbedWire)
def setUp(self): support.AITestCase.setUp(self) self.ai.data['lastTargetEvent'] = vision.TargetEvent()