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

How to retrieve the quaternion in (x,y,z,w) format from tf

asked 2013-12-06 20:51:04 -0500

Albert K gravatar image

When we use tf to retrieve the rotation relationship of two coordinate in quaternion form, according to the API of Quaternion, we can only get the rotation axis and its angle.

However, the commonly required quaternion in ROS, such as quaternion in geometry_msgs::Pose, is always in (x,y,z,w) format. Therefore, is there any function to get the quaternion from tf in (x,y,z,w) form? That will be very convienent.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
3

answered 2013-12-06 21:35:40 -0500

tfoote gravatar image

tf::Quaternion inherits from tf::QuadWord which has m_floats[0] through m_floats[3] which are x,y,z,w respectively. http://docs.ros.org/hydro/api/tf/html/c++/QuadWord_8h_source.html

edit flag offensive delete link more

Comments

Thanks for that! It works fine and can be verified by the relationship between (x,y,z,w) and the rotation axis plus the angle returned by quaternion.getAxis() and quaternion.getAngle().

Albert K gravatar image Albert K  ( 2013-12-08 19:54:27 -0500 )edit

But I would like to ask how to find this information? It is not in the tutorial and it is not obviously written out in the documentation. Although I can trace the code to get this info, are there any better approach to learn it? Thanks very much

Albert K gravatar image Albert K  ( 2013-12-08 19:58:00 -0500 )edit
1

It should show in the doxygen docs better but for some reason it doesn't show the inheritance correctly.

tfoote gravatar image tfoote  ( 2013-12-08 21:11:28 -0500 )edit

Yeah, I expect to see the inheritance diagram too. Do you have any idea about how to deal with such condition? Thanks

Albert K gravatar image Albert K  ( 2013-12-10 18:13:19 -0500 )edit

It's something about how doxygen is configured. If you want to dig into it you can checkout the package and run doxygen yourself. http://wiki.ros.org/rosdoc_lite has documentation about how to run the documentation like it is on the farm.

tfoote gravatar image tfoote  ( 2013-12-10 19:51:03 -0500 )edit
3

answered 2016-06-07 09:34:08 -0500

tobyhijzen gravatar image

m_floats is a protected variable. In stead access x,y,z,w through quaternion.x() etcetera.

edit flag offensive delete link more

Comments

Worked for me, on ROS Indigo! Thanks!

hmchung gravatar image hmchung  ( 2017-01-20 22:48:48 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2013-12-06 20:51:04 -0500

Seen: 5,765 times

Last updated: Jun 07 '16