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

# Quaternion rotation

Hi guys, i'm having some problems with the rotation through quaternions. I have two quaternions coming one from a nav_msgs::odometry and the other one from a geometry_msgs::pose. I want to rotate the robot until the quaternion of the nav_msgs is equal, or almost equal, to the geometry_msgs one. How is it possible to solve my problem? Thanks in advance.

edit retag close merge delete

Sort by » oldest newest most voted You can obtain the radians value for the yaw through tf::getYaw and then compute the angular speed command for the robot.

more

I obtain this warning: MSG to TF: Quaternion Not Properly Normalized, what's that? By the way, surfing the web, I found some mathematical formulas that state: yaw = atan2(2(wz+xy),1-2(y^2+z^2)). I compared the result from this formula and the result from tf::getYaw and they are different, which use?

If you got that error, it means that the quaternion was not properly computed. How do you obtain the two quaternions? The norm of the quaternions should always be 1. In order to compute the yaw, first, you should know how the rotation was built (x-y-z or z-y-x, etc...)

If I set an orientation goal (a geometry_msgs::Pose) equal to (0,0,1,1), it should rotate of 180° but the warning shows up, so what's wrong with this?

1

(0,0,1,1) is not a unitary quaternion. Its norm is 2. You can create quaternion with tf::createQuaternionFromYaw or tf::createQuaternionFromRPY. Check this