Skip to content

Commit

Permalink
⛽ Add Toggle to Enable Use of Gas Pedal While Openpilot is Engaged
Browse files Browse the repository at this point in the history
USE AT YOUR OWN RISK
  • Loading branch information
krkeegan committed Feb 23, 2022
1 parent fce1586 commit 80b9f02
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
Binary file added selfdrive/assets/offroad/icon_gas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 10 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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 @@ -44,6 +45,10 @@ def __init__(self, CP, CarController, CarState):
if CarController is not None:
self.CC = CarController(self.cp.dbc_name, CP, self.VM)

# KRKeegan Option to Enable Gas on Cruise
params = Params()
self.enable_gas_on_cruise = params.get_bool("EnableGasOnCruise")

@staticmethod
def get_pid_accel_limits(CP, current_speed, cruise_speed):
return ACCEL_MIN, ACCEL_MAX
Expand Down Expand Up @@ -73,6 +78,9 @@ def get_std_params(candidate, fingerprint):
ret = car.CarParams.new_message()
ret.carFingerprint = candidate
ret.unsafeMode = 0 # see panda/board/safety_declarations.h for allowed values
params = Params()
if params.get_bool("EnableGasOnCruise"):
ret.unsafeMode = ret.unsafeMode | 1

# standard ALC params
ret.steerControlType = car.CarParams.SteerControlType.torque
Expand Down Expand Up @@ -125,7 +133,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True):
events.add(EventName.wrongCarMode)
if cs_out.espDisabled:
events.add(EventName.espDisabled)
if cs_out.gasPressed:
if cs_out.gasPressed and not self.enable_gas_on_cruise:
events.add(EventName.gasPressed)
if cs_out.stockFcw:
events.add(EventName.stockFcw)
Expand Down Expand Up @@ -154,7 +162,7 @@ def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True):
events.add(EventName.steerUnavailable)

# Disable on rising edge of gas or brake. Also disable on brake when speed > 0.
if (cs_out.gasPressed and not self.CS.out.gasPressed) or \
if (not self.enable_gas_on_cruise and cs_out.gasPressed and not self.CS.out.gasPressed) 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 @@ -104,6 +104,7 @@ std::unordered_map<std::string, uint32_t> keys = {
{"DoUninstall", CLEAR_ON_MANAGER_START},
{"EnableWideCamera", CLEAR_ON_MANAGER_START},
{"EndToEndToggle", PERSISTENT},
{"EnableGasOnCruise", PERSISTENT},
{"ForcePowerDown", CLEAR_ON_MANAGER_START},
{"GitBranch", PERSISTENT},
{"GitCommit", PERSISTENT},
Expand Down
6 changes: 6 additions & 0 deletions selfdrive/ui/qt/offroad/settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ TogglesPanel::TogglesPanel(SettingsWindow *parent) : ListWidget(parent) {
"Display speed in km/h instead of mph.",
"../assets/offroad/icon_metric.png",
},
{
"EnableGasOnCruise",
"Enable Gas on Cruise",
"Pressing the gas pedal will NOT disengage openpilot, while this is the default design for Toyota, this is NOT enabled by default for OpenPilot. Use at your own risk!!",
"../assets/offroad/icon_gas.png",
},
{
"RecordFront",
"Record and Upload Driver Camera",
Expand Down

0 comments on commit 80b9f02

Please sign in to comment.