views:

122

answers:

1

I'm using the Android SDK (2.2) with a Droid and I have access to the 3-axis accelerometer and gyrometer.

I apologize in advance if this reveals my ignorance of physics. It has been awhile.

What I don't understand is why the accelerometer is giving different x,y,z values when I tilt the phone. It's standing still, at least, with negligible acceleration and even mostly constant velocity, it's just tilted. I thought that this was the gyrometer's job?

I don't want gravity in the equation...I just want the other forces affecting the phone. Everything had better be 0,0,0 unless I'm moving it faster. I want to know how hard I hit the phone on the table, and the direction and magnitude of the x,y,z forces when I do so. So far, I am confused beyond belief about how to access this with the accelerometer and gyrometer data. I'm trying to take the gyrometer as the direction and the accelerometer as the magnitude. Unfortunately, the data for those aren't really in sync (I have to setup two events to get each pair of data, and they may come at different times), but it might be good enough to just buffer them and assume some sort of synchronization.

Desperate, Andrew

A: 

I'm afraid that's just how accelerometers work, here on earth there will always be 9.8 Gs pointing at the ground.

If you can assume that you have a working compass, just take a vector of length STANDARD_GRAVITY, rotate with the current orientation taken from the magnetometer and subtract this from your accelerometer's vector.

Keep in mind that you should also dampen the values you get back from the accelerometer, use a running average of the last few values.

Gaz Davidson
Thanks. Yeah, that was what I had in mind. Umm I was just a little unsure of the math and all. I'll probably post a follow-up when I have time to look at it. Basically I didn't know how to subtract the vectors. Like, would I just be subtracting a <0,0,-9.81> vector? No right? Because depending on tilt that -9.81m/s^2 could be in the x,y,z dirs too. But I don't know how to setup a vector for that given azimuth, pitch, and roll.
Andy Matteson
Sorry I edited my above post a lot.
Andy Matteson