arduino-libraries / MadgwickAHRS

Arduino implementation of the MadgwickAHRS algorithm
465 stars 196 forks source link

Recommend Option be added to return the quaternions #10

Closed mjs513 closed 7 years ago

mjs513 commented 8 years ago

Besides YPR the quaternions are useful to calculate dynamic acceleration as well as other coordinate transformations. I recommend a getQ function be added to the filter files. In MadgwickAHRS.cpp you could add:

void Madgwick::getQ(float * q) {
    q[0] = q0;  
    q[1] = q1;
    q[2] = q2;
    q[3] = q3;
}

while in MadgwickAHRS.h under public functions:

void getQ(float * q);

In the visualizer sketch you would need to add: float q[4]; and obviously to call the new function: filter.getQ(*q);

R. Mike

PaulStoffregen commented 8 years ago

Yes, will do.

mjs513 commented 8 years ago

Thank you Paul, appreciate it.

GMcDowellJr commented 3 years ago

Besides YPR the quaternions are useful to calculate dynamic acceleration as well as other coordinate transformations. I recommend a getQ function be added to the filter files. In MadgwickAHRS.cpp you could add:

void Madgwick::getQ(float * q) {
    q[0] = q0;  
    q[1] = q1;
    q[2] = q2;
    q[3] = q3;
}

while in MadgwickAHRS.h under public functions:

void getQ(float * q);

In the visualizer sketch you would need to add: float q[4]; and obviously to call the new function: filter.getQ(*q);

R. Mike

Looks like this was never implemented. Curious if there's something wrong with it as I'm struggling to implement it myself.

edit - NM - i was looking in the wrong library folder! doh!! -- regardless, still wondering why it wasn't implemented - thanks