geeksville / Gaggle

An Android application for glider pilots
http://groups.google.com/group/gaggle-users/
33 stars 16 forks source link

G-Meter reporting phone orientation, not accelerometer forces. #39

Open DawsonLeBrown opened 13 years ago

DawsonLeBrown commented 13 years ago

Originating from http://groups.google.com/group/gaggle-users/browse_thread/thread/8537f1213c1899cc#

While holding the phone face up the G-meter shows 1.0, vertically 2.0 and face down 3.0.

This has been confirmed so far on

Samsung Galaxy S (Android 2.2) & HTC Hero (unknown Android version)

If anyone could confirm that this bug either does or doesn't exist on their phone, please reply below with your phone type & Android version.

com.geeksville.location.AccelerometerClient currently uses SensorManager.SENSOR_ACCELEROMETER (0x2) which is deprecated. When this is changed to Sensor.TYPE_ACCELEROMETER, the G meter behaves apropriately, but does not appear to be scaled correctly (It's very easy to get it to record 10G by just waving the phone around) I suspec that there is going to be more to it though, as android.hardware.SensorListener is also deprecated, and therefore a whole lot more engineering/experimentation may be needed.

It's also currently calculating the G force by just the side to side acceleration vector across the face of the phone.

To do this accurately, I suspect (I'm no expert here) that we'll need to do something like:

(Math.abs(xAccel_converted_To_G) + Math.abs(yAccelconverted_To_G) + Math.abs(zAccelconverted_To_G) - 1

This should give us (If my uneducated assumptions are correct) the G-Forces as experienced between the pilot and the wing. And avoid the need to account for phone orientation, which will be constantly changing during flight. Unfortunately, values[0], values[1] and values[2] with this algorithm after changing it to sue Sensor.TYPE_ACCELEROMETER doesn't appear to be correct either, as values array contains very different values to that which I was expecting.