thermald: consider pmic temp while onroad (#25959)

* thermald: consider pmic temp while onroad

* this is better
pull/25966/head
Adeeb Shihadeh 3 years ago committed by GitHub
parent dc63245b89
commit f35c234e9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 25
      selfdrive/thermald/thermald.py

@ -177,7 +177,8 @@ def thermald_thread(end_event, hw_queue):
modem_temps=[], modem_temps=[],
) )
temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML) all_temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML)
offroad_temp_filter = FirstOrderFilter(0., TEMP_TAU, DT_TRML)
should_start_prev = False should_start_prev = False
in_car = False in_car = False
engaged_prev = False engaged_prev = False
@ -239,24 +240,32 @@ def thermald_thread(end_event, hw_queue):
msg.deviceState.screenBrightnessPercent = HARDWARE.get_screen_brightness() msg.deviceState.screenBrightnessPercent = HARDWARE.get_screen_brightness()
max_comp_temp = temp_filter.update( # this one is only used for offroad
max(max(msg.deviceState.cpuTempC), msg.deviceState.memoryTempC, max(msg.deviceState.gpuTempC)) temp_sources = [
) msg.deviceState.memoryTempC,
max(msg.deviceState.cpuTempC),
max(msg.deviceState.gpuTempC),
]
offroad_comp_temp = offroad_temp_filter.update(max(temp_sources))
# this drives the thermal status while onroad
temp_sources.append(max(msg.deviceState.pmicTempC))
all_comp_temp = all_temp_filter.update(max(temp_sources))
if fan_controller is not None: if fan_controller is not None:
msg.deviceState.fanSpeedPercentDesired = fan_controller.update(max_comp_temp, onroad_conditions["ignition"]) msg.deviceState.fanSpeedPercentDesired = fan_controller.update(all_comp_temp, onroad_conditions["ignition"])
is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (sec_since_boot() - off_ts > 60 * 5)) is_offroad_for_5_min = (started_ts is None) and ((not started_seen) or (off_ts is None) or (sec_since_boot() - off_ts > 60 * 5))
if is_offroad_for_5_min and max_comp_temp > OFFROAD_DANGER_TEMP: if is_offroad_for_5_min and offroad_comp_temp > OFFROAD_DANGER_TEMP:
# If device is offroad we want to cool down before going onroad # If device is offroad we want to cool down before going onroad
# since going onroad increases load and can make temps go over 107 # since going onroad increases load and can make temps go over 107
thermal_status = ThermalStatus.danger thermal_status = ThermalStatus.danger
else: else:
current_band = THERMAL_BANDS[thermal_status] current_band = THERMAL_BANDS[thermal_status]
band_idx = list(THERMAL_BANDS.keys()).index(thermal_status) band_idx = list(THERMAL_BANDS.keys()).index(thermal_status)
if current_band.min_temp is not None and max_comp_temp < current_band.min_temp: if current_band.min_temp is not None and all_comp_temp < current_band.min_temp:
thermal_status = list(THERMAL_BANDS.keys())[band_idx - 1] thermal_status = list(THERMAL_BANDS.keys())[band_idx - 1]
elif current_band.max_temp is not None and max_comp_temp > current_band.max_temp: elif current_band.max_temp is not None and all_comp_temp > current_band.max_temp:
thermal_status = list(THERMAL_BANDS.keys())[band_idx + 1] thermal_status = list(THERMAL_BANDS.keys())[band_idx + 1]
# **** starting logic **** # **** starting logic ****

Loading…
Cancel
Save