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

Incorrect Roll,Pitch, Yaw values using getRPY()

asked 2013-03-21 09:36:31 -0500

nemesis gravatar image

updated 2014-01-28 17:15:50 -0500

ngrennan gravatar image

Hi, so I am trying to convert Quaternion to RPY (refer my other post)and use the following inorder to do so -

getRPY(roll, pitch, yaw)

I am trying to duplicate the values I get from Optitrack software (on a windows machine) and display those in ROS (on a separate computer) using the package - ros_vrpn_client

After wasting a lot of time trying to figure it out and also takign help from quite a few users over here, I did manage to display certain RPY values, but they don't match if I move my robot around.

The issues are varied too, it's not the same problem every time -

  • Sometimes the value I display is negative of the value obtained from Optitrack
  • Sometimes the value of Pitch and Roll are interchanged as compared to the Optitrack values.

The only value consistent enough is the Yaw.

Can anyone explain as to why this might be happening? (I would hope to hear from those who actually developed the package, or those who worked on it, but been unlucky mostly so far.) Thank you!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
10

answered 2013-03-21 10:56:01 -0500

This is likely due to a difference in how "Roll, Pitch, Yaw" are defined. It seems simple, but there is really no standard convention for what those terms mean. Usually, each term means a rotation about one of the coordinate axes (XYZ), but the order these are applies in varies by convention. And order is significant, in this case! To be further confusing, sometimes the angles are explained as rotations about fixed frames, and other times as rotations about the transformed frames. In fact, there are 24 different conventions for how to represent a rotation in terms of Euler Angles.

This is why it's sometimes "safer" to represent orientation (or rotation) using a full 3x3 rotation matrix or a 1x4 Quaternion. These are unambiguous, though slightly less "intuitive".

The ROS getRPY() function you're using above uses the following convention:

  1. rotate about fixed X-axis by Roll
  2. rotate about fixed Y-axis by Pitch
  3. rotate about fixed Z-axis by Yaw

On the other hand, this discussion on the subject seems to suggest that the Optitrak Tracking Tools software uses different axis directions. In particular, Y & Z are swapped.

In fact, I see a similar swap in your other post:

btVector3 pos(t.pos[0], -t.pos[2], t.pos[1]);

I suggest that you perform a similar swap in your quaternion:

btQuaternion q_orig(t.quat[0], -t.quat[2], t.quat[1], t.quat[3]);

Maybe that at least points you in the right direction!

edit flag offensive delete link more

Comments

2

@Jeremy Zoss - You.Are.Awesome! Thank you so much. That "small change" in the code that you suggested, I had completely overlooked that and never realized. As per your suggestion I fiddled around with that part a bit and finally (as of now) found a proper solution! I can't thank you enough!

nemesis gravatar image nemesis  ( 2013-03-21 11:16:32 -0500 )edit

Actually ros uses static ZYX convention. You can see this in the implementation of getRPY http://docs.ros.org/api/tf/html/c++/M... .

sid gravatar image sid  ( 2016-11-05 22:53:33 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2013-03-21 09:36:31 -0500

Seen: 10,999 times

Last updated: Mar 21 '13