Rename Koch classes

This commit is contained in:
Simon Alibert
2025-04-03 08:23:31 +02:00
parent 28cd3a6f3a
commit 2971bdfed5
7 changed files with 28 additions and 33 deletions

View File

@@ -1,4 +1,2 @@
from .configuration_koch import KochRobotConfig from .config_koch_follower import KochFollowerConfig
from .robot_koch import KochRobot from .koch_follower import KochFollower
__all__ = ["KochRobotConfig", "KochRobot"]

View File

@@ -5,10 +5,10 @@ from lerobot.common.cameras import CameraConfig
from ..config import RobotConfig from ..config import RobotConfig
@RobotConfig.register_subclass("koch") @RobotConfig.register_subclass("koch_follower")
@dataclass @dataclass
class KochRobotConfig(RobotConfig): class KochFollowerConfig(RobotConfig):
# Port to connect to the robot # Port to connect to the arm
port: str port: str
disable_torque_on_disconnect: bool = True disable_torque_on_disconnect: bool = True

View File

@@ -29,22 +29,22 @@ from lerobot.common.motors.dynamixel import (
from ..robot import Robot from ..robot import Robot
from ..utils import ensure_safe_goal_position from ..utils import ensure_safe_goal_position
from .configuration_koch import KochRobotConfig from .config_koch_follower import KochFollowerConfig
logger = logging.getLogger(__name__) 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 - [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) 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 - [Koch v1.1](https://github.com/jess-moss/koch-v1-1) developed by Jess Moss
""" """
config_class = KochRobotConfig config_class = KochFollowerConfig
name = "koch" name = "koch_follower"
def __init__(self, config: KochRobotConfig): def __init__(self, config: KochFollowerConfig):
super().__init__(config) super().__init__(config)
self.config = config self.config = config
self.arm = DynamixelMotorsBus( self.arm = DynamixelMotorsBus(
@@ -222,9 +222,7 @@ class KochRobot(Robot):
def disconnect(self): def disconnect(self):
if not self.is_connected: if not self.is_connected:
raise DeviceNotConnectedError( raise DeviceNotConnectedError(f"{self} is not connected.")
"ManipulatorRobot is not connected. You need to run `robot.connect()` before disconnecting."
)
self.arm.disconnect(self.config.disable_torque_on_disconnect) self.arm.disconnect(self.config.disable_torque_on_disconnect)
for cam in self.cameras.values(): for cam in self.cameras.values():

View File

@@ -30,10 +30,10 @@ def make_robot_config(robot_type: str, **kwargs) -> RobotConfig:
from .aloha.configuration_aloha import AlohaRobotConfig from .aloha.configuration_aloha import AlohaRobotConfig
return AlohaRobotConfig(**kwargs) return AlohaRobotConfig(**kwargs)
elif robot_type == "koch": elif robot_type == "koch_follower":
from .koch.configuration_koch import KochRobotConfig from .koch.config_koch_follower import KochFollowerConfig
return KochRobotConfig(**kwargs) return KochFollowerConfig(**kwargs)
# elif robot_type == "koch_bimanual": # elif robot_type == "koch_bimanual":
# return KochBimanualRobotConfig(**kwargs) # return KochBimanualRobotConfig(**kwargs)
elif robot_type == "moss": elif robot_type == "moss":

View File

@@ -1,4 +1,2 @@
from .configuration_koch import KochTeleopConfig from .config_koch_leader import KochLeaderConfig
from .teleop_koch import KochTeleop from .koch_leader import KochLeader
__all__ = ["KochTeleopConfig", "KochTeleop"]

View File

@@ -19,10 +19,10 @@ from dataclasses import dataclass
from ..config import TeleoperatorConfig from ..config import TeleoperatorConfig
@TeleoperatorConfig.register_subclass("koch") @TeleoperatorConfig.register_subclass("koch_leader")
@dataclass @dataclass
class KochTeleopConfig(TeleoperatorConfig): class KochLeaderConfig(TeleoperatorConfig):
# Port to connect to the teloperator # Port to connect to the arm
port: str port: str
# Sets the arm in torque mode with the gripper motor set to this value. This makes it possible to squeeze # Sets the arm in torque mode with the gripper motor set to this value. This makes it possible to squeeze

View File

@@ -26,22 +26,22 @@ from lerobot.common.motors.dynamixel import (
) )
from ..teleoperator import Teleoperator from ..teleoperator import Teleoperator
from .configuration_koch import KochTeleopConfig from .config_koch_leader import KochLeaderConfig
logger = logging.getLogger(__name__) 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 - [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) 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 - [Koch v1.1](https://github.com/jess-moss/koch-v1-1) developed by Jess Moss
""" """
config_class = KochTeleopConfig config_class = KochLeaderConfig
name = "koch" name = "koch_leader"
def __init__(self, config: KochTeleopConfig): def __init__(self, config: KochLeaderConfig):
super().__init__(config) super().__init__(config)
self.config = config self.config = config
self.arm = DynamixelMotorsBus( self.arm = DynamixelMotorsBus(
@@ -147,6 +147,9 @@ class KochTeleop(Teleoperator):
self.arm.write("Goal_Position", "gripper", self.config.gripper_open_pos) self.arm.write("Goal_Position", "gripper", self.config.gripper_open_pos)
def get_action(self) -> dict[str, float]: def get_action(self) -> dict[str, float]:
if not self.is_connected:
raise DeviceNotConnectedError(f"{self} is not connected.")
start = time.perf_counter() start = time.perf_counter()
action = self.arm.sync_read("Present_Position") action = self.arm.sync_read("Present_Position")
dt_ms = (time.perf_counter() - start) * 1e3 dt_ms = (time.perf_counter() - start) * 1e3
@@ -159,9 +162,7 @@ class KochTeleop(Teleoperator):
def disconnect(self) -> None: def disconnect(self) -> None:
if not self.is_connected: if not self.is_connected:
raise DeviceNotConnectedError( raise DeviceNotConnectedError(f"{self} is not connected.")
"ManipulatorRobot is not connected. You need to run `robot.connect()` before disconnecting."
)
self.arm.disconnect() self.arm.disconnect()
logger.info(f"{self} disconnected.") logger.info(f"{self} disconnected.")