Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove steering wheel offset for planner slow down for curves #33827

Merged
merged 5 commits into from
Oct 22, 2024

Conversation

twilsonco
Copy link
Contributor

@twilsonco twilsonco commented Oct 19, 2024

Description

In selfdrive/controls/lib/longitudinal_planner.py, the limit_accel_in_turns() function limits long accel based on lat accel. It uses a back of the hand calculation of lateral accel based on steering angle that does not include a car's steer angle offset (as observed by liveParams). In cars with a large steer offset, the carState steer angle can be high enough when traveling in a straight line that this function ends up limiting long accel. This problem is reported in #33667.

Additionally, limit_accel_in_turns() has a FIXME comment: "This function to calculate lateral accel is incorrect and should use the VehicleModel"

This PR implements this FIXME change, using a VehicleModel updated with liveParams values to calculate lateral accel more accurately. It also includes liveParams average steer angle offset in order to fix the problem described above.

Verification

Awaiting verification route on this commit

@garrettpall drove on these changes and verified the problem is resolved and everything drives as it should. However that was not on this specific commit.

Fixes #33667

@sshane
Copy link
Contributor

sshane commented Oct 21, 2024

While using the VM here with roll is correct, we have avoided making this change as these limits were found via in-car testing a few years ago to be comfortable and we don't want to change behavior until we decide to spend more time re-tuning them. Can you only include the angle offset fix here? That is more immediately mergable.

@twilsonco
Copy link
Contributor Author

Thanks Shane. I've reverted the use of vehicle model as you suggest. Now it's just the addition of angle offset (and cleanup of the repeated use of sm['carState'])

@jyoung8607
Copy link
Collaborator

Now it's just the addition of angle offset (and cleanup of the repeated use of sm['carState'])

The cleanup aspect is a little debatable, the style in which submaster objects are referenced is consistent before this PR and would be inconsistent after.

Could we leave that aside, at least for now? It's a good practice for null-effect refactors/cleanups to be considered separately from functional changes like this.

If we just recalculate the angle, right next to the v_ego assignment, and pass it to limit_accel_in_turns:

  calibrated_steer_angle = sm['carState'].steeringAngleDeg - sm['liveParameters'].angleOffsetAverageDeg

Then this becomes a three-line PR with the nature of the change visually obvious.

@sshane sshane changed the title Use vehicle model w/ avg steer offset for accel in turns Remove steering wheel offset for planner slow down for curves Oct 22, 2024
@sshane sshane added the bugfix label Oct 22, 2024
@sshane
Copy link
Contributor

sshane commented Oct 22, 2024

thanks for the PR! I hope you can see how this diff is much easier to merge immediately vs the original commit. It's a straightforward bugfix for the behavior

@sshane sshane merged commit d26730f into commaai:master Oct 22, 2024
4 checks passed
@sshane sshane deleted the pr_vm_lim_accel_w_offset branch October 22, 2024 19:50
sshane added a commit that referenced this pull request Oct 22, 2024
sshane added a commit that referenced this pull request Oct 22, 2024
#33848)

Revert "Remove steering wheel offset for planner slow down for curves (#33827)"

This reverts commit d26730f.
@twilsonco
Copy link
Contributor Author

Yes. Much cleaner this way. Thanks Shane and Jason!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

possible invalid use of steeringAngleDeg without calibration
3 participants