Path Planning Algorithm 3 Improved Artificial Potential Field Method (Matlab)

Table of contents

Traditional Artificial Potential Field

gravitational potential field

repulsive potential field

 force potential field

 Problems Existing in Traditional Artificial Potential Field Method

 Improved Artificial Potential Field Function

 Matlab code implementation


Reference link:

[1] Zhu Weida. Research on Vehicle Obstacle Avoidance Path Planning Based on Improved Artificial Potential Field Method [D]. Jiangsu University, 2017.

In 1986, Khatib first proposed the artificial potential field method and applied it in the field of robot obstacle avoidance. The basic idea of ​​this method is to construct an obstacle repulsive potential field around the obstacle and a gravitational potential field around the target point, which is similar to the electromagnetic field in physics. The controlled object is subjected to repulsive force and gravitational force in the composite field composed of these two potential fields. The resultant force of repulsive force and gravitational force guides the movement of the controlled object and searches for a collision-free obstacle avoidance path.

This method has a simple structure and is convenient for low-level real-time control. It has been widely used in real-time obstacle avoidance and smooth trajectory control. Its shortcomings lie in the existence of local optimal solutions, unreachable targets, and collisions with obstacles.

Traditional Artificial Potential Field

gravitational potential field

repulsive potential field

The factor that determines the obstacle repulsion potential field is the distance between the car and the obstacle. When the car does not enter the influence range of the obstacle, the potential energy value it receives is zero; after the car enters the influence range of the obstacle, the distance between the two The larger the distance, the smaller the potential energy value of the car, and the smaller the distance, the greater the potential energy value of the car.

 force potential field

insert image description here  + insert image description here

 Problems Existing in Traditional Artificial Potential Field Method

 Improved Artificial Potential Field Function

 

 Matlab code implementation

main main function

%main主函数
%created by MW
%date: 2023/2/28
%func: Artificial Potential Field(APF) avoiding obstacle
 
clc;
clear;
 
%% 创建并绘制障碍物
obstacle = [2 5;
            3 8;
            7 9;
            4 2;
            6 6;
            9 3];
figure(1);
scatter(obstacle(:,1),obstacle(:,2),'r')
axis equal;

%% 创建并绘制初始位置和目标位置
start = [0 0];
goal = [10 10];
hold on;
scatter(start(1),start(2),'filled','g');
scatter(goal(1),goal(2),'filled','g');
 
%% 图片标注
text(start(1),start(2),'起点');
text(goal(1),goal(2),'终点');
grid on;
axis equal;
axis([0 10 0 10]);
xlabel('x');
ylabel('y');
title('人工势场法生成避障路径')

%% 生成并绘制避障路径
path = APF2D(start, goal, obstacle);
hold on;
plot(path(:,1), path(:,2),'LineWidth',1,'Color','b');

The main function of the artificial potential field method:

function path = APF2D(start,goal,obstacle)
% Artificial Potential Field(APF)avoiding obstacle path
%%APF参数初始化
%如果不能实现预期目标,可能也与初始的增益系数,Po设置的不合适有关。
att = 35;%引力增益系数
req = 10;%斥力增益系数
p0 = 5;%障碍物产生影响的最大距离,当障碍与移动目标之间距离大于Po时,斥力为0。
step = 2;%步长
maxIter = 200;%最大循环迭代次数
n = length(obstacle(:,1));%障碍物个数

path = start;%路径初始化
newNode = start;
for i = 1:maxIter
    %% 引力计算
    V_att = goal - newNode;%路径点到目标点的向量
    r_att = sqrt(V_att(1)^2 + V_att(2)^2);%路径点到目标点的欧氏距离
    P_att = att * V_att;%引力
    
    %% 斥力计算
    %改进的人工势场法,将斥力分散一部分到引力方向。通过添加随机扰动r_att^n实现,r_att为路径点到目标点的欧氏距离,本文n取2。
    V_req = zeros(n,2);
    for j =1:n
        V_req(j,:) = [obstacle(j,1) - newNode(1), obstacle(j,2) - newNode(2)];%路径点到各个障碍物的向量
        r_req(j) = sqrt(V_req(j,1)* V_req(j,1) + V_req(j,2)* V_req(j,2));%路径点到各个障碍物的欧氏距离
    end   
    P_req = 0;
    for k = 1:n
        if r_req(k) <= p0
            P_req1 = req * (1 / r_req(k) - 1 / p0) * r_att^2 / r_req(k)^2;%斥力分量1:障碍物指向路径点的斥力
            P_req2 = req * (1 / r_req(k) - 1 / p0)^2 * r_att;%斥力分量2:路径点指向目标点的分引力
            P_reqk = P_req1 / r_req(k) * V_req(k,:) + P_req2 / r_att * V_att;%合力分散到x,y方向
            P_req = P_req + P_reqk;%斥力
        end     
    end
    %% 合力计算
    P = P_att + P_req;
    newNode = newNode + step * P / norm(P);
    path = [path; newNode];   
end

end

result:

It should be noted that the selection of gravity, repulsion gain, and step size will affect the result and can be adjusted appropriately.

In particular, the artificial potential field method is prone to fall into a local minimum, even if it is improved by adding an adjustment factor, it is still unavoidable in some cases. 

Guess you like

Origin blog.csdn.net/MWooooo/article/details/129149844