There are lots of questions about removing the noise from accelerometer data, other sensor's data, calculating spatio-temporal state, and using a Kalman filter in Android and in other devices.
Apparently, the easiest way of doing this is implementing the JKalman filter on Android for stable moving devices for example for cars.
But looking at the sample implementation in JKalman code package, it doesn't say much and it is actually very different from other Kalman implementations.
They instantiate a Kalman class like this:
JKalman kalman = new JKalman(4, 2);
Where according to the definition
public JKalman(int dynam_params, int measure_params) throws Exception {
this(dynam_params, measure_params, 0);
}
dynam_params
is "the number of measurement vector dimensions" and measure_params
is "the number of state vector dimensions".
How should the sensor data read in Android be mapped to these?
Below is the data from accelerometer to be seen, that is sampled every 500ms. In other listeners there are data from gyroscope and compass. How should I transform this data to input to Kalman?
@Override
public void onSensorChanged(SensorEvent event) {
actualTime = System.currentTimeMillis();
if(actualTime - lastUpdateAcc < 500)
return;
else{
lastUpdateAcc = actualTime;
//update myPosition
TextView tv = (TextView)findViewById(R.id.textView3);
tv.setText(String.format("X: %8.4f -- Y: %8.4f -- Z: %8.4f",
event.values[0], event.values[1], event.values[2]));
//draw on the screen
//draw new path, if one exists
}
}