Skip to content

Commit

Permalink
Fix safe_action (huggingface#395)
Browse files Browse the repository at this point in the history
  • Loading branch information
aliberts authored Aug 30, 2024
1 parent 708dd91 commit a62122e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lerobot/common/robot_devices/robots/koch.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,14 +554,16 @@ def send_action(self, action: torch.Tensor, follower_names: list[str] | None = N
safe_diff = torch.minimum(diff, max_relative_target)
safe_diff = torch.maximum(safe_diff, -max_relative_target)
safe_action = current_pos + safe_diff
if not torch.allclose(safe_action, action):
if not torch.allclose(safe_action, this_action):
logging.warning(
"Relative action magnitude had to be clamped to be safe.\n"
f" requested relative action target: {diff}\n"
f" clamped relative action target: {safe_diff}"
)
follower_goal_pos[name] = safe_action.numpy()
else:
follower_goal_pos[name] = this_action.numpy()

follower_goal_pos[name] = safe_action.numpy()
from_idx = to_idx

for name in self.follower_arms:
Expand Down

0 comments on commit a62122e

Please sign in to comment.