Skip to content

imaginelenses/kalmanMobile

Repository files navigation

Kalman Mobile

A tool to implement and understand Kalman Filters.

Kalman Mobile along with Kalman Desktop is a Server-Client pair that reads the accelerometer readings from an Android device and sends them over to a desktop application over websockets. Kalman Desktop then moves the cursor on the screen according to the change in acceleration of the mobile device.

Usage

  1. Download and install Kalman Mobile
  2. Provide camera access manually (TODO handle permissions)
  3. Download and run Kalman Desktop
  4. Scan the QR code shown fom Kalman Mobile
  5. Turn on or off the Move switch to move the cursor

Accelerometer Readings

A JSON containing acceleration along x, y and z in m/s2 and a timestamp in nanoseconds (time since the device has been on) is sent to Kalman Desktop.

    private final DecimalFormat f = new DecimalFormat("#0.000000");
    
    @Override
    public void onSensorChanged(SensorEvent event) {
        JSONObject data = new JSONObject();
        try {
            data.put("x", f.format(event.values[0]));
            data.put("y", f.format(event.values[1]));
            data.put("z", f.format(event.values[2]));
            data.put("timestamp", event.timestamp);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        
        socket.emit("move_event", data);
    }

Note

Kalman Mobile reads Sensor.TYPE_ACCELEROMETER and not Sensor.TYPE_ACCELEROMETER_UNCALIBRATED. Meaning it is bias compensated.

Websocket Compatibility

Server Client
Netty-socketio v1.7.19 Socket.IO-client Java v1.0.1

References for Kalman filter

License

GNU General Public License

App icon stolen from kalmanfilter.net