From e62756596b82e4e40d02a30b34d3f3c9960bffe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20R=C4=85czy?= Date: Tue, 12 Dec 2023 14:14:51 -0800 Subject: [PATCH] controlsd: require joystick mode param for the body (#30680) * Update joystick mode in step * Stop putting the body in joystick mode by default * Toggle JoystickDebugMode by default for notCars in process_replay * Remove subsection about web joystick * Update param only in non-cars * Make joystickDebug non-static event, and add it in a loop * Add comment --- selfdrive/controls/controlsd.py | 15 +++++++++------ selfdrive/test/process_replay/process_replay.py | 3 +++ tools/joystick/README.md | 11 ----------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 41866efc3d..bbfde95cd6 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -93,8 +93,7 @@ class Controls: else: self.CI, self.CP = CI, CI.CP - self.joystick_enabled = self.params.get_bool("JoystickDebugMode") - self.joystick_mode = self.joystick_enabled or self.CP.notCar + self.joystick_mode = self.params.get_bool("JoystickDebugMode") # set alternative experiences from parameters self.disengage_on_accelerator = self.params.get_bool("DisengageOnAccelerator") @@ -192,9 +191,6 @@ class Controls: set_offroad_alert("Offroad_NoFirmware", True) elif self.CP.passive: self.events.add(EventName.dashcamMode, static=True) - elif self.joystick_mode: - self.events.add(EventName.joystickDebug, static=True) - self.startup_event = None # controlsd is driven by can recv, expected at 100Hz self.rk = Ratekeeper(100, print_delay_threshold=None) @@ -215,6 +211,11 @@ class Controls: self.events.clear() + # Add joystick event, static on cars, dynamic on nonCars + if self.joystick_mode: + self.events.add(EventName.joystickDebug) + self.startup_event = None + # Add startup event if self.startup_event is not None: self.events.add(self.startup_event) @@ -371,7 +372,7 @@ class Controls: else: self.logged_comm_issue = None - if not (self.CP.notCar and self.joystick_enabled): + if not (self.CP.notCar and self.joystick_mode): if not self.sm['lateralPlan'].mpcSolutionValid: self.events.add(EventName.plannerError) if not self.sm['liveLocationKalman'].posenetOK: @@ -853,6 +854,8 @@ class Controls: self.is_metric = self.params.get_bool("IsMetric") self.experimental_mode = self.params.get_bool("ExperimentalMode") and self.CP.openpilotLongitudinalControl + if self.CP.notCar: + self.joystick_mode = self.params.get_bool("JoystickDebugMode") # Sample data from sockets and get a carState CS = self.data_sample() diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index c3c3670a74..19f1c127a6 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -749,6 +749,9 @@ def generate_params_config(lr=None, CP=None, fingerprint=None, custom_params=Non if CP.openpilotLongitudinalControl: params_dict["ExperimentalLongitudinalEnabled"] = True + if CP.notCar: + params_dict["JoystickDebugMode"] = True + return params_dict diff --git a/tools/joystick/README.md b/tools/joystick/README.md index 65422afe80..aea93dad53 100644 --- a/tools/joystick/README.md +++ b/tools/joystick/README.md @@ -45,17 +45,6 @@ In order to use a joystick over the network, we need to run joystickd locally fr tools/joystick/joystickd.py ``` -### Web joystick on your mobile device - -A browser-based virtual joystick designed for touch screens. Starts automatically when installed on comma body (non-car robotics platform). -For cars, start the web joystick service manually via SSH before starting the car. - -```shell -tools/joystick/web.py -``` - -After starting the car/body, open the web joystick app at this URL: `http://[comma three IP address]:5000` - --- Now start your car and openpilot should go into joystick mode with an alert on startup! The status of the axes will display on the alert, while button statuses print in the shell.