Skip to content

Commit

Permalink
Make keyboard optional
Browse files Browse the repository at this point in the history
  • Loading branch information
hanruihua committed Dec 22, 2024
1 parent 5ea4dc0 commit c574c1c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions irsim/env/env_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@

try:
from pynput import keyboard
keyboard_module = True
except ImportError:
print("pynput is not installed, keyboard control is disabled.")
keyboard_module = False

class EnvBase:
"""
Expand Down Expand Up @@ -87,7 +88,13 @@ def __init__(
env_param.objects = self.objects

if world_param.control_mode == "keyboard":
self.init_keyboard(self.env_config.parse["keyboard"])
if not keyboard_module:
self.logger.error(
"Keyboard module is not installed. Auto control applied. Please install pynput by 'pip install pynput'."
)
world_param.control_mode = "auto"
else:
self.init_keyboard(self.env_config.parse["keyboard"])

if full:
system_platform = platform.system()
Expand Down

0 comments on commit c574c1c

Please sign in to comment.