1

I have sensor data that I've calculated from an Android phone. I take and perform transformations using a matrix on the xyz coordinates. I then take the acceleration that I got from the phone to find the velocity and displacement. Here is my code to find displacement and velocity. It is always the be the corresponding previous value:

 velocity[e]   = (accel[e-3]) * (time[i]-time[i-1])+velocity[e-3];

 velocity[e+1] = (accel[e-2]) * (time[i]-time[i-1]) +velocity[e-2];

 velocity[e+2] = (accel[e-1]) * (time[i]-time[i-1])+ velocity[e-1];



      displacement[e] = (velocity[e-3])*(time[i]-time[i-1])+.5*(accel[e-3])*pow((time[i]-time[i-1]),2) + displacement[e-3];
      displacement[e+1] = (velocity[e-2])*(time[i]-time[i-1])+.5*(accel[e-2])*pow((time[i]-time[i-1]),2) + displacement[e-2];
      displacement[e+2] = (velocity[e-1])*(time[i]-time[i-1])+.5*(accel[e-1])*pow((time[i]-time[i-1]),2) + displacement[e-1];

However i am getting getting numbers like -3436.0 19206.2 11373.5 for the displacement which should not be nearly that high. I even made a test file to test my formula and everything was right in terms of the numbers I got. However, it doesn't work the same with real data. Also, I read something about removing the mean from the acceleration, velocity, and displacement but don't quite understand that so can someone explain a solution please to getting the right numbers?

Ali
  • 56,466
  • 29
  • 168
  • 265
CIM
  • 41
  • 5
  • There are errors in the code but even if you fix them it won't work. See my answer. – Ali Jul 01 '12 at 20:32

1 Answers1

1

It won't work, these sensors are not accurate enough to calculate the position.

It's amazing how many times this question comes up.

Community
  • 1
  • 1
Ali
  • 56,466
  • 29
  • 168
  • 265