Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix computational errors in quaternion implementation and Madgwick IMU filter #62

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Sep 17, 2024

  1. Fix computational error in quaternion/Madgwick implementation

    A few errors were found in the zscilib implementation the Madgwick filter which this pull request addresses.
    
    The python AHRS library was used as a reference for comparison, and the outputs of this implementation were compared with AHRS. The following discrepancies were found:
    
    1) In quaternions.c, the order of operations in zsl_quat_from_ang_vel is reversed. The orientation of the Earth frame relative to the sensor frame must be computed as qw, not wq. One can refer to the AHRS documentation at https://ahrs.readthedocs.io/en/latest/filters/madgwick.html for more details:
    
    https://github.com/user-attachments/assets/9d2f1d98-33c3-4d3d-9729-f89e9d12206c
    
    2) In the Magwick algorithm, we found that the objective function f is computed incorrectly due to an incorrect rotation to the earth frame:
    
    https://github.com/user-attachments/assets/920afc04-73ac-42f3-92b2-722396107127
    
    We fix this and compute f explicitly as per equation 25 of the Madgwick paper. This pull request aligns the implementation with that of AHRS and includes the equation numbers from the original Madgwick paper so that it is easy to troubleshoot.
    
    Signed-off-by: Ismail Degani <deganii@gmail.com>
    deganii committed Sep 17, 2024
    Configuration menu
    Copy the full SHA
    b1b35fe View commit details
    Browse the repository at this point in the history