Skip to content

Commit

Permalink
Add EnableGasPedal (toggle menu)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daehyuk Ahn authored and Casey Francis committed Aug 23, 2021
1 parent 4e9ac3b commit 9b45eb1
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void safety_setter_thread() {
cereal::CarParams::Reader car_params = cmsg.getRoot<cereal::CarParams>();
cereal::CarParams::SafetyModel safety_model = car_params.getSafetyModel();

panda->set_unsafe_mode(0); // see safety_declarations.h for allowed values
panda->set_unsafe_mode(1); // see safety_declarations.h for allowed values

auto safety_param = car_params.getSafetyParam();
LOGW("setting safety model: %d with param %d", (int)safety_model, safety_param);
Expand Down
6 changes: 4 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from cereal import car
from common.kalman.simple_kalman import KF1D
from common.params import Params
from common.realtime import DT_CTRL
from selfdrive.car import gen_empty_fingerprint
from selfdrive.config import Conversions as CV
Expand Down Expand Up @@ -100,6 +101,7 @@ def apply(self, c):

def create_common_events(self, cs_out, extra_gears=None, gas_resume_speed=-1, pcm_enable=True):
events = Events()
enable_gas_pedal = Params().get_bool('EnableGasPedal')

if cs_out.doorOpen:
events.add(EventName.doorOpen)
Expand All @@ -114,7 +116,7 @@ def create_common_events(self, cs_out, extra_gears=None, gas_resume_speed=-1, pc
events.add(EventName.wrongCarMode)
if cs_out.espDisabled:
events.add(EventName.espDisabled)
if cs_out.gasPressed:
if cs_out.gasPressed and not enable_gas_pedal:
events.add(EventName.gasPressed)
if cs_out.stockFcw:
events.add(EventName.stockFcw)
Expand Down Expand Up @@ -142,7 +144,7 @@ def create_common_events(self, cs_out, extra_gears=None, gas_resume_speed=-1, pc
# Disable on rising edge of gas or brake. Also disable on brake when speed > 0.
# Optionally allow to press gas at zero speed to resume.
# e.g. Chrysler does not spam the resume button yet, so resuming with gas is handy. FIXME!
if (cs_out.gasPressed and (not self.CS.out.gasPressed) and cs_out.vEgo > gas_resume_speed) or \
if (not enable_gas_pedal and cs_out.gasPressed and (not self.CS.out.gasPressed) and cs_out.vEgo > gas_resume_speed) or \
(cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)):
events.add(EventName.pedalPressed)

Expand Down
1 change: 1 addition & 0 deletions selfdrive/common/params.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"ControlsReady", CLEAR_ON_MANAGER_START | CLEAR_ON_PANDA_DISCONNECT | CLEAR_ON_IGNITION_ON},
{"CurrentRoute", CLEAR_ON_MANAGER_START | CLEAR_ON_IGNITION_ON},
{"DisableRadar", PERSISTENT}, // WARNING: THIS DISABLES AEB
{"EnableGasPedal", PERSISTENT},
{"EndToEndToggle", PERSISTENT},
{"CompletedTrainingVersion", PERSISTENT},
{"DisablePowerDown", PERSISTENT},
Expand Down
7 changes: 7 additions & 0 deletions selfdrive/ui/qt/offroad/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ TogglesPanel::TogglesPanel(QWidget *parent) : QWidget(parent) {
"../assets/offroad/icon_road.png",
this));

// DAEHAHN - added a new feature to system toggle
toggles.append(new ParamControl("EnableGasPedal",
"Enable to use Gas Pedal",
"Enable to use gas pedal while Openpilot engaged.",
"../assets/offroad/icon_openpilot.png",
this));

#ifdef ENABLE_MAPS
toggles.append(new ParamControl("NavSettingTime24h",
"Show ETA in 24h format",
Expand Down

0 comments on commit 9b45eb1

Please sign in to comment.