Robotics StackExchange | Archived questions

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 geometrymsgs::PoseStamped.position and geometrymsgs::PoseStamped.orientation?

Asked by erwhelewoli on 2016-04-14 13:29:09 UTC

Comments

Answers

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/how-to-understand-robot-orientation-from-quaternion-yaw-angle/

Asked by croesmann on 2016-04-14 16:29:21 UTC

Comments