Skip to content

Commit

Permalink
Revert "MADS: Map cruise main and lateral buttons to button events" (c…
Browse files Browse the repository at this point in the history
…ommaai#372)

Revert "MADS: Map cruise main and lateral buttons to button events (commaai#361)"

This reverts commit 4d7afe3.
  • Loading branch information
sunnyhaibin authored Jul 31, 2024
1 parent 9810b10 commit b3926fa
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
3 changes: 1 addition & 2 deletions selfdrive/car/chrysler/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def _update(self, c):
self.sp_update_params()

self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}))
self.CS.button_events.extend(create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}))

self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)

Expand All @@ -109,7 +108,7 @@ def _update(self, c):
if self.enable_mads:
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
self.CS.madsEnabled = True
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
if self.CS.prev_lkas_enabled != 1 and self.CS.lkas_enabled == 1:
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.lkas_disabled = not self.CS.lkas_disabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
Expand Down
3 changes: 1 addition & 2 deletions selfdrive/car/ford/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def _update(self, c):
self.sp_update_params()

self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}))
self.CS.button_events.extend(create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}))

self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)

Expand All @@ -86,7 +85,7 @@ def _update(self, c):
if self.enable_mads:
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
self.CS.madsEnabled = True
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
if not self.CS.prev_lkas_enabled and self.CS.lkas_enabled:
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
else:
Expand Down
4 changes: 1 addition & 3 deletions selfdrive/car/gm/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,6 @@ def _update(self, c):
]
distance_button = self.CS.distance_button

self.CS.button_events.extend(create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}))

self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)

if not self.CP.pcmCruise:
Expand All @@ -233,7 +231,7 @@ def _update(self, c):
if self.enable_mads:
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
self.CS.madsEnabled = True
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
if self.CS.prev_lkas_enabled != 1 and self.CS.lkas_enabled == 1:
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
else:
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 @@ -282,7 +282,7 @@ def _update(self, c):
if self.enable_mads:
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
self.CS.madsEnabled = True
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
if self.CS.prev_cruise_setting != 1 and self.CS.cruise_setting == 1:
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
else:
Expand Down
14 changes: 8 additions & 6 deletions selfdrive/car/hyundai/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,7 @@ def _update(self, c):
ret = self.CS.update(self.cp, self.cp_cam)
self.sp_update_params()

self.CS.button_events.extend(create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT))
self.CS.button_events.extend(create_button_events(self.CS.lfa_enabled, self.CS.prev_lfa_enabled, {1: ButtonType.altButton1}))
self.CS.button_events.extend(create_button_events(self.CS.main_buttons[-1], self.CS.prev_main_buttons, {1: ButtonType.altButton3}))
self.CS.button_events = create_button_events(self.CS.cruise_buttons[-1], self.CS.prev_cruise_buttons, BUTTONS_DICT)

self.CS.accEnabled = self.get_sp_v_cruise_non_pcm_state(ret, self.CS.accEnabled,
self.CS.button_events, c.vCruise)
Expand All @@ -216,12 +214,16 @@ def _update(self, c):

if ret.cruiseState.available:
if not self.CP.pcmCruiseSpeed:
if any(b.type in (ButtonType.altButton3, ButtonType.cancel) and not b.pressed for b in self.CS.button_events):
self.CS.accEnabled = True
if self.CS.prev_main_buttons == 1:
if self.CS.main_buttons[-1] != 1:
self.CS.accEnabled = True
elif self.CS.prev_cruise_buttons == 4:
if self.CS.cruise_buttons[-1] != 4:
self.accEnabled = True
if self.enable_mads:
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
self.CS.madsEnabled = True
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
if self.CS.prev_lfa_enabled != 1 and self.CS.lfa_enabled == 1:
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
else:
Expand Down
8 changes: 5 additions & 3 deletions selfdrive/car/mazda/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def _update(self, c):
self.sp_update_params()

# TODO: add button types for inc and dec
self.CS.button_events.extend(create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise}))
self.CS.button_events.extend(create_button_events(self.CS.lkas_enabled, self.CS.prev_lkas_enabled, {1: ButtonType.altButton1}))
self.CS.button_events = [
*self.CS.button_events,
*create_button_events(self.CS.distance_button, self.CS.prev_distance_button, {1: ButtonType.gapAdjustCruise})
]

self.CS.mads_enabled = self.get_sp_cruise_main_state(ret, self.CS)

Expand All @@ -52,7 +54,7 @@ def _update(self, c):
if self.enable_mads:
if not self.CS.prev_mads_enabled and self.CS.mads_enabled:
self.CS.madsEnabled = True
if any(b.type == ButtonType.altButton1 and b.pressed for b in self.CS.button_events):
if self.CS.prev_lkas_enabled != self.CS.lkas_enabled:
self.CS.madsEnabled = not self.CS.madsEnabled
self.CS.madsEnabled = self.get_acc_mads(ret.cruiseState.enabled, self.CS.accEnabled, self.CS.madsEnabled)
else:
Expand Down

0 comments on commit b3926fa

Please sign in to comment.