Easy Training / Mbed 2 deprecated Quaternionen_to_euler

Dependencies:   mbed

Committer:
MarcelPortmann
Date:
Wed Mar 04 17:49:57 2020 +0000
Revision:
0:4824ed76a312
Aus quanternionen eulerwinkel berechnen;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MarcelPortmann 0:4824ed76a312 1
MarcelPortmann 0:4824ed76a312 2 #include "MadgwickAHRS.h"
MarcelPortmann 0:4824ed76a312 3 #include "QtoEuler.h"
MarcelPortmann 0:4824ed76a312 4 #include <math.h>
MarcelPortmann 0:4824ed76a312 5
MarcelPortmann 0:4824ed76a312 6 // Programm zum umrecnen der Quatrionen in die 3 Eulerwinkel
MarcelPortmann 0:4824ed76a312 7 // Pitch roll und jaw
MarcelPortmann 0:4824ed76a312 8
MarcelPortmann 0:4824ed76a312 9 // Benötigt zum funktionieren den Madgwick Algorythmuss
MarcelPortmann 0:4824ed76a312 10
MarcelPortmann 0:4824ed76a312 11 volatile float pitch = 0.0f, rol = 0.0f, jaw = 0.0f;
MarcelPortmann 0:4824ed76a312 12
MarcelPortmann 0:4824ed76a312 13 void QtoEuler(void){
MarcelPortmann 0:4824ed76a312 14 jaw = atan2(2*q1*q2 - 2*q0*q3, 2*pow(q0,2)+2*pow(q1,2) - 1);
MarcelPortmann 0:4824ed76a312 15 pitch = -asin(2*q1*q3+2*q0*q2);
MarcelPortmann 0:4824ed76a312 16 rol = atan2(2*q2*q3-2*q0*q1,2*pow(q0,2)+2*pow(q3,2) - 1);
MarcelPortmann 0:4824ed76a312 17
MarcelPortmann 0:4824ed76a312 18
MarcelPortmann 0:4824ed76a312 19 }