假设你开车进入隧道,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的更多相关文章

  1. 卡尔曼滤波—Simple Kalman Filter for 2D tracking with OpenCV

    之前有关卡尔曼滤波的例子都比较简单,只能用于简单的理解卡尔曼滤波的基本步骤.现在让我们来看看卡尔曼滤波在实际中到底能做些什么吧.这里有一个使用卡尔曼滤波在窗口内跟踪鼠标移动的例子,原作者主页:http ...

  2. (转) Deep Reinforcement Learning: Pong from Pixels

    Andrej Karpathy blog About Hacker's guide to Neural Networks Deep Reinforcement Learning: Pong from ...

  3. 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 ...

  4. RootMotionComputer 根运动计算机

    using UnityEngine; using System.Collections; /* * -------------------------------------------------- ...

  5. Framework for Graphics Animation and Compositing Operations

    FIELD OF THE DISCLOSURE The subject matter of the present disclosure relates to a framework for hand ...

  6. Tracking without bells and whistles

    Tracking without bells and whistles 2019-08-07 20:46:12 Paper: https://arxiv.org/pdf/1903.05625 Code ...

  7. [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 ...

  8. [UE4]自定义MovementComponent组件

    自定义Movement组件 目的:实现自定义轨迹如抛物线,线性,定点等运动方式,作为组件控制绑定对象的运动. 基类:UMovementComponent 过程: 1.创建UCustomMovement ...

  9. UIScrollview使用

    改变内容偏移 - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;  // animate at const ...

随机推荐

  1. 关于科台斯k97gprs调试记录(1)

    模块调试 1.gprs模块了解 用流量上网的模块,可以发短信,打电话. 2.AT指令的学习 AT+UART=波特率,流控位,数据位长度,校验控制,停止位长度 AT+NET=TCP/UDP 选择,APN ...

  2. Javascript与C#编码解码

    (一) Javascript与C#编码解码的对应关系 http://www.jb51.net/article/44062.htm 这篇文章主要是对JS与C#编码解码进行了详细的介绍,需要的朋友可以过来 ...

  3. ASP.NET MVC 返回JsonResult序列化内容超出最大限制报错的解决办法

    在使用MVC的时候我们经常会在Controller的Action方法中返回JsonResult对象,但是有时候你如果序列化的对象太大会导致JsonResult从Controller的Action返回后 ...

  4. TVideoGrabber如何并行处理多摄像头

    大家都知道 TVideoGrabber是一款支持包括C#..NET.VB.NET.C++.Delphi.C++Builder和ActiveX平台在内的视频处理控件,可以捕捉视频,也可以作为多媒体播放器 ...

  5. 为 Macbook 增加锁屏热键技巧

    第一步,找到“系统偏好设置”下的“安全性与隐私”,在“通用”页里勾上“进入睡眠或开始屏幕保护程序后立即要求输入密码”. 第二步,要用快捷键启动屏幕保护程序,相对复杂一点.在“应用程序”里找到“Auto ...

  6. UIScrollView的滚动位置设置

    1.如果手动设置滚动异常,可以从最小值到最大值,极限调试.最小值取一个,中间值取n个,最大值取一个.

  7. std::map 自定义排序

    PS:开发中难免会用到快速检索的数据结构-map , 很多时候map自身提供的排序不能满足我们的需要或者不支持我们自定的数据结构的排序,解决办法就是自己实现排序. 这里的小案例是:我们要经用户的has ...

  8. Android使用Application总结

    对于application的使用,一般是 在Android源码中对他的描述是; * Base class for those who need to maintain global applicati ...

  9. 【转载】perl接受传递参数的方法

    #! /usr/bin/perl use Getopt::Std;use warnings;use strict; sub read_from_sh($) { my $file = shift; my ...

  10. Java中Synchronized的用法

    原文:http://blog.csdn.net/luoweifu/article/details/46613015 作者:luoweifu 转载请标名出处 <编程思想之多线程与多进程(1)——以 ...