Main Content

egoPointCloudExtractor

Extract point clouds around waypoints in ego trajectory

Since R2025a

Description

The egoPointCloudExtractor object extracts local point clouds from a larger point cloud with reference to an ego trajectory. The object crops the input point cloud for a specified region around each waypoint in the specified input trajectory and transforms the cropped point clouds to the vehicle coordinate system by emulating a lidar sensor mounted on an ego vehicle. For more information on the vehicle coordinate system, see Vehicle Coordinate System.

Creation

Description

pcExtractor = egoPointCloudExtractor(ptCloud,trajectory) creates an egoPointCloudExtractor object pcExtractor with the PointCloud and Trajectory properties set by the ptCloud and trajectory arguments, respectively.

example

pcExtractor = egoPointCloudExtractor(ptCloud,trajectory,params) sets the SensorParameters property using the params argument. If you use the extractFrame object function on an egoPointCloudExtractor object created using this syntax, the function returns organized point clouds. For more information, see What Are Organized and Unorganized Point Clouds? (Lidar Toolbox).

example

pcExtractor = egoPointCloudExtractor(___,Name=Value) sets writable properties using one or more name-value arguments, in addition to any combination of input arguments from previous syntaxes. For example, MaxRange=80 specifies the maximum detection range, from the ego vehicle, at which to extract a point cloud as 80 meters.

Note

This object requires the Scenario Builder for Automated Driving Toolbox™ support package and Lidar Toolbox™. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

Input Arguments

expand all

Point cloud, specified as a pointCloud object. The input ptCloud must be a larger point cloud from which to extract the local point clouds.

This argument sets the PointCloud property.

Ego trajectory, specified as a Trajectory object.

This argument sets the Trajectory property.

Lidar parameters, specified as a lidarParameters (Lidar Toolbox) object.

Note

If you use the extractFrame object function on an egoPointCloudExtractor object for which you have specified lidar parameters, the function returns an organized point cloud.

This argument sets the SensorParameters property.

Name-Value Arguments

expand all

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: egoPointCloudExtractor(ptCloud,trajectory,MaxRange=80) specifies the maximum detection range, from the ego vehicle, at which to extract a point cloud as 80 meters.

Maximum detection range, from the ego vehicle, at which to extract a point cloud, specified as a positive scalar. Units are in meters.

This argument sets the MaxRange property.

Data Types: double

Height from the road surface to the lidar sensor mounted on an ego vehicle, specified as a positive scalar. Units are in meters.

The default value represents the height, in meters, at which a lidar sensor is mounted on an ego vehicle of type sedan.

This argument sets the Height property.

Data Types: double

Properties

expand all

This property is read-only after object creation. To set this property, use the ptCloud argument when calling the egoPointCloudExtractor function.

Point cloud, represented as a pointCloud object.

This property is read-only after object creation. To set this property, use the trajectory argument when calling the egoPointCloudExtractor function.

Ego trajectory, represented as a Trajectory object.

Lidar parameters, specified as a lidarParameters (Lidar Toolbox) object.

Note

If you use the extractFrame object function on an egoPointCloudExtractor object for which you have specified lidar parameters, the function returns an organized point cloud.

Maximum detection range, from the ego vehicle, at which to extract a point cloud, specified as a positive scalar. Units are in meters.

Data Types: double

Height from the road surface to the lidar sensor mounted on an ego vehicle, specified as a positive scalar. Units are in meters.

The default value represents the height, in meters, at which a lidar sensor is mounted on an ego vehicle of type sedan.

Data Types: double

This property is read-only.

Number of local point clouds extractable from the egoPointCloudExtractor object, represented as a positive integer.

Data Types: double

Object Functions

extractFrameExtract point cloud frame
hasFrameCheck if point cloud frame is available to read
resetReset ego point cloud extractor object to initial state

Examples

collapse all

Load recorded point cloud data into the workspace.

ptCloud = pcread("USGS_LPC_CA_NoCAL_3DEP_Supp_Funding_2018_D18_w2276n1958_Cropped_geoReferenced.pcd");

Display the point cloud object.

pcshow(ptCloud)

Specify the xyz-coordinates of waypoints to create a trajectory. The trajectory coordinates must be within the spatial range of the loaded point cloud data.

