0

Currently, I am calculating quaternions using the Madgwick algorithm, incorporating magnetometer values. I have tried the code provided in Madgwick's original paper and also the implementation by Kris Winer. The results are reasonably accurate, as the quaternion values change correctly for each axis during rotation.

However, with this algorithm, the sensor fails to detect the correct north direction. When the program starts, the direction pointed to by the magnetometer's X-axis is always interpreted as north, even if the X-axis is actually pointing south. This is evident from the quaternion output, which is always (1, 0, 0, 0) when the sensor is first powered on or the program begins, regardless of whether the magnetometer's X-axis is pointing south, west, or east.

Could anyone help me to resolve this issue?

I tried implementing both Madgwick's original code from his paper and Kris Winer's implementation. I expected the sensor to correctly detect the north direction using the magnetometer, but instead, the sensor always treats the magnetometer's X-axis as pointing north regardless of its actual orientation.

so when the x axis of magnetometer pointed to west when the sensor first power on, the result is not 1,0,0,0 , but a value that represent the position of the sensor.

3
  • Can you test with synthetic magnetometer data to verify expected behavior ? Commented Dec 20, 2024 at 16:16
  • I would suggest to ask ChatGPT This question is not focused on a specific code or logic. Also you could try another Stack that is focused on: electronics.stackexchange.com/questions/tagged/sensor Commented Dec 22, 2024 at 21:59
  • Regarding that, I haven't tried it yet. Could you provide a link to synthetic data that I can use? @minorlogic Commented Dec 23, 2024 at 7:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.