Skip to content

Commit

Permalink
MADS: allow Disengage on Accelerator (commaai#243)
Browse files Browse the repository at this point in the history
* MADS: allow Disengage on Accelerator

* make sure to disable in interfaces
  • Loading branch information
sunnyhaibin authored Sep 4, 2023
1 parent c993256 commit e362198
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 3 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,13 +390,14 @@ def get_sp_v_cruise_non_pcm_state(self, cs_out, acc_enabled, button_events, vCru
return acc_enabled, button_events

def get_sp_cancel_cruise_state(self, mads_enabled, acc_enabled=False):
mads_enabled = False if not self.enable_mads else mads_enabled
mads_enabled = False if not self.enable_mads or self.disengage_on_accelerator else mads_enabled
return mads_enabled, acc_enabled

def get_sp_pedal_disengage(self, cs_out):
accel_pedal = cs_out.gasPressed and not self.CS.out.gasPressed and self.disengage_on_accelerator
brake = cs_out.brakePressed and (not self.CS.out.brakePressed or not cs_out.standstill)
regen = cs_out.regenBraking and (not self.CS.out.regenBraking or not cs_out.standstill)
return brake or regen
return accel_pedal or brake or regen

def get_sp_cruise_main_state(self, cs_out, CS):
if not CS.control_initialized:
Expand Down
3 changes: 0 additions & 3 deletions selfdrive/controls/controlsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ def __init__(self, sm=None, pm=None, can_sock=None, CI=None):
self.mads_disengage_lateral_on_brake = self.params.get_bool("DisengageLateralOnBrake")
self.mads_dlob = self.enable_mads and self.mads_disengage_lateral_on_brake
self.mads_ndlob = self.enable_mads and not self.mads_disengage_lateral_on_brake
if self.enable_mads and self.disengage_on_accelerator:
self.params.put_bool("DisengageOnAccelerator", False)
self.disengage_on_accelerator = False
self.CP.alternativeExperience = 0
if not self.disengage_on_accelerator:
self.CP.alternativeExperience |= ALTERNATIVE_EXPERIENCE.DISABLE_DISENGAGE_ON_GAS
Expand Down

0 comments on commit e362198

Please sign in to comment.