mavlink/mavlink — pull request #307 by thomasgubler (2014-12-24 17:59:49+00:00)
Title: Quaternion

This adds a Quaternion class with support for the existing pymavlink Vector3 and Matrix3 classes. The module comes with a testscript (included in travis). The main use case currently is for performing post-flight rotations during plotting. PX4 plans to switch to logging quaternions only and hence the plotting tools need to be prepared.
A quaternion can easily be created from an existing pymavlink Matrix3 (rotation matrix) object or from euler angles. Usage examples are provided in the docstring.

Beside the conversion from and to euler angles and DCM/rotation matrices the Quaternion class supports vector transformations and some operations on other Quaternions (multiply, divide, inverse, ...).

This PR should be relatively safe to merge as it only adds code.

I also added small helper functions to mavextra.py:
Some toy examples:
(At the moment PX4 still logs euler angles, hence I had to convert them to quaternions first)

`tools/mavgraph.py --flightmode=px4 ATT.Roll ATT.Pitch ATT.Yaw "quat_to_euler(euler_to_quat([ATT.Roll, ATT.Pitch, ATT.Yaw]))" 11_10_14.bin`
![example1](https://cloud.githubusercontent.com/assets/1419479/5550105/a03da218-8b9b-11e4-91c0-06226ffe4490.png) (plots are aligned like they should be)

`tools/mavgraph.py --flightmode=px4 ATT.Roll ATT.Pitch ATT.Yaw "quat_to_euler(rotate_quat(euler_to_quat([ATT.Roll, ATT.Pitch, ATT.Yaw]), 0, 0, 3.141592653589793/2.0))" 11_10_14.bin`
![example2](https://cloud.githubusercontent.com/assets/1419479/5550106/a28733d6-8b9b-11e4-8ad0-20cdc6961bd3.png) (yaw shifted by pi/2)