Skip to content

Bug in the calcQuaternion algorithm #9

@jtragtenberg

Description

@jtragtenberg

Hi there,
I've been all this time learning C++ and figuring out how the Motioner and RazorIMU libraries work.
I make my own prototyping board with just an arduino UNO soldered with a HMC8553L magnetometer and MPU6050 gyro+accel. I'm doing all my tests connecting the board through USB.
I made a code out of the Motioner.ino where in the loop() I just added the lines:

float qx = motioner.mRazorIMU.getQuatX();
float qy = motioner.mRazorIMU.getQuatY();
float qz = motioner.mRazorIMU.getQuatZ();
float qw = motioner.mRazorIMU.getQuatW();

Serial.print(qw);
Serial.print('|');
Serial.print(qx);
Serial.print('|');
Serial.print(qy);
Serial.print('|');
Serial.println(qz);

where the getQuat* functions I added are just:

float getQuatX() const { return quat.x; }
float getQuatY() const { return quat.y; }
float getQuatZ() const { return quat.z; }
float getQuatW() const { return quat.w; }

and I made the mRazorIMU object public on the Motioner class.

Out of this I noticed a bug in the angles as I tilt them, where the quaternions change sign for no reason...
I have calibrated my board with the IMUDebug.ino firmware and it all worked well in the IMUvisualization Processing sketch.

here is what the serial monitor shows:
https://youtu.be/AYBm-mMuhkI

Does anyone know why this bug keeps bugging me?
Is this discontinuity and sign inversion expected?

thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions