I'm trying to remove the drift generated upon the double integration of a noisy acceleration signal. But this question discusses only removing the drift upon single integration to generate velocity signal.
I'm following this research paper which uses Envelope method to remove the drift generated upon double integration of a signal.
TLDR Envelope Method for a given discrete signal $x(n)$:
- Identify all the local extrema of $x(n)$
- Interpolate between maxima (resp., minima) by a cubic spline to form the upper envelope $e_{u}(n)$ (resp., the lower envelope $e_{d}(n)$)
- Calculate the mean of the envelopes $e_{a}(n) = (e_{u}(n) + e_{d}(n))/2$
- Compute $y(n) = x(n) - e_{a}(n)$
Example I was trying to solve using envelope method
t = np.arange(0, 20, 0.1)
f1 = lambda t: 0.1*np.sin(np.pi*t) + 0.1*np.sin(20*np.pi*t) #Clean accleration signal
f2 = lambda t: 0.1*np.sin(np.pi*t) + 0.1*np.sin(20*np.pi*t) + 0.01 #Noisy acceleration signal
Upon Single integration for velocity:
Then located maxima and minima and performed cubic interpolation to generate upper and lower envelopes respectively using CubicSpline Method from the scipy package.
Then Generated mean of the envelopes:
Then Subtracting the mean of the envelopes from the Drift prone velocity:
I don't know what I did wrong but as it can be seen in the final plot, clean signal of velocity does not match the noisy signal corrected using the envelope method. I know there are other/better methods for correcting the baseline offsets but as starting point, the envelope method seemed easier to implement. If there are methods better than this and easier to implement, I'm all ears.
I would like to know what mistake I made along the way.