Robotics StackExchange | Archived questions

Is TF2 setRPY(0, 0, th) the same as tf::createQuaternionMsgFromYaw(th)

Good Day all,

I am trying writing an odometry script and am I using TF2 vs TF. My question is in my TF version I used tf::createQuaternionMsgFromYaw(th) to get the odom transform Quaternion for my rotation and pose oretientation. Now that I am using TF2 will this "tf2::Quaternion odomquat;" followed by "odomquat.setRPY(0, 0, th);" give the same result ? Please advise.

Basically is

tf::createQuaternionMsgFromYaw(th)

geometrymsgs::TransformStamped odomtrans

geometrymsgs::Quaternion odomquat

odomtrans.transform.rotation = odomquat

The same as :

tf2::Quaternion odomquat;

odomquat.setRPY(0, 0, th)

odom_trans.transform.rotation.x = odomquat.x();

odom_trans.transform.rotation.y = odomquat.y();

odom_trans.transform.rotation.z = odomquat.z();

odom_trans.transform.rotation.w = odomquat.w();

Or are they different and I am taking the wrong approach?

Asked by chm007 on 2022-05-01 15:49:34 UTC

Comments

Answers

You can prepare a minimal working example and check it yourself, I think, by printing out the message.

It looks by the documentation like it should be fine:

myQuaternion.setRPY( 0, 0, 0 );  // Create this quaternion from roll/pitch/yaw (in radians)

What I think is important - angles have to be in radians.

Asked by ljaniec on 2022-05-01 19:03:49 UTC

Comments