Only print keyboard help on poll start and unknown command (#31710)

old-commit-hash: 32fb58656a
chrysler-long2
Michel Le Bihan 1 year ago committed by GitHub
parent 9e54339af7
commit fd4ee6f1c5
  1. 4
      tools/sim/bridge/common.py
  2. 7
      tools/sim/lib/keyboard_ctrl.py

@ -13,7 +13,6 @@ from openpilot.selfdrive.car.honda.values import CruiseButtons
from openpilot.tools.sim.lib.common import SimulatorState, World from openpilot.tools.sim.lib.common import SimulatorState, World
from openpilot.tools.sim.lib.simulated_car import SimulatedCar from openpilot.tools.sim.lib.simulated_car import SimulatedCar
from openpilot.tools.sim.lib.simulated_sensors import SimulatedSensors from openpilot.tools.sim.lib.simulated_sensors import SimulatedSensors
from openpilot.tools.sim.lib.keyboard_ctrl import KEYBOARD_HELP
def rk_loop(function, hz, exit_event: threading.Event): def rk_loop(function, hz, exit_event: threading.Event):
@ -74,9 +73,6 @@ class SimulatorBridge(ABC):
def print_status(self): def print_status(self):
print( print(
f""" f"""
Keyboard Commands:
{KEYBOARD_HELP}
State: State:
Ignition: {self.simulator_state.ignition} Engaged: {self.simulator_state.is_engaged} Ignition: {self.simulator_state.ignition} Engaged: {self.simulator_state.is_engaged}
""") """)

@ -49,7 +49,12 @@ def getch() -> str:
termios.tcsetattr(STDIN_FD, termios.TCSADRAIN, old_settings) termios.tcsetattr(STDIN_FD, termios.TCSADRAIN, old_settings)
return ch return ch
def print_keyboard_help():
print(f"Keyboard Commands:\n{KEYBOARD_HELP}")
def keyboard_poll_thread(q: 'Queue[str]'): def keyboard_poll_thread(q: 'Queue[str]'):
print_keyboard_help()
while True: while True:
c = getch() c = getch()
if c == '1': if c == '1':
@ -77,6 +82,8 @@ def keyboard_poll_thread(q: 'Queue[str]'):
elif c == 'q': elif c == 'q':
q.put("quit") q.put("quit")
break break
else:
print_keyboard_help()
def test(q: 'Queue[str]') -> NoReturn: def test(q: 'Queue[str]') -> NoReturn:
while True: while True:

Loading…
Cancel
Save