From 25388d09475016a95f8a51478ee7413ec437e71f Mon Sep 17 00:00:00 2001 From: Simon Alibert Date: Sun, 23 Mar 2025 19:41:46 +0100 Subject: [PATCH] Add feetech operating modes --- lerobot/common/motors/feetech/__init__.py | 2 +- lerobot/common/motors/feetech/feetech.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lerobot/common/motors/feetech/__init__.py b/lerobot/common/motors/feetech/__init__.py index ae61d23b5..1f110e400 100644 --- a/lerobot/common/motors/feetech/__init__.py +++ b/lerobot/common/motors/feetech/__init__.py @@ -1,3 +1,3 @@ -from .feetech import FeetechMotorsBus +from .feetech import FeetechMotorsBus, OperatingMode from .feetech_calibration import apply_feetech_offsets_from_calibration, run_full_arm_calibration from .tables import * diff --git a/lerobot/common/motors/feetech/feetech.py b/lerobot/common/motors/feetech/feetech.py index 74c114b3a..14aeb3dff 100644 --- a/lerobot/common/motors/feetech/feetech.py +++ b/lerobot/common/motors/feetech/feetech.py @@ -13,6 +13,7 @@ # limitations under the License. from copy import deepcopy +from enum import Enum from ..motors_bus import Motor, MotorsBus from .tables import ( @@ -29,6 +30,20 @@ DEFAULT_TIMEOUT_MS = 1000 MAX_ID_RANGE = 252 +class OperatingMode(Enum): + # position servo mode + POSITION = 0 + # The motor is in constant speed mode, which is controlled by parameter 0x2e, and the highest bit 15 is + # the direction bit + VELOCITY = 1 + # PWM open-loop speed regulation mode, with parameter 0x2c running time parameter control, bit11 as + # direction bit + PWM = 2 + # In step servo mode, the number of step progress is represented by parameter 0x2a, and the highest bit 15 + # is the direction bit + STEP = 3 + + class FeetechMotorsBus(MotorsBus): """ The FeetechMotorsBus class allows to efficiently read and write to the attached motors. It relies on the