Ask Your Question
1

Relative Rotation Between two Quaternions

asked 2011-05-31 07:47:39 -0600

Subodh gravatar image

updated 2011-05-31 07:53:39 -0600

kwc gravatar image

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 flag offensive close merge delete

3 Answers

Sort by ยป oldest newest most voted
4

answered 2011-05-31 09:34:37 -0600

Wim gravatar image

updated 2011-06-01 18:26:29 -0600

kwc gravatar image

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.

edit flag offensive delete link more
6

answered 2011-05-31 08:07:55 -0600

updated 2011-05-31 09:14:55 -0600

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.

edit flag offensive delete link more
0

answered 2011-05-31 09:06:21 -0600

Subodh gravatar image

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

edit flag offensive delete link more

Comments

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?
Ivan Dryanovski gravatar image Ivan Dryanovski  ( 2011-05-31 09:15:55 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-05-31 07:47:39 -0600

Seen: 10,014 times

Last updated: Jun 01 '11