matlab利用已有激光雷达数据寻找地平面和车辆周围的障碍物仿真实验

简介: 简介:matlab利用已有激光雷达数据寻找地平面和车辆周围的障碍物仿真实验

第一步:显示激光三维点云

fileName = 'lidarData_ConstructionRoad.pcap';   
deviceModel = 'HDL32e';   
veloReader = velodyneFileReader(fileName,deviceModel);   
ptCloud = readFrame(veloReader);   
xlimits = [-25,45];ylimits = [-25,45];zlimits = [-20,20];   
lidarViewer = pcplayer(xlimits,ylimits,zlimits);             
xlabel(lidarViewer.Axes,'X(m)')   
ylabel(lidarViewer.Axes,'Y(m)')   
zlabel(lidarViewer.Axes,'Z(m)')  
view(lidarViewer,ptCloud)   

image.png


第二步:激光点云颜色映射。


为了分割属于地平面、主车辆和附近障碍物的点,需要设置颜色标签,并进行颜色映射。

colorLabels=[0,0.4470,0.7410;0.4660 0.6740 0.1880;0.929,0.694,0.125;0.635,0.078,0.1840];
colors.Unlabeled=1;
colors.Ground=2;
colors.Ego=3;
colors.Obstacle=4;
colormap(lidarViewer.Axes, colorLabels)

image.png


第三步:分割主车辆


vehicleDims=vehicleDimensions ();
mountLocation= [vehicleDims.Length/2-vehicleDims.RearOverhang,...
    0,vehicleDims.Height];
points=struct();
points.EgoPoints=helperSegmentEgoFromLidarData(ptCloud,vehicleDims, mountLocation);
closePlayer=false;
helperUpdateView(lidarViewer,ptCloud,points,colors,closePlayer);

helperSegmentEgoFromLidarData函数程序如下:

function egoPoints=helperSegmentEgoFromLidarData(ptCloud, vehicleDims,mountLocation)
bufferZone= [0.1,0.1,0.1];
egoXMin=-vehicleDims.RearOverhang-bufferZone (1);
egoXMax=egoXMin+vehicleDims.Length+bufferZone (1);
egoYMin=-vehicleDims.Width/2-bufferZone (2);
egoYMax=egoYMin+vehicleDims.Width+bufferZone (2);
egoZMin=0-bufferZone (3);
egoZMax=egoZMin+vehicleDims. Height+bufferZone (3);
egoXLimits= [egoXMin, egoXMax];
egoYLimits= [egoYMin, egoYMax];
egoZLimits= [egoZMin, egoZMax];
egoXLimits=egoXLimits-mountLocation(1);
egoYLimits=egoYLimits-mountLocation(2);
egoZLimits=egoZLimits-mountLocation(3);
egoPoints=ptCloud.Location(:,:,1)>egoXLimits(1)...
   & ptCloud. Location(:,:,1) <egoXLimits(2)...
   & ptCloud. Location(:,:,2) >egoYLimits(1)...
   & ptCloud. Location(:,:,2) <egoYLimits(2)...
   & ptCloud. Location(:,:,3) >egoZLimits(1)...
   & ptCloud. Location(:,:,3) <egoZLimits(2);
End

helperUpdateView函数程序如下:

function isPlayerOpen=helperUpdateView(lidarViewer,ptCloud,points,colors,closePlayer)
if closePlayer
     hide (lidarViewer);
     isPlayerOpen=false;
     return;
end
scanSize=size (ptCloud.Location);
scanSize=scanSize (1:2);
colormapValues=ones (scanSize,'like',ptCloud.Location) * colors.Unlabeled;
if isfield(points,'GroundPoints') 
    colormapValues (points.GroundPoints)=colors.Ground;
end
if isfield(points, 'EgoPoints')
    colormapValues (points.EgoPoints)=colors.Ego;
end
if isfield (points, 'ObstaclePoints')
    colormapValues (points.ObstaclePoints)=colors.Obstacle;   
end
view (lidarViewer,ptCloud. Location, colormapValues)
isPlayerOpen=isOpen (lidarViewer);
End

image.png


第四步:分割地平面。


为了从激光雷达数据中检测障碍物,首先对地平面进行分段,从有组织的激光雷达数据中分割出属于地平面的点。

elevationDelta = 10;   
points.GroundPoints=segmentGroundFromLidarData(ptCloud,'ElevationAngleDelta', elevationDelta);   
helperUpdateView(lidarViewer,ptCloud,points,colors,closePlayer); 

image.png


第五步:分割障碍物。


nonEgoGroundPoints=~points.EgoPoints &~points.GroundPoints;
ptCloudSegmented=select(ptCloud,nonEgoGroundPoints,'OutputSize','full');
sensorLocation=[0,0,0];
radius=40;
points.ObstaclePoints=findNeighborsInRadius(ptCloudSegmented,sensorLocation,radius);
helperUpdateView(lidarViewer,ptCloud,points,colors,closePlayer);

