diff --git a/opendbc_repo b/opendbc_repo index 63fbea047b..ac089b6314 160000 --- a/opendbc_repo +++ b/opendbc_repo @@ -1 +1 @@ -Subproject commit 63fbea047be715cb772701270e66eddda49433a4 +Subproject commit ac089b63147450275e2dd3d261463ff992271d6a diff --git a/selfdrive/selfdrived/selfdrived.py b/selfdrive/selfdrived/selfdrived.py index 36d1b27044..0b825869f4 100755 --- a/selfdrive/selfdrived/selfdrived.py +++ b/selfdrive/selfdrived/selfdrived.py @@ -198,7 +198,7 @@ class SelfdriveD(CruiseHelper): car_events = self.car_events.update(CS, self.CS_prev, self.sm['carControl']).to_msg() self.events.add_from_msg(car_events) - car_events_sp = self.car_events_sp.update().to_msg() + car_events_sp = self.car_events_sp.update(CS, self.events).to_msg() self.events_sp.add_from_msg(car_events_sp) if self.CP.notCar: diff --git a/sunnypilot/selfdrive/car/car_specific.py b/sunnypilot/selfdrive/car/car_specific.py index 057f79cf0c..649aceca01 100644 --- a/sunnypilot/selfdrive/car/car_specific.py +++ b/sunnypilot/selfdrive/car/car_specific.py @@ -5,12 +5,16 @@ This file is part of sunnypilot and is licensed under the MIT License. See the LICENSE.md file in the root directory for more details. """ -from cereal import custom +from cereal import log, custom from opendbc.car import structs +from opendbc.car.chrysler.values import RAM_DT +from openpilot.selfdrive.selfdrived.events import Events from openpilot.sunnypilot.selfdrive.selfdrived.events import EventsSP +EventName = log.OnroadEvent.EventName EventNameSP = custom.OnroadEventSP.EventName +GearShifter = structs.CarState.GearShifter class CarSpecificEventsSP: @@ -18,6 +22,7 @@ class CarSpecificEventsSP: self.CP = CP self.params = params + self.low_speed_alert = False self.hyundai_radar_tracks = self.params.get_bool("HyundaiRadarTracks") self.hyundai_radar_tracks_confirmed = self.params.get_bool("HyundaiRadarTracksConfirmed") @@ -25,10 +30,26 @@ class CarSpecificEventsSP: self.hyundai_radar_tracks = self.params.get_bool("HyundaiRadarTracks") self.hyundai_radar_tracks_confirmed = self.params.get_bool("HyundaiRadarTracksConfirmed") - def update(self): - events = EventsSP() + def update(self, CS: structs.CarState, events: Events): + events_sp = EventsSP() + + if self.CP.brand == 'chrysler': + if self.CP.carFingerprint in RAM_DT: + # remove belowSteerSpeed event from CarSpecificEvents as RAM_DT uses a different logic + if events.has(EventName.belowSteerSpeed): + events.remove(EventName.belowSteerSpeed) + + # TODO-SP: use if/elif to have the gear shifter condition takes precedence over the speed condition + # TODO-SP: add 1 m/s hysteresis + if CS.vEgo >= self.CP.minEnableSpeed: + self.low_speed_alert = False + if CS.gearShifter != GearShifter.drive: + self.low_speed_alert = True + if self.low_speed_alert: + events.add(EventName.belowSteerSpeed) + if self.CP.brand == 'hyundai': if self.hyundai_radar_tracks and not self.hyundai_radar_tracks_confirmed: - events.add(EventNameSP.hyundaiRadarTracksConfirmed) + events_sp.add(EventNameSP.hyundaiRadarTracksConfirmed) - return events + return events_sp