openpilot
openpilot copied to clipboard
Non-linear torque
- This fixes the jerky steering when making turns. Specifically at low speeds.
- Retune is required. This can be done by allowing torqued to converge by lifting the sanity limits.
- latAccelFactor will drop after tuning, allowing torqued to converge properly.
- A dramatic improvement in steering feel and stability.
- latAngleFactor should be added to torque_data. A zero factor means linear and anything above zero is non-linear. Then this can be added to the default torque_from_lateral_accel() function without needing the linear flag. But that's your choice to make.
commit 89158ae removes the linear calculation for pid error.
@nuwandavek I assume you tried this and it didn't work? Did it improve control at all? I see you went with interp tables to compensate instead. https://github.com/commaai/openpilot/commit/e49748d571d06a65a4361dde1f2f63c7294da13a
Are you completely satisfied with the control or does it still have a little room for improvement? I am wondering how you obtained the values in the tables. Did you brute force or measure? I wonder if it would also apply to my car.
Edit:
I see this https://github.com/commaai/openpilot/compare/bolt-revert. On my car, applying the non-linear torque would prevent it from eliminating the error at high angles which would lead to weak steering at low speeds. The solution was to only compensate for the feed-forward function. Maybe this will apply to the bolt.
@MoreTore The process Comma is using could be applied to any car. It's missing the speed dependence but is still hypothetically general. Have you tried using their function to fit data from your car? If you're interested, I'd be happy to collect logs from you and see how your car compares to others. Some cars (like Bolt EUV) have non-linear w.r.t lat accel but no speed dependence. Other cars (like Ram 1500) have speed dependence but it's linear at each step.
Here's my Bolt EUV fit vs comma's current one.

And here's my current Ram 1500 fit.

I've also found that roll compensation is speed dependent, and I've accurately fit the lateral jerk dependence for FF. In the Volt I'm using a 3-part composite lat accel + lat jerk + lat gravitational accel FF and it's been performing great, a big improvement over only having fit the lat accel component.
Meanwhile, I'm moving to a neural network approach in order to get a more robust FF that takes into account things like less roll compensation being necessary at high lat accel, and other interdependencies between what are considered the independent variables of FF. This is WIP but the preliminary results are fantastic, and importantly, the NN FF is recovering the same behavior w.r.t lateral jerk and lateral gravitational accel as that which resulted from my manual fitting processes, so it serves as a sort of validation of the behavior overall.
Here's the neural network feedforward I'm currently testing in the Volt.

This too will be a general feedforward solution for all cars. Let me know if you want to try one for your car.
@twilsonco if you believe you can improve the steering control differently than what I came up with, I would be very interested in testing.
Here are some drives.
164080f7933651c4|2023-04-07--07-26-08--0 164080f7933651c4|2023-04-07--07-14-42--0 164080f7933651c4|2023-02-21--12-51-09--0
How much data do you need?
@MoreTore The process Comma is using could be applied to any car. It's missing the speed dependence but is still hypothetically general. Have you tried using their function to fit data from your car? If you're interested, I'd be happy to collect logs from you and see how your car compares to others. Some cars (like Bolt EUV) have non-linear w.r.t lat accel but no speed dependence. Other cars (like Ram 1500) have speed dependence but it's linear at each step.
I see in your repo you are loading a CSV file. Where are you getting this file and what does it consist of?
function main()
data = load_data("/Users/haiiro/NoSync/voltlat_large.csv", false)
model, input_mean, input_std, X_train, y_train, X_test, y_test = train_model("/Users/haiiro/NoSync/voltlat", false, data)
test_plot_model(model, "/Users/haiiro/NoSync/voltlat", X_train, y_train, X_test, y_test, input_mean, input_std)
end
The proven process I use takes about 20+ hours of logs to adequately sample the problem space. I have log acquisition scripts for collecting logs over ssh or comma connect from dozens of users as I apply this to more makes. Or you can run the scripts and upload logs to me.
The code you pasted is from the Julia repo I’m using to do the neural network fits, unrelated to the proven method. But that csv contains steer torque, lateral acceleration, lateral jerk, longitudinal speed and acceleration, and lateral gravitational acceleration, used to train the NN model for making a function for steer command as a function of the rest. The data is collected from rlogs.
@MoreTore why was this closed?
@MoreTore why was this closed?
@cbenhagen Honestly, I screwed up and force-pushed to this branch when updating to the 9.2 torque controller. I meant to open a separate PR that was more incremental than this one and bump it up to the top of the PR list.
In any case, Comma is not interested in using the old code since it they went a different route for the GM Bolt. I just want to merge the Callback type so its easier to cherry-pick to master
@MoreTore @twilsonco does this look like it could be solved by your work? (Ford research vehicle) I would be happy to share logs and a pizza for your time. What do you mean by "lifting the sanity limits" and what should I set the values to accomplish this?

@MoreTore @twilsonco does this look like it could be solved by your work? (Ford research vehicle) I would be happy to share logs and a pizza for your time
If there is real pizza involved I would be glad to take a look. There isn't enough information here for me to make a determination. However, it does look similar to what I have seen in my car. If you could share a drive I could look. It would also save me some time if you could post a YT video of the issue when it happens.
@MoreTore @twilsonco does this look like it could be solved by your work? (Ford research vehicle) I would be happy to share logs and a pizza for your time
If there is real pizza involved I would be glad to take a look. There isn't enough information here for me to make a determination. However, it does look similar to what I have seen in my car. If you could share a drive I could look. It would also save me some time if you could post a YT video of the issue when it happens.
Allow me to collect some data, my discord username is rockerrock137
I am going to try out the non-linear function from the bolt now: https://github.com/rockerrock137/openpilot/commit/9432f4bba28612539661789421681dcf17d8f36e
Also going to try and "lift the sanity values" but I'm unsure what direction and how much I should change values, will try: https://github.com/rockerrock137/openpilot/commit/600fb676a1c79f8646eefb5029e440ddf4d49045
Also going to try and "lift the sanity values" but I'm unsure what direction and how much I should change values, will try: rockerrock137@600fb67
You should just remove the sanity checks for now and watch the values in plotjuggler.