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

Add rate-based feed-forward for lateral control #593

Open
wants to merge 9 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@Gernby
Copy link
Contributor

commented Apr 6, 2019

This enhancement combines desired steering rate with desired angle to calculate a more effective feed-forward input to the PID / PIF function for steering torque. The benefits are significant, but the logic is rather simple.

Since angle-based feed-forward is increasingly problematic near steering center, the proposed logic only uses rate-based feed-forward when the desired steering angle is close to center. However, since rate-based feed-forward is increasingly problematic in the outer steering range, the proposed logic interpolates the transition from rate-based to angle-based feed-forward as the desired steering angle departs from center.

I have found this to be very effective for reducing "lane hugging", typically caused by high steering angle offsets or alignment problems. It also improves lane centering, and reduces "ping-pong", which I believe is a problem with angle-based feed-forward in general. For cars with high actuator latency (like Toyota's), the ability to adjust steering behavior in the inner and outer steering ranges separately should improve overall performance tremendously.

A side benefit to the proposed logic is that it removes the need to be so conservative with angle-based feed-forward. By increasing angle-based feed-forward gain, the reliance on proportional and integral error is reduced. This improves steering response and reduces over-correction that's commonly caused by high proportional error. This is especially beneficial for cars with limited steering torque (like Honda's), where over-correction in the outer steering range comes at a high cost.

[EDIT]: I forgot to mention that I tested a broad range of gain values, and found that the logic is very forgiving of large and small values. I tested rate-based gain values in the range of 0.1 to 3.0, and observed that the steering was very relaxed at 0.1, but very "knife-edged" at 3.0. The behavior between those values seemed proportional to the value. I tested angle-based gain values in the range of 1.0 to 5.0, and observed that steering was similar to standard at 1.0, but had a tendency toward the inside lane line at 5.0.

I believe the gain values could be optimized dynamically in ParamsLearner, so that they don't need to be manually tuned. The rate-based gain could be optimized based on PIF noise near the zero crossing. The angle-based gain could be optimized based on the percentage of feedforward within PIF when target angle is in the outer range.

image

Here is a Grafana snapshot from a drive in my 2018 Accord on the highway. The snapshot is interactive, so you can zoom in / out, and pan left / right by clicking the buttons on the page OR using keyboard shortcuts.

I've also captures some screen prints of a few significant segments below.

image

image

arne182 added a commit to arne182/openpilot that referenced this pull request Apr 6, 2019

arne182 added a commit to arne182/openpilot that referenced this pull request Apr 7, 2019

Merge pull request #187 from arne182/Gernby593
Add rate-based feed-forward for lateral control commaai#593
@ErichMoraga

This comment has been minimized.

Copy link
Contributor

commented Apr 8, 2019

I was very optimistic about your concept and explanation, but when I tried this out on my 2017 Prius Prime, it was dangerously unstable at medium to high speeds as it would develop a runaway ping pong, with progressively dramatic counter-steering. Perhaps PID tuning would help, though it's strange your minimalist modification would necessitate that.

Reduce default gain values
While testing logic to auto-tune the angle and rate gain values, I found that the rate gain value can be **much smaller** without losing its effectiveness.  My Honda Accord performed well with a rate gain below 0.01, so it seems that 0.2 is not as conservative as I first thought.  

I've also reduced the default angle gain, since 1.0 should perform nearly the same with the proposed logic as it does with standard logic.
@Gernby

This comment has been minimized.

Copy link
Contributor Author

commented Apr 8, 2019

Thanks for the feedback!

While testing logic to auto-tune the angle and rate gain values, I found that the rate gain value can be much smaller without losing its effectiveness. My Honda Accord performed well with a rate gain below 0.01, so it seems that 0.2 is not as conservative as I first thought. I have reduced the default rate gain value to 0.02 and the default angle gain to 1.0.

@Gernby

This comment has been minimized.

Copy link
Contributor Author

commented Apr 8, 2019

Also, since the Toyota Prius provides such a unique steering challenge, I believe that it needs a Prius-specific fix. Over the past few months, while developing various strategies for lateral control, it seems that the Prius responded very well to an approach like this to reduce over-correction.
if self.CP.carFingerprint == CAR.PRIUS: self.angle_steers += self.angle_steers_rate * 0.1

@ErichMoraga
Copy link
Contributor

left a comment

Makes sense. I'll try it out later today.

@Gernby

This comment has been minimized.

Copy link
Contributor Author

commented Apr 9, 2019

FYI. I enhanced the logic to include a simple (but effective) auto-adjustment for the angle and rate gain values. I found that the gain value for rate-based feedforward should be much smaller than originally thought.

@icmma

This comment has been minimized.

Copy link

commented Apr 10, 2019

bro i wish i could try it:(

@arne182

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2019

@icmma this is integrated into my fork

Removed steer_override as a condition for gain adjustment
It originally seemed that steer_override would be a condition that should block auto-adjust of the feed-forward gain values.  However, after testing on other vehicles, it was clear that OP's torque requests alone can trigger false positives for steering overrides (specifically Toyota's).  This resulted in the rate-based feed-forward gain value to go off-scale positive, which caused extremely poor steering performance in a short period of time.
@Gernby

This comment has been minimized.

Copy link
Contributor Author

commented Apr 11, 2019

FYI, it originally seemed that steer_override would be a condition that should block auto-adjust of the feed-forward gain values. However, after testing on other vehicles (specifically Toyota's), it was clear that OP's torque requests alone can trigger false positives for steering overrides. This resulted in the rate-based feed-forward gain value to go off-scale positive, which caused extremely poor steering performance in a short period of time. The steer_override condition has been removed, but it seems that Toyota's steer_override threshold value should be reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.