本文主要是介绍【路径规划】基于matlab GUI粒子群算法机器人避障路径规划(手动设障)【含Matlab源码 924期】,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
✅博主简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,Matlab项目合作可私信。
🍎个人主页:海神之光
🏆代码获取方式:
海神之光Matlab王者学习之路—代码获取方式
⛳️座右铭:行百里者,半于九十。
更多Matlab仿真内容点击👇
Matlab图像处理(进阶版)
路径规划(Matlab)
神经网络预测与分类(Matlab)
优化求解(Matlab)
语音处理(Matlab)
信号处理(Matlab)
车间调度(Matlab)
⛄一、简介
1 粒子群算法的概念
粒子群优化算法(PSO:Particle swarm optimization) 是一种进化计算技术(evolutionary computation)。源于对鸟群捕食的行为研究。粒子群优化算法的基本思想:是通过群体中个体之间的协作和信息共享来寻找最优解.
PSO的优势:在于简单容易实现并且没有许多参数的调节。目前已被广泛应用于函数优化、神经网络训练、模糊系统控制以及其他遗传算法的应用领域。
2 粒子群算法分析
2.1基本思想
粒子群算法通过设计一种无质量的粒子来模拟鸟群中的鸟,粒子仅具有两个属性:速度和位置,速度代表移动的快慢,位置代表移动的方向。每个粒子在搜索空间中单独的搜寻最优解,并将其记为当前个体极值,并将个体极值与整个粒子群里的其他粒子共享,找到最优的那个个体极值作为整个粒子群的当前全局最优解,粒子群中的所有粒子根据自己找到的当前个体极值和整个粒子群共享的当前全局最优解来调整自己的速度和位置。下面的动图很形象地展示了PSO算法的过程:
2 更新规则
PSO初始化为一群随机粒子(随机解)。然后通过迭代找到最优解。在每一次的迭代中,粒子通过跟踪两个“极值”(pbest,gbest)来更新自己。在找到这两个最优值后,粒子通过下面的公式来更新自己的速度和位置。
公式(1)的第一部分称为【记忆项】,表示上次速度大小和方向的影响;公式(1)的第二部分称为【自身认知项】,是从当前点指向粒子自身最好点的一个矢量,表示粒子的动作来源于自己经验的部分;公式(1)的第三部分称为【群体认知项】,是一个从当前点指向种群最好点的矢量,反映了粒子间的协同合作和知识共享。粒子就是通过自己的经验和同伴中最好的经验来决定下一步的运动。以上面两个公式为基础,形成了PSO的标准形式。
公式(2)和 公式(3)被视为标准PSO算法。
3 PSO算法的流程和伪代码
⛄二、部分源代码
function varargout = PSM(varargin)
% PSM MATLAB code for PSM.fig
% PSM, by itself, creates a new PSM or raises the existing
% singleton*.
%
% H = PSM returns the handle to a new PSM or the handle to
% the existing singleton*.
%
% PSM(‘CALLBACK’,hObject,eventData,handles,…) calls the local
% function named CALLBACK in PSM.M with the given input arguments.
%
% PSM(‘Property’,‘Value’,…) creates a new PSM or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before PSM_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to PSM_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE’s Tools menu. Choose “GUI allows only one
% instance to run (singleton)”.
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help PSM
% Last Modified by GUIDE v2.5 22-May-2021 21:08:35
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct(‘gui_Name’, mfilename, …
‘gui_Singleton’, gui_Singleton, …
‘gui_OpeningFcn’, @PSM_OpeningFcn, …
‘gui_OutputFcn’, @PSM_OutputFcn, …
‘gui_LayoutFcn’, [] , …
‘gui_Callback’, []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% — Executes just before PSM is made visible.
function PSM_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to PSM (see VARARGIN)
% Choose default command line output for PSM
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes PSM wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% — Outputs from this function are returned to the command line.
function varargout = PSM_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% — Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton5 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
s=[0 0];%起点位置
g=[0 100];%目标点起始位置
axis([-20 120 -20 120]);
axis equal;
hold on;
axis off;
fill([-20,120,120,-20],[-20 -20 120 120],‘y’)%填充动图区域
text(-5,-5,’ Start’,‘FontSize’,12);%设定起点标识
fill([95,120,120,95],[-20 -20 10 10],‘w’)%设定说明区域
text(100,5,‘Notes:’,‘FontSize’,12)
plot(101,-5,‘sb’,‘markerfacecolor’,‘b’);
text(101,-5,’ Robot’,‘FontSize’,12);
plot(101,-15,‘om’,‘markerfacecolor’,‘m’);
text(101,-15,’ Ball’,‘FontSize’,12);
plot(0,0,‘bs’)%起点处小车填充
car=plot(0,0,‘sb’,‘markerfacecolor’,‘b’);
object=plot(0,100,‘om’,‘markerfacecolor’,‘m’);%目标起点处填充
but=1;%十字光标初始化
x_obs=1;
y_obs=1;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% — Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uiresume;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% — Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uiwait;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% — Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
uiresume;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% — Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%%%%%%%%%%%%%%%%%%绘制障碍%%%%%%%%%%%%%%%%%%
s=[0 0];%起点位置
g=[0 100];%目标起始位置
axis([-20 120 -20 120]);
axis equal;
hold on;
axis off;
fill([-20,120,120,-20],[-20 -20 120 120],‘y’)%填充动图区域
text(-5,-5,’ Start’,‘FontSize’,12);%设定起点标识
fill([95,120,120,95],[-20 -20 10 10],‘w’)%设定说明区域
text(100,5,‘Notes:’,‘FontSize’,12)
plot(101,-5,‘sb’,‘markerfacecolor’,‘b’);
text(101,-5,’ Robot’,‘FontSize’,12);
plot(101,-15,‘om’,‘markerfacecolor’,‘m’);
text(101,-15,’ Ball’,‘FontSize’,12);
plot(0,0,‘bs’)%起点处小车填充
car=plot(0,0,‘sb’,‘markerfacecolor’,‘b’);
object=plot(0,100,‘om’,‘markerfacecolor’,‘m’);%目标起点处填充
but=1;%十字光标初始化
x_obs=1;
y_obs=1;
num_obs=1;
%%%%%%%%%%%%%%开始检测光标%%%%%%%%%%%%%%%%
while but == 1
[x_obs,y_obs,but] = ginput(1);
if but==1
m_Obs(num_obs,:)=[x_obs y_obs];%储存障碍的中心点坐标
m_ObsR(num_obs)=3;
Theta=0:pi/20:pi;
xx =m_Obs(num_obs,1)+cos(Theta)*m_ObsR(num_obs);
yy= m_Obs(num_obs,2)+sin(Theta)m_ObsR(num_obs);
fill(xx,yy,‘w’)
Theta=pi:pi/20:2pi;
xx =m_Obs(num_obs,1)+cos(Theta)*m_ObsR(num_obs);
yy= m_Obs(num_obs,2)+sin(Theta)*m_ObsR(num_obs);
fill(xx,yy,‘k’)
num_obs=num_obs+1;
end
end %End of While loop
num_obs=num_obs-1;
uiwait;
%%%%%%%%%%%%%%%等待演示命令%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%定义全局变量%%%%%%%%%%%%%
%%%%粒子群的%%%%
global c1; %学习因子1
global c2; %学习因子2
global w; %惯性权重
global MaxDT; %最大迭代次数
global m; %搜索空间维数(未知数个数)
global N; %初始化群体个体数目
global eps; %设置精度(在已知最小值时候用)
global Kmax; %初始化x时用的最大迭代次数
global Qmax; %初始化x时粒子全部重新初始化用的最大迭代次数
global fitw1; %适应值函数中的两个权重
global fitw2;
global pathta ; %移动的角度为60度
global psosued; %粒子群成功
global pathsued; %路径可行
%%%%%%%%%%%%%%%%%路径规划%%%%%%%%%%%%%%%%%%%%%%%
⛄三、运行结果
⛄四、matlab版本及参考文献
1 matlab版本
2014a
2 参考文献
[1]王学武,严益鑫,丁冬雁,顾幸生.基于Lévy-PSO算法的焊接机器人避障路径规划[J].上海交通大学学报. 2016,50(10)
3 备注
简介此部分摘自互联网,仅供参考,若侵权,联系删除
🍅 仿真咨询
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化
2 机器学习和深度学习方面
卷积神经网络(CNN)、LSTM、支持向量机(SVM)、最小二乘支持向量机(LSSVM)、极限学习机(ELM)、核极限学习机(KELM)、BP、RBF、宽度学习、DBN、RF、RBF、DELM、XGBOOST、TCN实现风电预测、光伏预测、电池寿命预测、辐射源识别、交通流预测、负荷预测、股价预测、PM2.5浓度预测、电池健康状态预测、水体光学参数反演、NLOS信号识别、地铁停车精准预测、变压器故障诊断
3 图像处理方面
图像识别、图像分割、图像检测、图像隐藏、图像配准、图像拼接、图像融合、图像增强、图像压缩感知
4 路径规划方面
旅行商问题(TSP)、车辆路径问题(VRP、MVRP、CVRP、VRPTW等)、无人机三维路径规划、无人机协同、无人机编队、机器人路径规划、栅格地图路径规划、多式联运运输问题、车辆协同无人机路径规划、天线线性阵列分布优化、车间布局优化
5 无人机应用方面
无人机路径规划、无人机控制、无人机编队、无人机协同、无人机任务分配
6 无线传感器定位及布局方面
传感器部署优化、通信协议优化、路由优化、目标定位优化、Dv-Hop定位优化、Leach协议优化、WSN覆盖优化、组播优化、RSSI定位优化
7 信号处理方面
信号识别、信号加密、信号去噪、信号增强、雷达信号处理、信号水印嵌入提取、肌电信号、脑电信号、信号配时优化
8 电力系统方面
微电网优化、无功优化、配电网重构、储能配置
9 元胞自动机方面
交通流 人群疏散 病毒扩散 晶体生长
10 雷达方面
卡尔曼滤波跟踪、航迹关联、航迹融合
这篇关于【路径规划】基于matlab GUI粒子群算法机器人避障路径规划(手动设障)【含Matlab源码 924期】的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!