Main Content

detectRoadAngles

Detect road angles in point cloud

Description

example

roadAngles = detectRoadAngles(offRoadPointCloud) detects road angles in a point cloud. The point cloud must contain off-road points.

roadAngles = detectRoadAngles(offRoadPointCloud,Name=Value) specifies options using one or more name-value arguments. For example, MinSectorSize=10 specifies the minimum sector size required to detect a road segment as 10 degrees.

Examples

collapse all

Read point cloud data from a PCD file by using the pcread function.

ptCloud = pcread("HDL64LidarData.pcd");

Organize the point cloud data by using the pcorganize function.

ptCloud = pcorganize(ptCloud,lidarParameters("HDL64E",1024));

Extract a region of interest, which contains a road, from the point cloud data.

roi = [-25 25 -10 24 ptCloud.ZLimits];
indices = findPointsInROI(ptCloud,roi);
ptCloud = select(ptCloud,indices,OutputSize="full");

Segment the on-road and off-road points from the point cloud by using the segmentGroundSMRF function.

[~,offRoadPtCloud,onRoadPtCloud] = segmentGroundSMRF(ptCloud);

Detect road angles from the off-road points.

roadAngles = detectRoadAngles(offRoadPtCloud,MinSectorSize=10,SectorMergeThreshold=30);

Segment curb points from the on-road points of the point cloud.

[~,curbPtCloud] = segmentCurbPoints(onRoadPtCloud,roadAngles,NumScanNeighbors=10, ...
        HeightLimits=[0.001 0.5],HeightDeviationLimits=[0.001 0.5], ...
        SmoothnessThreshold=0.0001,HorizontalAngularResolution=0.33);

Visualize the segmented curb points.

figure
pcshow(ptCloud.Location,"w")
hold on;
pcshow(curbPtCloud.Location,"r",MarkerSize=200)
hold off
view(2)
title("Curb points")

Input Arguments

collapse all

Point cloud with off-road points, specified as a pointCloud object. Off-road points usually consist of trees, buildings, and other objects. You can apply ground segmentation or plane-fitting algorithms to your point cloud data to extract off-road points. For more details, see Extract On-Road and Off-Road Points from Point Cloud.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: detectRoadAngles(offRoadPointCloud,MinSectorSize=10) specifies the minimum sector size required to detect a road segment as 10 degrees.

Minimum sector size to detect a road segment, specified as a scalar in the range [0, 360, in degrees. The function does not detect any sector smaller than this value as a road segment. Increasing this value can improve the accuracy of the road angle detection. MinSectorSize must be in the range [0,360].

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Minimum merge angle between two sectors, specified as a scalar in the range [0, 360, in degrees. The function merges two sectors when the angle between them is lower than the SectorMergeThreshold value. Increasing this value can improve the accuracy of the road angle detection. SectorMergeThreshold must be in the range [0,360].

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Road segmentation angles, returned as an M-element vector. M is the number of directions in which the egovehicle can travel, depending on the road type. The values are in degrees, with respect to the lidar sensor coordinate system.

Road TypeM Value
Straight or curved road2
T-shaped or Y-shaped road3
Cross-road (+)4
6-way junction6

Algorithms

collapse all

The function uses a beam model, followed by a toe-finding algorithm, on the off-road points to detect the road angles.

Detect road angles

Beam Model

The beam model follows these steps.

  1. Launch a sequence of beams from the lidar sensor mounted on the ego vehicle. The lidar sensor is the launching point.

  2. Divide the beams into beam zones according to the angular resolution of the sensor.

  3. Determine the beam angles and beam lengths with respect to the launching point.

  4. For each beam zone, determine the distance between the point closest to the launching point and the point farthest from the launching point. Compute the normalized beam length as the ratio of the shortest distance to the longest distance.

Toe-Finding Algorithm

The toe-finding algorithm follows these steps.

  1. Classify the beam zones into sectors based on their normalized beam lengths.

  2. Update the sectors using the specified MinSectorSize and SectorMergeThreshold values.

    Minimum sector size and merge threshold

  3. Return the center angle of each sector with respect to the positive x-axis as the road segmentation angle.

Version History

Introduced in R2022b