udacity / fcnd-issue-reports

You can use this repository to file issue reports with the Flying Car Nanodegree content.
1 stars 4 forks source link

Math error in Estimator Lateral Position control #385

Open WillieMaddox opened 5 years ago

WillieMaddox commented 5 years ago

There is a math error in QuadControl::LateralPositionControl(). Specifically,

velCmd += kpPosXY * (posCmd - pos); and

accelCmd += kpVelXY * (velCmd - vel); If you combine these you end up with,

accelCmd += kpVelXY * (velCmd - vel + kpPosXY * (posCmd - pos)); which almost looks right but is incorrect. The correct answer is,

accelCmd += kpVelXY * (velCmd - vel) + kpPosXY * (posCmd - pos);

fabianlischka commented 4 years ago

From what I can gather, the former is a cascaded P + P controller, while the latter is a PD controller. As you demonstrate, they can basically be transformed into each other with different values for the constants.

The former (cascaded P-P) is the one to which the advice in the notes applies, that kpVelXY should be about 3 to 4 times kpPosXY, I think.

The latter can use the "usual" rule of thumb that k_d (that is, kpVelXY) should around 1.7 to 2 times sort(k_p).

It's all a bit messed up, at any rate.