⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 slam_kf.m

📁 贝叶斯算法(matlab编写) 安装,添加目录 /home/ai2/murphyk/matlab/FullBNT
💻 M
字号:
% Plot how precision matrix changes over time for KF solutionseed = 0;rand('state', seed);randn('state', seed);[A,B,C,Q,R,Qbig,Rbig,init_x,init_V,robot_block,landmark_block,...	  true_landmark_pos, true_robot_pos, true_data_assoc, ...	  obs_rel_pos, ctrl_signal] = mk_linear_slam(...	      'nlandmarks', 6, 'T', 12, 'ctrl', 'leftright', 'data-assoc', 'cycle');figure(1); clfhold onfor i=1:nlandmarks  %text(true_landmark_pos(1,i), true_landmark_pos(2,i), sprintf('L%d',i));  plot(true_landmark_pos(1,i), true_landmark_pos(2,i), '*')endhold off[x, V] = kalman_filter(obs_rel_pos, A, C, Qbig, Rbig, init_x, init_V, ...				     'model', true_data_assoc, 'u', ctrl_signal, 'B', B);est_robot_pos = x(robot_block, :);est_robot_pos_cov = V(robot_block, robot_block, :);for i=1:nlandmarks  bi = landmark_block(:,i);  est_landmark_pos(:,i) = x(bi, T);  est_landmark_pos_cov(:,:,i) = V(bi, bi, T);endif 0figure(1); hold onfor i=1:nlandmarks  h=plotgauss2d(est_landmark_pos(:,i), est_landmark_pos_cov(:,:,i));  set(h, 'color', 'r')endhold offhold onfor t=1:T  h=plotgauss2d(est_robot_pos(:,t), est_robot_pos_cov(:,:,t));  set(h,'color','r')  h=text(est_robot_pos(1,t), est_robot_pos(2,2), sprintf('R%d', t));  set(h,'color','r')endhold offendP = zeros(size(V));for t=1:T  P(:,:,t) = inv(V(:,:,t));endif 0  figure(2)  for t=1:T    subplot(T/2,2,t)    imagesc(P(1:2:end,1:2:end, t))    colorbar  endelse  figure(2)  for t=1:T    subplot(T/2,2,t)    imagesc(V(1:2:end,1:2:end, t))    colorbar  endend% marginalize out robot position and then check structurebi = landmark_block(:);V = V(bi,bi,T); P = inv(V);P(1:2:end,1:2:end)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -