Ask Your Question

Revision history [back]

There 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 if you want to learn about the theory.

Hope this helps.

There 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 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!