From 37e095eab785cf874dd6c94b9a13e3e45a0d3c4d Mon Sep 17 00:00:00 2001 From: Brian Hanson Date: Sun, 26 Apr 2026 12:43:08 -0500 Subject: [PATCH] controlsd: fix park short-circuit lac_log type mismatch crashing controlsd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The park short-circuit added in cea422b created lac_log as LateralDebugState. publish_logs assigns lac_log to controlsState.lateralControlState. based on CP.lateralTuning.which() — for torque-tuned cars (Hyundai Tucson here) that's torqueState, expecting LateralTorqueState. The mismatch threw a capnp KjException ("Value type mismatch") on the first state_control cycle in park, killing controlsd. Manager respawned it, it crashed again on the next park cycle, repeat — controlsState was never reliably published, so the UI never saw the started/onroad transition and didn't flip to the camera view. Fix: call self.LaC.update(False, ...) which internally early-returns when active is False (cheap) but produces the correct lac_log subtype for whichever controller this car uses (LateralTorqueState for torque, LateralPIDState for pid, LateralAngleState for angle). Pass through the same sm reads the regular path uses; they're cached so the cost is negligible. Co-Authored-By: Claude Opus 4.7 (1M context) --- selfdrive/controls/controlsd.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/selfdrive/controls/controlsd.py b/selfdrive/controls/controlsd.py index c0f9623..2f0fcdc 100755 --- a/selfdrive/controls/controlsd.py +++ b/selfdrive/controls/controlsd.py @@ -681,7 +681,12 @@ class Controls: self.LoC.reset(v_pid=CS.vEgo) self.frogpilot_variables.no_lat_lane_change = False self.FPCC.noLatLaneChange = False - lac_log = log.ControlsState.LateralDebugState.new_message() + # Call LaC.update with active=False so we get the right lac_log subtype + # for this car's lateralTuning (torque vs pid vs angle). Internally it + # early-returns when active is False — cheap. + lp = self.sm['liveParameters'] + _, _, lac_log = self.LaC.update(False, CS, self.VM, lp, self.steer_limited, 0.0, + self.sm['liveLocationKalman'], model_data=self.sm['modelV2']) return CC, lac_log # Update VehicleModel