move to car_specific_sp

This commit is contained in:
Jason Wen
2025-04-27 02:41:51 -04:00
parent a7114fad7c
commit 0ffa2f846b
3 changed files with 30 additions and 18 deletions
+5 -12
View File
@@ -6,7 +6,6 @@ from opendbc.car.interfaces import MAX_CTRL_SPEED
from opendbc.car.volkswagen.values import CarControllerParams as VWCarControllerParams
from opendbc.car.hyundai.interface import ENABLE_BUTTONS as HYUNDAI_ENABLE_BUTTONS
from opendbc.car.hyundai.carstate import PREV_BUTTON_SAMPLES as HYUNDAI_PREV_BUTTON_SAMPLES
from opendbc.car.chrysler.values import RAM_DT
from openpilot.selfdrive.selfdrived.events import Events
@@ -55,17 +54,11 @@ class CarSpecificEvents:
elif self.CP.brand == 'chrysler':
events = self.create_common_events(CS, CS_prev, extra_gears=[GearShifter.low])
# Low speed steer alert hysteresis logic
if self.CP.carFingerprint in RAM_DT:
if CS.vEgo >= self.CP.minEnableSpeed:
self.low_speed_alert = False
if (self.CP.minEnableSpeed >= 14.5) and (CS.gearShifter != GearShifter.drive):
self.low_speed_alert = True
else:
if self.CP.minSteerSpeed > 0. and CS.vEgo < (self.CP.minSteerSpeed + 0.5):
self.low_speed_alert = True
elif CS.vEgo > (self.CP.minSteerSpeed + 1.):
self.low_speed_alert = False
# Low speed steer alert hysteresis logic
if self.CP.minSteerSpeed > 0. and CS.vEgo < (self.CP.minSteerSpeed + 0.5):
self.low_speed_alert = True
elif CS.vEgo > (self.CP.minSteerSpeed + 1.):
self.low_speed_alert = False
if self.low_speed_alert:
events.add(EventName.belowSteerSpeed)
+1 -1
View File
@@ -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:
+24 -5
View File
@@ -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,24 @@ 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)
if CS.vEgo >= self.CP.minEnableSpeed:
self.low_speed_alert = False
if (self.CP.minEnableSpeed >= 14.5) and (CS.gearShifter != GearShifter.drive):
self.low_speed_alert = True
if self.low_speed_alert:
events.add(EventNameSP.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