Skip to content

Commit

Permalink
Allow gas press (on param enable)
Browse files Browse the repository at this point in the history
  • Loading branch information
sshane committed Oct 27, 2020
1 parent 4b10f40 commit f1c99e8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ void safety_setter_thread() {
cereal::CarParams::Reader car_params = cmsg.getRoot<cereal::CarParams>();
cereal::CarParams::SafetyModel safety_model = car_params.getSafetyModel();

LOGW("setting unsafe_mode for gas press");
panda->usb_write(0xdf, 9, 0);

auto safety_param = car_params.getSafetyParam();
LOGW("setting safety model: %d with param %d", (int)safety_model, safety_param);

Expand Down
8 changes: 5 additions & 3 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from selfdrive.controls.lib.events import Events
from selfdrive.controls.lib.vehicle_model import VehicleModel
from selfdrive.controls.lib.drive_helpers import V_CRUISE_MAX
from common.op_params import opParams

GearShifter = car.CarState.GearShifter
EventName = car.CarEvent.EventName
Expand All @@ -19,6 +20,7 @@ class CarInterfaceBase():
def __init__(self, CP, CarController, CarState):
self.CP = CP
self.VM = VehicleModel(CP)
self.disengage_on_gas = opParams().get('disengage_on_gas')

self.frame = 0
self.low_speed_alert = False
Expand Down Expand Up @@ -100,7 +102,7 @@ def create_common_events(self, cs_out, extra_gears=[], gas_resume_speed=-1, pcm_
events.add(EventName.wrongCarMode)
if cs_out.espDisabled:
events.add(EventName.espDisabled)
if cs_out.gasPressed:
if cs_out.gasPressed and self.disengage_on_gas:
events.add(EventName.gasPressed)
if cs_out.stockFcw:
events.add(EventName.stockFcw)
Expand All @@ -119,8 +121,8 @@ def create_common_events(self, cs_out, extra_gears=[], gas_resume_speed=-1, pcm_
# 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 \
(cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)):
if (cs_out.gasPressed and (not self.CS.out.gasPressed) and self.disengage_on_gas and cs_out.vEgo > gas_resume_speed) or \
(cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)): # still disengages on brake!
events.add(EventName.pedalPressed)

# we engage when pcm is active (rising edge)
Expand Down

0 comments on commit f1c99e8

Please sign in to comment.