mirror of
https://github.com/firestar5683/StarPilot.git
synced 2026-08-21 08:14:00 +08:00
Toggle to always enable DM (#32205)
* permanent * param * correct behavior * toggle * need trans * ref_commit * translate for chs/t * disable on P and R * read old-commit-hash: 1d05704d27dbe4f73c0eba7e8dad2ae84d4e205e
This commit is contained in:
@@ -17,7 +17,7 @@ def dmonitoringd_thread():
|
||||
pm = messaging.PubMaster(['driverMonitoringState'])
|
||||
sm = messaging.SubMaster(['driverStateV2', 'liveCalibration', 'carState', 'controlsState', 'modelV2'], poll='driverStateV2')
|
||||
|
||||
driver_status = DriverStatus(rhd_saved=params.get_bool("IsRhdDetected"))
|
||||
driver_status = DriverStatus(rhd_saved=params.get_bool("IsRhdDetected"), always_on=params.get_bool("AlwaysOnDM"))
|
||||
|
||||
v_cruise_last = 0
|
||||
driver_engaged = False
|
||||
@@ -52,7 +52,8 @@ def dmonitoringd_thread():
|
||||
events.add(car.CarEvent.EventName.tooDistracted)
|
||||
|
||||
# Update events from driver state
|
||||
driver_status.update_events(events, driver_engaged, sm['controlsState'].enabled, sm['carState'].standstill)
|
||||
driver_status.update_events(events, driver_engaged, sm['controlsState'].enabled,
|
||||
sm['carState'].standstill, sm['carState'].gearShifter in [car.CarState.GearShifter.reverse, car.CarState.GearShifter.park])
|
||||
|
||||
# build driverMonitoringState packet
|
||||
dat = messaging.new_message('driverMonitoringState', valid=sm.all_checks())
|
||||
@@ -76,6 +77,9 @@ def dmonitoringd_thread():
|
||||
}
|
||||
pm.send('driverMonitoringState', dat)
|
||||
|
||||
if sm['driverStateV2'].frameId % 40 == 1:
|
||||
driver_status.always_on = params.get_bool("AlwaysOnDM")
|
||||
|
||||
# save rhd virtual toggle every 5 mins
|
||||
if (sm['driverStateV2'].frameId % 6000 == 0 and
|
||||
driver_status.wheelpos_learner.filtered_stat.n > driver_status.settings._WHEELPOS_FILTER_MIN_COUNT and
|
||||
|
||||
@@ -121,7 +121,7 @@ class DriverBlink():
|
||||
self.right_blink = 0.
|
||||
|
||||
class DriverStatus():
|
||||
def __init__(self, rhd_saved=False, settings=None):
|
||||
def __init__(self, rhd_saved=False, settings=None, always_on=False):
|
||||
if settings is None:
|
||||
settings = DRIVER_MONITOR_SETTINGS()
|
||||
# init policy settings
|
||||
@@ -139,6 +139,7 @@ class DriverStatus():
|
||||
self.ee1_calibrated = False
|
||||
self.ee2_calibrated = False
|
||||
|
||||
self.always_on = always_on
|
||||
self.awareness = 1.
|
||||
self.awareness_active = 1.
|
||||
self.awareness_passive = 1.
|
||||
@@ -301,8 +302,12 @@ class DriverStatus():
|
||||
elif self.face_detected and self.pose.low_std:
|
||||
self.hi_stds = 0
|
||||
|
||||
def update_events(self, events, driver_engaged, ctrl_active, standstill):
|
||||
if (driver_engaged and self.awareness > 0 and not self.active_monitoring_mode) or not ctrl_active: # reset only when on disengagement if red reached
|
||||
def update_events(self, events, driver_engaged, ctrl_active, standstill, wrong_gear):
|
||||
always_on_valid = self.always_on and not wrong_gear
|
||||
if (driver_engaged and self.awareness > 0 and not self.active_monitoring_mode) or \
|
||||
(not always_on_valid and not ctrl_active) or \
|
||||
(always_on_valid and not ctrl_active and self.awareness <= 0):
|
||||
# always reset on disengage with normal mode; disengage resets only on red if always on
|
||||
self._reset_awareness()
|
||||
return
|
||||
|
||||
@@ -323,11 +328,13 @@ class DriverStatus():
|
||||
return
|
||||
|
||||
standstill_exemption = standstill and self.awareness - self.step_change <= self.threshold_prompt
|
||||
always_on_red_exemption = always_on_valid and not ctrl_active and self.awareness - self.step_change <= 0
|
||||
certainly_distracted = self.driver_distraction_filter.x > 0.63 and self.driver_distracted and self.face_detected
|
||||
maybe_distracted = self.hi_stds > self.settings._HI_STD_FALLBACK_TIME or not self.face_detected
|
||||
if certainly_distracted or maybe_distracted:
|
||||
# should always be counting if distracted unless at standstill and reaching orange
|
||||
if not standstill_exemption:
|
||||
# also will not be reaching 0 if DM is active when not engaged
|
||||
if not standstill_exemption and not always_on_red_exemption:
|
||||
self.awareness = max(self.awareness - self.step_change, -0.1)
|
||||
|
||||
alert = None
|
||||
|
||||
@@ -63,7 +63,7 @@ class TestMonitoring(unittest.TestCase):
|
||||
# cal_rpy and car_speed don't matter here
|
||||
|
||||
# evaluate events at 10Hz for tests
|
||||
DS.update_events(e, interaction[idx], engaged[idx], standstill[idx])
|
||||
DS.update_events(e, interaction[idx], engaged[idx], standstill[idx], 0)
|
||||
events.append(e)
|
||||
assert len(events) == len(msgs), f"got {len(events)} for {len(msgs)} driverState input msgs"
|
||||
return events, DS
|
||||
|
||||
Reference in New Issue
Block a user