Accelerometer Values from Android/iPhone device
Posted
by mrlinx
on Stack Overflow
See other posts from Stack Overflow
or by mrlinx
Published on 2010-04-23T03:25:29Z
Indexed on
2010/04/23
3:33 UTC
Read the original article
Hit count: 309
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:
© Stack Overflow or respective owner