当前位置: 首页 > news >正文

基于粒子群优化算法的无人机路径规划与轨迹算法的实现(Matlab代码实现)

💥💥💥💞💞💞欢迎来到本博客❤️❤️❤️💥💥💥

🏆博主优势:🌞🌞🌞博客内容尽量做到思维缜密,逻辑清晰,为了方便读者。

⛳️座右铭:行百里者,半于九十。

目录

💥1 概述

📚2 运行结果

🎉3 参考文献

👨‍💻4 Matlab代码实现

💥1 概述

     随着科学与技术的发展,因体积小和飞行速度快,军用和民用无人机已经得到了广泛的应用。无人机的智能化是目前无人机发展的主要发展方向之一,而无人机三维路径规划是无人机智能化的重要部分,也是智能控制和决策方向研究的热点。无人机三维路径规划是指在如地形、规避地方雷达武器和满足可飞行条件等约束条件下,在不同的三维环境中寻找一个从起点到达终点的最优路径。近年来,国内外大量研究人员对提高无人机路径规划的航行效率展开研究。研究发现,通过引入优化算法可以有效地提高无人机的路径规划能力且具有较好的稳定性。

📚2 运行结果

部分代码:

clc
clear all
close all

%%
%----------------------------------------------------------------
%Map params
%----------------------------------------------------------------
reduce_path_generated = true;

width = 6;
height = 6;
resolution = 0.01;

% prm param
nodes = 1500;
ConnectionDistance = 1;

%param to draw circles
ang=0:0.01:2*pi;
r_ext=0.75; % 0.7 if we use the line
r_int = 0.6 ;
xp_ext=r_ext*cos(ang);
yp_ext=r_ext*sin(ang);
xp_int=r_int*cos(ang);
yp_int=r_int*sin(ang);

% key points
trans = [3 3];
start = [-1.5 -1.5] + trans;
goal_1 = [0 2] + trans;
goal_2 = [1.5 -1.5] + trans;

% constraint circle at point B
r_constraint_circle = 0.3;
x_constraint_circle = 3;
y_constraint_circle = 4.5;

%%
%----------------------------------------------------------------
%Read obstacle data
%----------------------------------------------------------------
obs_fileID = fopen('obs','r');
obs_format = '%f %f';
obs_size = [2 inf];
obs = fscanf(obs_fileID, obs_format, obs_size);
num_obs = length(obs);

% transform coordinates
%  X = -Y
%  Y =  X
obs_exg = obs ;
obs(1,:) = -obs_exg(2,:) ;
obs(2,:) = obs_exg(1,:) ;
obs = obs + 3;

%%
%----------------------------------------------------------------
%Map Creation
%----------------------------------------------------------------
map = robotics.BinaryOccupancyGrid(width,height,1/resolution)
map_check = robotics.BinaryOccupancyGrid(width,height,1/resolution)

