AHRS based on MatrixPilot DCM algorithm; ported from Pololu MinIMU-9 example code in turn based on ArduPilot 1.5 built for sensor gy_80
Fork of DCM_AHRS by
Matrix.h@14:6cb3c2204b9b, 2013-10-16 (annotated)
- Committer:
- oprospero
- Date:
- Wed Oct 16 07:49:34 2013 +0000
- Revision:
- 14:6cb3c2204b9b
- Parent:
- 6:49cbf2acc4e6
Fixed vector copy;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
shimniok | 0:62284d27d75e | 1 | #ifndef __MATRIX_H |
shimniok | 0:62284d27d75e | 2 | #define __MATRIX_H |
shimniok | 0:62284d27d75e | 3 | |
oprospero | 6:49cbf2acc4e6 | 4 | #include "math.h" |
shimniok | 0:62284d27d75e | 5 | /** Take cross product of two 3x1 vectors: v1 x v2 = vectorOut |
shimniok | 0:62284d27d75e | 6 | * @param v1 is the first vector |
shimniok | 0:62284d27d75e | 7 | * @param v2 is the second vector |
shimniok | 0:62284d27d75e | 8 | * @returns vectorOut = v1 x v2 |
shimniok | 0:62284d27d75e | 9 | */ |
shimniok | 0:62284d27d75e | 10 | void Vector_Cross_Product(float vectorOut[3], float v1[3], float v2[3]); |
shimniok | 0:62284d27d75e | 11 | |
shimniok | 0:62284d27d75e | 12 | /** Multiple 3x1 vector by scalar: vectorOut = vectorIn times scale2 |
shimniok | 0:62284d27d75e | 13 | * @param vectorIn the vector |
shimniok | 0:62284d27d75e | 14 | * @param scale2 is the scalar |
shimniok | 0:62284d27d75e | 15 | * @returns vectorOut the result |
shimniok | 0:62284d27d75e | 16 | */ |
shimniok | 0:62284d27d75e | 17 | void Vector_Scale(float vectorOut[3], float vectorIn[3], float scale2); |
shimniok | 0:62284d27d75e | 18 | |
shimniok | 0:62284d27d75e | 19 | /** TDot product of two 3x1 vectors vector1 . vector2 |
shimniok | 0:62284d27d75e | 20 | * @param vector1 is the first vector |
shimniok | 0:62284d27d75e | 21 | * @param vector2 is the second vector |
shimniok | 0:62284d27d75e | 22 | * @returns float result of dot product |
shimniok | 0:62284d27d75e | 23 | */ |
shimniok | 0:62284d27d75e | 24 | float Vector_Dot_Product(float vector1[3], float vector2[3]); |
shimniok | 0:62284d27d75e | 25 | |
shimniok | 0:62284d27d75e | 26 | /** Adds two 3x1 vectors: vectorOut = vectorIn1 + vectorIn2 |
shimniok | 0:62284d27d75e | 27 | * @param vectorIn1 is the first vector |
shimniok | 0:62284d27d75e | 28 | * @param vectorIn2 is the second vector |
shimniok | 0:62284d27d75e | 29 | * @returns vectorOut is the result of the addition |
shimniok | 0:62284d27d75e | 30 | */ |
shimniok | 0:62284d27d75e | 31 | void Vector_Add(float vectorOut[3], float vectorIn1[3], float vectorIn2[3]); |
shimniok | 0:62284d27d75e | 32 | |
shimniok | 0:62284d27d75e | 33 | /** Multiplies two 3x3 matrices to get a third 3x3 matrix: c = ab |
shimniok | 0:62284d27d75e | 34 | * @param a is the first vector |
shimniok | 0:62284d27d75e | 35 | * @param b is the second vector |
shimniok | 0:62284d27d75e | 36 | * @returns c as the result of the mutliplication |
shimniok | 0:62284d27d75e | 37 | */ |
shimniok | 0:62284d27d75e | 38 | void Matrix_Multiply(float c[3][3], float a[3][3], float b[3][3]); |
oprospero | 6:49cbf2acc4e6 | 39 | void init_rotation_matrix(float m[3][3], float yaw, float pitch, float roll); |
shimniok | 0:62284d27d75e | 40 | #endif |