I am trying to correctly track orientation of a sensor with accelerometer and gyroscope using the open source Madgwick algorithm. The algorithm returns quaternions which represent the rotation between the internal and external frames and I use it to determine gravity vector to correct accelerometers.
The algorithm works well when movements are slow and static, but when I try to excite the sensors with fast and periodic movements the quaternions always end up drifting. You can see below the representative figure of this drift when a back and forth movement from top to bottom is performed, the drift is observed on gravity vectors calculated with the quaternions obtained by the fusion algorithm.
(Blue = X axis, Red = Y axis and Yellow = Z axis)
The IMU is a low-cost one : Invensense ICM20948, my sample rate is good (about 300 Hz 100 Hz), I have smooth quaternions, and set parameters algorithm to have good result with slow and static movements.
So my question is : Do you think it's possible to have good result with Madgwick algorithm when this kind of movements are performed? (fast and periodic).