-
Notifications
You must be signed in to change notification settings - Fork 2.9k
fix HIL-SERL keyboard teleop #2345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -103,11 +103,14 @@ def calibrate(self) -> None: | |
|
|
||
| def _on_press(self, key): | ||
| if hasattr(key, "char"): | ||
| self.event_queue.put((key.char, True)) | ||
| key = key.char | ||
| self.event_queue.put((key, True)) | ||
|
|
||
| def _on_release(self, key): | ||
| if hasattr(key, "char"): | ||
| self.event_queue.put((key.char, False)) | ||
| key = key.char | ||
| self.event_queue.put((key, False)) | ||
|
|
||
| if key == keyboard.Key.esc: | ||
|
||
| logging.info("ESC pressed, disconnecting.") | ||
| self.disconnect() | ||
|
|
@@ -214,8 +217,6 @@ def get_action(self) -> dict[str, Any]: | |
| # this is useful for retrieving other events like interventions for RL, episode success, etc. | ||
| self.misc_keys_queue.put(key) | ||
|
|
||
| self.current_pressed.clear() | ||
|
|
||
| action_dict = { | ||
| "delta_x": delta_x, | ||
| "delta_y": delta_y, | ||
|
|
@@ -266,6 +267,8 @@ def get_teleop_events(self) -> dict[str, Any]: | |
| ] | ||
| is_intervention = any(self.current_pressed.get(key, False) for key in movement_keys) | ||
|
|
||
| self.current_pressed.clear() | ||
|
|
||
| # Check for episode control commands from misc_keys_queue | ||
| terminate_episode = False | ||
| success = False | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change now allows special keys (like arrow keys, shift, ctrl) to be added to
event_queueaskeyboard.Keyobjects when they don't have a 'char' attribute. However, inget_action()(line 196), the code directly compares keys withkeyboard.Keyobjects (e.g.,key == keyboard.Key.up), which will work. But in the baseKeyboardTeleop.get_action()(line 137), the code creates a set fromcurrent_presseditems without type awareness. This inconsistency could lead to mixed key types incurrent_presseddictionary, which may cause unexpected behavior when comparing or processing keys.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in linux spacial key do not have char, but don't know if this change affect other part of LeRobot