Skip to content

Commit

Permalink
MADS: better doorOpen event logic (commaai#65)
Browse files Browse the repository at this point in the history
* MADS: better doorOpen event logic

* unnecessary
  • Loading branch information
sunnyhaibin authored Mar 28, 2023
1 parent c30c140 commit a7f756f
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion selfdrive/car/chrysler/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def _update(self, c):
ret.buttonEvents = buttonEvents

# events
events = self.create_common_events(ret, extra_gears=[car.CarState.GearShifter.low], pcm_enable=False)
events = self.create_common_events(ret, c, extra_gears=[car.CarState.GearShifter.low], pcm_enable=False)

events, ret = self.create_sp_events(self.CS, ret, events)

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def _update(self, c):
ret.buttonEvents = buttonEvents

# The ECM allows enabling on falling edge of set, but only rising edge of resume
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low,
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low,
GearShifter.eco, GearShifter.manumatic],
pcm_enable=False, enable_buttons=(ButtonType.decelCruise,))
#if not self.CP.pcmCruise:
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/honda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ def _update(self, c):
ret.buttonEvents = buttonEvents

# events
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low], pcm_enable=False)
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low], pcm_enable=False)

events, ret = self.create_sp_events(self.CS, ret, events)

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def _update(self, c):
# To avoid re-engaging when openpilot cancels, check user engagement intention via buttons
# Main button also can trigger an engagement on these cars
allow_enable = any(btn in ENABLE_BUTTONS for btn in self.CS.cruise_buttons) or any(self.CS.main_buttons)
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.manumatic],
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.manumatic],
pcm_enable=False, allow_enable=allow_enable)

events, ret = self.create_sp_events(self.CS, ret, events, main_enabled=True, allow_enable=allow_enable)
Expand Down
4 changes: 2 additions & 2 deletions selfdrive/car/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ def update(self, c: car.CarControl, can_strings: List[bytes]) -> car.CarState:
def apply(self, c: car.CarControl, now_nanos: int) -> Tuple[car.CarControl.Actuators, List[bytes]]:
pass

def create_common_events(self, cs_out, extra_gears=None, pcm_enable=True, allow_enable=True,
def create_common_events(self, cs_out, c, extra_gears=None, pcm_enable=True, allow_enable=True,
enable_buttons=(ButtonType.accelCruise, ButtonType.decelCruise)):
events = Events()

if cs_out.doorOpen:
if cs_out.doorOpen and (c.latActive or c.longActive):
events.add(EventName.doorOpen)
if cs_out.seatbeltUnlatched and cs_out.gearShifter != GearShifter.park:
events.add(EventName.seatbeltNotLatched)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/mazda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def _update(self, c):
ret.buttonEvents = buttonEvents

# events
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
pcm_enable=False)

events, ret = self.create_sp_events(self.CS, ret, events)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/nissan/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _update(self, c):

ret.buttonEvents = buttonEvents

events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
pcm_enable=False)

events, ret = self.create_sp_events(self.CS, ret, events)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/subaru/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def _update(self, c):

ret.buttonEvents = buttonEvents

events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low], pcm_enable=False)
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low], pcm_enable=False)

events, ret = self.create_sp_events(self.CS, ret, events)

Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/toyota/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def _update(self, c):
ret.buttonEvents = buttonEvents

# events
events = self.create_common_events(ret, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
events = self.create_common_events(ret, c, extra_gears=[GearShifter.sport, GearShifter.low, GearShifter.brake],
pcm_enable=False)

events, ret = self.create_sp_events(self.CS, ret, events)
Expand Down
2 changes: 1 addition & 1 deletion selfdrive/car/volkswagen/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def _update(self, c):

ret.buttonEvents = buttonEvents

events = self.create_common_events(ret, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic],
events = self.create_common_events(ret, c, extra_gears=[GearShifter.eco, GearShifter.sport, GearShifter.manumatic],
pcm_enable=False,
enable_buttons=(ButtonType.setCruise, ButtonType.resumeCruise))

Expand Down

0 comments on commit a7f756f

Please sign in to comment.