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.0Tue, 02 Jul 2019 05:53:42 -0500Equivalent turtlesim/Pose and geometry_msgs/Posehttps://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/Hello,
I have a question about the *Pose* message. There art two different *Pose* :
- geometry_msgs/Pose.msg <br>Point position<br>Quaternion orientation
- turtlesim/Pose.msg <br> float32 x <br> float32 y <br> float32 theta <br> float32 linear_velocity <br> float32 angular_velocity
I want to know what is the equivalent of turtlesim pose.theta in the geometry pose :
- pose.orientation.z ?
- pose.orientation.w ?
- yaw from *euler_from_quaternion(pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w)* ?
Thank you in advance.Fri, 28 Jun 2019 08:55:16 -0500https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/Answer by PeteBlackerThe3rd for <p>Hello,</p>
<p>I have a question about the <em>Pose</em> message. There art two different <em>Pose</em> :</p>
<ul>
<li><p>geometry_msgs/Pose.msg <br>Point position<br>Quaternion orientation</p></li>
<li><p>turtlesim/Pose.msg <br> float32 x <br> float32 y <br> float32 theta <br> float32 linear_velocity <br> float32 angular_velocity</p></li>
</ul>
<p>I want to know what is the equivalent of turtlesim pose.theta in the geometry pose :</p>
<ul>
<li>pose.orientation.z ? </li>
<li>pose.orientation.w ?</li>
<li>yaw from <em>euler_from_quaternion(pose.orientation.x, pose.orientation.y, pose.orientation.z, pose.orientation.w)</em> ?</li>
</ul>
<p>Thank you in advance.</p>
https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?answer=327257#post-id-327257There is no 1 to 1 mapping between `turtlesim pose.theta` and any of the values in `geometry_msgs/Pose`. The turtlesim pose is a 2D pose so it expresses orientation as a single angle in radians, but `geometry_msgs/Pose` is a 3D pose so it expresses rotation as a Quaternion (4D unit vector).
If you need to create a `geometry_msgs/Pose` from a `turtlesim/Pose` message then you can use the `tf2::Quaternion.setRPY( Roll, Pitch, Yaw )` method and set Roll and Pitch to zero. This will create the quaternion and do all the complicated maths for you.
Here is some background on [rotation quaternions](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation) if you want to learn about the theory.
Hope this helps.
**Update:**
If it is safe to assume that your robot will always be upright on a level surface then it will be safe to use the euler_from_quaternion method to calculate the roll, pitch and yaw of the pose and then to take the yaw value and use that. It should be noted that the behaviour of this approach will be strange and incorrect if the pose messages are not level!Fri, 28 Jun 2019 09:04:55 -0500https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?answer=327257#post-id-327257Comment by PeteBlackerThe3rd for <p>There is no 1 to 1 mapping between <code>turtlesim pose.theta</code> and any of the values in <code>geometry_msgs/Pose</code>. The turtlesim pose is a 2D pose so it expresses orientation as a single angle in radians, but <code>geometry_msgs/Pose</code> is a 3D pose so it expresses rotation as a Quaternion (4D unit vector).</p>
<p>If you need to create a <code>geometry_msgs/Pose</code> from a <code>turtlesim/Pose</code> message then you can use the <code>tf2::Quaternion.setRPY( Roll, Pitch, Yaw )</code> method and set Roll and Pitch to zero. This will create the quaternion and do all the complicated maths for you.</p>
<p>Here is some background on <a href="https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation">rotation quaternions</a> if you want to learn about the theory. </p>
<p>Hope this helps.</p>
<p><strong>Update:</strong></p>
<p>If it is safe to assume that your robot will always be upright on a level surface then it will be safe to use the euler_from_quaternion method to calculate the roll, pitch and yaw of the pose and then to take the yaw value and use that. It should be noted that the behaviour of this approach will be strange and incorrect if the pose messages are not level!</p>
https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327484#post-id-327484I've updated me answer for you now.Tue, 02 Jul 2019 05:53:42 -0500https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327484#post-id-327484Comment by Shanika for <p>There is no 1 to 1 mapping between <code>turtlesim pose.theta</code> and any of the values in <code>geometry_msgs/Pose</code>. The turtlesim pose is a 2D pose so it expresses orientation as a single angle in radians, but <code>geometry_msgs/Pose</code> is a 3D pose so it expresses rotation as a Quaternion (4D unit vector).</p>
<p>If you need to create a <code>geometry_msgs/Pose</code> from a <code>turtlesim/Pose</code> message then you can use the <code>tf2::Quaternion.setRPY( Roll, Pitch, Yaw )</code> method and set Roll and Pitch to zero. This will create the quaternion and do all the complicated maths for you.</p>
<p>Here is some background on <a href="https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation">rotation quaternions</a> if you want to learn about the theory. </p>
<p>Hope this helps.</p>
<p><strong>Update:</strong></p>
<p>If it is safe to assume that your robot will always be upright on a level surface then it will be safe to use the euler_from_quaternion method to calculate the roll, pitch and yaw of the pose and then to take the yaw value and use that. It should be noted that the behaviour of this approach will be strange and incorrect if the pose messages are not level!</p>
https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327375#post-id-327375Yes. In the tutorial, they use the `turtlesim/Pose.theta` but I don't know to what it corresponds in the `geometry_msgs/Pose`.Mon, 01 Jul 2019 02:04:52 -0500https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327375#post-id-327375Comment by PeteBlackerThe3rd for <p>There is no 1 to 1 mapping between <code>turtlesim pose.theta</code> and any of the values in <code>geometry_msgs/Pose</code>. The turtlesim pose is a 2D pose so it expresses orientation as a single angle in radians, but <code>geometry_msgs/Pose</code> is a 3D pose so it expresses rotation as a Quaternion (4D unit vector).</p>
<p>If you need to create a <code>geometry_msgs/Pose</code> from a <code>turtlesim/Pose</code> message then you can use the <code>tf2::Quaternion.setRPY( Roll, Pitch, Yaw )</code> method and set Roll and Pitch to zero. This will create the quaternion and do all the complicated maths for you.</p>
<p>Here is some background on <a href="https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation">rotation quaternions</a> if you want to learn about the theory. </p>
<p>Hope this helps.</p>
<p><strong>Update:</strong></p>
<p>If it is safe to assume that your robot will always be upright on a level surface then it will be safe to use the euler_from_quaternion method to calculate the roll, pitch and yaw of the pose and then to take the yaw value and use that. It should be noted that the behaviour of this approach will be strange and incorrect if the pose messages are not level!</p>
https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327264#post-id-327264To clarify you need to convert a `geometry_msgs/Pose` into a `turtlesim/Pose` message?Fri, 28 Jun 2019 09:51:26 -0500https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327264#post-id-327264Comment by Shanika for <p>There is no 1 to 1 mapping between <code>turtlesim pose.theta</code> and any of the values in <code>geometry_msgs/Pose</code>. The turtlesim pose is a 2D pose so it expresses orientation as a single angle in radians, but <code>geometry_msgs/Pose</code> is a 3D pose so it expresses rotation as a Quaternion (4D unit vector).</p>
<p>If you need to create a <code>geometry_msgs/Pose</code> from a <code>turtlesim/Pose</code> message then you can use the <code>tf2::Quaternion.setRPY( Roll, Pitch, Yaw )</code> method and set Roll and Pitch to zero. This will create the quaternion and do all the complicated maths for you.</p>
<p>Here is some background on <a href="https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation">rotation quaternions</a> if you want to learn about the theory. </p>
<p>Hope this helps.</p>
<p><strong>Update:</strong></p>
<p>If it is safe to assume that your robot will always be upright on a level surface then it will be safe to use the euler_from_quaternion method to calculate the roll, pitch and yaw of the pose and then to take the yaw value and use that. It should be noted that the behaviour of this approach will be strange and incorrect if the pose messages are not level!</p>
https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327263#post-id-327263I am trying to write a *Go to Goal* code for my robot based on [turtlesim Go to Goal tutorial](http://wiki.ros.org/turtlesim/Tutorials/Go%20to%20Goal). Howerver, how I suscribe to my robot's pose is different than for the turtlesim one. I suscribed to my odom topic and use the pose of my odom message.Fri, 28 Jun 2019 09:43:08 -0500https://answers.ros.org/question/327256/equivalent-turtlesimpose-and-geometry_msgspose/?comment=327263#post-id-327263