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

Can z value in quaternion get negative?

asked 2011-11-03 12:47:25 -0600

130s gravatar image

updated 2011-11-04 05:19:54 -0600

I'm still learning kinematics like quaternion. The answer of this QA page, which I thank the author for the complete explanation, describes as follows:

(x, y, z, w) = (0, 0, sin(theta/2), cos(theta/2))

That means I guess 0 < z < 1 (when 0 <= theta < 2pi). However, in the return value from tf.TransformListener().lookupTransform (in C++), z can often be negative. For example, using turtleSim on RViz, z value I see is -0.717892 when a turtle looks almost down or 6PM or 3pi/2. Am I wrong somewhere?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
5

answered 2011-11-03 21:25:01 -0600

updated 2011-11-04 03:05:37 -0600

If you have a rotation quaternion q=(x,y,z,w), then -q=(-x,-y,-z,-w) describes the same rotation, so you cannot rely on z (or any other component) being positive.

A rotation quaternion is essentially a rotation axis (x,y,z) and an amount of rotation w (I avoid the word angle because it's not an angle in the usual sense), scaled to unit length (|q|=1). If you change the sign of w, you reverse the rotation direction. The same thing happens if you mirror the rotation axis to (-x,-y,-z). So if you do both, these effects cancel each other out.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2011-11-03 12:47:25 -0600

Seen: 3,662 times

Last updated: Nov 04 '11