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

Revision history [back]

click to hide/show revision 1
initial version

tf provides some methods for the use case that you want to do (2D navigation).

In general there is: tf::createQuaternionFromYaw

Specifically for setting ROS messages, there is also: tf::createQuaternionMsgFromYaw

So, your code can be shortened to:

goal.target_pose.pose.orientation = tf::createQuaternionMsgFromYaw(inRadians)

You'll almost never have to set quaternion components manually when dealing with ROS data types. There are also conversions between tf types and messages for all common tf types.