Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Using Kalman filter from Java, Is there a working example?

I read the Java API docs, other then the constructor there are only to methods and one of them takes no input. This should be easy because there is not much you CAN do but I don't get results.

A very minimal "hello world" type working example in Java would be great.

Here is what I think you do..

KalmanFilter kf  = new KalmanFilter(3, 4);
Mat state        = new MatOfDouble(3,1);    // (x, y, h)
Mat measurement  = new MatOfDouble(4,1);    // (odoX, odoY, odoH, compassH)    

while(1){
      //stuff new sensor data into "measurements"

      // call these to methods
      kf.correct(measurement);
      state = kf.predict();

      // pull predicted state from "state"
    }

correct() does produce a return value but it's not clear what and correct() take no input