What happened to Madgwick getQuaternion Function

So I built a sensor glove last year and am currently trying to add vibration motors to the fingertips. The problem I’m having is that I was using the madgwick.h and in the loop I was calling filter.getQuaternion() I just opened my once working sketch and try and compile it and now its telling me that function doesn’t exist.

Ive gone to the madgwickahrs github page and download and looked through the code and the getQuaternion() is no longer there. Did someone remove this functionality from the code? Or am I missing some sort of end of support timeline?

To be clear, I was using #include <Madgwick.h> previously and now that doesn’t compile so I downloaded MadgwickAHRS from github and now that function doesn’t work. I have a new NANO 33 IOT which only has a 6DOF on it and I don’t know how to get quaternion output now.

Someone please chime in and enlighten me as to why my formerly working sketch is broken… Or help me get quaternions from my 6DOF IMU. I’ve never been able to implement any of the Kalman filters.

Post the sketch, using code tags as described in the "How to use this forum" post, and post links to the libraries that were originally included (the ones you downloaded).

For help with compile errors, post the entire text of the error message using quote or code tags.

With a 6DOF sensor, use the MahonyQuaternionUpdate() rather than the Madgwick...() update. The yaw value will be relative and slowly drift.

Madgwick's algorithm uses quaternions internally, so I see no reason why you couldn't add a simple getter to extract that information. (You need members q0,q1,q2,q3.)


Thanks for the replies, i havent ised mahony yet, ive heard its lighter for memory but madgwick had better math behind it. I wont try and pretend i understand the math behind it cause ive tried to comprehend it. Lol.

I will try putting a getter into the code to pull out the q's from the methods. I was just curious why the madgwick filter would remove the function for getting quaternions. The code used to work as i had it all implemented and functioning before.

I didn't post the code cause i figured its from the official madgwick github. And the wrror was just telling me that the function didnt exist. Which it used to which is where the confusion came from.

madgwick had better math behind it

Actually, no. It is not even clear why the Madgwick procedure seems to work with 6DOF sensors (it shouldn't).

See this discussion, which recaps the math.

Well after having added a method to the madgwick.h file which is located in the documents/arduino/libraries folder like so...

// Function declarations
    void begin(float sampleFrequency) { invSampleFreq = 1.0f / sampleFrequency; }
    void update(float gx, float gy, float gz, float ax, float ay, float az, float mx, float my, float mz);
    void updateIMU(float gx, float gy, float gz, float ax, float ay, float az);
    //float getPitch(){return atan2f(2.0f * q2 * q3 - 2.0f * q0 * q1, 2.0f * q0 * q0 + 2.0f * q3 * q3 - 1.0f);};
    //float getRoll(){return -1.0f * asinf(2.0f * q1 * q3 + 2.0f * q0 * q2);};
    //float getYaw(){return atan2f(2.0f * q1 * q2 - 2.0f * q0 * q3, 2.0f * q0 * q0 + 2.0f * q1 * q1 - 1.0f);};
	float getQuaternion() {
		if (!anglesComputed) computeAngles();
        return {q0,q1,q2,q3};
    float getRoll() {
        if (!anglesComputed) computeAngles();
        return roll * 57.29578f;

When I go to compile the sketch I get this error of no matching function to call from

no matching function for call to 'Madgwick::getQuaternion(float*, float*, float*, float*)'

So now I'm trying to find where the madgwick files are from the other arduino library location cause I'm assuming its trying to use the installed library through the arduino library manager.

You are just wasting our time by failing to post links, and posting useless snippets of code.

I'm not sure what links you are expecting me to post? but yes of course my sole purpose of this whole post is to waste everyone's time. that makes total sense. I am using the OFFICIAL github master copy of MadgwickAHRS. Do I need to post the whole code? and can we assume its a standard piece of coding that everyone has access to. I have no problem posting the entire script if you'd like but I felt that was a waste of screen space. I did however post the changed code in my "useless" snippet so show whomever decides to help me, the changes I made in the master code.

I dont post much as I try and source answers out of google for a fair bit of time before I try and post so my forum etiquette isnt polished. The first post was a straight up question about whether I missed some sort of overhaul on the again official madgwick code. So posted code right off the bat was pointless. Then I try to show the code that I have changed.

Please advise me as to what links or useful snippets you would like to see as I obviously am looking through your replies and dont see any sort of direction for me to follow. You did share a link for the math behind it all though which I upfront told everyone I wasn't very well versed in.

Just trying to get some quaternions from my IMU is all. What might seem simple to you after doing whatever it is you do for however long might not be as straight forward and simple to other who are trying to learn and create.