Cycle onroad when changing offroad-only toggles (#35361)

* bad

* Revert "bad"

This reverts commit 6b5475dd90c3a29c00d946c94d726563cbec6179.

* notify param

* doesn't need to live in low level paramcontrol, rename param

* should work

* fix

* disable while engaged

* note

* fix

* just in case

* param is cleared by manager -- this was all to ensure manager got our `started` transition

* clean up

* and that

* rm

* negative better than generic thing

* timer is needed as it's not clean to fix case where you toggle while no ignition -- you can't go onroad + this allows some nice tolerance time for user to switch 2 toggles

* these aren't required or useful

* add to description

* no longer unlive

* allow reset button too

* another pr -- Revert "allow reset button too"

This reverts commit 5d03edddc80d8625ceba5d5178b2781e9d10d9c9.

* rm space from i18n string

* car is powered on
This commit is contained in:
Shane Smiskol
2025-05-27 20:20:38 -07:00
committed by GitHub
parent 83ba27d7c0
commit b119006f6a
5 changed files with 41 additions and 5 deletions
+10 -1
View File
@@ -34,6 +34,7 @@ CURRENT_TAU = 15. # 15s time constant
TEMP_TAU = 5. # 5s time constant
DISCONNECT_TIMEOUT = 5. # wait 5 seconds before going offroad after disconnect so you get an alert
PANDA_STATES_TIMEOUT = round(1000 / SERVICE_LIST['pandaStates'].frequency * 1.5) # 1.5x the expected pandaState frequency
ONROAD_CYCLE_TIME = 1 # seconds to wait offroad after requesting an onroad cycle
ThermalBand = namedtuple("ThermalBand", ['min_temp', 'max_temp'])
HardwareState = namedtuple("HardwareState", ['network_type', 'network_info', 'network_strength', 'network_stats',
@@ -170,6 +171,7 @@ def hardware_thread(end_event, hw_queue) -> None:
onroad_conditions: dict[str, bool] = {
"ignition": False,
"not_onroad_cycle": True,
}
startup_conditions: dict[str, bool] = {}
startup_conditions_prev: dict[str, bool] = {}
@@ -195,6 +197,7 @@ def hardware_thread(end_event, hw_queue) -> None:
should_start_prev = False
in_car = False
engaged_prev = False
offroad_cycle_count = 0
params = Params()
power_monitor = PowerMonitoring()
@@ -211,6 +214,12 @@ def hardware_thread(end_event, hw_queue) -> None:
peripheralState = sm['peripheralState']
peripheral_panda_present = peripheralState.pandaType != log.PandaState.PandaType.unknown
# handle requests to cycle system started state
if params.get_bool("OnroadCycleRequested"):
params.put_bool("OnroadCycleRequested", False)
offroad_cycle_count = sm.frame
onroad_conditions["not_onroad_cycle"] = (sm.frame - offroad_cycle_count) >= ONROAD_CYCLE_TIME * SERVICE_LIST['pandaStates'].frequency
if sm.updated['pandaStates'] and len(pandaStates) > 0:
# Set ignition based on any panda connected
@@ -231,7 +240,7 @@ def hardware_thread(end_event, hw_queue) -> None:
cloudlog.error("panda timed out onroad")
# Run at 2Hz, plus either edge of ignition
ign_edge = (started_ts is not None) != onroad_conditions["ignition"]
ign_edge = (started_ts is not None) != all(onroad_conditions.values())
if (sm.frame % round(SERVICE_LIST['pandaStates'].frequency * DT_HW) != 0) and not ign_edge:
continue