Skip to content
Snippets Groups Projects

Raw encoder ticks

Merged Samuel Tardieu requested to merge raw-encoder-ticks into main
Files
12
@@ -3,7 +3,7 @@ from numbers import Real
from typing import Optional
# Major and minor version of required firmware
_REQUIRED_FIRMWARE_VERSION = (1, 0)
_REQUIRED_FIRMWARE_VERSION = (1, 1)
class FirmwareVersionMismatch(Exception):
@@ -28,6 +28,7 @@ class Controller:
CMD_RAW_MOTOR_SPEED = 0x30
CMD_CONTROLLED_MOTOR_SPEED = 0x31
CMD_ENCODER_TICKS = 0x32
CMD_RAW_ENCODER_TICKS = 0x33
CMD_STATUS = 0x36
CMD_RESET = 0xE0
CMD_REBOOT_TO_BOOTLOADER = 0xE1
@@ -137,6 +138,12 @@ class Controller:
sense. Return a pair with left and right data."""
return self._read(self.CMD_ENCODER_TICKS, 4, "hh")
def get_raw_encoder_ticks(self) -> tuple[int, int]:
"""Retrieve the raw encoder ticks as an unsigned absolute 16 bit
value with wraparound arithmetic for each encoder. Return a pair
with left and right data."""
return self._read(self.CMD_RAW_ENCODER_TICKS, 4, "HH")
def get_status(self) -> dict[str, bool]:
"""Return a dict with status fields:
- "moving": True if at least one motor is moving, False otherwise
Loading