Main Content

robotLidarPointCloudGenerator

Generate point cloud from meshes

Since R2022a

Description

The robotLidarPointCloudGenerator System object™ generates detections from a statistical simulated lidar sensor. The system object uses a statistical sensor model to simulate lidar detections with added random noise. All detections are with respect to the coordinate frame of the vehicle-mounted sensor. You can use the robotLidarPointCloudGenerator object in a scenario, created using a robotSensor, containing static meshes, robot platforms, and sensors.

To generate lidar point clouds:

  1. Create the robotLidarPointCloudGenerator object and set its properties.

  2. Call the object with arguments, as if it were a function.

To learn more about how System objects work, see What Are System Objects?

Creation

Description

lidar = robotLidarPointCloudGenerator creates a statistical sensor model to generate point cloud for a lidar. This sensor model will have default properties.

example

lidar = robotLidarPointCloudGenerator(Name=Value) sets properties using one or more name-value pair arguments. For example, robotLidarPointCloudGenerator(UpdateRate=100,HasNoise=false) creates a lidar point cloud generator that reports detections at an update rate of 100 Hz without noise.

Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

For more information on changing property values, see System Design in MATLAB Using System Objects.

Update rate of the lidar sensor, specified as a positive real scalar in Hz. This property sets the frequency at which new detections happen.

Example: UpdateRate=100

Data Types: single | double

Maximum detection range of the lidar sensor, specified as a positive real scalar in meters. The sensor does not detect objects beyond this range.

Example: MaxRange=100

Data Types: single | double

Accuracy of the range measurements, specified as a positive real scalar in meters. This property sets the one-standard-deviation accuracy of the sensor range measurements.

Example: RangeAccuracy=0.001

Data Types: single | double

Azimuthal resolution of the lidar sensor, specified as a positive real scalar in degrees. The azimuthal resolution defines the minimum separation in azimuth angle at which the lidar sensor can distinguish two targets.

Example: AzimuthResolution=0.6000

Data Types: single | double

Elevation resolution of the lidar sensor, specified as a positive real scalar in degrees. The elevation resolution defines the minimum separation in elevation angle at which the lidar can distinguish two targets.

Example: ElevationResolution=0.6000

Data Types: single | double

Azimuth limits of the lidar sensor, specified as a two-element vector of the form [min max]. Units are in degrees.

Example: AzimuthLimits=[-60 100]

Data Types: single | double

Elevation limits of the lidar sensor, specified as a two-element vector of the form [min max]. Units are in degrees.

Example: ElevationLimits=[-60 100]

Data Types: single | double

Add noise to lidar sensor measurements, specified as true or false. Set this property to true to add noise to the sensor measurements. Otherwise, the measurements have no noise. The sensor adds random Gaussian noise to each point with mean equal to zero and standard deviation specified by the RangeAccuracy property.

Example: HasNoise=false

Data Types: logical

Output generated data as organized point cloud locations, specified as true or false.

When this property is set as true, the Location property of the pointCloud object is an M-by-N-by-3 matrix of organized point cloud. M is the number of elevation channels, and N is the number of azimuth channels.

When this property is set as false, the Location property of the pointCloud object is an M-by-3 matrix of unorganized list of points. M is the product of the numbers of elevation and azimuth channels.

Example: HasOrganizedOutput=false

Data Types: logical

Usage

Description

example

ptCloud = lidar(tgts,simTime) generates a lidar point cloud object ptCloud from the specified target object, tgts, at the specified simulation time simTime.

[ptCloud,isValidTime] = lidar(tgts,simTime) additionally returns isValidTime which specifies if the specified simTime is a multiple of the sensor's update interval (1/UpdateRate).

Input Arguments

expand all

Target object data, specified as a structure or structure array. Each structure corresponds to a mesh. The table shows the properties that the object uses to generate detections.

Target Object Data

FieldDescription
MeshAn extendedObjectMesh object representing the geometry of the target object in its own coordinate frame.
PositionA three-element vector defining the coordinate position of the target with respect to the sensor frame.
OrientationA quaternion object or a 3-by-3 matrix, containing Euler angles, defining the orientation of the target with respect to the sensor frame.

Example: struct("Mesh",scale(extendedObjectMesh('cuboid'),[100 100 2]),"Position",[0 0 -10],"Orientation",quaternion([1 0 0 0]))

Data Types: struct

Current simulation time, specified as a positive real scalar in seconds. The lidar object calls the lidar point cloud generator at regular intervals to generate new point clouds at a frequency defined by the updateRate property. The value of the UpdateRate property must be an integer multiple of the simulation time interval. Updates requested from the sensor between update intervals do not generate a point cloud.

Example: 0

Data Types: single | double

Output Arguments

expand all

Point cloud data, returned as a pointCloud object.

Valid time to generate point cloud, returned as logical 0 (false) or 1 (true). isValidTime is 0 when the requested update time is not a multiple of the updateRate property value.

Data Types: logical

Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

stepRun System object algorithm
releaseRelease resources and allow changes to System object property values and input characteristics
resetReset internal states of System object

Examples

collapse all

This example shows how to use a statistical lidar sensor model to generate point clouds from a mesh.

Create Sensor Model

Create a statistical sensor model, lidar, using the robotLidarPointCloudGenerator System object.

lidar = robotLidarPointCloudGenerator(HasOrganizedOutput=false);

Create Floor

Use the extendedObjectMesh object to create mesh for the target object. Define the position and orientation of the target object with respect to the sensor frame.

target = struct("Mesh",scale(extendedObjectMesh("cuboid"),[100 100 2]), ...
                "Position",[0 0 -10], ...
                "Orientation",quaternion([1 0 0 0]));

Generate Point Clouds from Floor

ptCloud = lidar(target,0);

Visualize

Use the translate function to translate the object mesh to its specified location and use the show function to visualize it. Use the scatter3 function to plot the point clouds stored in ptCloud.

show(translate(target.Mesh,target.Position));
hold on
scatter3(ptCloud.Location(:,1),ptCloud.Location(:,2),ptCloud.Location(:,3))

Version History

Introduced in R2022a