Fix safe_action (#395)

This commit is contained in:
Simon Alibert 2024-08-30 10:36:05 +02:00 committed by GitHub
parent 4806336816
commit 04a995e7d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -554,14 +554,16 @@ class KochRobot:
safe_diff = torch.minimum(diff, max_relative_target) safe_diff = torch.minimum(diff, max_relative_target)
safe_diff = torch.maximum(safe_diff, -max_relative_target) safe_diff = torch.maximum(safe_diff, -max_relative_target)
safe_action = current_pos + safe_diff safe_action = current_pos + safe_diff
if not torch.allclose(safe_action, action): if not torch.allclose(safe_action, this_action):
logging.warning( logging.warning(
"Relative action magnitude had to be clamped to be safe.\n" "Relative action magnitude had to be clamped to be safe.\n"
f" requested relative action target: {diff}\n" f" requested relative action target: {diff}\n"
f" clamped relative action target: {safe_diff}" f" clamped relative action target: {safe_diff}"
) )
follower_goal_pos[name] = safe_action.numpy() follower_goal_pos[name] = safe_action.numpy()
else:
follower_goal_pos[name] = this_action.numpy()
from_idx = to_idx from_idx = to_idx
for name in self.follower_arms: for name in self.follower_arms: