openpilot icon indicating copy to clipboard operation
openpilot copied to clipboard

Bolt EUV: custom torque feedforward

Open twilsonco opened this issue 3 years ago • 1 comments

Custom torque controller FF for Chevy Bolt EUV

Submitting for @sshane to test. Would like to have more data for a more "complete" fit, but preliminary reports from Bolt EUV drivers was that it improves lateral.

Fit info:

mph Much like the Volt, the key difference between the fit Bolt EUV torque FF and linear FF is more torque for lateral acceleration values close to 0, but only a low-speed. At higher speeds it becomes sublinear, but almost linear like the stock torque FF.

Quick digression: I speculate that cars with this type of behavior will not work well with live-torque when using linear FF due to the dramatic speed dependence. If you drove at highway speeds for long enough, then live-torque would converge to the nearly-linear high-speed FF, but if you drove at very low speeds, it would instead converge to the much, much steeper FF corresponding to the limited lateral acceleration range achievable at low-speed. Once live-torque converged at low speed to the steeper FF, if the driver suddenly went to highway speeds it would oversteer like crazy until live-torque started to lower the FF again. Therefore, a non-linear FF is necessary in order to capture the speed dependence. I think a non-linear live-torque would work great here, and the process would be very similar because this custom FF function is simply a linear FF term plus a sigmoidal FF term. They could both be fit by live-torque in order to adjust for each car and changing conditions while still recovering the correct (though perplexing) non-linear FF necessary.

The fit was made with a very good sampling of the lateral acceleration space, but with somewhat insufficient data at low speeds.

Samples: 1064231
Regularizing...
Regularized samples: 1953
speed: DescribeResult(nobs=1953, minmax=(3.6600955207392856, 37.26225728574006), mean=24.107058187831083, variance=39.06859043082223, skewness=-0.3493749134340054, kurtosis=-0.3120815124278069)
angle: DescribeResult(nobs=1953, minmax=(-3.40212519818844, 2.9553544530533724), mean=0.015742608757060732, variance=0.8768781289762231, skewness=-0.13117937475462793, kurtosis=0.7229028003083386)
steer: DescribeResult(nobs=1953, minmax=(-0.9779738564458159, 0.9343111108409036), mean=-0.030172362786193823, variance=0.16971948383230204, skewness=-0.12211453450840001, kurtosis=-0.9798018287992099)
Performing fit...
Fit: [ 0.16179233  0.20691964  0.04420955 -7.94958973  0.34906506  0.2
  0.38748798]
ANGLE_COEF = 0.16179233
ANGLE_COEF2 = 0.20691964
ANGLE_OFFSET = 0.04420955
SPEED_OFFSET = -7.94958973
SIGMOID_COEF_RIGHT = 0.34906506
SIGMOID_COEF_LEFT = 0.20000000
SPEED_COEF = 0.38748798
MAE old 0.1232, new 0.0751
STD old 0.0814, new 0.0626
lat_accel 0.00-0.20:467, lat_accel 0.21-0.41:316, lat_accel 0.43-0.63:263, lat_accel 0.64-0.84:228, lat_accel 0.86-1.06:152
lat_accel 1.07-1.27:123, lat_accel 1.29-1.49:103, lat_accel 1.50-1.70:55, lat_accel 1.71-1.91:45, lat_accel 1.93-2.13:36
lat_accel 2.14-2.34:28, lat_accel 2.36-2.56:19, lat_accel 2.57-2.77:6, lat_accel 2.79-2.99:7, lat_accel 3.00-3.20:1

mph 08-13:5, mph 13-18:11, mph 18-23:21, mph 23-28:49, mph 28-33:75
mph 33-38:93, mph 38-43:150, mph 43-48:226, mph 48-53:264, mph 53-58:226
mph 58-63:307, mph 63-68:167, mph 68-73:221, mph 73-78:99, mph 78-83:29
mph 83-88:10, mph 88-93:0, 
rm -rf ~/Downloads/plots
convert -delay 20 plots/mph*.png mph-up.gif
convert -reverse mph-up.gif mph-down.gif
convert -loop -1 mph-up.gif mph-down.gif mph.gif
mv *.gif plots/
mv plots ~/Downloads/
rm -f ~/Downloads/plots/deg*.png
rm -f ~/Downloads/plots/lat*.png
rm -f ~/Downloads/plots/mph*.png
rm -f regularized
mv ~/Downloads/plots ~/Downloads/plots_torque```

twilsonco avatar Oct 17 '22 00:10 twilsonco

Low speed lateral is much better (more responsive)! However, high speed is much worse. It undershoots much more

sshane avatar Oct 19 '22 06:10 sshane

Thanks for the PR, @nuwandavek is continuing this in #26242.

adeebshihadeh avatar Nov 05 '22 23:11 adeebshihadeh