Easy Training / Mbed 2 deprecated Quaternionen_to_euler

Dependencies:   mbed

QtoEuler.cpp

Committer:
MarcelPortmann
Date:
2020-03-04
Revision:
0:4824ed76a312

File content as of revision 0:4824ed76a312:


#include "MadgwickAHRS.h" 
#include "QtoEuler.h"
#include <math.h>

// Programm zum umrecnen der Quatrionen in die 3 Eulerwinkel
// Pitch roll und jaw

// Benötigt zum funktionieren den Madgwick Algorythmuss

volatile float pitch = 0.0f, rol = 0.0f, jaw = 0.0f;

void QtoEuler(void){
    jaw   =   atan2(2*q1*q2 - 2*q0*q3, 2*pow(q0,2)+2*pow(q1,2) - 1);
    pitch =   -asin(2*q1*q3+2*q0*q2);
    rol   =   atan2(2*q2*q3-2*q0*q1,2*pow(q0,2)+2*pow(q3,2) - 1);
    
    
    }