卡尔曼滤波— 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 ...
随机推荐
- 创建本地yum软件源,为本地Package安装Cloudera Manager、Cloudera Hadoop及Impala做准备
一.包管理工具及CentOS的yum 1.包管理工具如何发现可以用的包 包管理工具依赖一系列软件源,工具下载源的信息存储在配置文件中,其位置随某包管理工具不同而变化 使用yum的RedHat/Cent ...
- 【MFC三天一个游戏】之 局域网黑白棋
欢迎加入我们的QQ群,无论你是否工作,学生,只要有c / vc / c++ 编程经验,就来吧!158427611 花了三天上班时间,妈的上班写就是不能静下心来,擦,要防BOSS巡山.... 以前也写过 ...
- mysql笔记05 优化服务器设置
优化服务器设置 1. MySQL有大量可以修改的参数--但不应该随便去修改.通常只需要把基本的项配置正确(大部分情况下只有很少一些参数时真正重要的),应将更多时间花在schema的优化.索引,以及查询 ...
- 由 "select *" 引发的“惨案”
今天凌晨做发布, 要合并多个分数据库的表数据到主数据库中, 有 30+ 分数据库. 前面都比较顺利, 在临近结束时,突然发现一个字段的值插入错误. 有一个表 T,字段分别为 (f1, f2, f3, ...
- DELPHI出现无法加载dclite50.bpl的解决办法(转)
现象: Borland Integrated Translation Environment 加载出错 解决办法: 我的电脑--->(鼠标右键)属性--->高级--->(性能)设置- ...
- linux内核中jiffies的回绕问题【转】
本文转载自:http://blog.csdn.net/yuanlulu/article/details/6019862 ======================================== ...
- mysql datetime设置now()无效,直接用程序设置默认值比较好
mysql datetime设置now()无效的,没有此用法,datetime类型不能设置函数式默认值,只能通过触发器等来搞.想设置默认值,只能使用timestamp类型,然后默认值设置为:CURRE ...
- TI BLE CC2541的SPI主模式
SPI就是用4条线来串行传输数据, 2541只能用模拟的方式用GPIO来做. //*********************************************************** ...
- Microsoft Office 2013 Product Key
Microsoft Office 2013 Product Key ( Professional Plus ) PGD67-JN23K-JGVWW-KTHP4-GXR9G B9GN2-DXXQC-9D ...
- Caused by: org.hibernate.HibernateException: Connection cannot be null when 'hibernate.dialect' not set
docs.jboss.org文档示例代码:(http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/) sta ...