ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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.
2 | No.2 Revision |
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.