Skip to content

Madgwick coordinate system #136

@x1y9

Description

@x1y9
from ahrs.filters import Madgwick
import numpy as np

madgwick = Madgwick()
q = np.array([1.0, 0.0, 0.0, 0.0])  

acc_device = [0.08853444, 0.009571291, -9.856036]  
gyro_device = [6.8720314E-4,1.5271181E-4,6.8720314E-4]
mag_device=[34.912502, -0.84375006, 53.531254]

from scipy.spatial.transform import Rotation
for i in range(0,10000):
    q = madgwick.updateMARG(q, gyr=gyro_device, acc=acc_device, mag=mag_device) 
euler = Rotation.from_quat([q[1], q[2], q[3], q[0]]).as_euler('xyz', degrees=True)
print(euler) 

The value of the acc/gyro/mag sensor in the above code is read from an Android phone with NED attitude, I thought the output would be three Euler angles of 0, but the actual output is [-59.91242581 -56.71604791 6.81958275], why?

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