detectRoadAngles
Syntax
Description
detects road angles in a point cloud. The point cloud must contain off-road points. roadAngles
= detectRoadAngles(offRoadPointCloud
)
specifies options using one or more name-value arguments. For example,
roadAngles
= detectRoadAngles(offRoadPointCloud
,Name=Value
)MinSectorSize=10
specifies the minimum sector size required to detect a
road segment as 10 degrees.
Examples
Segment Curb Points from Point Cloud
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
offRoadPointCloud
— Point cloud with off-road points
pointCloud
object
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.
MinSectorSize
— Minimum sector size to detect road segment
5
(default) | scalar in the range [0
, 360
]
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
SectorMergeThreshold
— Minimum merge angle between two sectors
15
(default) | scalar in the range [0
, 360
]
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
roadAngles
— Road segmentation angles
M-element vector
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 Type | M Value |
---|---|
Straight or curved road | 2 |
T-shaped or Y-shaped road | 3 |
Cross-road (+) | 4 |
6-way junction | 6 |
Algorithms
The function uses a beam model, followed by a toe-finding algorithm, on the off-road points to detect the road angles.
Beam Model
The beam model follows these steps.
Launch a sequence of beams from the lidar sensor mounted on the ego vehicle. The lidar sensor is the launching point.
Divide the beams into beam zones according to the angular resolution of the sensor.
Determine the beam angles and beam lengths with respect to the launching point.
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.
Classify the beam zones into sectors based on their normalized beam lengths.
Update the sectors using the specified
MinSectorSize
andSectorMergeThreshold
values.Return the center angle of each sector with respect to the positive x-axis as the road segmentation angle.
Version History
Introduced in R2022b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)