- #1
Pugio
- 3
- 0
There's a problem I've been working on for a few days that I can't seem to resolve:
There is a model train going around a set track with a 2-D accelerometer mounted along the axis of the train. The accelerometer provides the current x/y acceleration values at a frequency of about once every 0.01 seconds.
Using just those values, I am trying to recreate the path of the train. I thought I had understood the problem, and it's solution, but I seem to be getting stuck somewhere.
My strategy is first to assume initial position and velocity to be 0. I then keep track of a velocity vector. For each line of data I first:
1. Perform a coordinate translation to translate the given acceleration vector from coordinates local to the train/accelerometer to a global coordinate system.
2. Modify my velocity by the new accel vector * delta t.
3. Modify my position by the velocity * delta t.
Since the velocity vector encodes the current orientation of the train, I can use that value to translate the local acceleration vectors into the global coordinate frame.
Ideally, by plotting each position point I should get a graph illustrating the path of the train.
This seems to work at first, but at some point the train looks like it almost jumps the tracks and sails off in a straight direction. Somehow, despite the fact that the acceleration vectors indicate some form of curve/turn, the velocity supersedes this and the train heads straight off to nowhere.
I've checked my code/algorithm many times, and I don't think this is a simple programming error. It seems as if I am not understanding an aspect of this problem. Maybe something to do with propagated error in the acceleration readings?
An example of the data:
Any insight into this would be appreciated.
There is a model train going around a set track with a 2-D accelerometer mounted along the axis of the train. The accelerometer provides the current x/y acceleration values at a frequency of about once every 0.01 seconds.
Using just those values, I am trying to recreate the path of the train. I thought I had understood the problem, and it's solution, but I seem to be getting stuck somewhere.
My strategy is first to assume initial position and velocity to be 0. I then keep track of a velocity vector. For each line of data I first:
1. Perform a coordinate translation to translate the given acceleration vector from coordinates local to the train/accelerometer to a global coordinate system.
2. Modify my velocity by the new accel vector * delta t.
3. Modify my position by the velocity * delta t.
Since the velocity vector encodes the current orientation of the train, I can use that value to translate the local acceleration vectors into the global coordinate frame.
Ideally, by plotting each position point I should get a graph illustrating the path of the train.
This seems to work at first, but at some point the train looks like it almost jumps the tracks and sails off in a straight direction. Somehow, despite the fact that the acceleration vectors indicate some form of curve/turn, the velocity supersedes this and the train heads straight off to nowhere.
I've checked my code/algorithm many times, and I don't think this is a simple programming error. It seems as if I am not understanding an aspect of this problem. Maybe something to do with propagated error in the acceleration readings?
An example of the data:
Code:
t x y
0.01 -0.008 -0.002
0.02 -0.015 -0.003
0.03 -0.02 -0.003
0.04 -0.022 -0.003
0.05 -0.027 -0.002
0.06 -0.032 -0.001
0.07 -0.038 0
0.08 -0.042 0
0.09 -0.045 0
Any insight into this would be appreciated.