Skip to content

Instantly share code, notes, and snippets.

@mani-monaj
Created September 21, 2012 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mani-monaj/e5170cf046b8001f4e65 to your computer and use it in GitHub Desktop.
Save mani-monaj/e5170cf046b8001f4e65 to your computer and use it in GitHub Desktop.
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