I'm working with an MPU9250 and using the Madgwick Filter. For what I know I need to subtract the GRAVITY from my X, Y, Z Acceleration values, basically, some kind of gravity compensation to get linear acceleration values. I was using the following code (q is my quaternion generated by the Madgwick filter):
g = 2 * (q * q - q * q) g = 2 * (q * q + q * q) g = q * q - q * q - q * q + q * q
Then, to compensate the gravity, I subtract gx, gy, gz from my ax, ay, az values respectively. I'm not sure if this is the correct approach to solve this problem and I would like a bit of help. After stripping the gravity values, I need to get velocity. I don't need position so I'm not going to double integrate the acceleration values. By the way, I have to mention that this will be used to measure speed and acceleration/deceleration of football players while running, so I don't need this to be extremely precise.
PS: I read about using a Low-Pass filter to subtract gravity, but I'm not sure if I should be doing that.