#include "otosKalmanFilter.h"

// Kalmam filters for x, y axes (heading handled by the IMU)
otosKalmanFilter xKf(1e-8, 1e-6, 1e-4);
otosKalmanFilter yKf(1e-8, 1e-6, 1e-4);
//otosKalmanFilter hKf(1e-10, 1e-7, 1e-1);

void setup() {
  // put your setup code here, to run once:

  Serial.begin(115200);
}

int32_t last_time = 0;

void loop() {
  float vx = (analogRead(A0) - 512) + random(0,20); // generate speed with measurement error

  int32_t dt = micros() - last_time * 1000000;
  
  xKf.predict(dt);
  //yKf.predict(dt);

  xKf.updateVel(vx, 6e-3);
  //yKf.updateVel(vy, 6e-3 * registerSignalProcess->enVar);

  Serial.print(xKf.xData[0]); Serial.print("\t");
  Serial.print(xKf.xData[1]); Serial.print("\t");

  Serial.println();
}