【路径规划】基于改进动态窗口法DWA实现机器人动态避障matlab源码含 GUI
发布日期:2021-05-04 12:56:13 浏览次数:11 分类:技术文章

本文共 9579 字,大约阅读时间需要 31 分钟。

一、简介

DWA算法全称为dynamic window approach,其原理主要是在速度空间(v,w)中采样多组速度,并模拟这些速度在一定时间内的运动轨迹,再通过一个评价函数对这些轨迹打分,最优的速度被选择出来发送给下位机。

1 原理分析
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
2 速度采样

机器人的轨迹运动模型有了,根据速度就可以推算出轨迹。

因此只需采样很多速度,推算轨迹,然后评价这些轨迹好不好就行了。
(一)移动机器人受自身最大速度最小速度的限制
(二) 移动机器人受电机性能的影响:由于电机力矩有限,存在最大的加減速限制,因此移动机器人軌迹前向模拟的周期sim_period内,存在一个动态窗口,在该窗口内的速度是机器人能够实际达到的速度:
(三) 基于移动机器人安全的考虑:为了能够在碰到障碍物前停下来, 因此在最大减速度条件下, 速度有一个范围。

二、源代码

function varargout = Simulate(varargin)clcSamplingPeriod = 0.1;time = 0;timer1 = [];txt_timer = [];FuzzyLoaded = 0;Z1 = [];Z2 = [];W_Zone = 20;H_Zone = 20;data = importdata ('fuzzytabledata.mat');OUT1 = data.OUT1;OUT2 = data.OUT2;Z1 = reshape(OUT1(102:end,1)',101,[]);Z2 = reshape(OUT2(102:end,1)',101,[]);FuzzyLoaded = 1;scrsz = get(0,'ScreenSize');% Create a figure that will have a uitable, axes and checkboxesfigure('Position',[15*scrsz(3)/100 70 scrsz(3)-2*(15*scrsz(3)/100) scrsz(4)-100],...       'WindowStyle', 'normal',...       'CloseRequestFcn',{@CloseFcn},...       'Name', '具有动态障碍物的DWA仿真',...  % Title figure       'NumberTitle', 'off') % Do not show figure number   % figure('Position',[15*scrsz(3)/100 70 scrsz(3)-2*(15*scrsz(3)/100) scrsz(4)-100],...%        'WindowStyle', 'normal',...%        'CloseRequestFcn',{@CloseFcn},...%        'Name', '具有动态障碍物的DWA仿真',...  % Title figure%        'NumberTitle', 'off',... % Do not show figure number%        'MenuBar', 'none');      % Hide standard menu bar menus% Create an axes set x and y limits to the value extremes, and format labelsW_Zone = ceil(W_Zone/10)*10;H_Zone = ceil(H_Zone/10)*10;haxes = axes('Units', 'normalized',...             'Position', [.25 .05 0.75 0.9],...             'XLim', [-W_Zone/2 W_Zone/2],...             'YLim', [-H_Zone/2 H_Zone/2],...             'XLimMode', 'manual',...             'YLimMode', 'manual',...             'XTick',-W_Zone/2:1:W_Zone/2,...             'YTick',-H_Zone/2:1:H_Zone/2);%,...%              'XTickLabel',...%              {'-10 m','-5 m','0','5 m','10 m'},...%              'YTickLabel',...%              {'-10 m','-5 m','0','5 m','10 m'});set(haxes,'DataAspectRatio',[1 1 1]);title(haxes, '移动机器人动态避障仿真')   % Describe data set% Prevent axes from clearing when new lines or markers are plottedhold(haxes, 'all')grid on;uicontrol('Style', 'pushbutton',...          'Units', 'normalized',...          'Position', [.02 .86 .2 .05],...          'String', '开始仿真',...          'Value', 0,...          'Callback', {@StartSimulation});uicontrol('Style', 'pushbutton',...          'Units', 'normalized',...          'Position', [.02 .81 .2 .05],...          'String', '重新仿真',...          'Value', 0,...          'Callback', {@ResetSimulation});% % Create a text to show timer;txt_timer = uicontrol('Style', 'text',...            'Units', 'normalized',...            'Position', [.02 .915 .2 .035],...            'FontWeight', 'bold',...            'ForegroundColor', [0 .2 .8],...            'fontname', 'Helvetica',...            'fontsize', 14,...            'BackgroundColor', 'w', 'String','00:00 00');      % % Create some texts to monitor variables;txt_inp1 = uicontrol('Style', 'text', 'Units', 'normalized', 'Position', [.05 .54 .08 .035],...            'FontWeight', 'bold', 'ForegroundColor', [0 0 0], 'fontname', 'Helvetica', 'fontsize', 12, 'BackgroundColor', [0.9 0.9 0.9]);txt_inp2 = uicontrol('Style', 'text', 'Units', 'normalized', 'Position', [.14 .54 .08 .035],...            'FontWeight', 'bold', 'ForegroundColor', [0 0 0], 'fontname', 'Helvetica', 'fontsize', 12, 'BackgroundColor', [0.9 0.9 0.9]);txt_out1 = uicontrol('Style', 'text', 'Units', 'normalized', 'Position', [.05 .47 .08 .035],...            'FontWeight', 'bold', 'ForegroundColor', [0 0 0], 'fontname', 'Helvetica', 'fontsize', 12, 'BackgroundColor', [0.9 0.9 0.9]);txt_out2 = uicontrol('Style', 'text', 'Units', 'normalized', 'Position', [.14 .47 .08 .035],...            'FontWeight', 'bold', 'ForegroundColor', [0 0 0], 'fontname', 'Helvetica', 'fontsize', 12, 'BackgroundColor', [0.9 0.9 0.9]);uicontrol('Style', 'text','Units', 'normalized', 'Position', [.05 .61 .15 .025],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 10,...            'BackgroundColor', [0.8 0.8 0.8], 'String', 'DWA权值调整');        uicontrol('Style', 'text','Units', 'normalized', 'Position', [.00 .55 .05 .02],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 9,...            'BackgroundColor', [0.8 0.8 0.8], 'String', 'INPs :');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.00 .48 .05 .02],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 9,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '误差值 :');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.05 .58 .08 .02],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 9,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '目标航向角');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.14 .58 .08 .02],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 9,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '障碍物');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.05 .51 .08 .02],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 9,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '左偏离');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.14 .51 .08 .02],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 9,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '右偏离');        uicontrol('Style', 'text','Units', 'normalized', 'Position', [.09 .78 .12 .025],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 10,...            'BackgroundColor', [0.8 0.8 0.8], 'String', 'X             Y');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.02 .74 .06 .03],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 10,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '起始点坐标:');uicontrol('Style', 'text','Units', 'normalized', 'Position', [.02 .7 .06 .03],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 10,...            'BackgroundColor', [0.8 0.8 0.8], 'String', '  目标点坐标:');        % % Create a text get Robot X0 Pos;edit_robot_x0 = uicontrol('Style', 'edit',...            'Units', 'normalized',...            'Position', [.09 .74 .06 .035],... %'String',... %'Use Plot check boxes to graph columns',...            'FontWeight', 'bold',...            'fontname', 'Helvetica',...            'fontsize', 12);% % Create a text get Robot Y0 Pos;edit_robot_y0 = uicontrol('Style', 'edit',...            'Units', 'normalized',...            'Position', [.16 .74 .06 .035],... %'String',... %'Use Plot check boxes to graph columns',...            'FontWeight', 'bold',...            'fontname', 'Helvetica',...            'fontsize', 12);        % % Create a text get Goal X Pos;edit_goal_x = uicontrol('Style', 'edit',...            'Units', 'normalized',...            'Position', [.09 .7 .06 .035],... %'String',... %'Use Plot check boxes to graph columns',...            'FontWeight', 'bold',...            'fontname', 'Helvetica',...            'fontsize', 12);% % Create a text get Goal Y Pos;edit_goal_y = uicontrol('Style', 'edit',...            'Units', 'normalized',...            'Position', [.16 .7 .06 .035],... %'String',... %'Use Plot check boxes to graph columns',...            'FontWeight', 'bold',...            'fontname', 'Helvetica',...            'fontsize', 12);uicontrol('Style', 'pushbutton',...          'Units', 'normalized',...          'Position', [.09 .655 .13 .04],... %'TooltipString', 'Update Values Independently',...          'String', '更新',...          'Value', 0,...          'Callback', {@UpdateParams});slider_x = uicontrol('Style', 'slider','Units', 'normalized', 'Position', [.02 .41 .2 .025],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 10,...            'BackgroundColor', [0.8 0.8 0.8],'Min',0,'Value',1,'Max',2,'SliderStep',[0.01 0.1]);slider_y = uicontrol('Style', 'slider','Units', 'normalized', 'Position', [.02 .37 .2 .025],...            'FontWeight', 'bold', 'fontname', 'Helvetica', 'fontsize', 10,...            'BackgroundColor', [0.8 0.8 0.8],'Min',0,'Value',1,'Max',2,'SliderStep',[0.01 0.1]);      % uicontrol('Style', 'pushbutton',...%           'Units', 'normalized',...%           'Position', [0.35 .95 .25 .05],... %'TooltipString', 'Update Values Independently',...%           'String', 'Save Data',...%           'Value', 0,...%           'Callback', {@SaveData});% % Create an invisible marker plot of the data and save handles% % to the lineseries objects; use this to simulate data brushing.% % hmkrs = plot([1:10],[1:10].^2, 'LineStyle', 'none',...% %                     'Marker', 'o',...% %                     'MarkerFaceColor', 'y',...% %                     'HandleVisibility', 'off',...% %                     'Visible', 'on');% Create three check boxes to toggle plots for columns% uicontrol('Style', 'checkbox',...%           'Units', 'normalized',...%           'Position', [.10 .96 .09 .035],...%           'TooltipString', 'Check to plot column 1',...%           'String', 'Col 1',...%           'Value', 0,...%           'Callback', {@plot_callback,1});% % % Create a text label to say what the checkboxes do% uicontrol('Style', 'text',...%           'Units', 'normalized',...%           'Position', [.025 .955 .06 .035],...%           'String', 'Plot',...%           'FontWeight', 'bold');

