feat: ramp-up delay on lat engagement to prevent commIssue flash
Some checks failed
prebuilt / build prebuilt (push) Has been cancelled
badges / create badges (push) Has been cancelled

Decouples "tell modeld to go fast" from "steering actually active":
- New LatRequested memory param — controlsd writes when lat would be active
- modeld reads LatRequested (not carControl.latActive) for FPS decision,
  so it switches to 20fps immediately on engage request
- controlsd delays CC.latActive becoming true by 250ms (5 frames @ 20fps)
  after LatRequested goes true, giving downstream services
  (longitudinalPlan, liveCalibration, etc.) time to stabilize at the new rate

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 16:46:37 -05:00
parent 1eb8d41454
commit 2d819c784b
6 changed files with 20 additions and 5 deletions

View File

@@ -242,10 +242,12 @@ def main(demo=False):
sm.update(0)
# CLEARPILOT: power saving — three modes based on driving state
# Full 20fps: lat active or lane changing
# Reduced 4fps: not lat active, not standstill (driving without cruise)
# Full 20fps: lat requested or lane changing
# Reduced 4fps: not lat requested, not standstill (driving without cruise)
# Standby 0fps: standstill
lat_active = sm['carControl'].latActive
# Uses LatRequested (not carControl.latActive) so modeld ramps to 20fps BEFORE
# controlsd actually engages steering — gives downstream services time to stabilize.
lat_active = params_memory.get_bool("LatRequested")
lane_changing = params_memory.get_bool("no_lat_lane_change")
standstill = sm['carState'].standstill
calibrating = sm['liveCalibration'].calStatus != log.LiveCalibrationData.Status.calibrated