mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-17 16:17:36 +08:00
Euler: simplify DCM constructor
Co-authored-by: Matthias Grob <maetugr@gmail.com>
This commit is contained in:
+11
-14
@@ -91,23 +91,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
Euler(const Dcm<Type> &dcm)
|
Euler(const Dcm<Type> &dcm)
|
||||||
{
|
{
|
||||||
Type phi_val = Type(atan2(dcm(2, 1), dcm(2, 2)));
|
theta() = asin(-dcm(2, 0));
|
||||||
Type theta_val = Type(asin(-dcm(2, 0)));
|
|
||||||
Type psi_val = Type(atan2(dcm(1, 0), dcm(0, 0)));
|
|
||||||
Type pi = Type(M_PI);
|
|
||||||
|
|
||||||
if (Type(fabs(theta_val - pi / Type(2))) < Type(1.0e-3)) {
|
if ((fabs(theta() - Type(M_PI / 2))) < Type(1.0e-3)) {
|
||||||
phi_val = Type(0);
|
phi() = 0;
|
||||||
psi_val = Type(atan2(dcm(1, 2), dcm(0, 2)));
|
psi() = atan2(dcm(1, 2), dcm(0, 2));
|
||||||
|
|
||||||
} else if (Type(fabs(theta_val + pi / Type(2))) < Type(1.0e-3)) {
|
} else if ((fabs(theta() + Type(M_PI / 2))) < Type(1.0e-3)) {
|
||||||
phi_val = Type(0);
|
phi() = 0;
|
||||||
psi_val = Type(atan2(-dcm(1, 2), -dcm(0, 2)));
|
psi() = atan2(-dcm(1, 2), -dcm(0, 2));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
phi() = atan2(dcm(2, 1), dcm(2, 2));
|
||||||
|
psi() = atan2(dcm(1, 0), dcm(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
phi() = phi_val;
|
|
||||||
theta() = theta_val;
|
|
||||||
psi() = psi_val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user