Ask Your Question
1

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

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

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 -0600

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 imageAlbert K ( 2013-12-08 19:54:27 -0600 )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 imageAlbert K ( 2013-12-08 19:58:00 -0600 )edit
1

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

tfoote gravatar imagetfoote ( 2013-12-08 21:11:28 -0600 )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 imageAlbert K ( 2013-12-10 18:13:19 -0600 )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 imagetfoote ( 2013-12-10 19:51:03 -0600 )edit
2

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

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 imagehmchung ( 2017-01-20 22:48:48 -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

1 follower

Stats

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

Seen: 3,772 times

Last updated: Jun 07 '16