Ask Your Question
0

Quaternion rotation

asked 2017-05-24 10:24:42 -0500

tonio gravatar image

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

1 Answer

Sort by » oldest newest most voted
2

answered 2017-05-24 10:39:44 -0500

Chaos gravatar image

You can obtain the radians value for the yaw through tf::getYaw and then compute the angular speed command for the robot.

edit flag offensive delete link more

Comments

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?

tonio gravatar image tonio  ( 2017-05-24 11:04:13 -0500 )edit

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

Chaos gravatar image Chaos  ( 2017-05-25 02:49:56 -0500 )edit

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?

tonio gravatar image tonio  ( 2017-05-25 04:30:34 -0500 )edit
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

Chaos gravatar image Chaos  ( 2017-05-25 04:43:19 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-05-24 10:24:42 -0500

Seen: 1,304 times

Last updated: May 24 '17