def test_controller_update_with_adjusted_max_reverse(self, serial): controller = RoboHATController(cfg, True) controller.STOPPED_PWM = 1500 controller.MAX_REVERSE = 1200 controller.serial.readline.side_effect = [ b"1500, 1000\n", b"1500, 1250\n", b"1500, 1000\n", b"1500, 1250\n", b"1500, 1500\n" ] # 1500, 1000 controller.read_serial() assert controller.angle == 0 assert controller.throttle == -1.0 # 1500, 1250 controller.read_serial() assert controller.angle == 0 assert controller.throttle == -0.5 # 1500, 1000 controller.STOPPED_PWM = 1400 controller.read_serial() assert controller.angle == 0 assert controller.throttle == -1.0 # 1500, 1250 controller.read_serial() assert controller.angle == 0 assert controller.throttle == -0.5 # 1500, 1500 controller.read_serial() assert controller.angle == 0 assert controller.throttle == 0
def test_controller_update_with_adjusted_max_throttle(self, serial): ''' The adjusted MAX_FORWARD here should not affect the output throttle value. For example, when RC controller sending a 2000 value it means the user want to go full speed. The throttle value should therefore be 1.0. It is the RoboHATDriver responsibility to translate this 1.0 to an adjusted pwm value. ''' controller = RoboHATController(cfg, True) controller.MAX_FORWARD = 1800 controller.STOPPED_PWM = 1500 controller.serial.readline.side_effect = [ b"1500, 2000\n", b"1500, 1500\n", b"1500, 1750\n" ] # 1500, 2000 controller.read_serial() assert controller.angle == 0 assert controller.throttle == 1.0 # 1500, 1500 controller.read_serial() assert controller.angle == 0 assert controller.throttle == 0 # 1500, 1750 controller.read_serial() assert controller.angle == 0 assert controller.throttle == 0.5