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

相关文章
|
24天前
OFDM深入学习及MATLAB仿真(二)
OFDM深入学习及MATLAB仿真
22 1
|
24天前
|
机器学习/深度学习
信道编码译码及MATLAB仿真(三)
信道编码译码及MATLAB仿真
29 3
|
24天前
|
算法
信道编码译码及MATLAB仿真(二)
信道编码译码及MATLAB仿真
25 3
|
5天前
|
机器学习/深度学习 人工智能 算法
基于DCT和扩频的音频水印嵌入提取算法matlab仿真
本文介绍了结合DCT和扩频技术的音频水印算法,用于在不降低音质的情况下嵌入版权信息。在matlab2022a中实现,算法利用DCT进行频域处理,通过扩频增强水印的隐蔽性和抗攻击性。核心程序展示了水印的嵌入与提取过程,包括DCT变换、水印扩频及反变换步骤。该方法有效且专业,未来研究将侧重于提高实用性和安全性。
|
24天前
数字频带传输——多进制数字调制及MATLAB仿真
数字频带传输——多进制数字调制及MATLAB仿真
36 2
|
3天前
|
机器学习/深度学习 传感器 数据可视化
MATLAB用深度学习长短期记忆 (LSTM) 神经网络对智能手机传感器时间序列数据进行分类
MATLAB用深度学习长短期记忆 (LSTM) 神经网络对智能手机传感器时间序列数据进行分类
19 1
MATLAB用深度学习长短期记忆 (LSTM) 神经网络对智能手机传感器时间序列数据进行分类
|
3天前
|
机器学习/深度学习 算法 数据挖掘
基于PSO优化的CNN-LSTM-Attention的时间序列回归预测matlab仿真
该文档介绍了使用MATLAB2022A中PSO优化算法提升时间序列预测模型性能的过程。PSO优化前后对比显示了优化效果。算法基于CNN、LSTM和Attention机制构建CNN-LSTM-Attention模型,利用PSO调整模型超参数。代码示例展示了PSO的迭代优化过程及训练、预测和误差分析环节。最终,模型的预测结果以图形形式展示,并保存了相关数据。
|
9天前
|
机器学习/深度学习 数据可视化 网络架构
matlab使用长短期记忆(LSTM)神经网络对序列数据进行分类
matlab使用长短期记忆(LSTM)神经网络对序列数据进行分类
13 0
|
9天前
|
数据可视化
matlab用高斯曲线拟合模型分析疫情数据
matlab用高斯曲线拟合模型分析疫情数据
13 0
|
24天前
雷达模糊函数及MATLAB仿真(三)
雷达模糊函数及MATLAB仿真
15 0

热门文章

最新文章