mirror of
https://github.com/huggingface/lerobot.git
synced 2026-05-14 08:09:45 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4457c978b2 |
@@ -102,12 +102,21 @@ class KeyboardTeleop(Teleoperator):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def _on_press(self, key):
|
def _on_press(self, key):
|
||||||
|
# Capture both character keys and special keys (arrows, shift, ctrl, etc.)
|
||||||
if hasattr(key, "char"):
|
if hasattr(key, "char"):
|
||||||
self.event_queue.put((key.char, True))
|
self.event_queue.put((key.char, True))
|
||||||
|
else:
|
||||||
|
# Capture special keys directly (keyboard.Key enum values)
|
||||||
|
self.event_queue.put((key, True))
|
||||||
|
|
||||||
def _on_release(self, key):
|
def _on_release(self, key):
|
||||||
|
# Capture both character keys and special keys
|
||||||
if hasattr(key, "char"):
|
if hasattr(key, "char"):
|
||||||
self.event_queue.put((key.char, False))
|
self.event_queue.put((key.char, False))
|
||||||
|
else:
|
||||||
|
# Capture special keys directly (keyboard.Key enum values)
|
||||||
|
self.event_queue.put((key, False))
|
||||||
|
|
||||||
if key == keyboard.Key.esc:
|
if key == keyboard.Key.esc:
|
||||||
logging.info("ESC pressed, disconnecting.")
|
logging.info("ESC pressed, disconnecting.")
|
||||||
self.disconnect()
|
self.disconnect()
|
||||||
@@ -214,8 +223,6 @@ class KeyboardEndEffectorTeleop(KeyboardTeleop):
|
|||||||
# this is useful for retrieving other events like interventions for RL, episode success, etc.
|
# this is useful for retrieving other events like interventions for RL, episode success, etc.
|
||||||
self.misc_keys_queue.put(key)
|
self.misc_keys_queue.put(key)
|
||||||
|
|
||||||
self.current_pressed.clear()
|
|
||||||
|
|
||||||
action_dict = {
|
action_dict = {
|
||||||
"delta_x": delta_x,
|
"delta_x": delta_x,
|
||||||
"delta_y": delta_y,
|
"delta_y": delta_y,
|
||||||
@@ -283,6 +290,8 @@ class KeyboardEndEffectorTeleop(KeyboardTeleop):
|
|||||||
terminate_episode = True
|
terminate_episode = True
|
||||||
success = False
|
success = False
|
||||||
|
|
||||||
|
self.current_pressed.clear()
|
||||||
|
|
||||||
return {
|
return {
|
||||||
TeleopEvents.IS_INTERVENTION: is_intervention,
|
TeleopEvents.IS_INTERVENTION: is_intervention,
|
||||||
TeleopEvents.TERMINATE_EPISODE: terminate_episode,
|
TeleopEvents.TERMINATE_EPISODE: terminate_episode,
|
||||||
|
|||||||
Reference in New Issue
Block a user