假设你开车进入隧道,GPS信号丢失,现在我们要确定汽车在隧道内的位置。汽车的绝对速度可以通过车轮转速计算得到,汽车朝向可以通过yaw rate sensor(A yaw-rate sensor is a gyroscopic device that measures a vehicle’s angular velocity around its vertical axis. )得到,因此可以获得X轴和Y轴速度分量Vx,Vy

首先确定状态变量,恒速度模型中取状态变量为汽车位置和速度:

根据运动学定律(The basic idea of any motion models is that a mass cannot move arbitrarily due to inertia):

由于GPS信号丢失,不能直接测量汽车位置,则观测模型为:

卡尔曼滤波步骤如下图所示:

 1 # -*- coding: utf-8 -*-
 2 import numpy as np
 3 import matplotlib.pyplot as plt
 4
 5 # Initial State x0
 6 x = np.matrix([[0.0, 0.0, 0.0, 0.0]]).T
 7
 8 # Initial Uncertainty P0
 9 P = np.diag([1000.0, 1000.0, 1000.0, 1000.0])
10
11 dt = 0.1 # Time Step between Filter Steps
12
13 # Dynamic Matrix A
14 A = np.matrix([[1.0, 0.0, dt, 0.0],
15               [0.0, 1.0, 0.0, dt],
16               [0.0, 0.0, 1.0, 0.0],
17               [0.0, 0.0, 0.0, 1.0]])
18
19 # Measurement Matrix
20 # We directly measure the velocity vx and vy
21 H = np.matrix([[0.0, 0.0, 1.0, 0.0],
22               [0.0, 0.0, 0.0, 1.0]])
23
24 # Measurement Noise Covariance
25 ra = 10.0**2
26 R = np.matrix([[ra, 0.0],
27               [0.0, ra]])
28
29 # Process Noise Covariance
30 # The Position of the car can be influenced by a force (e.g. wind), which leads
31 # to an acceleration disturbance (noise). This process noise has to be modeled
32 # with the process noise covariance matrix Q.
33 sv = 8.8
34 G = np.matrix([[0.5*dt**2],
35                [0.5*dt**2],
36                [dt],
37                [dt]])
38 Q = G*G.T*sv**2
39
40 I = np.eye(4)
41
42 # Measurement
43 m = 200 # 200个测量点
44 vx= 20  # in X
45 vy= 10  # in Y
46 mx = np.array(vx+np.random.randn(m))
47 my = np.array(vy+np.random.randn(m))
48 measurements = np.vstack((mx,my))
49
50 # Preallocation for Plotting
51 xt = []
52 yt = []
53
54
55 # Kalman Filter
56 for n in range(len(measurements[0])):
57
58     # Time Update (Prediction)
59     # ========================
60     # Project the state ahead
61     x = A*x
62
63     # Project the error covariance ahead
64     P = A*P*A.T + Q
65
66
67     # Measurement Update (Correction)
68     # ===============================
69     # Compute the Kalman Gain
70     S = H*P*H.T + R
71     K = (P*H.T) * np.linalg.pinv(S)
72
73     # Update the estimate via z
74     Z = measurements[:,n].reshape(2,1)
75     y = Z - (H*x)                            # Innovation or Residual
76     x = x + (K*y)
77
78     # Update the error covariance
79     P = (I - (K*H))*P
80
81
82     # Save states for Plotting
83     xt.append(float(x[0]))
84     yt.append(float(x[1]))
85
86
87 # State Estimate: Position (x,y)
88 fig = plt.figure(figsize=(16,16))
89 plt.scatter(xt,yt, s=20, label='State', c='k')
90 plt.scatter(xt[0],yt[0], s=100, label='Start', c='g')
91 plt.scatter(xt[-1],yt[-1], s=100, label='Goal', c='r')
92
93 plt.xlabel('X')
94 plt.ylabel('Y')
95 plt.title('Position')
96 plt.legend(loc='best')
97 plt.axis('equal')
98 plt.show()

汽车在隧道中的估计位置如下图:

参考

Improving IMU attitude estimates with velocity data

https://zhuanlan.zhihu.com/p/25598462

转载于:https://www.cnblogs.com/21207-iHome/p/5274819.html

