ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Thu, 14 Apr 2016 16:29:21 -0500How to create orientation in geometry_msgs::PoseStamped from anglehttps://answers.ros.org/question/231941/how-to-create-orientation-in-geometry_msgsposestamped-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? Thu, 14 Apr 2016 13:29:09 -0500https://answers.ros.org/question/231941/how-to-create-orientation-in-geometry_msgsposestamped-from-angle/Answer by croesmann for <p>Hello</p>
<p>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? </p>
https://answers.ros.org/question/231941/how-to-create-orientation-in-geometry_msgsposestamped-from-angle/?answer=231952#post-id-231952The position part can be copied componentwise without any conversions.
The orientation part is usually represented as [Unit Quaternion](https://en.wikipedia.org/wiki/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/Thu, 14 Apr 2016 16:29:21 -0500https://answers.ros.org/question/231941/how-to-create-orientation-in-geometry_msgsposestamped-from-angle/?answer=231952#post-id-231952