long mpc: use model predicted lead trajectory#37824
Draft
Conversation
… from x, don't trust model. fix radar to camera offset
This comment was marked as spam.
This comment was marked as spam.
Contributor
Author
|
@elkoled is this an error from adding list fields? |
Contributor
|
yes the new list fields cause it. Process replay throws the same but without traceback. |
Contributor
Author
|
It shouldn't crash |
Contributor
|
fixed |
were using smoothed vego which just made everything more reactive
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/4View plot
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:5View plot
new MPC was predicting significant deviation here where original case didn't brake enough for stopped lead, triggering FCW:
dffcf1de8723a20f/000000c7--01f89d6c43/3:10View plot
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