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

Rotate quaternion by body yaw

asked 2018-09-25 21:12:52 -0500

okalachev gravatar image

updated 2018-09-25 21:13:28 -0500

How to change a quaternion's body-fixed yaw?

Using Matrix3x3's getRPY and then setRPY doesn't work, because this is about the axes, fixed to the initial orientation, so it's fixed yaw, not body yaw.

Using getEulerYPR and then setEulerYPR doesn't work as well, because yaw rotation it the first, and it gets affected the following pitch and roll rotation.

I think getEulerRPY/setEulerRPY might work, but there are no such functions in the tf and tf2 libraries.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-09-28 18:43:48 -0500

okalachev gravatar image

This looks working (pq - input quaternion):

tf::Quaternion q;
q.setRPY(0, 0, angle_to_rotate);
pq = pq * q;
edit flag offensive delete link more

answered 2018-09-25 23:38:24 -0500

Hamid Didari gravatar image


try to use:

tf::Quaternion rotation;
rotation = tf::createQuaternionFromRPY(Roll,Pitch,Yaw);
edit flag offensive delete link more


The problem is, that if I keep roll and pitch, changing the yaw, that would be rotation about extrinsic Z axis, while I need about intrinsic (body-attached) one.

okalachev gravatar image okalachev  ( 2018-09-26 08:30:46 -0500 )edit

Question Tools



Asked: 2018-09-25 21:12:52 -0500

Seen: 1,197 times

Last updated: Sep 28 '18