15 #ifndef TF2__IMPL__UTILS_H_
16 #define TF2__IMPL__UTILS_H_
18 #include <tf2_geometry_msgs/tf2_geometry_msgs.h>
68 geometry_msgs::msg::QuaternionStamped q = toMsg<tf2::Stamped<T>,
69 geometry_msgs::msg::QuaternionStamped>(t);
81 geometry_msgs::msg::Quaternion q = toMsg<T, geometry_msgs::msg::QuaternionStamped>(t);
97 const double pi_2 = 1.57079632679489661923;
110 double sarg = -2 * (q.x() * q.z() - q.w() * q.y()) / (sqx + sqy + sqz + sqw);
111 if (sarg <= -0.99999) {
114 yaw = -2 * atan2(q.y(), q.x());
115 }
else if (sarg >= 0.99999) {
118 yaw = 2 * atan2(q.y(), q.x());
121 roll = atan2(2 * (q.y() * q.z() + q.w() * q.x()), sqw - sqx - sqy + sqz);
122 yaw = atan2(2 * (q.x() * q.y() + q.w() * q.z()), sqw + sqx - sqy - sqz);
149 double sarg = -2 * (q.x() * q.z() - q.w() * q.y()) / (sqx + sqy + sqz + sqw);
151 if (sarg <= -0.99999) {
152 yaw = -2 * atan2(q.y(), q.x());
153 }
else if (sarg >= 0.99999) {
154 yaw = 2 * atan2(q.y(), q.x());
156 yaw = atan2(2 * (q.x() * q.y() + q.w() * q.z()), sqw + sqx - sqy - sqz);
163 #endif // TF2__IMPL__UTILS_H_