Kalman-filtered GPS data is still fluctuating a lot

风流意气都作罢 提交于 2019-12-06 13:20:42

I see a few issues:

  • Your update() contains predict and update, but you also have a predict(), so you would be double-integrating velocity if you actually call predict() (you didn't include the outer loop).
  • There's some confusion as to whether your measurement is position or position and velocity. You can see comments claiming H=[1,0] and H=[1,1] (by which they probably meant H=[1,0;0,1]) Since the matrix math is hand-written, the assumption about the single measurement is baked into all of the matrix steps, but the code still tries to "measure" velocity as well.
  • For a KF which estimates velocity from positions, you do not want to inject synthetic velocity like that (as a first-order difference). Let that result occur naturally from the KF. For H=[1,0], you can see how K=PH'/S should have 2 rows, and both apply to y0. That will update both x0 and x1.

I didn't really check the matrix math other than to see what they had done with H. You should really develop this kind of algorithm with a nice matrix library (e.g. numpy, for Python, or Eigen for C++). That will save you a lot of code changes when you make trivial changes (e.g. if you want to experiment with a 2D filter) and avoid simple matrix math errors that will drive you mad. If you have to optimize to fully hand-written matrix operations, do it last so you can compare your results and verify your hand coding.

And finally, the other posts are entirely correct about your specific application: The GPS is already filtering the data, and one of the outputs is velocity.

Try this simple change:

float speed = location.getSpeed() x 4;

GPS location, delivered by the GPS receiver are already heavily Kalman filtered. If the locations are still jumping you cannot well solve that with a Kalman filter. The cause is that moving with a low speed does not well give stable positions and speed (and direction) Just remove all location under 10km/h and there will be no further need to any filtering.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!