def _transitions(): return { pipe.Centering.SETTLED: task.Next, task.TIMEOUT: task.Next, 'GATE': state.Branch(pipe.Searching), 'PIPE': state.Branch(pipe.Seeking) }
def transitions(): return { "Start" : End, "Change" : Simple, "LoopBack" : LoopBack , MockEventSource.THING_UPDATED : Simple, MockEventSource.ANOTHER_EVT : QueueTestState, "Branch" : state.Branch(BranchedState) }
def enter(self, defaultTimeout=240): timeout = self.ai.data['config'].get('Bin', {}).get('taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout=timeout) self.stateMachine.start(state.Branch(bin.Start))
def _transitions(): return { bin.COMPLETE: task.Next, task.TIMEOUT: task.Next, RandomBin.MOVE_ON: task.Next, 'GO': state.Branch(bin.Start) }
def enter(self, defaultTimeout=120): timeout = self.ai.data['config'].get('Hedge', {}).get('taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout=timeout) self.stateMachine.start(state.Branch(hedge.Start))
def enter(self, defaultTimeout = 120): # Initialize task part of class timeout = self.ai.data['config'].get('Target', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.stateMachine.start(state.Branch(target.Start))
def _transitions(): return { gate.COMPLETE: task.Next, vision.EventType.PIPE_FOUND: task.Next, Gate.PIPE_ON: Gate, 'GO': state.Branch(gate.Start) }
def _transitions(thisState = None): if thisState is None: thisState = Light return { light.COMPLETE : task.Next, light.FAILURE : task.Failure, task.TIMEOUT : task.Next, 'GO' : state.Branch(light.Start) }
def PIPE_FOUND(self, event): if not self._branched: self.motionManager.stopCurrentMotion() self.stateMachine.start(state.Branch(pipe.Seeking)) self._branched = True if self.timer is not None: self.timer.stop()
def _transitions(currentState = None): if currentState is None: currentState = Pipe return { pipe.Centering.SETTLED : currentState, Pipe.COMPLETE : task.Next, task.TIMEOUT : task.Next, 'GO' : state.Branch(pipe.Start) }
def enter(self, defaultTimeout = 90): self._className = type(self).__name__ timeout = self.ai.data['config'].get(self._className, {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.stateMachine.start(state.Branch(light.Start))
def _transitions(): return { buoy.COMPLETE: task.Next, buoy.Searching.BUOY_SEARCHING: Buoy, vision.EventType.BUOY_FOUND: Buoy, task.TIMEOUT: task.Next, 'GO': state.Branch(buoy.Start) }
def enter(self, defaultTimeout = 60): self._className = type(self).__name__ timeout = self.ai.data['config'].get(self._className, {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) # Branch off state machine for finding the pipe self.stateMachine.start(state.Branch(cupid.Start))
def enter(self, defaultTimeout = 500): # TODO: base the timeout off an offset from how much time we have left # in the mission timeout = self.ai.data['config'].get('SafeSonar', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.stateMachine.start(state.Branch(sonarSafe.Settling))
def _transitions(): return { task.TIMEOUT: task.Next, vision.EventType.WINDOW_FOUND: Window, window.Searching.WINDOW_SEARCHING: Window, window.COMPLETE: task.Next, 'GO': state.Branch(window.Start) }
def testBranchState(self): self.machine.start(state.Branch(Simple)) # Make sure current state stayed self.assertEqual(Start, type(self.machine.currentState())) # Ensure we actually branched self.assertEqual(1, len(self.machine.branches)) self.assert_(self.machine.branches.has_key(Simple))
def enter(self, defaultTimeout = 60): self._className = type(self).__name__ timeout = self.ai.data['config'].get(self._className, {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.ai.data['pipeBiasDirection'] = \ self.ai.data['config'].get('PipeGate', {}).get( 'biasDirection', None) self.ai.data['pipeThreshold'] = \ self.ai.data['config'].get('PipeGate', {}).get( 'threshold', None) # Branch off state machine for finding the pipe if self.ai.data.get('foundPipeEarly', False): self.stateMachine.start(state.Branch(pipe.Seeking)) else: self.stateMachine.start(state.Branch(pipe.Searching))
def enter(self): task.Task.enter(self) # Activate the sonar system self.stateMachine.start(state.Branch(sonar.Hovering)) # Start our dive diveMotion = motion.basic.RateChangeDepth( desiredDepth=self._config.get('depth', 10), speed=self._config.get('diveSpeed', 0.3)) self.motionManager.setMotion(diveMotion)
def enter(self, defaultTimeout=60): timeout = self.ai.data['config'].get('RandomBin', {}).get('taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout=timeout) if self.ai.data.get('binComplete', False): self.publish(RandomBin.MOVE_ON, core.Event()) else: self.stateMachine.start(state.Branch(randombin.Start))
def enter(self, defaultTimeout = 120): # Initialize task part of class timeout = self.ai.data['config'].get('Window', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self._lostDelay = self.ai.data['config'].get('Window', {}).get( 'lostTimeout', 5) self._lostTimeout = None self._windowFound = False self.stateMachine.start(state.Branch(window.Start))
def testBranchStop(self): self.machine.start(state.Branch(Simple)) branchedState = self.machine.branches[Simple].currentState() self.machine.stop() # Ensure we actually stopped the branch self.assertEqual(0, len(self.machine.branches)) self.assert_(branchedState.exited) # Now test stopping just one branch self.machine.start(state.Branch(Simple)) self.machine.start(state.Branch(Start)) self.assertEqual(2, len(self.machine.branches)) self.machine.stopBranch(Simple) self.assertEqual(1, len(self.machine.branches)) self.assertFalse(self.machine.branches.has_key(Simple)) self.machine.stopBranch(Start) self.assertEqual(0, len(self.machine.branches)) self.assertFalse(self.machine.branches.has_key(Start))
def enter(self, defaultTimeout = 500): timeout = self.ai.data['config'].get('Vase', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.ai.data['vaseOrientation'] = \ self._config.get('vaseOrientation', 0) if self.ai.data['vaseOrientation'] == 0: # Save current heading self.ai.data['vaseOrientation'] = \ self.stateEstimator.getEstimatedOrientation().getYaw().valueDegrees() self.stateMachine.start(state.Branch(vase.Start))
def enter(self, defaultTimeout = 90): timeout = self.ai.data['config'].get('Buoy', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self._lostDelay = self.ai.data['config'].get('Buoy', {}).get( 'lostTimeout', 5) self._lostTimeout = None self._searchDelay = self.ai.data['config'].get('Buoy', {}).get( 'searchTimeout', 10) self._searchTimeout = None self._buoyFound = False self.stateMachine.start(state.Branch(oldBuoy.Start))
def enter(self, defaultTimeout = 60): self._className = type(self).__name__ timeout = self.ai.data['config'].get(self._className, {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.ai.data['laneOrientation'] = \ self.ai.data['config'].get(self._className, {}).get( 'orientation', 0) self.ai.data['laneDepth'] = \ self.ai.data['config'].get(self._className, {}).get( 'depth', 5) # Branch off state machine for finding the pipe self.stateMachine.start(state.Branch(lane.Start))
def enter(self): task.Task.enter(self) self.ai.data['foundPipeEarly'] = False self.exited = False # Branch of state machine for gate self.stateMachine.start(state.Branch(gate.Start)) # Save current heading self.ai.data['gateOrientation'] = \ self.controller.getDesiredOrientation() # Setup timer to trigger pipe detector after a certain delay delay = self._config.get('pipeDelay', 30) self.timer = self.timerManager.newTimer(Gate.PIPE_ON, delay) self.timer.start()
def enter(self, defaultTimeout = 60): self._className = type(self).__name__ timeout = self.ai.data['config'].get(self._className, {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self._pipesToFind = self._config.get('pipesToFind', 1) self._pipeCount = 0 self.ai.data['pipeBiasDirection'] = \ self.ai.data['config'].get(self._className, {}).get( 'biasDirection', None) self.ai.data['pipeThreshold'] = \ self.ai.data['config'].get(self._className, {}).get( 'threshold', None) # Branch off state machine for finding the pipe self.stateMachine.start(state.Branch(pipe.Start))
def enter(self, defaultTimeout = 240): self._className = type(self).__name__ self.ai.data['binOrientation'] = self.ai.data['config'].get(self._className, {}).get('orientation', 0) # get the list of buoys we want to hit self.ai.data['symbolList'] = \ self.ai.data['config'].get('targetSymbols', []) if len(self.ai.data['symbolList']) == 0: raise LookupError, "No symbols specified" # if self.ai.data['buoyOrientation'] is None: # raise LookupError, "No orientation specified" timeout = self.ai.data['config'].get('Bin', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) self.stateMachine.start(state.Branch(bin.Start))
def enter(self): task.Task.enter(self) self.exited = False # Branch of state machine for gate self.stateMachine.start(state.Branch(gate.Start)) self.ai.data['gateOrientation'] = \ self._config.get('gateOrientation', 0) self.ai.data['fakeGateDistance'] = \ self._config.get('fakeGateDistance', 5) self.ai.data['fakeGate'] = True if self.ai.data['gateOrientation'] == 0: # Save current heading self.ai.data['gateOrientation'] = \ self.stateEstimator.getEstimatedOrientation().getYaw().valueDegrees()
def enter(self, defaultTimeout = 90): timeout = self.ai.data['config'].get('Buoy', {}).get( 'taskTimeout', defaultTimeout) task.Task.enter(self, defaultTimeout = timeout) # get the list of buoys we want to hit self.ai.data['buoyList'] = \ self.ai.data['config'].get('targetBuoys', []) if len(self.ai.data['buoyList']) == 0: raise LookupError, "No buoys specified" self._lostDelay = self.ai.data['config'].get('Buoy', {}).get( 'lostTimeout', 5) self._lostTimeout = None self._searchDelay = self.ai.data['config'].get('Buoy', {}).get( 'searchTimeout', 10) self._searchTimeout = None self._buoyFound = False self.stateMachine.start(state.Branch(buoy.Start))
def enter(self): task.Task.enter(self) self.ai.data['foundPipeEarly'] = False self.exited = False # Branch of state machine for gate self.stateMachine.start(state.Branch(gate.Start)) self.ai.data['gateOrientation'] = \ self._config.get('gateOrientation', 0) if self.ai.data['gateOrientation'] == 0: # Save current heading self.ai.data['gateOrientation'] = \ self.stateEstimator.getEstimatedOrientation().getYaw().valueDegrees() self.ai.data['fakeGate'] = False # Setup timer to trigger pipe detector after a certain delay delay = self._config.get('pipeDelay', 30) self.timer = self.timerManager.newTimer(Gate.PIPE_ON, delay) self.timer.start()