一、粒子滤波简介
粒子滤波的基本思想是用随机样本来描述概率分布,然后在测量的基础上,通过调节各粒子权值的大小和样本的位置,来近似实际概率分布,并以样本的均值作为系统的估计值。
粒子滤波是指:通过寻找一组在状态空间中传播的随机样本对概率密度函数P(Xk|Zk)进行近似,以样本均值代替积分运算,从而获得状态最小方差估计的过程,这些样本即称为“粒子。采用数学语言描述如下:对于平稳的随机过程,假定k-1时刻系统的后验概率密度为P(Xk-1|Zk-1),依据一定原则选取n个随机样本点,k时刻获得测量信息后,经过状态和时间更新过程,n个粒子的后验概率密度可近似为P(Xk|Zk) 。随着粒子数目的增加,粒子的概率密度函数逐渐逼近状态的概率密度数,粒子滤波估计即达到了最优贝叶斯估计的效果。
粒子滤波的算法步骤如下:
粒子滤波的推导过程详见http://blog.csdn.net/heyijia0327/article/category/3245449
二、粒子滤波在机器人定位中的应用
from math import *
import random
# --------
#
# some top level parameters
#
max_steering_angle = pi / 4.0 # You do not need to use this value, but keep in mind the limitations of a real car.
bearing_noise = 0.1 # Noise parameter: should be included in sense function.
steering_noise = 0.1 # Noise parameter: should be included in move function.
distance_noise = 5.0 # Noise parameter: should be included in move function.
tolerance_xy = 15.0 # Tolerance for localization in the x and y directions.
tolerance_orientation = 0.25 # Tolerance for orientation.
# --------
#
# the "world" has 4 landmarks.
# the robot's initial coordinates are somewhere in the square
# represented by the landmarks.
#
# NOTE: Landmark coordinates are given in (y, x) form and NOT
# in the traditional (x, y) format!
landmarks = [[0.0, 100.0], [0.0, 0.0], [100.0, 0.0], [100.0, 100.0]] # position of 4 landmarks in (y, x) format.
world_size = 100.0 # world is NOT cyclic. Robot is allowed to travel "out of bounds"
# ------------------------------------------------
#
# this is the robot class
#
class robot:
# --------
# i