卡尔曼滤波— Constant Velocity Model相关推荐

  1. 半轴CVJ(constant velocity joint)

    半轴(Driver Shaft)也叫驱动轴(CVJ,CV joint,constant velocity joint)是将差速器与驱动轮连接起来的轴.半轴是变速箱减速器与驱动轮之间传递扭矩的轴,其内外 ...

  2. jenkins换服务器找不到包,服务器重启后Jenkins项目部分丢失问题解决方法

    UVALive 4670 Dominating Patterns --AC自动机第一题 题意:多个模板串,一个文本串,求出那些模板串在文本串中出现次数最多. 解法:AC自动机入门模板题. 代码: #i ...

  3. 卡尔曼滤波滤波方程_了解卡尔曼滤波器及其方程

    卡尔曼滤波滤波方程 Before getting into what a Kalman filter is or what it does, let's first do an exercise. O ...

  4. 卡尔曼滤波的细致讲解从一维到多维

    卡尔曼滤波的细致讲解从一维到多维 还是去看原文吧:原文 python代码实现: # vim: expandtab:ts=4:sw=4 import numpy as np import scipy.l ...

  5. 目标跟踪:卡尔曼滤波(Kalman Filter)到底是怎么工作的?

    Kalman filter到底是怎么工作的? 本文主要参考的文章:https://www.bzarg.com/p/how-a-kalman-filter-works-in-pictures/,图片也基 ...

  6. deepsort原理快速弄懂——时效比最高的

    主要转载自:https://www.cnblogs.com/liuboblog/p/12105473.html 分模块的代码参考:https://zhuanlan.zhihu.com/p/908352 ...

  7. 目标跟踪初探(DeepSORT)

    点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达本文转自|AI算法与图像处理 简述 本文首先将介绍在目标跟踪任务中常 ...

  8. 多目标跟踪方法 A Baseline for 3D Multi-Object Tracking

    多目标跟踪方法 A Baseline for 3D Multi-Object Tracking (感谢前辈)转自:https://zhuanlan.zhihu.com/p/80993033 本文对论文 ...

  9. MOT学习 - SORT算法

    paper:https://arxiv.org/abs/1602.00763 code:https://github.com/open-mmlab/mmtracking https://github. ...

最新文章

  1. kd-tree理论以及在PCL 中的代码的实现
  2. iOS开发之--TableViewCell重用机制避免重复显示问题
  3. python使用matplotlib可视化线图(line plot)、使用arrow函数在matplotlib可视化图像中添加箭头(drawing arrows in matplotlib)
  4. python可以做什么项目-Python可以做大项目吗?
  5. 基于 MATLAB 的 PCM 编码解码实现
  6. 百度Android定位API使用指南
  7. 【vue】---vue中使用async+await出现的问题及解决方案
  8. linux-centos6.5一键安装 Redmine
  9. 15 年工龄的阿里P9职场历程自述
  10. java 文件比对(四)-- 使用 diffutils
  11. C# MessageBox 确定|取消
  12. 激活剂、天梯与火石:从ASC 19解读产学结合的关键密码
  13. vue html模板递归,vue使用递归组件实现多级列表
  14. servu用户信息如何导出_用户如何增强信息安全防护意识
  15. IM软件中的语音录制与播放【iOS】
  16. PPT导出高清图片,提高图片分辨率
  17. 使用scala将数据写入linux上的MongoDB数据库
  18. udk开发-稀里糊涂
  19. 美国把一名俄罗斯黑客告上法庭 4年前曾入侵LinkedIn
  20. cad,3dmax,vray,photoshop

热门文章

  1. linux7 kernel.sem,centos7.4内核调优,tcp单服务器万级并发
  2. laravel mysql save 后 查看 受影响行数_swoft2教程系列-mysql模型
  3. python 无头模式 绕过检测_Python chrome 无头模式的问题
  4. linux mysql 5.7.12_Linux环境mysql5.7.12安装教程
  5. linux下date -d,linux date -d的一些用法
  6. python 写脚本 预约课程_Python盘纪念币系列之三:自动预约脚本编写 03 系列总结...
  7. fragment中文网_更新 · React Native 中文网
  8. 系统怎么手动打补丁_韩国服务器不稳定怎么办?
  9. windows用 tree命令查看目录文件夹结构
  10. C语言:随笔11--文件操作