卡尔曼滤波— Constant Velocity Model
假设你开车进入隧道,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信号丢失,不能直接测量汽车位置,则观测模型为:
卡尔曼滤波步骤如下图所示:
# -*- coding: utf-8 -*-
import numpy as np
import matplotlib.pyplot as plt # Initial State x0
x = np.matrix([[0.0, 0.0, 0.0, 0.0]]).T # Initial Uncertainty P0
P = np.diag([1000.0, 1000.0, 1000.0, 1000.0]) dt = 0.1 # Time Step between Filter Steps # Dynamic Matrix A
A = np.matrix([[1.0, 0.0, dt, 0.0],
[0.0, 1.0, 0.0, dt],
[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]]) # Measurement Matrix
# We directly measure the velocity vx and vy
H = np.matrix([[0.0, 0.0, 1.0, 0.0],
[0.0, 0.0, 0.0, 1.0]]) # Measurement Noise Covariance
ra = 10.0**2
R = np.matrix([[ra, 0.0],
[0.0, ra]]) # Process Noise Covariance
# The Position of the car can be influenced by a force (e.g. wind), which leads
# to an acceleration disturbance (noise). This process noise has to be modeled
# with the process noise covariance matrix Q.
sv = 8.8
G = np.matrix([[0.5*dt**2],
[0.5*dt**2],
[dt],
[dt]])
Q = G*G.T*sv**2 I = np.eye(4) # Measurement
m = 200 # 200个测量点
vx= 20 # in X
vy= 10 # in Y
mx = np.array(vx+np.random.randn(m))
my = np.array(vy+np.random.randn(m))
measurements = np.vstack((mx,my)) # Preallocation for Plotting
xt = []
yt = [] # Kalman Filter
for n in range(len(measurements[0])): # Time Update (Prediction)
# ========================
# Project the state ahead
x = A*x # Project the error covariance ahead
P = A*P*A.T + Q # Measurement Update (Correction)
# ===============================
# Compute the Kalman Gain
S = H*P*H.T + R
K = (P*H.T) * np.linalg.pinv(S) # Update the estimate via z
Z = measurements[:,n].reshape(2,1)
y = Z - (H*x) # Innovation or Residual
x = x + (K*y) # Update the error covariance
P = (I - (K*H))*P # Save states for Plotting
xt.append(float(x[0]))
yt.append(float(x[1])) # State Estimate: Position (x,y)
fig = plt.figure(figsize=(16,16))
plt.scatter(xt,yt, s=20, label='State', c='k')
plt.scatter(xt[0],yt[0], s=100, label='Start', c='g')
plt.scatter(xt[-1],yt[-1], s=100, label='Goal', c='r') plt.xlabel('X')
plt.ylabel('Y')
plt.title('Position')
plt.legend(loc='best')
plt.axis('equal')
plt.show()
汽车在隧道中的估计位置如下图:
参考
Improving IMU attitude estimates with velocity data
https://zhuanlan.zhihu.com/p/25598462
卡尔曼滤波— Constant Velocity Model的更多相关文章
- 卡尔曼滤波—Simple Kalman Filter for 2D tracking with OpenCV
之前有关卡尔曼滤波的例子都比较简单,只能用于简单的理解卡尔曼滤波的基本步骤.现在让我们来看看卡尔曼滤波在实际中到底能做些什么吧.这里有一个使用卡尔曼滤波在窗口内跟踪鼠标移动的例子,原作者主页:http ...
- (转) Deep Reinforcement Learning: Pong from Pixels
Andrej Karpathy blog About Hacker's guide to Neural Networks Deep Reinforcement Learning: Pong from ...
- Mini-project # 4 - "Pong"___An Introduction to Interactive Programming in Python"RICE"
Mini-project #4 - "Pong" In this project, we will build a version of Pong, one of the firs ...
- RootMotionComputer 根运动计算机
using UnityEngine; using System.Collections; /* * -------------------------------------------------- ...
- Framework for Graphics Animation and Compositing Operations
FIELD OF THE DISCLOSURE The subject matter of the present disclosure relates to a framework for hand ...
- Tracking without bells and whistles
Tracking without bells and whistles 2019-08-07 20:46:12 Paper: https://arxiv.org/pdf/1903.05625 Code ...
- [Elementary Mechanics Using Python-02]Feather in tornado
Problem 9.17 Feather in tornado. In this project you will learn to use Newton's laws and the force m ...
- [UE4]自定义MovementComponent组件
自定义Movement组件 目的:实现自定义轨迹如抛物线,线性,定点等运动方式,作为组件控制绑定对象的运动. 基类:UMovementComponent 过程: 1.创建UCustomMovement ...
- UIScrollview使用
改变内容偏移 - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; // animate at const ...
随机推荐
- IE浏览器相关的问题及解决方案[转]
seleniumquery和IE的司机 本网页是关于seleniumquery和IE(Internet Explorer)作为驱动/ WebDriver /浏览器. 首先,确保你检查internete ...
- COM编程之一 组件
[1]组件产生的背景 一个应用程序通常是由单个二进制文件组成的. 当应用程序版本发布后一般不会发生任何变化,对于操作系统.硬件以及客户需求的改变都必须要等到修复源代码后且整个应用程序被重新编译才可处理 ...
- linux设备驱动归纳总结(八):4.总线热插拔【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-110774.html linux设备驱动归纳总结(八):4.总线热插拔 xxxxxxxxxxxxxxx ...
- 前端开发自动化工作流工具,JavaScript自动化构建工具grunt、gulp、webpack介绍
前端开发自动化工作流工具,JavaScript自动化构建工具grunt.gulp.webpack介绍 前端自动化,这样的一个名词听起来非常的有吸引力,向往力.当今时代,前端工程师需要维护的代码变得及为 ...
- AJAX 数据库实例
AJAX 用于创建动态性更强的应用程序. AJAX ASP 实例 下面的例子将演示当用户在输入框中键入字符时,网页如何与服务器进行通信: 实例 请在下面的输入框中键入字母(A - Z): 姓名: 建议 ...
- SQLServer学习笔记<>sql的范围内查找,sql数据类型,字符串处理函数
sql的范围内查找 (1)between.....and用法 通常情况下我们查找一个在某固定区域内的所有记录,可以采用>=,<=来写sql语句,例如:查找订单价格在1000到2000之间的 ...
- js实现通用的微信分享组件示例
一.可定义的信息 1.分享时显示的LOGO:2.分享LOGO的宽度:3.分享LOGO的高度:4.分享出去显示的标题(默认调用网页标题):5.分享出去显示的描述(默认调用网页标题):6.分享链接(默认为 ...
- python怎么装模块
windows下 最简单的方法: File---Settings--Project ---Project Interpreter 下----点击 +号,输入你需要安装的模块名,点击Install P ...
- 杭电1013-Digitai Root(另解)
#include<stdio.h>#define maxsize 1000 int main(){ char N[maxsize+1]; int i,j,sum,n; c ...
- asp.net dropdownlist和listbox
if (!IsPostBack) { //页面初次加载时执行这里的内容 DataSet ds = new DataSet(); //数据集 ds.Tables.Add("stu") ...