Skip to content

Commit

Permalink
poll on peripheralState
Browse files Browse the repository at this point in the history
after pandaStates
  • Loading branch information
sshane committed Sep 16, 2023
1 parent 2c99c19 commit 5eecb83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions selfdrive/boardd/boardd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -476,13 +476,13 @@ void panda_state_thread(std::vector<Panda *> pandas, bool spoofing_started) {
RateKeeper rk("panda_state_thread", 10);

while (!do_exit && check_all_connected(pandas)) {
auto ignition_opt = send_panda_states(&pm, pandas, spoofing_started);

if (sm.frame % 5 == 0) {
// send out peripheralState at 2Hz
send_peripheral_state(&pm, peripheral_panda);
}

auto ignition_opt = send_panda_states(&pm, pandas, spoofing_started);

if (!ignition_opt) {
LOGE("Failed to get ignition_opt");
rk.keepTime();
Expand Down
10 changes: 3 additions & 7 deletions selfdrive/thermald/thermald.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +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
PERIPHERAL_STATE_TIMEOUT = round(1000 / service_list['peripheralState'].frequency * 1.5) # 1.5x the expected peripheralState frequency

ThermalBand = namedtuple("ThermalBand", ['min_temp', 'max_temp'])
HardwareState = namedtuple("HardwareState", ['network_type', 'network_info', 'network_strength', 'network_stats',
Expand Down Expand Up @@ -168,7 +168,7 @@ def hw_state_thread(end_event, hw_queue):

def thermald_thread(end_event, hw_queue) -> None:
pm = messaging.PubMaster(['deviceState'])
sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "controlsState", "pandaStates"], poll=["pandaStates"])
sm = messaging.SubMaster(["peripheralState", "gpsLocationExternal", "controlsState", "pandaStates"], poll=["peripheralState"])

count = 0

Expand Down Expand Up @@ -209,11 +209,7 @@ def thermald_thread(end_event, hw_queue) -> None:
fan_controller = 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
sm.update(PERIPHERAL_STATE_TIMEOUT)

pandaStates = sm['pandaStates']
peripheralState = sm['peripheralState']
Expand Down

0 comments on commit 5eecb83

Please sign in to comment.