image.png


第六步:显示激光雷达数据处理结果。


从激光雷达记录的数据序列中处理20s。

reset(veloReader);
stopTime=veloReader.StartTime+seconds(20);
isPlayerOpen=true;
while hasFrame(veloReader)&&veloReader.CurrentTime<stopTime&&isPlayerOpen
    ptCloud=readFrame(veloReader);
    points.EgoPoints=helperSegmentEgoFromLidarData(ptCloud,vehicleDims,mountLocation);
    points.GroundPoints=segmentGroundFromLidarData(ptCloud,'ElevationAngleDelta',elevationDelta);
    nonEgoGroundPoints=~points.EgoPoints&~points.GroundPoints;
    ptCloudSegmented=select(ptCloud,nonEgoGroundPoints,'OutputSize','full');
    points.ObstaclePoints=findNeighborsInRadius(ptCloudSegmented,sensorLocation,radius);
    closePlayer=~hasFrame(veloReader);
    isPlayerOpen=helperUpdateView(lidarViewer,ptCloud,points,colors,closePlayer);
end

916534efb4dc435ab49ea9049d83e044.gif

相关文章
|
2月前
|
数据可视化
基于MATLAB的OFDM调制发射与接收仿真
基于MATLAB的OFDM调制发射与接收仿真
|
2月前
|
传感器 算法 安全
基于分布式模型预测控制DMPC的单向拓扑结构下异构车辆车队研究(Matlab代码实现)
基于分布式模型预测控制DMPC的单向拓扑结构下异构车辆车队研究(Matlab代码实现)
110 4
|
1月前
|
5G
基于IEEE 802.11a标准的物理层MATLAB仿真
基于IEEE 802.11a标准的物理层MATLAB仿真
158 0
|
2月前
|
传感器 机器学习/深度学习 算法
【使用 DSP 滤波器加速速度和位移】使用信号处理算法过滤加速度数据并将其转换为速度和位移研究(Matlab代码实现)
【使用 DSP 滤波器加速速度和位移】使用信号处理算法过滤加速度数据并将其转换为速度和位移研究(Matlab代码实现)
221 1
|
1月前
|
算法
基于MATLAB/Simulink平台搭建同步电机、异步电机和双馈风机仿真模型
基于MATLAB/Simulink平台搭建同步电机、异步电机和双馈风机仿真模型
|
1月前
|
机器学习/深度学习 算法 数据可视化
基于MVO多元宇宙优化的DBSCAN聚类算法matlab仿真
本程序基于MATLAB实现MVO优化的DBSCAN聚类算法,通过多元宇宙优化自动搜索最优参数Eps与MinPts,提升聚类精度。对比传统DBSCAN,MVO-DBSCAN有效克服参数依赖问题,适应复杂数据分布,增强鲁棒性,适用于非均匀密度数据集的高效聚类分析。
|
1月前
|
开发框架 算法 .NET
基于ADMM无穷范数检测算法的MIMO通信系统信号检测MATLAB仿真,对比ML,MMSE,ZF以及LAMA
简介:本文介绍基于ADMM的MIMO信号检测算法,结合无穷范数优化与交替方向乘子法,降低计算复杂度并提升检测性能。涵盖MATLAB 2024b实现效果图、核心代码及详细注释,并对比ML、MMSE、ZF、OCD_MMSE与LAMA等算法。重点分析LAMA基于消息传递的低复杂度优势,适用于大规模MIMO系统,为通信系统检测提供理论支持与实践方案。(238字)
|
2月前
|
传感器 算法 数据挖掘
基于协方差交叉(CI)的多传感器融合算法matlab仿真,对比单传感器和SCC融合
基于协方差交叉(CI)的多传感器融合算法,通过MATLAB仿真对比单传感器、SCC与CI融合在位置/速度估计误差(RMSE)及等概率椭圆上的性能。采用MATLAB2022A实现,结果表明CI融合在未知相关性下仍具鲁棒性,有效降低估计误差。
198 15
|
2月前
|
机器学习/深度学习 算法 安全
【图像处理】使用四树分割和直方图移动的可逆图像数据隐藏(Matlab代码实现)
【图像处理】使用四树分割和直方图移动的可逆图像数据隐藏(Matlab代码实现)
159 2
|
1月前
|
机器学习/深度学习 人工智能 算法
【基于TTNRBO优化DBN回归预测】基于瞬态三角牛顿-拉夫逊优化算法(TTNRBO)优化深度信念网络(DBN)数据回归预测研究(Matlab代码实现)
【基于TTNRBO优化DBN回归预测】基于瞬态三角牛顿-拉夫逊优化算法(TTNRBO)优化深度信念网络(DBN)数据回归预测研究(Matlab代码实现)
112 0

热门文章

最新文章

下一篇
oss云网关配置