示例#1
0
    def test_create_jobs_right(self):
        robot_state = RobotState()

        message_processor = MessageProcessor('left_brick', robot_state)
        message_processor.process_rotate_command(RotateCommand('ev3-ports:outD', 10, 100, 'hold'))

        for i in range(300):
            c, l, r = robot_state.next_motor_jobs()
            self.assertIsNone(c)
            self.assertIsNone(l)
            self.assertAlmostEqual(r, 0.104, 3)

        self.assertEqual((None, None, None), robot_state.next_motor_jobs())
示例#2
0
    def test_create_jobs_center(self):
        robot_state = RobotState()

        message_processor = MessageProcessor('left_brick', robot_state)
        message_processor.process_rotate_command(RotateCommand('ev3-ports:outB', 20, 100, 'hold'))

        for i in range(150):
            c, l, r = robot_state.next_motor_jobs()
            self.assertAlmostEqual(c, -0.667, 3)
            self.assertIsNone(l)
            self.assertIsNone(r)

        self.assertEqual((None, None, None), robot_state.next_motor_jobs())
示例#3
0
    def test_create_jobs_coast_left(self):
        coasting_sub = apply_scaling(get_config().get_data()['motor_settings']['pixel_coasting_subtraction'])
        robot_state = RobotState()

        message_processor = MessageProcessor('left_brick', robot_state)
        message_processor.process_rotate_command(RotateCommand('ev3-ports:outA', 80, 200, 'coast'))

        for i in range(75):
            c, l, r = robot_state.next_motor_jobs()
            self.assertIsNone(c)
            self.assertAlmostEqual(l, 0.833, 3)
            self.assertIsNone(r)

        ppf = 0.833 - coasting_sub
        for i in range(2):
            c, l, r = robot_state.next_motor_jobs()
            self.assertIsNone(c)
            self.assertAlmostEqual(l, ppf, 3)
            self.assertIsNone(r)
            ppf = max(ppf - coasting_sub, 0)

        self.assertEqual((None, None, None), robot_state.next_motor_jobs())
示例#4
0
    def test_create_jobs_coast_center(self):
        coasting_sub = get_config().get_data()['motor_settings']['degree_coasting_subtraction']
        robot_state = RobotState()

        message_processor = MessageProcessor('left_brick', robot_state)
        message_processor.process_rotate_command(RotateCommand('ev3-ports:outB', 80, 200, 'coast'))

        for i in range(75):
            c, l, r = robot_state.next_motor_jobs()
            self.assertAlmostEqual(c, -2.667, 3)
            self.assertIsNone(l)
            self.assertIsNone(r)

        ppf = 2.667 - coasting_sub
        for i in range(2):
            c, l, r = robot_state.next_motor_jobs()
            self.assertAlmostEqual(c, -ppf, 3)
            self.assertIsNone(l)
            self.assertIsNone(r)
            ppf = max(ppf - coasting_sub, 0)

        self.assertEqual((None, None, None), robot_state.next_motor_jobs())