Ros quaternion component w not behaving as it should.

asked 2020-04-23 08:20:32 -0600

priestoferis gravatar image

updated 2020-04-23 09:37:26 -0600

The quaternions in ros are supposed to be (x,y,z,w), where w = cos(theta/2) where theta is the angle of the rotation.

I did the following, I used tf_listener to get the position of my robot t_base,r_base = tf_listener.lookupTransform('/map','/base_link',rospy.Time(0))

and then I printed the last component of r_base as I did a 360° continuous turn with the robot. What I get is values between -0.3 and 0.3 with a jump in sign between -0.3 and 0.3. (So I start from -0.3 it goes up to 1 then down to 0.3 where it jumps to -0.3) as if the robot were missing around 30°from the 360°.

What is happening here?

edit retag flag offensive close merge delete

Comments

Keep in mind what w is in a quaternion: its a normalization term.

stevemacenski gravatar image stevemacenski  ( 2020-04-23 12:21:05 -0600 )edit

I don't think I get your point.

priestoferis gravatar image priestoferis  ( 2020-04-23 12:34:16 -0600 )edit

I prefer to think in euler angles rather than quaternions .. use (r,p,y) = tf.transformations.euler_from_quaternion(quaternion=r_base) to save yourself a headahe

pring gravatar image pring  ( 2020-04-25 14:39:50 -0600 )edit