|
20 | 20 | from typing import Any |
21 | 21 |
|
22 | 22 | from lerobot.cameras import CameraConfig, make_cameras_from_configs |
| 23 | +from lerobot.motors.motors_bus import Motor, MotorNormMode |
23 | 24 | from lerobot.robots import Robot, RobotConfig |
24 | 25 | from lerobot.utils.errors import DeviceAlreadyConnectedError, DeviceNotConnectedError |
| 26 | +from tests.mocks.mock_motors_bus import MockMotorsBus |
25 | 27 |
|
26 | 28 |
|
27 | 29 | @RobotConfig.register_subclass("mock_robot") |
@@ -58,9 +60,22 @@ def __init__(self, config: MockRobotConfig): |
58 | 60 | self.config = config |
59 | 61 | self._is_connected = False |
60 | 62 | self._is_calibrated = config.calibrated |
61 | | - self.motors = [f"motor_{i + 1}" for i in range(config.n_motors)] |
62 | 63 | self.cameras = make_cameras_from_configs(config.cameras) |
63 | 64 |
|
| 65 | + mock_motors = {} |
| 66 | + for i in range(config.n_motors): |
| 67 | + motor_name = f"motor_{i + 1}" |
| 68 | + mock_motors[motor_name] = Motor( |
| 69 | + id=i + 1, |
| 70 | + model="model_1", # Use model_1 which exists in MockMotorsBus tables |
| 71 | + norm_mode=MotorNormMode.RANGE_M100_100, |
| 72 | + ) |
| 73 | + |
| 74 | + self.bus = MockMotorsBus("/dev/dummy-port", mock_motors) |
| 75 | + |
| 76 | + # NOTE(fracapuano): The .motors attribute was used from the previous interface |
| 77 | + self.motors = [f"motor_{i + 1}" for i in range(config.n_motors)] |
| 78 | + |
64 | 79 | @property |
65 | 80 | def _motors_ft(self) -> dict[str, type]: |
66 | 81 | return {f"{motor}.pos": float for motor in self.motors} |
|
0 commit comments