Generate point clouds from meshes
System object™ generates detections from a lidar sensor. The system object uses a statistical
sensor model to simulate real lidar detections with added random noise. All detections are
with respect to the coordinate frame of the vehicle mounted sensor. You can use the
uavLidarPointCloudGenerator object in a scenario containing static
meshes, UAV platforms and sensors, which you can create using a
To generate lidar point clouds:
uavLidarPointCloudGenerator object and set its properties.
Call the object with arguments, as if it were a function.
To learn more about how System objects work, see What Are System Objects?.
statistical sensor model to generate point cloud for a lidar. This sensor model will have
sets additional properties for the statistical sensor model using one or more name-value
pairs. For example,
uavLidarPointCloudGenerator('UpdateRate',100,'HasNoise',0) creates a
lidar point cloud generator that reports detections at an update rate of 100 Hz without
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.
UpdateRate— Update rate of the lidar sensor
Update rate of the lidar sensor specifies the frequency at which the lidar point clouds are generated in Hz. This property sets the frequency at which new detections happen.
MaxRange— Maximum detection range
Maximum detection range of the sensor, specified as a positive scalar value. The sensor cannot detect objects beyond this range. The units are in meters.
RangeAccuracy— Accuracy of the range measurements
Accuracy of the range measurements, specified as a positive real scalar with units in meters. This property sets the one standard deviation accuracy of the sensor range measurements.
AzimuthResolution— Azimuthal resolution of the lidar
Azimuthal resolution of the lidar, specified as a positive real scalar with units in degrees. The azimuthal resolution defines the minimum separation in azimuth angle at which the lidar can distinguish two targets.
ElevationResolution— Elevation resolution of the lidar
Elevation resolution of the lidar, specified as a positive real scalar with units in degrees. The elevation resolution defines the minimum separation in elevation angle at which the lidar can distinguish two targets.
AzimuthLimits— Azimuthal limits of the lidar
Azimuth limits of the lidar, specified as a 1-by-2 real-valued vector of the form [min max]. Units are in degrees.
Example: [-60 100]
ElevationLimits— Elevation limits of the lidar
Elevation limits of the lidar, specified as a 1-by-2 real-valued vector of the form [min max]. Units are in degrees.
Example: [-15 20]
HasNoise— Enable adding noise to lidar sensor measurements
Enable adding noise to lidar sensor measurements, specified as
false. Set this property to
true to add noise to the sensor measurements. Otherwise, the
measurements have no noise.
HasOrganizedOutput— Output generated data as organized point cloud
Output generated data as organized point cloud, specified as
false. Set this property to
true to output an organized point cloud. Otherwise, the output is
tgts— Target object data
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
|A 3-element vector defining the coordinate position of the target with respect to the sensor frame|
simTime— Current simulation time
Current simulation time, specified as a positive real scalar. The
lidar object calls the lidar point cloud generator at regular
intervals to generate new point clouds at 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. Units are in seconds.
ptCloud— Point cloud data
Point cloud data, returned as a
isValidTime— Valid time to generate point cloud
Valid time to generate point cloud, returned as 0 or 1.
isValidTime is 0 when updates are requested at times that are
between update intervals specified by 1/
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
This example shows how to use a statistical lidar sensor model to generate point clouds from meshes.
Create Sensor Model
uavLidarPointCloudGenerator to create a statistical sensor model,
lidar = uavLidarPointCloudGenerator('HasOrganizedOutput',false);
extendedObjectMesh object to create mesh for the target object.
tgts.Mesh = scale(extendedObjectMesh('cuboid'),[100 100 2]);
Define the position of the target object with respect to the sensor frame.
tgts.Position = [0 0 -10];
Define orientation of the target with respect to the sensor frame.
tgts.Orientation = quaternion([1 0 0 0]);
Generate Point Clouds from Floor
ptCloud = lidar(tgts,0);
translate function to translate the object mesh to its location and use
show function to visualize it. Use the
scatter3 function to plot the point clouds stored in
figure(1); show(translate(tgts.Mesh,tgts.Position)); hold on scatter3(ptCloud.Location(:,1), ptCloud.Location(:,2), ... ptCloud.Location(:,3));