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

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

asked 2022-05-01 15:49:34 -0600

chm007 gravatar image

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)

geometry_msgs::TransformStamped odom_trans

geometry_msgs::Quaternion odom_quat

odom_trans.transform.rotation = odom_quat

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?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-05-01 19:03:49 -0600

ljaniec gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-05-01 15:49:34 -0600

Seen: 154 times

Last updated: May 01 '22