From 8bd4e9878acf1f4a768884e918805e1da898ca28 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Thu, 28 Aug 2025 19:55:11 -0700 Subject: [PATCH] Refactor actuator enabling checks Refactor actuator enabling checks into a conditional block for better clarity and organization. --- selfdrive/controls/controlsd.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index 029d16e59e..c4275c90c7 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -88,13 +88,14 @@ class Controls: model_v2 = self.sm['modelV2'] CC = car.CarControl.new_message() - CC.enabled = self.sm['selfdriveState'].enabled - - # Check which actuators can be enabled - standstill = abs(CS.vEgo) <= max(self.CP.minSteerSpeed, 0.3) or CS.standstill - CC.latActive = self.sm['selfdriveState'].active and not CS.steerFaultTemporary and not CS.steerFaultPermanent and \ - (not standstill or self.CP.steerAtStandstill) - CC.longActive = CC.enabled and not any(e.overrideLongitudinal for e in self.sm['onroadEvents']) and self.CP.openpilotLongitudinalControl + if self.sm.all_checks(['selfdriveState']): + CC.enabled = self.sm['selfdriveState'].enabled + + # Check which actuators can be enabled + standstill = abs(CS.vEgo) <= max(self.CP.minSteerSpeed, 0.3) or CS.standstill + CC.latActive = self.sm['selfdriveState'].active and not CS.steerFaultTemporary and not CS.steerFaultPermanent and \ + (not standstill or self.CP.steerAtStandstill) + CC.longActive = CC.enabled and not any(e.overrideLongitudinal for e in self.sm['onroadEvents']) and self.CP.openpilotLongitudinalControl actuators = CC.actuators actuators.longControlState = self.LoC.long_control_state