1

I am trying to develop an Android application to calculate accurate distances covered by a user using the devices accelerometer.

I have two vectors in each 5 seconds, one contains the acceleration values and the other contains the timeStamp.

First, I calculate the cumulative for acceleration values which represent the speed and I calculate distance as below:

float calcDistance(Vector<Float> samples, Vector<Float> times) {
    float distance = 0;
    for (int i = 1; i < samples.size(); i++)
   samples.set(i, samples.get(i) + samples.get(i - 1));
    for (int i = 0; i < samples.size() - 1; i++)
   distance += samples.get(i) * (times.get(i + 1) - times.get(i));
return distance;
 }

But it's not giving accurate distances. Is there any way to calculate accurate distance?

0 Answers0