Keywords: OSDK quaternion, attitude angle (Euler angle)
The quaternion data can be obtained by subscribing to TOPIC_QUATERNION, and then the attitude angle can be calculated by the quaternion. The calculation method can refer to:
Vector3f FlightSample::quaternionToEulerAngle(
const Telemetry::Quaternion& quat) {
Telemetry::Vector3f eulerAngle;
double q2sqr = quat.q2 * quat.q2;
double t0 = -2.0 * (q2sqr + quat.q3 * quat.q3) + 1.0;
double t1 = 2.0 * (quat.q1 * quat.q2 + quat.q0 * quat.q3);
double t2 = -2.0 * (quat.q1 * quat.q3 - quat.q0 * quat.q2);
double t3 = 2.0 * (quat.q2 * quat.q3 + quat.q0 * quat.q1);
double t4 = -2.0 * (quat.q1 * quat.q1 + q2sqr) + 1.0;
t2 = (t2 > 1.0) ? 1.0 : t2;
t2 = (t2 < -1.0) ? -1.0 : t2;
eulerAngle.x = asin(t2);
eulerAngle.y = atan2(t3, t4);
eulerAngle.z = atan2(t1, t0);
return eulerAngle;
}
Note: This article is from Chinese and is translated by machine. If there is any suggestions, please point it out and we will correct it in time
Comments
0 comments
Please sign in to leave a comment.