% populate obstacle
for obs_i = 1:length(obs)
    setOccupancy(map, obs(:, obs_i)', 1);
    setOccupancy(map_check, obs(:, obs_i)', 1);
end
inflate(map,.75);
inflate(map_check,.6);

% constraint_circle
x = (0:resolution/1.1:width);
y = (0:resolution/1.1:height);

for i = 1:(1.1*width/resolution)
    for j = 1:(1.1*height/resolution)
        if sqrt((x(i)- x_constraint_circle)^2+(y(j)-y_constraint_circle-resolution/2)^2) < r_constraint_circle ...
        && y(j) > y_constraint_circle+0.5*r_constraint_circle
            setOccupancy(map, [x(i) y(j)], 1)
        end
    end
end

figure
show(map)

%%
%------------------------------------------------------------------
%PRM
%------------------------------------------------------------------
planner = robotics.PRM(map,nodes);
planner.ConnectionDistance = ConnectionDistance;
planner

path1 = findpath(planner,start,goal_1);
figure()
show(planner)
print('prm_ptA_ptB','-dpng');
path2 = findpath(planner,goal_1,goal_2);
figure()
show(planner)
print('prm_ptB_ptC','-dpng');
grid on


path = vertcat(start,path1(4:end-2,1:end),goal_1,path2(3:end-2,1:end),goal_2);

figure('Name', 'Path Generated');
plot(path(:,1),path(:,2), 'o'); hold on;
for i = 1: num_obs
    plot(obs(1,i)+xp_ext,obs(2,i)+yp_ext,'--k');
    plot(obs(1,i)+xp_int,obs(2,i)+yp_int,'-r');
end;
axis([0 6 0 6])
pbaspect([1 1 1])
print('path_generated','-dpng');
hold off ;

% find the index of point b
for i=1:length(path)
    if (path(i,:) == goal_1)
        ptb_idx = i ;
    end
end

%%
%------------------------------------------------------------------
%Path Point Reduction
%------------------------------------------------------------------

if (reduce_path_generated == false)
    clearvars -except map_check path obs num_obs ptb_idx
    return;
end

tol = 0.1 ;
i = 1 ; % index of first path
j = 3 ; % index of path two ahead
distance_ok = true ;

while (distance_ok)
    if (j > length(path))
        path(i+1:j-2,:) = [] ;
        distance_ok = false ;
    elseif ((max(max(point_to_line_distance([path(i+1:j-1, :), zeros(j-i-1,1)], ...
            [path(i,:), 0], [path(j,:), 0] )))>tol )...             % check point to line
            || min(path(j-1,:) == goal_1)...                        % don't remove if it's point B
            || check_path_collision(map_check, path(i,:), path(j-1,:)))   % check for collision
        path(i+1:j-2,:) = [] ;
        i = i+1 ;
        j = i+2 ;
    else
        j = j+1 ;
    end
end

% update the index of point b
for i=1:length(path)
    if (path(i,:) == goal_1)
        ptb_idx = i ;
    end
end

figure('Name', 'Path Reduced')
plot(path(:,1),path(:,2), 'o'); hold on;
for i = 1: num_obs
    plot(obs(1,i)+xp_ext,obs(2,i)+yp_ext,'--k');
    plot(obs(1,i)+xp_int,obs(2,i)+yp_int,'-r');
end;
axis([0 6 0 6])
pbaspect([1 1 1])
print('path_reduced','-dpng');
hold off ;

clearvars -except map_check path obs num_obs ptb_idx

🎉3 参考文献

[1]王小璐,黄辰,于远航,陈福豪,胡蝶,陆琪,崔曦予.基于适应度值优劣粒子群算法的无人机路径规划[J].电子制作,2022,30(16):16-19.DOI:10.16589/j.cnki.cn11-3571/tn.2022.16.005.

[2]赵志,段炼,路东林,张杨,邱雪.基于蚁群算法的无人机三维路径规划与冲突解脱[J].航空计算技术,2022,52(04):33-37.

👨‍💻4 Matlab代码实现

相关文章:

  • Spring Cloud基本介绍
  • 【目标检测】使用TensorRT加速YOLOv5
  • python数据分析及可视化(九)pandas数据规整(分组聚合、数据透视表、时间序列、数据分析流程)
  • 到了30岁,我才有了深刻的感悟:千万不要一辈子靠技术生存
  • 过滤器和拦截器的区别
  • i.MX 6ULL 驱动开发 十九:RGBLCD
  • 前端谷歌浏览器基本介绍及前后端分离原理分析
  • Day12-尚品汇-trade静态组件
  • 十大排序算法(java实现万字详解)
  • Qt文档阅读笔记-Hello Speak Example
  • 【Golang开发面经】知乎(两轮技术面)
  • 1024程序员节:从关注自身健康开始
  • 负载均衡式在线OJ
  • SQL注入天书笔记(1)布尔盲注
  • 【2022集创赛】安谋科技杯一等奖作品:Cortex-M0智能娱乐收音机
  • 【comparator, comparable】小总结
  • Bytom交易说明(账户管理模式)
  • Docker: 容器互访的三种方式
  • If…else
  • JavaScript创建对象的四种方式
  • Java教程_软件开发基础
  • JSDuck 与 AngularJS 融合技巧
  • mysql中InnoDB引擎中页的概念
  • text-decoration与color属性
  • 对象引论
  • 关于 Linux 进程的 UID、EUID、GID 和 EGID
  • 关于List、List?、ListObject的区别
  • 将回调地狱按在地上摩擦的Promise
  • 使用docker-compose进行多节点部署
  • 数据可视化之 Sankey 桑基图的实现
  • 原创:新手布局福音!微信小程序使用flex的一些基础样式属性(一)
  • 好程序员web前端教程分享CSS不同元素margin的计算 ...
  • 湖北分布式智能数据采集方法有哪些?
  • ​ArcGIS Pro 如何批量删除字段
  • ​html.parser --- 简单的 HTML 和 XHTML 解析器​
  • !$boo在php中什么意思,php前戏
  • (1)(1.9) MSP (version 4.2)
  • (13)Hive调优——动态分区导致的小文件问题
  • (day 12)JavaScript学习笔记(数组3)
  • (第27天)Oracle 数据泵转换分区表
  • (附源码)ssm航空客运订票系统 毕业设计 141612
  • (原創) 未来三学期想要修的课 (日記)
  • (中等) HDU 4370 0 or 1,建模+Dijkstra。
  • (转)清华学霸演讲稿:永远不要说你已经尽力了
  • .gitignore文件设置了忽略但不生效
  • .MSSQLSERVER 导入导出 命令集--堪称经典,值得借鉴!
  • .NET DevOps 接入指南 | 1. GitLab 安装
  • .net 简单实现MD5
  • .NET 设计模式初探
  • .Net多线程总结
  • .NET关于 跳过SSL中遇到的问题
  • .Net小白的大学四年,内含面经
  • .Net中wcf服务生成及调用
  • .NET中winform传递参数至Url并获得返回值或文件
  • ??myeclipse+tomcat