Hi,I read the code of mc_pos_control.cpp.
Some code I can’t understand.
It’s followed:
/* vector of desired yaw direction in XY plane, rotated by PI/2 */
math::Vector<3> y_C(-sinf(_att_sp.yaw_body), cosf(_att_sp.yaw_body), 0.0f);
if (fabsf(body_z(2)) > SIGMA) {
/* desired body_x axis, orthogonal to body_z */
body_x = y_C % body_z;
/* keep nose to front while inverted upside down */
if (body_z(2) < 0.0f) {
body_x = -body_x;
}
body_x.normalize();
} else {
/* desired thrust is in XY plane, set X downside to construct correct matrix,
* but yaw component will not be used actually */
body_x.zero();
body_x(2) = 1.0f;
}
when fabsf(body_z(2)) < SIGMA,SIGMA is 0.000001f.
body_z(2) almost equal 0,then set body_x all zero and body_x(2) 1.0f.
And the code comment upon the operation note that set X downside to construct correct matrix.
It’s mean regard x axis as downside axis instead of z axis ?
Any one give some interpretation?