pykinematics.imu.orientation.MadgwickAHRS

class pykinematics.imu.orientation.MadgwickAHRS(sample_period=0.00390625, q_init=array([1, 0, 0, 0]), beta=0.041)

Algorithm for estimating the orientation of an inertial sensor with or without a magnetometer.

Parameters:
sample_period : float, optional

Sampling period in seconds. Default is 1/256 (ie sampling frequency is 256Hz).

q_init : numpy.ndarray, optional

Initial quaternion estimate. Default is [1, 0, 0, 0].

beta : float, optional

Beta value for the algorithm. Default is 1.0

References

S. Madgwick et al. “Estimation of IMU and MARG orientation using a gradient descent algorithm.” IEEE Intl. Conf. on Rehab. Robotics. 2011.

Methods

update(self, gyr, acc, mag) Perform update step.
updateIMU(self, gyr, acc) Perform update step using only gyroscope and accelerometer measurements
update(self, gyr, acc, mag)

Perform update step.

Parameters:
gyr : numpy.ndarray

Angular velocity at time t. Units of rad/s.

acc : numpy.ndarray

Acceleration at time t. Units of g.

mag : numpy.ndarray

Magnetometer reading at time t.

Returns:
q : numpy.ndarray

Quaternion estimate of orientation at time t.

updateIMU(self, gyr, acc)

Perform update step using only gyroscope and accelerometer measurements

Parameters:
gyr : numpy.ndarray

Angular velocity at time t. Units of rad/s.

acc : numpy.ndarray

Acceleration at time t. Units of g.

Returns:
q : numpy.ndarray

Quaternion estimate of orientation at time t.