Skip to content

Commit

Permalink
Make gripper_open_degree a config param (huggingface#379)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-soare committed Aug 26, 2024
1 parent 9c7649f commit 97086cd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lerobot/common/robot_devices/robots/koch.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# In nominal degree range ]-180, +180[
ZERO_POSITION_DEGREE = 0
ROTATED_POSITION_DEGREE = 90
GRIPPER_OPEN_DEGREE = 35.156


def assert_drive_mode(drive_mode):
Expand Down Expand Up @@ -165,6 +164,11 @@ class KochRobotConfig:
follower_arms: dict[str, MotorsBus] = field(default_factory=lambda: {})
cameras: dict[str, Camera] = field(default_factory=lambda: {})

# Optionally set the leader arm in torque mode with the gripper motor set to this angle. This makes it
# possible to squeeze the gripper and have it spring back to an open position on its own. If None, the
# gripper is not put in torque mode.
gripper_open_degree: float | None = None


class KochRobot:
# TODO(rcadene): Implement force feedback
Expand Down Expand Up @@ -339,11 +343,12 @@ def connect(self):
print(f"Activating torque on {name} follower arm.")
self.follower_arms[name].write("Torque_Enable", 1)

# Enable torque on the gripper of the leader arms, and move it to 45 degrees,
# so that we can use it as a trigger to close the gripper of the follower arms.
for name in self.leader_arms:
self.leader_arms[name].write("Torque_Enable", 1, "gripper")
self.leader_arms[name].write("Goal_Position", GRIPPER_OPEN_DEGREE, "gripper")
if self.config.gripper_open_degree is not None:
# Set the leader arm in torque mode with the gripper motor set to an angle. This makes it possible
# to squeeze the gripper and have it spring back to an open position on its own.
for name in self.leader_arms:
self.leader_arms[name].write("Torque_Enable", 1, "gripper")
self.leader_arms[name].write("Goal_Position", self.config.gripper_open_degree, "gripper")

# Connect the cameras
for name in self.cameras:
Expand Down
3 changes: 3 additions & 0 deletions lerobot/configs/robot/koch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ cameras:
fps: 30
width: 640
height: 480
# Sets the leader arm in torque mode with the gripper motor set to this angle. This makes it possible
# to squeeze the gripper and have it spring back to an open position on its own.
gripper_open_degree: 35.156

0 comments on commit 97086cd

Please sign in to comment.