Ejemplo n.º 1
0
 def _transitions():
     return {
         pipe.Centering.SETTLED: task.Next,
         task.TIMEOUT: task.Next,
         'GATE': state.Branch(pipe.Searching),
         'PIPE': state.Branch(pipe.Seeking)
     }
Ejemplo n.º 2
0
 def transitions():
     return { "Start" : End,
              "Change" : Simple,
              "LoopBack" : LoopBack ,
              MockEventSource.THING_UPDATED : Simple,
              MockEventSource.ANOTHER_EVT : QueueTestState,
              "Branch" : state.Branch(BranchedState) }
Ejemplo n.º 3
0
    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))
Ejemplo n.º 4
0
 def _transitions():
     return {
         bin.COMPLETE: task.Next,
         task.TIMEOUT: task.Next,
         RandomBin.MOVE_ON: task.Next,
         'GO': state.Branch(bin.Start)
     }
Ejemplo n.º 5
0
    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))
Ejemplo n.º 6
0
    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))
Ejemplo n.º 7
0
 def _transitions():
     return {
         gate.COMPLETE: task.Next,
         vision.EventType.PIPE_FOUND: task.Next,
         Gate.PIPE_ON: Gate,
         'GO': state.Branch(gate.Start)
     }
Ejemplo n.º 8
0
 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) }
Ejemplo n.º 9
0
 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()
Ejemplo n.º 10
0
 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) }
Ejemplo n.º 11
0
    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))
Ejemplo n.º 12
0
 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)
     }
Ejemplo n.º 13
0
 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))
Ejemplo n.º 14
0
 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))
Ejemplo n.º 15
0
 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)
     }
Ejemplo n.º 16
0
 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))
Ejemplo n.º 17
0
 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))
Ejemplo n.º 18
0
    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)
Ejemplo n.º 19
0
    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))
Ejemplo n.º 20
0
    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))
Ejemplo n.º 21
0
 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))
Ejemplo n.º 22
0
    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))
Ejemplo n.º 23
0
    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))
Ejemplo n.º 24
0
 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))
Ejemplo n.º 25
0
    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()
Ejemplo n.º 26
0
 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))
Ejemplo n.º 27
0
    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))
Ejemplo n.º 28
0
    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()
Ejemplo n.º 29
0
    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))
Ejemplo n.º 30
0
    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()