Esempio n. 1
0
    def setUp(self):
        cfg = {
            'Ai' : {
                'config' : {
                    'targetWindows' : 'red'
                    }
                }
            }

        support.AITestCase.setUp(self, cfg = cfg)
        self.ai.data['windowData'] = { vision.Color.RED : vision.WindowEvent() }
Esempio n. 2
0
    def testFinish(self):
        # Create a fake event with the y position positive
        event = vision.WindowEvent()
        event.x, event.y, event.color = (0, -0.75, vision.Color.YELLOW)
        self.ai.data['windowData'][vision.Color.YELLOW] = event

        # Start the machine
        self.machine.start(window.CorrectHeight)
        self.assertCurrentMotion(motion.basic.RateChangeDepth)

        # Test motion finished
        self.injectEvent(motion.basic.MotionManager.FINISHED)
        self.assertCurrentState(window.SeekingToCentered)
Esempio n. 3
0
    def testUpwardMotion(self):
        # Create a fake event with the y position positive
        event = vision.WindowEvent()
        event.x, event.y, event.color = (0, 0.75, vision.Color.YELLOW)
        self.ai.data['windowData'][vision.Color.YELLOW] = event

        # Start the machine
        self.machine.start(window.CorrectHeight)

        # Check if the dive motion is downwards (and follows the offset)
        self.assertCurrentMotion(motion.basic.RateChangeDepth)
        self.assertCurrentState(window.CorrectHeight)
        desiredDepth = self.motionManager.currentMotion.desiredDepth
        self.assertAlmostEqual(4.7, desiredDepth, 5)
Esempio n. 4
0
    def testTimeout(self):
        """
        Make sure that the timeout works properly
        """
        # Restart with a working timer
        self.machine.stop()
        self.machine.start(window.FindAttempt)

        # Make sure the timer has the correct value
        self.assertEquals(self.machine.currentState()._timeout,
                          TestFindAttempt.TIMEOUT)
        
        # For Recover
        self.ai.data['windowData'][vision.Color.RED] = vision.WindowEvent()

        # Release timer
        self.releaseTimer(state.FindAttempt.TIMEOUT)
        
        # Test that the timeout worked properly
        self.assertCurrentState(window.Recover)
        self.assert_(self.visionSystem.windowDetector)