Skip to content

long mpc: use model predicted lead trajectory#37824

Draft
sshane wants to merge 10 commits intomasterfrom
mpc-lead-trajectory
Draft

long mpc: use model predicted lead trajectory#37824
sshane wants to merge 10 commits intomasterfrom
mpc-lead-trajectory

Conversation

@sshane
Copy link
Copy Markdown
Contributor

@sshane sshane commented Apr 14, 2026

Unclear if this should extend to radar cars and in what form, but this is an experiment to throw out MPC's lead interpolation and acceleration decay to 0 m/s^2 from one immediate lead prediction and instead use model's full predicted lead horizon. Theoretically, this should capture model intelligently predicting lead continuing to decelerate harder (jerk) for a red light. Inversely, it should predict to not slow down as much if a lead cuts in and is expected to continue at high rate of acceleration. Or not react to temporary, spurious slow downs.

I also threw out model's lead velocity prediction and derived it from derivative of x, as from analysis it is heavily biases to following vEgo in high distance and high velocity diff scenarios.


Tesla VOACC segments improved by this:

MPC outputs light braking 1.2s earlier using velocity derived from model's moving distance prediction in this hard high v delta case. and this is with vEgo smoothed in, if actuated in the real world, model should slowly improve its distance predictions as we approach, potentially recovering from this entirely (unclear)

dffcf1de8723a20f/000000be--f00fb3e5b5/4

View plot image

lead steadily decelerating, model predicts lead traveling faster than it is, new MPC output has us decelerating more and earlier entire time

dffcf1de8723a20f/00000094--612ddfe306/3:5

View plot image

new MPC was predicting significant deviation here where original case didn't brake enough for stopped lead, triggering FCW:

dffcf1de8723a20f/000000c7--01f89d6c43/3:10

View plot image

same route, potentially also reacts to acceleration changes quicker, and you can see where lead braked temporarily but new MPC doesn't react as much, also potentially ignoring spurious lead braking. subject to model accuracy:

View plot image

@github-actions

This comment was marked as spam.

@sshane
Copy link
Copy Markdown
Contributor Author

sshane commented Apr 14, 2026

@elkoled is this an error from adding list fields?

@elkoled
Copy link
Copy Markdown
Contributor

elkoled commented Apr 14, 2026

yes the new list fields cause it. Process replay throws the same but without traceback.

@sshane
Copy link
Copy Markdown
Contributor Author

sshane commented Apr 14, 2026

It shouldn't crash

@elkoled
Copy link
Copy Markdown
Contributor

elkoled commented Apr 15, 2026

fixed

jjackbrandt added a commit to NotAutopilot/openpilot that referenced this pull request Apr 15, 2026
Cherry-pick of Shane's "last good commit" (65e302f) from
commaai#37824. Replaces the old extrapolate_lead()
(single-point + exponential decay) with the model's full predicted
lead trajectory (6 points at 0-10s).

The model predicts where the lead will be, not just where it is now.
This captures intent (braking for red lights, acceleration patterns)
that kinematic extrapolation can't.

This is the vision-only version — does not anchor on radar at h=0.
Shane's radar-anchored version (5698b41) is still experimental.

NAP-specific code preserved: adaptive accel limits, follow distance
override, jerk_factor=1.0. Adaptive accel now uses model lead
probability instead of radarState.

FOR TESTING ONLY — not merged to nap-dev.
greatgitsby pushed a commit to greatgitsby/openpilot that referenced this pull request Apr 20, 2026
Squashed from commaai#37824.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants