0 down vote favorite
share [fb] share [tw]

I am developing application for car acceleration tracking. I used
standard accelerometer, calibrating it in specific position before
start, than - considering phone's orientation is not changing -
logging accelerometer data for specified time and calculating move
parameters, one of them - car speed at the end of test. It works
almost good, on strait horizontal road - few percent mistake.

But then I found out, that in apl-level 10 there is virtual sensor
TYPE_LINEAR_ACCELERATION, and, as far as i understand, it must do what
i need: filter gravity, orientation changing - so i may use it and get
pure linear acceleration of mobile device. BUT in real life.. I made
simply application, that does little test:

//public class Accelerometer implements SensorEventListener { ...
public void onSensorChanged(SensorEvent se)
{
    if(!active)
        return;

    lastX = se.values[SensorManager.DATA_X];
    lastY = se.values[SensorManager.DATA_Y];
    lastZ = se.values[SensorManager.DATA_Z];
    long now = System.currentTimeMillis();
    interval = now - lastEvetn;
    lastEvetn = now;
    out.write(Float.toString(lastX) + ";" +
                    Float.toString(lastY) + ";" +
                    Float.toString(lastZ) + ";" +
                    Long.toString(interval) + "\n");
}

I bind listener with following parameters:

  mSensorManager.registerListener(linAcc,
 
mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION),
                SensorManager.SENSOR_DELAY_GAME);

It works OK, but when i analyze data dump, calculating speed like V =
V0 + AT, where V0 = 0 at first, then - speed of interval before this,
A = acceleration (SQRT (x*x+y*y+z*z)), t = time of interval, at the
end i get very little speed - three times less than real speed.
Changing Sensor type to TYPE_ACCELEROMETER, calibrating and using same
formula to calculate speed - i get good results, much close to
reality. So, the question is: what Sensor.TYPE_LINEAR_ACCELERATION
really shows? Where am I wrong, or something is wrong with
Sensor.TYPE_LINEAR_ACCELERATION realization? I use Samsung Nexus S
phone

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to