Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
How do you convert a quaternion into an axis-angle representation?

The way that I do it using tf is like this (ROS Fuerte) . [Assuming that q_msg is geometry_msgs::Quaternion]

#include <tf/tf.h>    
...
double roll, pitch, yaw;
tf::Quaternion q;
tf::quaternionMsgToTF(q_msg, q);
tf::Matrix3x3(q).getEulerYPR(yaw, pitch, roll);

You can also use fixed-angle function getRPY. More information can be found here: http://www.ros.org/wiki/geometry/RotationMethods#Bullet

It is possible to use Bullet directly. Lots of tf stuff are just wrappers around Bullet. Unfortunately I had some problems adding Bullet directly as a rosdep to my package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment