MPC weight problem #4720
-
Hey guys In mpc.cpp file does anyone know how to derivate these two functions 'addSteerWeightR' and 'addSteerWeightF'? I can not understand these two functions. Looking forward to receiving help! |
Beta Was this translation helpful? Give feedback.
Answered by
HansOersted
May 22, 2024
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
maxime-clem
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To my understanding, addSteerWeightR and addSteerWeightF penalize the change (or derivative of the change) in the steering angle in the upcoming MPC result and penalize the change in the steering angle between the last MPC and the beginning of the upcoming MPC result.
The best way to understand these two matrices is to expand it.
We will take
const Eigen::Matrix2d D = steer_rate_r * (Eigen::Matrix2d() << 1.0, -1.0, -1.0, 1.0).finished();
for example.This will result in a diagonal matrix below:
Define u = [u1 u2 u3 ...]'
Expand u' * R * u yields
(u1 - u2) ^2 + (u2 - u3) ^2 + (u3 - u4) ^2 + ...
Consequently, the weight for the steering rate compensation is defined in this part.
Likewise, …