diff --git a/lerobot/common/robots/koch/__init__.py b/lerobot/common/robots/koch/__init__.py index dfbe6369..ae98a2c3 100644 --- a/lerobot/common/robots/koch/__init__.py +++ b/lerobot/common/robots/koch/__init__.py @@ -1,4 +1,2 @@ -from .configuration_koch import KochRobotConfig -from .robot_koch import KochRobot - -__all__ = ["KochRobotConfig", "KochRobot"] +from .config_koch_follower import KochFollowerConfig +from .koch_follower import KochFollower diff --git a/lerobot/common/robots/koch/configuration_koch.py b/lerobot/common/robots/koch/config_koch_follower.py similarity index 83% rename from lerobot/common/robots/koch/configuration_koch.py rename to lerobot/common/robots/koch/config_koch_follower.py index a72bd05f..c6cd9f31 100644 --- a/lerobot/common/robots/koch/configuration_koch.py +++ b/lerobot/common/robots/koch/config_koch_follower.py @@ -5,10 +5,10 @@ from lerobot.common.cameras import CameraConfig from ..config import RobotConfig -@RobotConfig.register_subclass("koch") +@RobotConfig.register_subclass("koch_follower") @dataclass -class KochRobotConfig(RobotConfig): - # Port to connect to the robot +class KochFollowerConfig(RobotConfig): + # Port to connect to the arm port: str disable_torque_on_disconnect: bool = True diff --git a/lerobot/common/robots/koch/robot_koch.py b/lerobot/common/robots/koch/koch_follower.py similarity index 96% rename from lerobot/common/robots/koch/robot_koch.py rename to lerobot/common/robots/koch/koch_follower.py index 72724daf..fc94f0ea 100644 --- a/lerobot/common/robots/koch/robot_koch.py +++ b/lerobot/common/robots/koch/koch_follower.py @@ -29,22 +29,22 @@ from lerobot.common.motors.dynamixel import ( from ..robot import Robot from ..utils import ensure_safe_goal_position -from .configuration_koch import KochRobotConfig +from .config_koch_follower import KochFollowerConfig logger = logging.getLogger(__name__) -class KochRobot(Robot): +class KochFollower(Robot): """ - [Koch v1.0](https://github.com/AlexanderKoch-Koch/low_cost_robot), with and without the wrist-to-elbow expansion, developed by Alexander Koch from [Tau Robotics](https://tau-robotics.com) - [Koch v1.1](https://github.com/jess-moss/koch-v1-1) developed by Jess Moss """ - config_class = KochRobotConfig - name = "koch" + config_class = KochFollowerConfig + name = "koch_follower" - def __init__(self, config: KochRobotConfig): + def __init__(self, config: KochFollowerConfig): super().__init__(config) self.config = config self.arm = DynamixelMotorsBus( @@ -222,9 +222,7 @@ class KochRobot(Robot): def disconnect(self): if not self.is_connected: - raise DeviceNotConnectedError( - "ManipulatorRobot is not connected. You need to run `robot.connect()` before disconnecting." - ) + raise DeviceNotConnectedError(f"{self} is not connected.") self.arm.disconnect(self.config.disable_torque_on_disconnect) for cam in self.cameras.values(): diff --git a/lerobot/common/robots/utils.py b/lerobot/common/robots/utils.py index c8a06b67..9c0b28ac 100644 --- a/lerobot/common/robots/utils.py +++ b/lerobot/common/robots/utils.py @@ -30,10 +30,10 @@ def make_robot_config(robot_type: str, **kwargs) -> RobotConfig: from .aloha.configuration_aloha import AlohaRobotConfig return AlohaRobotConfig(**kwargs) - elif robot_type == "koch": - from .koch.configuration_koch import KochRobotConfig + elif robot_type == "koch_follower": + from .koch.config_koch_follower import KochFollowerConfig - return KochRobotConfig(**kwargs) + return KochFollowerConfig(**kwargs) # elif robot_type == "koch_bimanual": # return KochBimanualRobotConfig(**kwargs) elif robot_type == "moss": diff --git a/lerobot/common/teleoperators/koch/__init__.py b/lerobot/common/teleoperators/koch/__init__.py index f86454d1..ad2d6a0e 100644 --- a/lerobot/common/teleoperators/koch/__init__.py +++ b/lerobot/common/teleoperators/koch/__init__.py @@ -1,4 +1,2 @@ -from .configuration_koch import KochTeleopConfig -from .teleop_koch import KochTeleop - -__all__ = ["KochTeleopConfig", "KochTeleop"] +from .config_koch_leader import KochLeaderConfig +from .koch_leader import KochLeader diff --git a/lerobot/common/teleoperators/koch/configuration_koch.py b/lerobot/common/teleoperators/koch/config_koch_leader.py similarity index 87% rename from lerobot/common/teleoperators/koch/configuration_koch.py rename to lerobot/common/teleoperators/koch/config_koch_leader.py index cf95f547..64aaae12 100644 --- a/lerobot/common/teleoperators/koch/configuration_koch.py +++ b/lerobot/common/teleoperators/koch/config_koch_leader.py @@ -19,10 +19,10 @@ from dataclasses import dataclass from ..config import TeleoperatorConfig -@TeleoperatorConfig.register_subclass("koch") +@TeleoperatorConfig.register_subclass("koch_leader") @dataclass -class KochTeleopConfig(TeleoperatorConfig): - # Port to connect to the teloperator +class KochLeaderConfig(TeleoperatorConfig): + # Port to connect to the arm port: str # Sets the arm in torque mode with the gripper motor set to this value. This makes it possible to squeeze diff --git a/lerobot/common/teleoperators/koch/teleop_koch.py b/lerobot/common/teleoperators/koch/koch_leader.py similarity index 94% rename from lerobot/common/teleoperators/koch/teleop_koch.py rename to lerobot/common/teleoperators/koch/koch_leader.py index e0cfc89e..85cad16c 100644 --- a/lerobot/common/teleoperators/koch/teleop_koch.py +++ b/lerobot/common/teleoperators/koch/koch_leader.py @@ -26,22 +26,22 @@ from lerobot.common.motors.dynamixel import ( ) from ..teleoperator import Teleoperator -from .configuration_koch import KochTeleopConfig +from .config_koch_leader import KochLeaderConfig logger = logging.getLogger(__name__) -class KochTeleop(Teleoperator): +class KochLeader(Teleoperator): """ - [Koch v1.0](https://github.com/AlexanderKoch-Koch/low_cost_robot), with and without the wrist-to-elbow expansion, developed by Alexander Koch from [Tau Robotics](https://tau-robotics.com) - [Koch v1.1](https://github.com/jess-moss/koch-v1-1) developed by Jess Moss """ - config_class = KochTeleopConfig - name = "koch" + config_class = KochLeaderConfig + name = "koch_leader" - def __init__(self, config: KochTeleopConfig): + def __init__(self, config: KochLeaderConfig): super().__init__(config) self.config = config self.arm = DynamixelMotorsBus( @@ -147,6 +147,9 @@ class KochTeleop(Teleoperator): self.arm.write("Goal_Position", "gripper", self.config.gripper_open_pos) def get_action(self) -> dict[str, float]: + if not self.is_connected: + raise DeviceNotConnectedError(f"{self} is not connected.") + start = time.perf_counter() action = self.arm.sync_read("Present_Position") dt_ms = (time.perf_counter() - start) * 1e3 @@ -159,9 +162,7 @@ class KochTeleop(Teleoperator): def disconnect(self) -> None: if not self.is_connected: - raise DeviceNotConnectedError( - "ManipulatorRobot is not connected. You need to run `robot.connect()` before disconnecting." - ) + raise DeviceNotConnectedError(f"{self} is not connected.") self.arm.disconnect() logger.info(f"{self} disconnected.")