ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange

# Relative Rotation Between two Quaternions

I want to find a relative rotation between two quaternions quatA and quatB, i.e. quatC is a quaternion rotation that if applied to quatA would result in quatB. Is there a command/library in ROS which does this? Will tf be of any help?

edit retag close merge delete

Sort by ยป oldest newest most voted

There is a Python version of the KDL library (PyKDL), which allows you to do all sorts of conversions between rotation representations. An example would look like this:

import PyKDL
a = PyKDL.Rotation.Quaternion(x, y, z, w)
b = PyKDL.Rotation.Quaternion(x, y, z, w)

c = a * b.Inverse()
c.GetQuaternion()  # get quaternion result
c.GetRPY()  # get roll pitch yaw result
c.GetEulerZYX()   # get euler angle result in zyx format


There is a small tutorial here that will give you some more background.

more

Try using tf::Quaterion. You need to include the following line in the manifest.xml file of your pacakge:

<depend package="tf"/>

This should compile:

#include <tf/transform_datatypes.h>

tf::Quaternion a, b, c;
c = b * a.inverse();


I assume it will do what you're asking for, but you should double-check that.

more

Are you sure tf::Quaternion is a valid data type? This is not working.

more

I updated the original post with more info. tf::Quaternion is a valid datatype. When you say it doesn't work, do you mean in doesn't compile? Or that it runs, but it doesn't produce the desired rotation?
( 2011-05-31 09:15:55 -0500 )edit

## Stats

Seen: 12,190 times

Last updated: Jun 01 '11