opgm / openpilot

GM openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 100 supported car makes and models.
https://standbacklabs.com
MIT License
57 stars 37 forks source link

Pr gm long pitch compensation #78

Closed twilsonco closed 1 year ago

twilsonco commented 1 year ago

Adds pitch compensation to be used in cars that use gas/brake control, where the command specifies an amount of acceleration force rather than an amount of acceleration relative to the road.

To allow this to account for longitudinal actuator delay to allow for smoothing of the pitch signal, future model pitch is used to create a smoothed, predictive pitch.

The result is a complete elimination of long error due to pitch changes. In the following image the plots on the left are without pitch compensation, and on the right with pitch compensation.

Screen Shot 2022-08-17 at 3 16 49 PM

See that as I climb up the stepped hill (pitch changing between 0 and ~12% grade), the pitchFutureLone (right side, second plot from top, orange line) predicts the liveParams pitch by ~0.4s, which is the value set for longitudinalActuatorDelayLowerBound (and upper bound), so it's predicting by the correct amount.

While there are large deviations between target and actual acceleration (fourth plot from top, left side) without pitch compensation, the pitch-induced error is completely removed on the right (error stays within ±0.05m/s^2 vs ±0.25m/s^2). Also the with pitch compensation speed stays within 0±0.1m/s^2 compared to ±0.4m/s^2 (top plot).

Here's another image showing data where I descend down the same stepped hill. Again, with pitch compensation, the speed and acceleration oscillations due to changing pitch are completely removed.

Screen Shot 2022-08-17 at 3 12 35 PM

This PR includes three other PRs to 1) add liveParams pitch, 2) add liveParams future predicted pitch based on long actuator delay, and 3) to add calculation of pitch-compensated acceleration, saved to actuators.accelPitchCompensated.