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

Recommended way to construct quaternion from roll/pitch/yaw with tf2?

asked 2018-09-27 08:30:29 -0500

bluenote gravatar image

What is the recommended way to construct a quaternion from roll/pitch/yaw with tf2?

The tf2 wiki page gives this code:

tf::Quaternion q = tf::createQuaternionFromRPY(0, 0, 0);

Unfortunately tf itself is deprecated and I'm looking for a pure tf2 solution. I can't find the createQuaternionFromRPY function in tf2, although the migration guide says it is a superset of tf. Am I missing something?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-09-27 10:48:06 -0500

Yes the createQuaternionFromRPY constructor is deprecated. But you can do it using two lines with the setRPY method:

float roll = 0;
float pitch = 0;
float yaw = 0;

tf2::Quaternion myQuaternion;
myQuaternion.setRPY( roll, pitch, yaw );

Hope this helps.

edit flag offensive delete link more

Comments

Okay than my understand of "superset" is different. Not so nice that there is no longer a single expression (e.g. when I want a const quaternion).

bluenote gravatar image bluenote  ( 2018-09-28 01:52:37 -0500 )edit
1

I agree, I've put this change in my own code too. It's not as elegant but it's supported.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2018-09-28 09:10:03 -0500 )edit

Anyone know why it's deprecated? it's a nice one-line way to create a quaternion.

IanCol gravatar image IanCol  ( 2020-03-19 16:51:05 -0500 )edit

Question Tools

3 followers

Stats

Asked: 2018-09-27 08:30:29 -0500

Seen: 2,051 times

Last updated: Sep 27 '18