views:

510

answers:

1

I'm trying to map my movements with a android device into an OpenGL scene.

I've recorded accelerometer values for a simples movement: Moving the phone (lies flat on a table) 10cm forward (+x), and then 10cm backward (-x).

The problem is that this values when used to calculate velocity and position, makes only the opengl cube go forward. Seems like the negative acceleration recorded was not enough to reduce the speed and invert its movement.

What can be the problem?

This is my function that updates the velocity and position every time new data comes in:

void updatePosition(double T2) {
    double T = 0.005;
    Vec3 old_pos = position.clone(), old_vel = velocity.clone();

    velocity = old_vel.plus(acceleration.times(T));
    position = old_pos.plus(old_vel.times(T).plus(acceleration.times(0.5 * Math.pow(T, 2))));

}

This is the X,Y,Z accelerometer values over the entire captured time:

alt text

A: 

Your function takes the parameter T2 which I am assuming is the accelerator input? but you are using T which you have declared as double T = 0.005; so your function will be always going forward at a static rate.

stealthcopter
T2 is the time duration of the movement (time between different samples of the accelerometer). For testing purposes I'm using a constant, but even using the real values, produces the same results.
mrlinx
Think more of your code is needed to understand the problem. Checked your not squaring the value and losing the sign?
stealthcopter