Accelerometers (again…) using appropriate transformation for drifting signal returning back to x-axis (0 m/s)

Quick question on processing velocity results from accelerometer data. I'm aware of the unreliability of the data, but I'm willing to tolerate a fair amount of error. Also willing to perform lots of corrections...

I currently have a velocity graph from integrating acceleration which looks like as below:

And the true motion of the physical event looks more like:

So it is very interesting that the accelerometer does contain the correct signal, just that, notoriously, the accelerometer has no reliable coordinate frame and appears to lose orientation of the movements.

So my question is, to the knowledgeable signal processors on here, is there a simple correction function which would perform this transformation to get this curve to flatten down to 0 m/s?

I have fit linear lines & subtracted those from the data to fix the start of the event to the x-axis... I know I could pick the point where the data begins to drift and fit another linear line and subtract that error again. But, surely there is something more elegant?

(Other prior graphs which might be relevant:

You can see the drift begin to happen in the acceleration data basically right in the middle of the movement, the offset starts. Otherwise, I would assume, the acceleration data would be a complete mirror if bi-sected...)

• Is the first plot of the second figure the original acceleration signal? If yes, then that signal does not return to zero which is what is causing the constant drift. The signal starts from zero but it does not return to zero. What is it that produces this acceleration profile? – A_A Mar 13 at 7:57
• Correct, that's the acceleration calculation preceding the velocity results. It's some machinery that moves across a conveyor belt. The true velocity is meant to ramp up, pass across the conveyor, brake and park. – K Puri Mar 14 at 8:20