✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,代码获取、论文复现及科研仿真合作可私信。
🍎个人主页:Matlab科研工作室
🍊个人信条:格物致知。
更多Matlab完整代码及仿真定制内容点击👇
🔥 内容介绍
我们使用最先进的视觉同步定位和建图(VSLAM)方法来追踪无人机位姿,同时逐步构建周围环境的增量地图。在这方面,首先使用单目视觉方法来绘制感兴趣区域的地图。构建的地图被处理为优化算法的输入手段,以规划多架无人机的最佳路径。我们设计了一个基于粒子群优化(PSO)的路径规划器,并提出了一个基于区域敏感性(RS)的路径更新机制,以避免在执行最终路径时检测到危险事件时的敏感区域。此外,我们提出了一个动态适应度函数(DFF),以评估路径规划器的规划策略,同时考虑各种优化参数,如飞行风险估计、能量消耗和操作完成时间。所提出的规划器获得了较高的适应度值,并安全地到达目的地,同时遵循最短路径,避免所有意外的危险事件和限制区域,这验证了我们提出的 PSO-VSLAM 系统的有效性,如仿真结果所示。**避开了所有意外的危险事件和限制区域,这验证了我们提出的 PSO-VSLAM 系统的有效性,如仿真结果所示。
📣 部分代码
function [isLoopClosed, mapPoints, vSetKeyFrames] = helperAddLoopConnections(...
mapPoints, vSetKeyFrames, loopCandidates, currKeyFrameId, currFeatures, currPoints, intrinsics)
%helperAddLoopConnections add connections between the current key frame and
% the valid loop candidate key frames. A loop candidate is valid if it has
% enough covisible map points with the current key frame.
% This is an example helper function that is subject to change or removal
% in future releases.
% Copyright 2019 The MathWorks, Inc.
scaleFactor = 1.2;
imageSize = [480, 640];
% Minimum number of matched features for loop edge
minNumMatches = 60;
numCandidates = size(loopCandidates,1);
loopConnections = [];
[index3d1, index2d1] = getProjectionIndexPair(mapPoints, currKeyFrameId);
validFeatures1 = currFeatures.Features(index2d1, :);
validPoints1 = currPoints(index2d1).Location;
for k = numCandidates : -1 : 1
[index3d2, index2d2] = getProjectionIndexPair(mapPoints, loopCandidates(k));
allFeatures2 = vSetKeyFrames.Views.Features{loopCandidates(k)};
validFeatures2 = allFeatures2(index2d2, :);
allPoints2 = vSetKeyFrames.Views.Points{loopCandidates(k)};
validPoints2 = allPoints2(index2d2);
indexPairs = matchFeatures(binaryFeatures(validFeatures1), binaryFeatures(validFeatures2), ...
'Unique', true, 'MaxRatio', 0.9, 'MatchThreshold', 90);
% Check if all the candidate key frames have strong connection with the
% current keyframe
if size(indexPairs, 1) < minNumMatches
isLoopClosed = false;
return
end
% Estimate the relative pose of the current key frame with respect to the
% loop candidate keyframe with the highest similarity score
if k == 1
worldPoints = mapPoints.Locations(index3d2(indexPairs(:,2)),:);
matchedImagePoints = cast(validPoints1(indexPairs(:,1),:), 'like', worldPoints);
[worldOrientation, worldLocation] = estimateWorldCameraPose(matchedImagePoints, worldPoints, intrinsics, ...
'Confidence', 90, 'MaxReprojectionError', 6, 'MaxNumTrials', 1e4);
cameraPose = rigid3d(worldOrientation, worldLocation);
[R, t] = cameraPoseToExtrinsics(cameraPose.Rotation, cameraPose.Translation);
xyzPoints = mapPoints.Locations(index3d2,:);
projectedPoints = worldToImage(intrinsics, R, t, xyzPoints);
isInImage = find(projectedPoints(:,1)<imageSize(2) & projectedPoints(:,1)>0 & ...
projectedPoints(:,2)< imageSize(1) & projectedPoints(:,2)>0);
minScales = validPoints2.Scale(isInImage)/scaleFactor;
maxScales = validPoints2.Scale(isInImage)*scaleFactor;
r = 3;
searchRadius = r*validPoints2.Scale(isInImage);
matchedIndexPairs = helperMatchFeaturesInRadius(validFeatures2(isInImage,:), currFeatures.Features, ...
validPoints2(isInImage), currPoints, projectedPoints(isInImage,:), searchRadius, minScales, maxScales);
matchedIndexPairs(:,1) = isInImage(matchedIndexPairs(:,1));
visiblePointsIndex = index3d2(matchedIndexPairs(:,1));
validWorldPoints = mapPoints.Locations(visiblePointsIndex, :);
matchedImagePoints = currPoints.Location(matchedIndexPairs(:,2),:);
% Refine the pose
cameraPose = bundleAdjustmentMotion(validWorldPoints, matchedImagePoints, ...
cameraPose, intrinsics, 'PointsUndistorted', true, 'AbsoluteTolerance', 1e-7,...
'RelativeTolerance', 1e-15, 'MaxIteration', 50);
% Fuse covisible map points
[matchedIndex2d1, ia1, ib1] = intersect(index2d1, matchedIndexPairs(:,2), 'stable');
matchedIndex3d1 = index3d1(ia1);
matchedIndex3d2 = index3d2(matchedIndexPairs(ib1,1));
matchedIndex2d2 = index2d2(matchedIndexPairs(ib1,1));
mapPoints = updateLocation(mapPoints, mapPoints.Locations(matchedIndex3d2, :), matchedIndex3d1);
% Add connection between the current key frame and the loop key frame
pose1 = vSetKeyFrames.Views.AbsolutePose(loopCandidates(k));
pose2 = cameraPose;
relPose = rigid3d(pose2.Rotation*pose1.Rotation', (pose2.Translation-pose1.Translation)*pose1.Rotation');
matches = [matchedIndex2d2, matchedIndex2d1];
vSetKeyFrames = addConnection(vSetKeyFrames, loopCandidates(k), currKeyFrameId, relPose, 'Matches', matches);
disp(['Loop edge added between keyframe: ', num2str(loopCandidates(k)), ' and ', num2str(currKeyFrameId)]);
% Add connections between the current key frame and the connected
% key frames of the loop key frame
neighborViews = connectedViews(vSetKeyFrames, loopCandidates(k));
for m = 1:numel(neighborViews.ViewId)
neighborViewId = neighborViews.ViewId(m);
[index3d3, index2d3] = getProjectionIndexPair(mapPoints, neighborViewId);
[covPointsIndices, ia2, ib2] = intersect(index3d3, matchedIndex3d2, 'stable');
if numel(covPointsIndices) > minNumMatches
pose1 = neighborViews.AbsolutePose(m);
pose2 = cameraPose;
relPose = rigid3d(pose2.Rotation*pose1.Rotation', (pose2.Translation-pose1.Translation)*pose1.Rotation');
matches = [index2d3(ia2), matchedIndex2d1(ib2)];
if ~hasConnection(vSetKeyFrames, neighborViewId, currKeyFrameId)
vSetKeyFrames = addConnection(vSetKeyFrames, neighborViewId, currKeyFrameId, relPose, 'Matches', matches);
end
disp(['Loop edge added between keyframe: ', num2str(neighborViewId), ' and ', num2str(currKeyFrameId)]);
end
end
isLoopClosed = true;
end
end
end
⛳️ 运行结果
🔗 参考文献
[1] Mughal U A , Ahmad I , Pawase C J ,et al.UAVs Path Planning by Particle Swarm Optimization Based on Visual-SLAM Algorithm[J]. 2022.DOI:10.1007/978-981-19-1292-4_8.
🎈 部分理论引用网络文献,若有侵权联系博主删除
🎁 关注我领取海量matlab电子书和数学建模资料
👇 私信完整代码和数据获取及论文数模仿真定制
1 各类智能优化算法改进及应用
生产调度、经济调度、装配线调度、充电优化、车间调度、发车优化、水库调度、三维装箱、物流选址、货位优化、公交排班优化、充电桩布局优化、车间布局优化、集装箱船配载优化、水泵组合优化、解医疗资源分配优化、设施布局优化、可视域基站和无人机选址优化、背包问题、 风电场布局、时隙分配优化、 最佳分布式发电单元分配、多阶段管道维修、 工厂-中心-需求点三级选址问题、 应急生活物质配送中心选址、 基站选址、 道路灯柱布置、 枢纽节点部署、 输电线路台风监测装置、 集装箱船配载优化、 机组优化、 投资优化组合、云服务器组合优化、 天线线性阵列分布优化
2 机器学习和深度学习方面
2.1 bp时序、回归预测和分类
2.2 ENS声神经网络时序、回归预测和分类
2.3 SVM/CNN-SVM/LSSVM/RVM支持向量机系列时序、回归预测和分类
2.4 CNN/TCN卷积神经网络系列时序、回归预测和分类
2.5 ELM/KELM/RELM/DELM极限学习机系列时序、回归预测和分类
2.6 GRU/Bi-GRU/CNN-GRU/CNN-BiGRU门控神经网络时序、回归预测和分类
2.7 ELMAN递归神经网络时序、回归\预测和分类
2.8 LSTM/BiLSTM/CNN-LSTM/CNN-BiLSTM/长短记忆神经网络系列时序、回归预测和分类
2.9 RBF径向基神经网络时序、回归预测和分类