粒子滤波和蒙特卡洛定位
算法主要过程如下:
1.根据观测更新粒子权重
2.根据权重resample,也就是根据权重更新所有粒子位置,并使得所有粒子权重恢复到一样。
3.利用一个模型让所有粒子随着robot的移动而移动。
无公式解释粒子滤波(需要FQ) : https://www.youtube.com/watch?v=aUkBa1zMKv4
蒙特卡洛定位(继续FQ):https://www.youtube.com/watch?v=eAqAFSrTGGY
其中无公式解释粒子滤波的MATLAB开源代码如下:
1 function [] = PF () 2 % Just call PF (without any arguments) to run the animation 3 % 4 % This is the matlab code behind the movie "Particle Filter Explained 5 % without Equations", which can be found at http://youtu.be/aUkBa1zMKv4 6 % Written by Andreas Svensson, October 2013 7 % Updated by Andreas Svensson, February 2013, fixing a coding error in the 8 % 'propagation-update' of the weights 9 % andreas.svensson@it.uu.se 10 % http://www.it.uu.se/katalog/andsv164 11 % 12 % The code is provided as is, and I take no responsibility for what this 13 % code may do to you, your computer or someone else. 14 % 15 % This code is licensed under a 16 % Creative Commons Attribution-ShareAlike 3.0 Unported License. 17 % http://creativecommons.org/licenses/by-sa/3.0/ 18 19 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 20 %%% Setup and initialization %%% 21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 22 23 % Setting the random seed, so the same example can be run several times 24 s = RandStream('mt19937ar','Seed',1); 25 RandStream.setGlobalStream(s); 26 27 % Some unceratinty parameters 28 measurementNoiseStdev = 0.1; speedStdev = 1; 29 30 % Speed of the aircraft 31 speed = 1; 32 % Set starting position of aircraft 33 planePosX = -25; planePosY = 4; 34 35 % Some parameters for plotting the particles 36 m = 1000; k = 0.0001; 37 38 % Number of particles 39 N = 200; 40 41 % Some variables for plotting 42 plotVectorSea = -10:0.01:10; 43 plotVectorMountains = [-40:0.01:-10.01, 10.01:0.01:40]; 44 plotHeight = 5; 45 46 % The function describing the ground 47 ground = @(x) (x>=10).*((1-(x-10)/30).*sin(x-10)+((x-10)/30).*sin(1.5*(x-10))+0.2.*(x-10).*(x<=20)+2*(x>20))+... 48 (x<=-10).*((1-(-x-10)/30).*sin(-x-10)+((-x-10)/30).*sin(1.5*(-x-10))+0.2.*(-x-10).*(x>=-20)+2*(x<-20)); 49 50 % Plot the environment 51 area(plotVectorMountains,ground(plotVectorMountains),-1,'FaceColor',[0 0.6 0]) 52 set(gca,'XTick',[]); set(gca,'YTick',[]); hold on 53 area(plotVectorSea,ground(plotVectorSea),-1,'FaceColor',[0 0 0.8]); axis([-40 40 -1 10]) 54 plane = plotPlane(planePosX,planePosY,1); 55 measurementLine = line([planePosX planePosX],[ground(planePosX),planePosY],'Color',[1 0 0],'LineStyle',':'); 56 pause(1) 57 58 59 %%%%%%%%%%%%%%%%%%%%%%% 60 %%% Begin filtering %%% 61 %%%%%%%%%%%%%%%%%%%%%%% 62 63 % Generate particles 64 particles = rand(N,1)*80-40; 65 66 % Plot particles 67 particleHandle = scatter(particles,plotHeight(ones(size(particles))),m*(1/N*ones(N,1)+k),'k','filled'); 68 pause(1) 69 70 FirstRun = 1; 71 72 % Initialize particle weights 73 w = 1/N*ones(N,1); 74 75 for t = 1:60 76 % Generate height measurements (with gaussian measurement noise) 77 planeMeasDist = planePosY - ground(planePosX) + randn*measurementNoiseStdev; 78 79 % Evaluate measurements (i.e., create weights) using the pdf for the normal distribution 80 w = w.*(1/(sqrt(2*pi)*measurementNoiseStdev)*exp(-((planePosY-ground(particles))-planeMeasDist).^2/(2*measurementNoiseStdev^2))); 81 82 % Normalize particle weigths 83 w = w/sum(w); 84 85 if FirstRun 86 87 % Sort out some particles to evaluate them "in public" the first 88 % run (as in the movie) 89 [~, order] = sort(w,'descend'); 90 pmax = order(1); 91 pmaxi = setdiff(1:N,pmax); 92 delete(particleHandle) 93 particleHandle = scatter([particles(pmaxi);particles(pmax)],plotHeight(ones(size(particles))),m*([ones(N-1,1)/N;w(pmax)]+k),'k','filled'); 94 pause(1) 95 96 pmax2 = order(2); 97 pmaxi2 = setdiff(pmaxi,pmax2); 98 delete(particleHandle) 99 particleHandle = scatter([particles(pmaxi2);particles(pmax);particles(pmax2)],plotHeight(ones(size(particles))),m*([ones(N-2,1)/N;w(pmax);w(pmax2)]+k),'k','filled'); 100 pause(1) 101 102 % Plot all weighted particles 103 delete(particleHandle) 104 particleHandle = scatter(particles,plotHeight(ones(size(particles))),m*(w+k),'k','filled'); 105 pause(1) 106 end 107 108 % Resample the particles 109 u = rand(N,1); wc = cumsum(w); 110 [~,ind1] = sort([u;wc]); ind=find(ind1<=N)-(0:N-1)'; 111 particles=particles(ind,:); w=ones(N,1)./N; 112 113 delete(particleHandle); 114 particleHandle = scatter(particles,plotHeight(ones(size(particles))),m*(w+k),'k','filled'); 115 pause(1) 116 117 % Time propagation 118 speedNoise = speedStdev*randn(size(particles)); 119 particles = particles + speed + speedNoise; 120 121 % Update weights 122 % w = w, since the update in the previous step is done using our motion model, so the 123 % information is already contained in that update. 124 125 % Move and plot moved aircraft 126 planePosX = planePosX + speed; 127 delete(plane); delete(measurementLine) 128 plane = plotPlane(planePosX,planePosY,1); 129 measurementLine = line([planePosX planePosX],[ground(planePosX),planePosY],'Color',[1 0 0],'LineStyle',':'); 130 131 if FirstRun 132 % Plot updated particles 133 delete(particleHandle) 134 particleHandle = scatter(particles,plotHeight(ones(size(particles))),m*(w+k),'k','filled'); 135 pause(1) 136 end 137 138 FirstRun = 0; 139 end 140 end 141 142 function [ h ] = plotPlane( xpos,ypos,fignr ) 143 figure(fignr) 144 145 X = xpos - 0.6 + [-1, -0.1, -0.09, 0.3, 0.7, 0.8, 0.7, 0.3, -0.09, -0.1, -1]; 146 Y = ypos + [-0.05, -0.05, -0.4, -0.05, -0.05,0 0.05, 0.05, 0.4, 0.05, 0.05]; 147 h = fill(X,Y,'k'); 148 end
View Code
转载于:https://www.cnblogs.com/wellp/p/9320548.html
粒子滤波和蒙特卡洛定位相关推荐
- 机器人学习--粒子滤波SLAM/MCL定位参考资料+学习经验
学习材料1: <概率机器人学> 谷歌无人驾驶之父 Sebastian Thrun等人著作. 注释: 可能是本人智商有限,或者是移动机器人学领域的基础知识了解不多. 刚刚看这本书的时候,尤其 ...
- 粒子滤波用于机器人定位
粒子滤波用于机器人定位 0.引言 1.里程计 1.1.里程计模型 1.2.里程计运动模型 2.二维激光雷达的观测模型 2.1.光束模型 2.2.似然场模型 3.重采样 4.滤波结果 5.数据集 0.引 ...
- 机器人学习--粒子滤波及其在定位中的应用
前提基础,先看一下 贝叶斯滤波 和 蒙特卡洛方法 一.什么是粒子滤波? 这里有个基于粒子滤波的物体跟踪 案例说明: 参考:基于粒子滤波的物体跟踪 - yangyangcv - 博客园 如果还是看不懂 ...
- 机器人学习--粒子滤波/MCL定位的理论基础(先验知识)
跨学科(未学过数理统计和滤波等课程)的研究人员看懂粒子滤波或MCL定位的理论 2019年剑桥大学一名教授 Simon Godsill 发表了一篇论文: Godsill S. Particle filt ...
- 【目标定位】基于matlab粒子滤波的定位算法【含Matlab源码 2161期】
一.基于粒子滤波污染源定位简介 粒子滤波定位算法是目前最精准定位可移动物体的位置,由于水域的流动,工业固体废物污染源很可能随着水流移动位置,基于粒子滤波算法将污染物定位分为预测.测量以及重新采样可大大 ...
- 粒子滤波实现物体跟踪
转自http://www.cnblogs.com/cfantaisie/archive/2011/06/16/2082267.html 粒子滤波实现物体跟踪的算法原理: 1)初始化阶段-提取跟踪目标特 ...
- 基于粒子滤波的物体跟踪
一直都觉得粒子滤波是个挺牛的东西,每次试图看文献都被复杂的数学符号搞得看不下去.一个偶然的机会发现了Rob Hess(http://web.engr.oregonstate.edu/~hess/)实现 ...
- OpenCV3学习(12.5) opencv实现粒子滤波目标跟踪
OpenCV高版本已经把粒子滤波的CV方面的condensation算法给去掉了,以前学的condensation算法不能用C++开发还是只能用C版本,(OpenCV3学习(12.4) 粒子滤波Con ...
- 卡尔曼滤波和粒子滤波
整篇转自:https://blog.csdn.net/zkl99999/article/details/46619771/ 转自http://blog.csdn.net/karen99/article ...
最新文章
- linux无法解析主机地址(could not resolve host)解决办法
- Java、Scala和Go语言多线程并发对比测试
- 操作系统(5) -- 输入/输出管理
- JSF和“立即”属性–命令组件
- VC2013 代码图,依赖项关系图,等出错解决办法.
- 疑似小米11 Pro保护壳曝光:横向矩阵相机设计
- 通过Git进行分支管理
- MySQL——优化ORDER BY语句
- Android获取前台进程的方法
- 金蝶中间层服务器组件注册使用信任方式,提示:用户名或密码错误
- go语言for循环break、continue高级用法
- 育儿心得,所有适龄女青年都该看一下(转)
- Java开发中OnlyOffice、OpenOffice和LibreOffice怎么选?
- cascader 动态加载 回显_elementUI的cascader级联选择控件的默认值(回显)问题
- linux编译blas,CBLAS编译安装与使用举例
- 咸鱼前端—CSS高级技巧
- 【python】自动填写问卷星问卷及提交
- bootloader的作用
- 生成1至10位随机数
- android编译集成dialer应用,Comet Android Dialer
热门文章
- shell编程(连载)
- 20175234 2018-2019-2 个人项目:数字黑洞
- 」北京有名恁地一个 水浒传
- swagger不显示接口的可能性
- ajax 导致 css 延迟_腾讯START云游戏《英雄联盟》的Mac 轻体验:延迟较高时会卡顿 - 游戏 - IT商业网...
- 【实验技术笔记】细胞表型检测之细胞粘附(细胞粘附实验) + 细胞侵袭(transwell实验)
- ipad iphone开发_如何在iPhone,iPad或Mac上进行FaceTime通话
- java地图文件的编辑器_地图编辑器的选择1
- 我的世界java怎么放药水_药水/Java版1.9前
- CC00276.CloudKubernetes——|KuberNetes中间件容器化及helm.V23|——|中间件.v03|helm.v3.5.4|集群测试|