0
$\begingroup$

I had downloaded the android app Phyphox and collected acceleration data. It provides the acceleration at time t, in a CSV file.

I was tasked with finding the position of the object. I would like it first filter out the noise from the sensor data. I am quite new to Signal Processing. I have attached a picture of the plot of the acceleration data(Initially was kept stationary, and then it was moved).

The acceleration data

I would not be able to use a Kalman filter as of now, as I do not really have a model for the movement of the object. I would like to know what other filters I can use that would be good enough.

PS: I am using Python for filtering purposes, so even if the math is heavy, but an existing python library makes life easier, I would still like to hear about it.

(For information on what I would do later, might be useful if this also is needed to determine the choice of the filter. The data was sampled somewhat irregularly, so I had used linear interpolation to find out values at n*T_s, where n is an integer and T_s is a suitably chosen sampling time. Then, I would take an FFT, use omega arithmetic, and then an IFFT to get back displacement.)

Thanks a lot

$\endgroup$
5
  • $\begingroup$ "position of the object"? what object? assume that we need context that you haven't given. $\endgroup$ Commented May 31 at 10:52
  • $\begingroup$ I strongly suggest you start with building a few simple test cases with known motions and work your way up slowly to more complicated ones. Start with simple linear motion along one axes. From there you can assess the noise spectrum which then can guide the filter selection and strategy. $\endgroup$
    – Hilmar
    Commented May 31 at 13:18
  • $\begingroup$ from acceleration to position, you'd need to integrate twice. error accumulates especially badly. you won't get away with "simple" filters for this. this is research-level stuff. you need to do literature review for this, if you want to get any decent results for it. $\endgroup$ Commented May 31 at 14:36
  • $\begingroup$ Without tightly bounding the problem, the answer is that you can't get there from here. Acceleration is the double-derivative of position. In general you can't even get the velocity of an object reliably. For example, if you start from some known reference state (position and velocity) then you can use acceleration to infer an ending state (position and velocity), but the longer the period between start and finish, the worse your estimate will be. $\endgroup$
    – TimWescott
    Commented May 31 at 18:11
  • $\begingroup$ If there's more detail to what you're doing (like, starting from a known state) you may want to edit your question to elaborate. Alternately, you may want to change your question to some variation on "why can't I do this in general". $\endgroup$
    – TimWescott
    Commented May 31 at 18:12

1 Answer 1

0
$\begingroup$

To your question about what filter should be used, be aware that it is impossible to remove noise entirely if the noise is random because it cannot be predicted, and therefore, at best, all you can do is reduce its mean and variance. For random noise, your objective might be to minimise the output noise variance, in which case a moving average filter is optimal, whose output noise distribution is: $${\rm E}[\bar X] = \mu$$ $${\rm Var}\left[\bar X\right] = \frac{\sigma^2}{n}$$ Where $\bar X$ is the noise mean computed over $n$ samples, and $\mu$ and $\sigma^2$ are the noise mean and variance, respectively, and ${\rm E[\bar X]}$ and ${\rm Var[\bar X]}$ means the expected value and variance of $\bar X$, respectively.

Now, as comments have pointed out, unfortunately there is a high probability that you are not going to obtain satisfactory results estimating position from acceleration measurements due to rapidly growing uncertainty, which I will show analytically based on expected value and propagation of variance:

Firstly, the velocity is computed from the integrated acceleration signal, which is proportional to a cumulative sum in the discrete time domain, so this operation inherently minimises output noise variance since it equally weights all samples used, with the velocity noise distribution being: $${\rm E}\left[T\sum X\right] = NT\mu$$ $${\rm Var}\left[T\sum X\right] = NT^2\sigma^2$$ Where $N$ is the number of samples used in a cumulative sum, and $T$ is the sample interval.

Then, the velocity is integrated to determine position, which, notably, no longer equally weights all samples used, meaning the output noise variance is no longer minimised, with the position noise distribution being: $${\rm E}\left[T^2\sum\sum X\right] = \frac{N(N+1)}{2}T^2\mu$$ $${\rm Var}\left[T^2\sum\sum X\right] = \frac{N(N+1)(2N+1)}{6}T^4\sigma^2$$

Therefore, the noise's distribution in the position for large $N$ asymptotes to the following 95% confidence interval: $$\frac{N^2}{2}T^2\mu\pm\frac{2}{\sqrt3}N^{1.5}T^2\sigma$$ As such, returning to my original statement, position uncertainty will grow with the number of samples, that is, time, with any non-zero noise mean eventually dominating as it grows as $N^2$, and whilst you might be able to zero your acceleration readings in an attempt to remove the noise mean, I can guarantee the noise mean will change over time due to sensor imperfections, and it still leaves the component of uncertainty due to noise variance that grows as $N^{1.5}$.

Finally, I will also mention that linearly interpolating your data can introduce significant undesirable artefacts because at one extreme it involves averaging two samples when the interpolation point is midway between two samples, and at the other extreme has no averaging when the interpolation point falls coincident with a sample. Therefore, just in case you're not aware, make sure your signal bandwidth is such that any artefacts introduced by this are within acceptable bounds.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.