Skip to content

Madgwick Algorithm With Magnetometer: Issues in True North Detection #495

@gafa7758

Description

@gafa7758

Hello,

I am currently calculating quaternions using the Madgwick algorithm with magnetometer data. The calculation works well, as the quaternion values change correctly when the sensor is rotated. I have verified the results using a quaternion calculator and visualized them with a 3D cube model.

However, I am encountering an issue with the qz value (yaw/heading).
When the sensor is powered on while lying flat, with the magnetometer's X-axis pointing north, the initial quaternion is (1, 0, 0, 0). If I power off the sensor, rotate it 90 degrees about the Z-axis (so the magnetometer's X-axis points west), and power it back on, the quaternion remains (1, 0, 0, 0).

This behavior seems incorrect since the magnetometer readings have to change after the rotation. I also tested rotating the sensor so that the magnetometer's X-axis points south or east, but the quaternion still does not change (still 1, 0, 0,0) when the program is restarted.

Could I have missed something that prevents the quaternion's Z-axis rotation from updating properly, even after changing the sensor's position and restarting the system (turning off the sensor, adjusting its position, and turning it back on)?

Note: Restarting means turning off the sensor, adjusting its position, and then powering it back on.

Thank you for your attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions