1

Is it possible to decorrelate accelerometer data in real-time? If so, how is it done?

Background: My application is receiving (X,Y,Z) accelerometer data in real-time (sample rate is 6.75Hz). The sensor is moving in a periodic motion but the motion is not necessarily along only one axis. The 3 signals x(t), y(t) and z(t) are therefore slightly correlated and I would like to know if I can find a rotation matrix (in real time) which can be used to rotate the measured (x,y,z) into a new vector (x*,y*,z*) so that the entire motion is along the z-axis?

I would like to implement the algorithm in C. Thanks.

user1884325
  • 2,530
  • 1
  • 30
  • 49
  • How would you do it with a static set of data? – chux - Reinstate Monica Jan 03 '16 at 04:28
  • @chux no idea. That's why i am asking – user1884325 Jan 03 '16 at 04:33
  • So the periodic motion is linear and not circular? – pat Jan 03 '16 at 04:52
  • @pat yes it is like a point moving back and forth a line in 3D space – user1884325 Jan 03 '16 at 04:53
  • As OP has no idea how to do this with static data, let alone dynamic data and has posted no code showing level of coding expertise, the task is far too broad for SO. Voting to close. – chux - Reinstate Monica Jan 03 '16 at 04:55
  • 2
    @chux i think my question is quite specific. The task is to rotate an acceleration vector so that all the acceleration is projected onto 1 axis. I was thinking abou t double integration of highpass filtered versions of x,y and z to get the position. Not sure if that's a good approach – user1884325 Jan 03 '16 at 04:59
  • The `C` tag is misplaced at this point since there is no code in sight, and the question is likely to attract negative comments because of that. Once you figure out the algorithm and have questions about a particular `C` implementation, then it would become on topic for the `C` tag. Meanwhile, see if [Rotating a Vector in 3D Space](http://stackoverflow.com/questions/14607640/rotating-a-vector-in-3d-space) maybe helps. – dxiv Jan 03 '16 at 05:51
  • Rotation and projection are 2 different things. You can rotate to coordinates where the correlation matrix is diagonal, that's called PCA. But it is not clear from your question if that's what you need. – Itamar Katz Jan 03 '16 at 13:27

2 Answers2

3

What you're trying to do is generally called "principal component analysis". The Wikipedia article is pretty good:

https://en.wikipedia.org/wiki/Principal_component_analysis

For static data you generally use the eigenvectors of the covariance matrix as your new coordinate basis.

PCA in real time is doable, but not super easy. See, for example: http://www.bio-conferences.org/articles/bioconf/pdf/2011/01/bioconf_skills_00055.pdf

Matt Timmermans
  • 53,709
  • 3
  • 46
  • 87
1

I'd like to first of all emphasize that Matt Timmermans' answer has done exactly what people are actually doing when classifying accelerometer data from clinical studies (a project I worked on).

Then: you're observing a sampled signal. In general, if you have a sensor that gives you samples at a rate of 6.75Hz, the highest frequency of a signal you can detect is 6.75Hz/2 = 3.375Hz. Everything that has a frequency higher than that will inherently be aliased back and look like it was something with a frequency f with 0<=f<3.375Hz. If you've not considered this, please go and read up on the Nyquist–Shannon sampling theorem. Especially: shield your sensors (however you do that, e.g. by employing dampeners) from all input above that limit, otherwise your measurements might be worth very little or even nothing. If your sensor does this internally (that's absolutely possible, there are enough accelerometers with analog low pass filters), this has been taken care of. However, document that characteristics of your sensor.

Now, your case is a little bit easier because you know pretty well that your whole observation is going to be periodic, and it's measured along three orthogonal axis.

In this case, just doing three discrete Fourier transforms at once, extracting the "strongest" spectral component over all three channels, and finding the phase of that spectral component (which is but the complex argument of that DFT bin) in the two others would give you something that you can map to a periodic movement around a specific axis in 3D space. If you want to, remove these value (set the bins to 0), and search for strongest component again etc.

Discrete cosine transforms can be done in staggering speed nowadays. with 6.75Hz, no PC in this world will ever get into trouble when you try this while you receive further samples. It's a hilariously low sampling rate.

Another, more elegant (read: you need less samples to compute this) would be using a parametric estimator; in your case, a direction-of-arrival sensor from the world of RF technology with multiple antennas would, as far as I can think, map directly to detection of rotational axis. The classical algorithms here are MUSIC and ESPRIT, and for your case (limited, known amount of oscillating parts), ESPRIT might be the better choice.

Community
  • 1
  • 1
Marcus Müller
  • 34,677
  • 4
  • 53
  • 94