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

How to create orientation in geometry_msgs::PoseStamped from angle

asked 2016-04-14 13:29:09 -0500

erwhelewoli gravatar image

updated 2016-05-22 19:10:54 -0500

130s gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2016-04-14 16:29:21 -0500

croesmann gravatar image

updated 2016-04-14 16:30:46 -0500

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...

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-04-14 13:29:09 -0500

Seen: 4,287 times

Last updated: Apr 14 '16