✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab仿真内容点击👇
⛄ 内容介绍
路径规划问题是移动机器人导航研究中的基本和关键的课题,机器人根据某一性能指标自主地搜索出一条从起始状态到目标状态的最优或次优无碰撞路径。许多路径规划算法在环境先验信息已知情况下能够良好地规划出路径,但在未知环境特别是存在各种不规则障碍的复杂环境中,很多算法很可能失去效用。随着移动机器人复杂性提高与应用范围增大,对路径规划的要求也逐渐增高,局部规划应用受到传统规划方法的制约。本文对人工势场法展开研究,分析传统人工势场的局限性,对改进人工势场法进行探讨,提出一种新的改进人工势场算法,提高局部路径规划算法的适用性与规划效率。本文基于人工势场(APF)算法、Vortex APF 算法、Safe APF 算法和动态窗口实现机器人路径规划。
⛄ 部分代码
clc
clear all
close all
% Initial position and orientation
x = -0.5;
y = 0.5;
theta = 0;
% Goal position
x_goal = 3.5;
y_goal = 2.75;
position_accuracy = 0.1;
% Sampling period
dT = 0.1;
% Generate obstacles
Obstacle_count = 10;
angles = linspace(0, 2*pi, 360)';
obstacle = zeros(Obstacle_count, length(angles), 2);
c = zeros(Obstacle_count,2);
r = zeros(Obstacle_count,1);
for i=1:Obstacle_count
while 1
c(i,:) = 4*rand(1,2) - 1;
r(i) = 0.25*rand() + 0.15;
if norm([x y] - c(i,:)) > (r(i) + 0.35) && norm([x_goal y_goal] - c(i,:)) > (r(i) + 0.35)
if i == 1, break; end
[idx, dist] = dsearchn([c(1:(i-1),1) c(1:(i-1),2)], c(i,:));
if dist > (r(idx)+r(i)+0.1)
break;
end
end
end
obstacle(i,:,:) = [r(i) * cos(angles)+c(i,1) r(i)*sin(angles)+c(i,2) ];
end
% Simulation
simTimeMax = 600;
APF = ArtificialPotentialField(x, y, theta, x_goal, y_goal, position_accuracy, obstacle, dT, simTimeMax);
SAPF = SafeArtificialPotentialField(x, y, theta, x_goal, y_goal, position_accuracy, obstacle, dT, simTimeMax);
DWA = DynamicWindowApproach(x, y, theta, x_goal, y_goal, position_accuracy, obstacle, dT, simTimeMax);
VAPF = VortexArtificialPotentialField(x, y, theta, x_goal, y_goal, position_accuracy, obstacle, dT, simTimeMax);
% Plot it
figure(1);
cla; hold on; grid on; box on;
daspect([1 1 1]);
xlim([-1,4]); ylim([-1 3]);
box on; hold on;
plot(DWA.X(1:DWA.t), DWA.Y(1:DWA.t), 'Color',[0.8500 0.3250 0.0980], 'LineWidth', 2); % Plot traveled path
plot(APF.X(1:APF.t), APF.Y(1:APF.t), 'Color',[0 0.4470 0.7410], 'LineWidth', 2); % Plot traveled path
plot(VAPF.X(1:VAPF.t), VAPF.Y(1:VAPF.t), 'Color',[0.4660 0.6740 0.1880], 'LineWidth', 2); % Plot traveled path
plot(SAPF.X(1:SAPF.t), SAPF.Y(1:SAPF.t), 'Color',[0.6350 0.0780 0.1840], 'LineWidth', 2); % Plot traveled path
plot(x_goal, y_goal, 'xg');
for i=1:Obstacle_count
plot(obstacle(i,:,1), obstacle(i,:,2), '-r');
end
legend('DWA', 'APF', 'VAPF', 'SAPF', 'Location','best');
drawnow;
⛄ 运行结果
⛄ 参考文献
[1] 李昶威, 甘屹, 孙福佳,等. 基于蝙蝠算法-人工势场的机器人路径规划研究[J]. 制造业自动化, 2021, 043(002):76-81.
[2] 蔡鑫伟, 侯向辉, 莫清宇,等. 面向群组机器人路径规划的Voronoi-APF算法研究[J]. 小型微型计算机系统, 2021.
[3] 许源. 结合粒子群算法和改进人工势场法的移动机器人混合路径规划[D]. 浙江大学, 2013.
[4] 白园, 刘婵, 何健辉. 基于APF算法的无人机动态航迹规划研究及仿真[J]. 通信技术, 2018, 51(8):8.
[5] O. Khatib, “Real-time obstacle avoidance for manipulators and mobile robots,” in Proceedings. 1985 IEEE International Conference on Robotics and Automation, vol. 2. IEEE, 1985, pp. 500–505
[6] X. Yun and K.-C. Tan, “A wall-following method for escaping local minima in potential field based motion planning,” in 1997 8th International Conference on Advanced Robotics. Proceedings. ICAR’97. IEEE, 1997, pp. 421–426
[7]D. Fox, W. Burgard, and S. Thrun, “The dynamic window approach to collision avoidance,” IEEE Robotics & Automation Magazine, vol. 4, no. 1, pp. 23–33, 1997.