diff --git a/docs/SAFETY.md b/docs/SAFETY.md index 23ee251af4..49f88df8c0 100644 --- a/docs/SAFETY.md +++ b/docs/SAFETY.md @@ -22,7 +22,7 @@ Following Hazard and Risk Analysis and FMEA, at a very high level, we have desig ensuring two main safety requirements. 1. The driver must always be capable to immediately retake manual control of the vehicle, - by stepping on either pedal or by pressing the cancel button. + by stepping on the brake pedal or by pressing the cancel button. 2. The vehicle must not alter its trajectory too quickly for the driver to safely react. This means that while the system is engaged, the actuators are constrained to operate within reasonable limits. diff --git a/selfdrive/assets/offroad/icon_disengage_on_accelerator.svg b/selfdrive/assets/offroad/icon_disengage_on_accelerator.svg new file mode 100644 index 0000000000..d5a8c87e21 --- /dev/null +++ b/selfdrive/assets/offroad/icon_disengage_on_accelerator.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5252412f2225c89ea7e78ad0fbd6544170aea157693ce0f9778f26a64f582ec2 +size 6821 diff --git a/selfdrive/car/interfaces.py b/selfdrive/car/interfaces.py index f01c8a8aa0..34ca75cd48 100644 --- a/selfdrive/car/interfaces.py +++ b/selfdrive/car/interfaces.py @@ -124,8 +124,6 @@ class CarInterfaceBase(ABC): events.add(EventName.wrongCarMode) if cs_out.espDisabled: events.add(EventName.espDisabled) - if cs_out.gasPressed: - events.add(EventName.pedalPressedPreEnable) if cs_out.stockFcw: events.add(EventName.stockFcw) if cs_out.stockAeb: diff --git a/selfdrive/common/params.cc b/selfdrive/common/params.cc index 8180ee4293..0c36511be7 100644 --- a/selfdrive/common/params.cc +++ b/selfdrive/common/params.cc @@ -98,6 +98,7 @@ std::unordered_map keys = { {"DisableRadar_Allow", PERSISTENT}, {"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB {"DisableUpdates", PERSISTENT}, + {"DisengageOnAccelerator", PERSISTENT}, {"DongleId", PERSISTENT}, {"DoReboot", CLEAR_ON_MANAGER_START}, {"DoShutdown", CLEAR_ON_MANAGER_START}, diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 3ad8ce166f..5f2fe34721 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -10,6 +10,7 @@ from common.profiler import Profiler from common.params import Params, put_nonblocking import cereal.messaging as messaging from common.conversions import Conversions as CV +from panda import ALTERNATIVE_EXPERIENCE from selfdrive.swaglog import cloudlog from selfdrive.boardd.boardd import can_list_to_can_capnp from selfdrive.car.car_helpers import get_car, get_startup_event, get_one_can @@ -100,7 +101,11 @@ class Controls: else: self.CI, self.CP = CI, CI.CP - self.CP.alternativeExperience = 0 # see panda/board/safety_declarations.h for allowed values + # set alternative experiences from parameters + self.disengage_on_accelerator = params.get_bool("DisengageOnAccelerator") + self.CP.alternativeExperience = 0 + if not self.disengage_on_accelerator: + self.CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_ON_GAS # read params self.is_metric = params.get_bool("IsMetric") @@ -200,11 +205,15 @@ class Controls: self.events.add(EventName.controlsInitializing) return - # Disable on rising edge of gas or brake. Also disable on brake when speed > 0 - if (CS.gasPressed and not self.CS_prev.gasPressed) or \ + # Disable on rising edge of accelerator or brake. Also disable on brake when speed > 0 + if (CS.gasPressed and not self.CS_prev.gasPressed and self.disengage_on_accelerator) or \ (CS.brakePressed and (not self.CS_prev.brakePressed or not CS.standstill)): self.events.add(EventName.pedalPressed) + if CS.gasPressed: + self.events.add(EventName.pedalPressedPreEnable if self.disengage_on_accelerator else + EventName.gasPressedOverride) + self.events.add_from_msg(CS.events) if not self.CP.notCar: diff --git a/selfdrive/controls/lib/longcontrol.py b/selfdrive/controls/lib/longcontrol.py index 21682d8263..f91ddcf44e 100644 --- a/selfdrive/controls/lib/longcontrol.py +++ b/selfdrive/controls/lib/longcontrol.py @@ -87,7 +87,7 @@ class LongControl(): v_target, v_target_future, CS.brakePressed, CS.cruiseState.standstill) - if self.long_control_state == LongCtrlState.off or CS.gasPressed: + if self.long_control_state == LongCtrlState.off: self.reset(CS.vEgo) output_accel = 0. diff --git a/selfdrive/controls/lib/longitudinal_planner.py b/selfdrive/controls/lib/longitudinal_planner.py index 8aade9b9c4..41c41e5493 100755 --- a/selfdrive/controls/lib/longitudinal_planner.py +++ b/selfdrive/controls/lib/longitudinal_planner.py @@ -71,7 +71,6 @@ class Planner: # Reset current state when not engaged, or user is controlling the speed reset_state = long_control_state == LongCtrlState.off - reset_state = reset_state or sm['carState'].gasPressed # No change cost when user is controlling the speed, or when standstill prev_accel_constraint = not (reset_state or sm['carState'].standstill) diff --git a/selfdrive/manager/manager.py b/selfdrive/manager/manager.py index 21b8cb9657..b5fa439671 100755 --- a/selfdrive/manager/manager.py +++ b/selfdrive/manager/manager.py @@ -38,6 +38,7 @@ def manager_init() -> None: default_params: List[Tuple[str, Union[str, bytes]]] = [ ("CompletedTrainingVersion", "0"), + ("DisengageOnAccelerator", "1"), ("HasAcceptedTerms", "0"), ("OpenpilotEnabledToggle", "1"), ] diff --git a/selfdrive/test/process_replay/process_replay.py b/selfdrive/test/process_replay/process_replay.py index 6e3398f9cc..9a2a161562 100755 --- a/selfdrive/test/process_replay/process_replay.py +++ b/selfdrive/test/process_replay/process_replay.py @@ -346,6 +346,7 @@ def setup_env(simulation=False): params.clear_all() params.put_bool("OpenpilotEnabledToggle", True) params.put_bool("Passive", False) + params.put_bool("DisengageOnAccelerator", True) os.environ["NO_RADAR_SLEEP"] = "1" os.environ["REPLAY"] = "1" diff --git a/selfdrive/test/process_replay/ref_commit b/selfdrive/test/process_replay/ref_commit index a0cebb0961..cd6ae5f315 100644 --- a/selfdrive/test/process_replay/ref_commit +++ b/selfdrive/test/process_replay/ref_commit @@ -1 +1 @@ -ad17c3c1d11691bc35efe3de78a7cef3daf5dbdf \ No newline at end of file +5f9efe721de4d947567eae55a8dd331f0bae4ded \ No newline at end of file diff --git a/selfdrive/ui/qt/offroad/settings.cc b/selfdrive/ui/qt/offroad/settings.cc index f3584460d6..4fde627341 100644 --- a/selfdrive/ui/qt/offroad/settings.cc +++ b/selfdrive/ui/qt/offroad/settings.cc @@ -65,6 +65,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) { "In this mode openpilot will ignore lanelines and just drive how it thinks a human would.", "../assets/offroad/icon_road.png", }, + { + "DisengageOnAccelerator", + "Disengage On Accelerator Pedal", + "When enabled, openpilot will disengage when the accelerator pedal is pressed.", + "../assets/offroad/icon_disengage_on_accelerator.svg", + }, #ifdef ENABLE_MAPS { "NavSettingTime24h",