三、运行结果

在这里插入图片描述

在这里插入图片描述

四、备注

完整代码或者代写添加QQ 1575304183

转载地址:https://blog.csdn.net/qq_34763204/article/details/116379741 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:【人脸识别】基于PCA+LDA实现人脸识别matlab 源码
下一篇:【路径规划】基于改进动态窗口DWA算法机器人静态避障matlab源码

发表评论

最新留言

做的很好,不错不错
[***.243.131.199]2024年03月01日 13时24分44秒

关于作者

    喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!

推荐文章

java国际化bundle_java语言国际化--ResouceBundle、struts 2019-04-21
java图片延迟加载_jQuery实现图片延迟加载 2019-04-21
java开发加入购物车功能_java web开发——购物车功能实现 2019-04-21
Java虚拟机不能满足_深入理解Java虚拟机--读书笔记1/3 2019-04-21
python 协程 asyncio_python – asyncio.as_completed是否会产生期货或协同程序? 2019-04-21
java设定xml文件的encoding_配置web-xml解决中文乱码问题,及各种乱码问题集结 2019-04-21
hanlp java api_java分词工具hanlp介绍 2019-04-21
nginx php 源码安装,Nginx1.12.2加php7.2.0的编译安装 2019-04-21
php 删除字节,php – 删除无效/不完整的多字节字符 2019-04-21
php 实现版本号对比,如何在PHP中实现比较版本号 2019-04-21
php sql 给数据库追加内容,php如何向数据库中的某串数据后追加内容【急】 2019-04-21
php微信小程序获取用户信息,微信小程序授权获取用户详细信息openid的实例详解... 2019-04-21
Java三元运算和if,Java三元运算符与<JDK8兼容性中的if / else 2019-04-21
graphql-php enum,php – 如何在不写长查询的情况下查询所有的GraphQL类型字段? 2019-04-21
php date 函数用法,php中date()日期时间函数使用方法 2019-04-21
php除法获取整数和余数,PHP除法取整和取余数 2019-04-21
java迷宫路径,Java中的迷宫路径查找器 2019-04-21
php substr cnblog,php中substr用法示例 2019-04-21
php链接怎么截取,PHP 截取网页中的固定种子链接 2019-04-21
iis运行不起来php报500,解决IIS上安装thinkphp6运行报500错误 2019-04-21