Automotive Vision_5 II Particle Filter(粒子滤波)

Kalman Filter is limited to linear gaussian models
Particle Filter has no model limitations but is more computational expensive
粒子滤波更加通用却更加耗算力
在这里插入图片描述
下面的图很好的解释了过程,通过几次过程就可以判断更为准确的位置
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

load('data_simple.mat');

% initialization
numParticles = 500;
initial_state_uncertainty = 4; % initial uncertainty: 4m
initial_state_cov_matrix = diag([initial_state_uncertainty^2 initial_state_uncertainty^2]);

% the particle set, the weight is supposed to be stored in the first column. Please define
% the remaining part of the particle set vector according to the task.
% initialization of particles
particles = pf_init (numParticles, initial_state_cov_matrix);

% preparation for simulation of particle filter
particle_sets = cell(numT + 1, 3);
particle_sets{1, 3} = particles;

% this vectors stores the list of estimated states (excluding the initial state). 
state_history = zeros(numT, 2);

% main loop of particle filter
for i = 1:numT
    particles_predicted = pf_predict(particles, delta_motion(i,:), noise_system);
    particles_updated = pf_update(particles_predicted, measurements(i,:), noise_meas);
    particles_resampled = pf_resample(particles_updated);
    particles = particles_resampled;
    
    % store the particle sets for the simulation
    particle_sets(i+1,:) = {particles_predicted, particles_updated, particles_resampled};    

    % store the estimated state after resampling for error analysis in 'state_history'
    state_history (i,:) = compute_particle_statistics (particles_updated);
end

% analyze the estimation error
mean_error = analyze_state_error(state_history, true_poses);

% simulate the particle filter
simulate_particle_filter(particle_sets, true_poses);

function particles = pf_init (numParticles, initial_state_cov_matrix)
% Create initial set of numParticles particles around 0 with random 
% deviation given by the covariance matrix initial_state_cov_matrix.
% Each particle should contain in its first column its weight and the 
% other columns its state.

particles = zeros(numParticles, 3);

% fill in your code below this line
particles (:,1) = 1/numParticles;%第一个是概率,w,都是一样的
particles (:,2:3) = mvnrnd([0 0], initial_state_cov_matrix, numParticles);%随机生成高斯分布点,x的坐标随机分布


end

function particles_pred = pf_predict(particles, delta_motion, noise_system)
particles_pred = zeros(size(particles));

% number of particles
num_particles = size(particles, 1);

% keep the weights during prediction
particles_pred(:,1) = particles(:,1);%w不变
% update the delta motion with noise
particles_pred(:,2:3) = particles(:,2:3) + repmat(delta_motion, num_particles, 1) + mvnrnd([0 0], noise_system, num_particles);%加入系统动态和噪声
%repmat重复矩阵
end
function particles_upd = pf_update(particles, measurement, noise_meas)
particles_upd = zeros(size(particles));

num_particles = size(particles, 1);

% the state variables are kept
particles_upd(:,2:3) = particles(:,2:3);%点位置不变

for i = 1:num_particles 
particles_upd(i,1) = particles(i,1) .* mvnpdf(measurement, particles(i,2:3), noise_meas);%w变化,加入了噪声,根据坐标以及测量值用高斯模型来修正w,所以是根据测量点的距离来判断w
end
function particles_resampled = pf_resample(particles)
particles_resampled = zeros(size(particles));
num_particles = size(particles, 1);
normalized_weights = particles(:,1) ./ sum(particles(:,1), 1);
%把weights和变成1再重新计算
% weights are distributed uniformly
particles_resampled(:,1) = repmat(1/num_particles, num_particles, 1);
%重新有同等weight的矩阵
% draw samples according to normalized weights,根据新的normalized_weights来计算各个粒子的分布。
indices = mnrnd(num_particles, normalized_weights);
cur_index = 1;
for i = 1:num_particles
    amount = indices(i);
    if (amount > 0)
        particles_resampled(cur_index:cur_index+amount-1, 2:3) = repmat(particles(i,2:3), amount, 1);
        cur_index = cur_index + amount;
    end
end

end

这个是一个一直再走直线的点,所以也没有感觉粒子有明显的变化

Robot Localization

这个代码跟上面其实比较类似,也是分了3步,不同的就是加入了一个面向角度,毕竟是机器人需要考虑面向
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
旅游社交小程序功能有管理员和用户。管理员有个人中心,用户管理,每日签到管理,景点推荐管理,景点分类管理,防疫查询管理,美食推荐管理,酒店推荐管理,周边推荐管理,分享圈管理,我的收藏管理,系统管理。用户可以在微信小程序上注册登录,进行每日签到,防疫查询,可以在分享圈里面进行分享自己想要分享的内容,查看和收藏景点以及美食的推荐等操作。因而具有一定的实用性。 本站后台采用Java的SSM框架进行后台管理开发,可以在浏览器上登录进行后台数据方面的管理,MySQL作为本地数据库,微信小程序用到了微信开发者工具,充分保证系统的稳定性。系统具有界面清晰、操作简单,功能齐全的特点,使得旅游社交小程序管理工作系统化、规范化。 管理员可以管理用户信息,可以对用户信息添加修改删除。管理员可以对景点推荐信息进行添加修改删除操作。管理员可以对分享圈信息进行添加,修改,删除操作。管理员可以对美食推荐信息进行添加,修改,删除操作。管理员可以对酒店推荐信息进行添加,修改,删除操作。管理员可以对周边推荐信息进行添加,修改,删除操作。 小程序用户是需要注册才可以进行登录的,登录后在首页可以查看相关信息,并且下面导航可以点击到其他功能模块。在小程序里点击我的,会出现关于我的界面,在这里可以修改个人信息,以及可以点击其他功能模块。用户想要把一些信息分享到分享圈的时候,可以点击新增,然后输入自己想要分享的信息就可以进行分享圈的操作。用户可以在景点推荐里面进行收藏和评论等操作。用户可以在美食推荐模块搜索和查看美食推荐的相关信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值