I am reading accelerometer data and want to determine the distance that the accelerometer is moved. ( My question is similar to the one placed here, Calculate speed from accelerometer . I just feel as if it lacks in formulating a complete example for me to use )
How my accelerometer output looks like:
x,y,time
-1.046700,0.120410,2015-02-02 07:22:33.609
How my accelerometer moves:
My accelerometer is placed on the ankle of a person. As position changes from $1$ to $2$, the accelerometer x and y values move from second quadrant to first quadrant. The image below depicts this scenario:
Note, while not shown, the persons leg can go back and forth, so $z$ axis would incur some change. I don't want "what happens on the $z$ axis" to interfere with distance estimates using $x$ and $y$.
What I (think) I know and what I know:
So far I know that acceleration will be present on both of these axis, $x$ and $y$. Hence, I think I know that the total acceleration between the two axis can be represented with this formula:
$total_{accl} = sqrt(x^2 + y^2)$
Given $total_{accl}$, it would make sense to me to convert the accelerometer data measurements to $m/s^2$, and subtract standard gravity from it. Hence, I think I know that my above formula would be as follows:
$total_{accl} = sqrt(x^2 + y^2) * 9.81 - 9.81$
I know that I can get velocity from $total_{accl}$ by taking the first integral. I can do this in matlab using this funciton, trapz. And then, I can solve for distance, using $d = t * v$, where $v$ is my first integral of $total_{accl}$ ( velocity ), and $t$ the amount of elapsed time that the leg was moving.
My question:
Is my logic here correct?
I ask because when I try this method out, I get really bad error, almost $+100cm$ from the actual distance. I understand that accumulated error can be bad, but it's so big that I am questioning if I am doing this right.
UPDATE:
This post, Instantaneous velocity calculation from accelerometer, really nails down why the eventual drift and error accumulation will destroy and form of velocity and distance estimation in the example above. ( Especially as time continues )