【路径规划与定位,例程分享】三维RRT+APF路径规划与TOA-AOA-TDOA融合定位算法,MATLAB,附下载链接
可直接运行有中文注释文章目录量测模型运行结果MATLAB源代码程序采用 RRT 与 APF 串联的混合规划结构。首先利用 RRT 在三维连续空间中完成全局采样搜索得到一条可行的避障路径随后对这条路径进行稠密化并基于人工势场法在每个中间路径点上叠加邻接路径点形成的平滑力、指向终点的吸引力、来自长方体障碍物的斥力。APF更新只在前后路径段仍然无碰撞时才会被接受因此既保留了 RRT 的全局可达性也改善了原始采样路径的锯齿和突变。量测模型TOA-AOA-TDOA 多源融合定位部分与原版本保持一致。程序分别生成 TOA、AOA、TDOA 三类量测并把三类残差统一堆叠到同一个 Gauss-Newton 最小二乘框架中求解位置。运行结果路径规划结果图路径规划轨迹与定位估计轨迹对比图各坐标分量随路径点序号变化曲线定位误差曲线命令行会输出路径长度、路径点数、规划迭代次数、平均定位误差、最大定位误差、最小定位误差和 RMSE 等统计结果。MATLAB源代码部分代码如下%% 三维RRTAPF路径规划与TOA-AOA-TDOA融合定位算法% 作者: matlabfilterV同号可接代码定制、讲解% 2026-09-24/Ver2%% 程序流程% 1. 完成RRTAPF全局采样与APF局部势场细化三维路径规划将规划路径点作为运动轨迹真值% 2. 在每个路径点处模拟TOA AOA TDOA量测% 3. 使用本脚本对应的定位模型估计路径点位置% 4. 使用普通figure窗口绘制规划轨迹、定位轨迹、坐标分量和误差曲线。clear;clc;close all;rng(0);%% 参数设置algorithmName三维RRTAPF路径规划与TOA-AOA-TDOA融合定位算法;measureNameTOA AOA TDOA;sigmaToaRange0.55;% TOA等效测距噪声单位msigmaAngle0.010;% AOA角度噪声单位radsigmaTdoaRange0.45;% TDOA距离差噪声单位mmaxGnIter14;% Gauss-Newton最大迭代次数%% 路径规划[rawPath,anchors,mapLimit,obstacles,planStats]planRrtApf3D();%% 沿规划轨迹进行定位仿真[estPath,posErr,iterUsed]runToaAoaTdoaLocalization3D(rawPath,anchors,sigmaToaRange,sigmaAngle,sigmaTdoaRange,maxGnIter,mapLimit);%% 结果绘图与输出plotPlanningResult(rawPath,anchors,mapLimit,obstacles,algorithmName);plotLocalizationResult(rawPath,estPath,anchors,obstacles,mapLimit,algorithmName);plotCoordinateResult(rawPath,estPath,algorithmName);plotErrorResult(posErr,algorithmName);printSummary(rawPath,posErr,iterUsed,planStats,algorithmName,measureName);%% 本地函数function[rawPath,anchors,mapLimit,obstacles,stats]planRrtApf3D()mapLimit[020002000200];startPos[101010];goalPos[180180180];stepSize7;goalThreshold8;maxIter18000;goalProb0.18;obstacles[30020158040;604010158060;1008050304040;14012080255035;80120100353030];anchors[000;20000;02000;2002000;00200;2000200;0200200;200200200;1001000;100100200];[guidePath,guideStats]planRrtGuide3D(startPos,goalPos,mapLimit,obstacles,stepSize,goalThreshold,maxIter,goalProb);[rawPath,apfStats]refineGuidePathWithApf3D(guidePath,goalPos,mapLimit,obstacles);stats.iterguideStats.iterapfStats.iter;stats.nodeCountguideStats.nodeCount;stats.lengthpathLength(rawPath);stats.plannerRRTAPF;endfunction[rawPath,stats]planRrtGuide3D(startPos,goalPos,mapLimit,obstacles,stepSize,goalThreshold,maxIter,goalProb)tree.posstartPos;tree.parent0;foundPathfalse;foriterCount1:maxIterifrandgoalProb qRandgoalPos;elseqRand[mapLimit(1)rand*(mapLimit(2)-mapLimit(1)),...mapLimit(3)rand*(mapLimit(4)-mapLimit(3)),...mapLimit(5)rand*(mapLimit(6)-mapLimit(5))];end[~,nearIdx]min(sqrt(sum((tree.pos-qRand).^2,2)));qNeartree.pos(nearIdx,:);directionqRand-qNear;distValnorm(direction);ifdistValepscontinue;endqNewqNearstepSize*direction/distVal;ifany(qNew[mapLimit(1)mapLimit(3)mapLimit(5)])||...any(qNew[mapLimit(2)mapLimit(4)mapLimit(6)])continue;endifplannerCheckCollision3D(qNear,qNew,obstacles)continue;endtree.pos(end1,:)qNew;%#okAGROWtree.parent(end1)nearIdx;%#okAGROWifnorm(qNew-goalPos)goalThreshold~plannerCheckCollision3D(qNew,goalPos,obstacles)tree.pos(end1,:)goalPos;tree.parent(end1)size(tree.pos,1)-1;foundPathtrue;break;endendif~foundPatherror(RRT未找到可行路径请增大maxIter或调整障碍物参数。);endcurrIdxnumel(tree.parent);rawPathtree.pos(currIdx,:);whiletree.parent(currIdx)~0currIdxtree.parent(currIdx);rawPath[tree.pos(currIdx,:);rawPath];%#okAGROWendrawPathplannerShortcutPath3D(rawPath,obstacles,100);rawPathplannerDensifyPath3D(rawPath,4);stats.iteriterCount;stats.nodeCountsize(tree.pos,1);end完整代码https://download.csdn.net/download/callmeup/93501521或前往专栏文章查看https://blog.csdn.net/callmeup/article/details/166577645?spm1011.2415.3001.5331如需帮助或有导航、定位滤波相关的代码定制需求可联系我