Skip to content

Commit

Permalink
thermald: publish immediately after ignition (commaai#31981)
Browse files Browse the repository at this point in the history
* thermald: publish immediately after ignition

* fix
  • Loading branch information
adeebshihadeh authored Mar 22, 2024
1 parent 6e60fed commit c0a96d2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions selfdrive/thermald/thermald.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,17 +207,10 @@ def thermald_thread(end_event, hw_queue) -> None:
while not end_event.is_set():
sm.update(PANDA_STATES_TIMEOUT)

# Run at 2Hz
if sm.frame % round(SERVICE_LIST['pandaStates'].frequency * DT_TRML) != 0:
continue

pandaStates = sm['pandaStates']
peripheralState = sm['peripheralState']
peripheral_panda_present = peripheralState.pandaType != log.PandaState.PandaType.unknown

msg = read_thermal(thermal_config)
msg.deviceState.deviceType = HARDWARE.get_device_type()

if sm.updated['pandaStates'] and len(pandaStates) > 0:

# Set ignition based on any panda connected
Expand All @@ -237,6 +230,14 @@ def thermald_thread(end_event, hw_queue) -> None:
onroad_conditions["ignition"] = False
cloudlog.error("panda timed out onroad")

# Run at 2Hz, plus rising edge of ignition
ign_edge = started_ts is None and onroad_conditions["ignition"]
if (sm.frame % round(SERVICE_LIST['pandaStates'].frequency * DT_TRML) != 0) and not ign_edge:
continue

msg = read_thermal(thermal_config)
msg.deviceState.deviceType = HARDWARE.get_device_type()

try:
last_hw_state = hw_queue.get_nowait()
except queue.Empty:
Expand Down

0 comments on commit c0a96d2

Please sign in to comment.