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

Revision history [back]

click to hide/show revision 1
initial version

What is definitely wrong is as you suspected the use of getAxis.

I think the python code puts out the raw quaternion.

In c++ you use getAxis(). First, to get the rotation, you should use getAngle() (you output the non-existent w component of the axis, that is zero). This will print out the rotation axis and angle correctly.

However, a quaternion represents axis and angle, but it is not exactly xyz=axis and w=angle. Usually w is cos(angle/2) and the axis is scaled to give a unit quaternion. If you look at your output the python and c++ axes seem to be collinear, just differently scaled.

What is definitely wrong is as you suspected the use of getAxis.

I think the python code puts out the raw quaternion.

In c++ you use getAxis(). First, to get the rotation, you should use getAngle() (you output the non-existent w component of the axis, that is zero). This will print out the rotation axis and angle correctly.

However, a quaternion represents axis and angle, but it is not exactly xyz=axis and w=angle. Usually w is cos(angle/2) and the axis is scaled to give a unit quaternion. If you look at your output the python and c++ axes seem to be collinear, just differently scaled.

To get comparable outputs in c++ just use x(), y(),... to output the raw quaternion instead of getAxis.