egoTraj = [-122.8437 12.1113 39.8113;
            -21.3297 32.1351 33.9599;
             80.4809 49.1138 32.9193];

Specify timestamps for the waypoints of the trajectory.

timestamps = (1:3)'; 

Create a trajectory object by using the specified xyz-coordinates and timestamps.

traj = recordedSensorData("trajectory",timestamps,egoTraj);

Plot the trajectory object.

plot(traj,HeadingStep=1,ShowHeading=true)

Create an ego point cloud extractor object using the point cloud and trajectory information.

pcExtractor = egoPointCloudExtractor(ptCloud,traj)
pcExtractor = 
  egoPointCloudExtractor with properties:

              Height: 1.6000
            MaxRange: 120
    SensorParameters: []
          PointCloud: [1×1 pointCloud]
          Trajectory: [1×1 scenariobuilder.Trajectory]
      NumPointClouds: 3

Extract and display point cloud frames from the ego point cloud extractor object until it has no new frames to extract.

figure
frame = 0;
while(hasFrame(pcExtractor))
    pcFrame = extractFrame(pcExtractor);
    frame = frame + 1;
    subplot(1,3,frame)
    pcshow(pcFrame)
end

Reset the ego point cloud extractor object.

reset(pcExtractor)

Load recorded point cloud data into the workspace.

ptCloud = pcread("USGS_LPC_CA_NoCAL_3DEP_Supp_Funding_2018_D18_w2276n1958_Cropped_geoReferenced.pcd");

Specify the xyz-coordinates of waypoints to create a trajectory. The trajectory coordinates must be within the spatial range of the loaded point cloud data.

egoTraj = [-122.8437 12.1113 39.8113; ...
            -21.3297 32.1351 33.9599; ...
             80.4809 49.1138 32.9193];

Specify timestamps for the waypoints of the trajectory.

timestamps = (1:3)'; 

Create a trajectory object using the specified xyz-coordinates and timestamps.

traj = recordedSensorData("trajectory",timestamps,egoTraj);

Specify lidar sensor parameters.

params = lidarParameters("HDL64E",1024)
params = 
  lidarParameters with properties:

       HorizontalResolution: 1024
         VerticalResolution: 64
                VerticalFoV: [2.8100 -23.9500]
         VerticalBeamAngles: [2.8100 2.5100 2.1900 1.8600 1.5200 1.1500 0.8900 0.4800 0.2300 -0.1500 -0.5200 -0.8800 -1.1800 -1.5500 -1.8400 -2.2200 -2.5300 -2.9100 -3.2000 -3.5800 -3.8400 -4.2600 -4.5700 -4.9600 -5.2900 -5.6100 -5.8900 … ] (1×64 double)
              HorizontalFoV: 360
    HorizontalAngResolution: 0.3516
       HorizontalBeamAngles: [0 0.3516 0.7031 1.0547 1.4062 1.7578 2.1094 2.4609 2.8125 3.1641 3.5156 3.8672 4.2188 4.5703 4.9219 5.2734 5.6250 5.9766 6.3281 6.6797 7.0312 7.3828 7.7344 8.0859 8.4375 8.7891 9.1406 9.4922 9.8438 … ] (1×1024 double)
            SweepStartAngle: 90
            RotateClockwise: 1

Create an ego point cloud extractor object using the point cloud, ego trajectory, and lidar sensor parameter information.

pcExtractor = egoPointCloudExtractor(ptCloud,traj,params)
pcExtractor = 
  egoPointCloudExtractor with properties:

              Height: 1.6000
            MaxRange: 120
    SensorParameters: [1×1 lidarParameters]
          PointCloud: [1×1 pointCloud]
          Trajectory: [1×1 scenariobuilder.Trajectory]
      NumPointClouds: 3

Extract and visualize all point cloud frames from the ego point cloud extractor object.

while(hasFrame(pcExtractor))
    pcFrame = extractFrame(pcExtractor);
    pcshow(pcFrame)
end

Algorithms

For each waypoint specified in the input trajectory trajectory, the object extracts a point cloud frame based on these conditions:

  • Waypoints in the specified input trajectory trajectory must be located within the spatial range of the input point cloud ptCloud.

  • The input point cloud ptCloud must contain lidar points around a specified waypoint within the range defined by the MaxRange and Height properties.

Version History

Introduced in R2025a