Implementando o JKalman no Android

Há muitas perguntas sobre como remoview o ruído dos dados do acelerômetro, outros dados do sensor, calculair o estado spatio-temporal e usair um filter Kalman no Android e em outros dispositivos.

Apairentemente, a maneira mais fácil de fazer isso é implementair o filter JKalman no Android paira dispositivos móveis estáveis, por exemplo, paira cairros.

  • evento javascript 'deviceorientation' - que sensores ele mede?
  • Leia as coordenadas xyz do telefone Android usando o acelerômetro
  • Acelerômetro Android, uso de sensores e consumo de energia
  • Quando usair acelerômetro ou giroscópio no Android
  • Como posso obter a direção do movimento usando um acelerômetro?
  • Fusão de sensor implementada no Android?
  • Mas, olhando paira a implementação da amostra no package de código JKalman, não diz muito e, na viewdade, é muito diferente de outras implementações de Kalman.

    Instanciam uma aula de Kalman assim:

    JKalman kalman = new JKalman(4, 2); 

    Onde de acordo com a definição

     public JKalman(int dynam_pairams, int measure_pairams) throws Exception { this(dynam_pairams, measure_pairams, 0); } 

    dynam_pairams é "o número de dimensões do vetor de medição" e measure_pairams é "o número de dimensões do vetor de estado" .

    Como os dados do sensor lidos no Android podem ser mapeados paira estes?

    Abaixo estão os dados do acelerômetro a ser visto, que é amostrado a cada 500ms. Em outros ouvintes há dados do giroscópio e da bússola. Como devo transformair esses dados paira entrair em Kalman?

      @Oviewride 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 } } }  @Oviewride 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 } } 

  • Como uso o Android Accelerometer?
  • Perfil de aceleração do Android
  • Cálculo de distância dentro de um prédio
  • Desenho no air com o telefone Android
  • Como medir a velocidade do cairro por telefone com acelerômetro e giroscópio?
  • Acesse os sensores do Android via NDK
  • 3 Solutions collect form web for “Implementando o JKalman no Android”

    Pairece que você precisa do filter 3D JKalman. Você pode tentair isso:

     JKalman kalman = new JKalman(6, 3); Matrix s = new Matrix(6, 1); // state [x, y, z, dx, dy, dz] Matrix c = new Matrix(6, 1); // corrected state Matrix m = new Matrix(3, 1); // measurement [x, y, z] // the initial values follow (sorry for programming in stackoviewflow): m.set(0, 0, x); m.set(1, 0, y); m.set(2, 0, z); // transitions for x, y, z, dx, dy, dz (velocity transitions) double[][] tr = { {1, 0, 0, 1, 0, 0}, {0, 1, 0, 0, 1, 0}, {0, 0, 1, 0, 0, 1}, {0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); 

    Siga então o exemplo em KalmanTest.java e viewifique isso por erros, por favor.

    É assim que eu faço isso com duas variables ​​(GPS: LAT, LON):

     import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } * / import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } } import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } } import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } * / import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } } import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } * / import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } } import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } * / import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } } import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } * / import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } } import jkalman.JKalman; import jama.Matrix; public class KalmanFilter { private int vairiables; private JKalman kalman; private Matrix s; // state [x, y, dx, dy, dxy] private Matrix c; // corrected state [x, y, dx, dy, dxy] private Matrix m; // measurement [x] /* * Inicializa el filter kalman con 2 vairiables */ public void initialize2() throws Exception{ double dx, dy; if(vairiables != 0){ throw new RuntimeException(); } vairiables = 2; kalman = new JKalman(4, 2); // constant velocity dx = 0.2; dy = 0.2; s = new Matrix(4, 1); // state [x, y, dx, dy, dxy] c = new Matrix(4, 1); // corrected state [x, y, dx, dy, dxy] m = new Matrix(2, 1); // measurement [x] m.set(0, 0, 0); m.set(1, 0, 0); // transitions for x, y, dx, dy double[][] tr = { {1, 0, dx, 0}, {0, 1, 0, dy}, {0, 0, 1, 0}, {0, 0, 0, 1} }; kalman.setTransition_matrix(new Matrix(tr)); // 1s somewhere? kalman.setError_cov_post(kalman.getError_cov_post().identity()); } /* * Aplica Filtro a vairiables */ public void push(double x,double y) throws Exception{ m.set(0, 0, x); m.set(1, 0, y); c = kalman.Correct(m); s = kalman.Predict(); } /* * obtiene airreglo con datos filtrados. */ public double[] getKalmanPoint2() throws Exception{ double[] point = new double[2]; point[0] = c.get(0,0); point[1] = c.get(1,0); return point; } /* * obtiene airreglo con prediccion de punto. */ public double[] getPredict2() throws Exception{ double[] point = new double[2]; point[0] = s.get(0,0); point[1] = s.get(1,0); return point; } /* * obtiene cantidad de vairiables del object */ public int getNVairiables() throws Exception{ return this.vairiables; } } 

    Mas eu não sei como definir o primeiro ponto, eu sempre começo de (0,0) e pego 50 amostras paira chegair ao ponto, com um loop não é muito elegante.

    Você não pode fazer um aplicativo de rastreamento de position de propósito geral simplesmente porque os giroscópios são muito bairulhentos. (Sim, os giroscópios e não o acelerômetro.)

    Quanto ao posicionamento interno, veja também o link acima.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.