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

# How to create orientation in geometry_msgs::PoseStamped from angle Hello

I have a point in x,y, and an angle of 30 degrees, that represents a position and an orientation of a robot. The angle is about the z axis. An angle of 0 means that the robot is aligned with the x axis, and an angle of 90 degrees means that the robot is aligned with the y axis. How do represent this as a geometry_msgs::PoseStamped.position and geometry_msgs::PoseStamped.orientation?

edit retag close merge delete

Sort by » oldest newest most voted

The position part can be copied componentwise without any conversions. The orientation part is usually represented as Unit Quaternion due its numerically robustness, elegant computations and absence of singularities. But on the other hand, they are not intuitively interpretable.

Therefore you must convert your rotation around the z axis (also called yaw angle in terms of the ZYX euler representation) to a Quaternion (represented by a 4D vector [w,x,y,z]^T).

The tf package provides handy methods for converting points and angles to geometry_msgs::Pose / tf::Pose and vice versa.

pose.orientation = tf::createQuaternionMsgFromYaw(angle);

Just check the Code API for more methods.

There are other questions regarding the conversion, e.g. http://answers.ros.org/question/41233...

more