sim3d.sensors.Lidar
Description
Use the sim3d.sensors.Lidar object to implement a lidar sensor in a 3D
environment. After you create a sim3d.sensors.Lidar object, you can modify aspects
of the actor object by setting property values.
Creation
Description
creates a
default lidar = sim3d.sensors.Lidar()sim3d.sensors.Lidar object in the 3D environment.
specifies options using one or more optional name-value arguments. For example, to create
a lidar sensor with a range of 100 meters, set lidar = sim3d.sensors.Lidar(Name=Value)Range to
100.
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: lidar =
sim3d.sensors.Lidar(ActorName='Lidar',Range=100)
Name of actor, specified as a character array or string. If you do not specify an actor name,
then the software assigns the actor an autogenerated name. Use
this argument to set the name of the
sim3d.sensors.Lidar object.
Note
If you specify the same name as an actor that already exists, then the software appends actor name you specify with a unique identifier.
Since R2025a
Coordinate system that the actor uses for translation and rotation in the 3D environment, specified as one of these listed values:
'Default'– World coordinate system'MATLAB'– MATLAB® coordinate system'ISO8855'– ISO 8855 standard coordinate system'AERO'– SAE coordinate system'VRML'– X3D ISO standard coordinate system'SAE'– SAE coordinate system
For more details on the different coordinate systems, see Coordinate Systems in Simulink 3D Animation.
Data Types: string
Relative translation
(x,y,z) of the actor object to its
parent actor, specified as a real 1-by-3 vector. Use Translation to change
the position of the sim3d.sensors.Lidar object in the 3D environment along the
X, Y, and Z axes of the
coordinate system. When you add an actor to the 3D environment, the default parent actor is the
Scene Origin at (0,0,0).
Example: Translation=[1 2 1]
Relative rotation (roll,
pitch, yaw) of the actor object to its parent actor,
specified as a real 1-by-3 vector. Use Rotation to rotate the
sim3d.sensors.Lidar object in the 3D environment.
Example: Rotation=[pi/4 pi/8 pi/2]
Maximum distance measured by the lidar sensor, specified as a positive scalar less than or equal to 500, in m. Points outside this range are ignored.
Example: Range=100
Vertical field of view of the lidar sensor, specified as a positive scalar less than or equal to 90, in degrees.
Example: VerticalFieldOfView=60
Vertical angular resolution of the lidar sensor, specified as a positive scalar, in degrees.
Example: VerticalAngularResolution=1.5
Horizontal field of view of the lidar sensor, specified as a positive scalar, in degrees.
Example: HorizontalFieldOfView=120
Horizontal angular (azimuth) resolution of the lidar sensor, specified as a positive scalar, in degrees.
Example: HorizontalAngularResolution=0.2
Resolution of the lidar sensor range, in m, specified as a
positive real scalar. The minimal value of this factor is
Drange / 224, where
Drange is the maximum distance measured by the
lidar sensor, as specified by Range.
Example: RangeQuantizationFactor=0.001
Output Arguments
Actor object, returned as a sim3d.sensors.Lidar object.
Properties
Parent of actor, specified as a handle to the parent actor
object. After you add an actor to the sim3d.World object, the default parent
actor is the Scene Origin at (0,0,0). Use
Parent to set any actor in the 3D environment as the parent actor of a
sim3d.sensors.Lidar object.
This property is read-only.
Children of actor, specified as a structure.
Each field of the structure contains a handle to
the child of a sim3d.sensors.Lidar
object.
Parent world, specified as a handle to the parent sim3d.World
object. You can use this property only if the sim3d.sensors.Lidar object is
added to the parent sim3d.World object.
This property is read-only.
Unique ID of the sensor, specified as a real positive scalar.
Data Types: uint32
Since R2025a
Coordinate system that the actor uses for translation and rotation in the 3D environment, specified as one of these listed values:
'Default'– World coordinate system'MATLAB'– MATLAB coordinate system'ISO8855'– ISO 8855 standard coordinate system'AERO'– SAE coordinate system'VRML'– X3D ISO standard coordinate system'SAE'– SAE coordinate system
For more details on the different coordinate systems, see Coordinate Systems in Simulink 3D Animation.
Data Types: string
Relative translation
(x,y,z) of the actor object to its
parent actor, specified as a real 1-by-3 vector. Use Translation to change
the position of the sim3d.sensors.Lidar object in the 3D environment along the
X, Y, and Z axes of the
coordinate system. When you add an actor to the 3D environment, the default parent actor is the
Scene Origin at (0,0,0).
Example: lidar.Translation = [1 2 1]
Relative rotation (roll,
pitch, yaw) of the actor object to its parent actor,
specified as a real 1-by-3 vector. Use Rotation to rotate the
sim3d.sensors.Lidar object in the 3D environment.
Example: lidar.Rotation = [pi/4 pi/8 pi/2]
Type of actor mobility to respond to physics, move the actor
during simulation, or both, specified as 'sim3d.utils.MobilityTypes.Movable'
or 'sim3d.utils.MobilityTypes.Static'. When Mobility is
'sim3d.utils.MobilityTypes.Static', only the Material Attributes are run-time configurable.
When you set Mobility to
'sim3d.utils.MobilityTypes.Movable', all the actor properties become
run-time configurable, allowing for programmatic interaction. For more details on programmatic
interaction, see Programmatic Interaction.
Example: lidar.Mobility =
sim3d.utils.MobilityTypes.Movable
Data Types: sim3d.utils.MobilityTypes
Maximum distance measured by the lidar sensor, specified as a positive scalar less than or equal to 500, in m. Points outside this range are ignored.
Example: lidar.Range = 100
Vertical field of view of the lidar sensor, specified as a positive scalar less than or equal to 90, in degrees.
Example: lidar.VerticalFieldOfView = 60
Vertical angular resolution of the lidar sensor, specified as a positive scalar, in degrees.
Example: lidar.VerticalAngularResolution = 1.5
Horizontal field of view of the lidar sensor, specified as a positive scalar, in degrees.
Example: lidar.HorizontalFieldOfView = 120
Horizontal angular (azimuth) resolution of the lidar sensor, specified as a positive scalar, in degrees.
Example: lidar.HorizontalAngularResolution = 0.2
Resolution of the lidar sensor range, in m, specified as a
positive real scalar. The minimal value of this factor is
Drange / 224, where
Drange is the maximum distance measured by the
lidar sensor, as specified by Range.
Example: lidar.RangeQuantizationFactor = 0.001
Object Functions
read | Return target data using lidar |
Examples
Since R2025a
Create a lidar sensor in the 3D environment using the sim3d.sensors.Lidar object. You can extract the point cloud with the specified field of view and angular resolution and display it in MATLAB®. Use the read function to extract the point cloud data from the 3D environment. The point cloud is a collection of data points that represents objects in the 3D environment. You can use point cloud data to map a 3D environment.
Create a 3D environment and set up communication with the Unreal Engine simulation environment using the output function OutputImpl and the update function UpdateImpl. The sim3d.World object can send and receive data about the 3D environment to and from the Unreal Engine at each simulation step using output and update functions, respectively. Before the Unreal Engine simulates, MATLAB calls the output function and sends data to the Unreal Engine. Then, the Unreal Engine executes at each time step and sends data to MATLAB in the update function. You can use the update function to read this data or change values after each simulation step.
world = sim3d.World(Output=@OutputImpl,Update=@UpdateImpl);
Create a box actor Cube1 in the 3D environment using the sim3d.Actor object and add the box to the world.
cube1 = sim3d.Actor( ... ActorName="Cube1", ... Mobility=sim3d.utils.MobilityTypes.Movable); createShape(cube1,"box"); cube1.Color = [1 0 0]; cube1.Translation = [5.30 1.10 -0.80]; add(world,cube1);
Create a box actor Cube2 in the 3D environment using the sim3d.Actor object and add the box to the world.
cube2 = sim3d.Actor( ... ActorName="Cube2", ... Mobility=sim3d.utils.MobilityTypes.Movable); cube2.Translation = [8.00 -2.20 -0.60]; createShape(cube2,"box"); cube2.Color = [0 1 0]; add(world,cube2);
Create a plane actor Plane1 in the 3D environment using the sim3d.Actor object and add the plane to the world.
plane1 = sim3d.Actor( ... ActorName="Plane1", ... Mobility=sim3d.utils.MobilityTypes.Movable); plane1.Translation = [20 0 0]; plane1.Rotation = [0 -pi/2 0]; plane1.Scale = [10 10 1]; createShape(plane1,"plane"); add(world,plane1);
Create a lidar object using the sim3d.sensors.Lidar object. Add the lidar to the world.
lidar = sim3d.sensors.Lidar(ActorName="Lidar");
add(world,lidar);Run the co-simulation.
sampletime = 1/60; stoptime = 10; run(world,sampletime,stoptime);

Output Function
The output function sends data about the actor to the Unreal Engine environment at each simulation step. For this example, the function rotates the Cube about its Z-axis by updating the Rotation property of the Cube at each simulation step.
function OutputImpl(world) world.Actors.Cube1.Rotation(3) = world.Actors.Cube1.Rotation(3) ... + 0.002; end
Update Function
The update function reads data from the Unreal Engine environment at each simulation step. For this example, the update function uses the read function of the sim3d.sensors.Lidar object to get the point cloud data from the Lidar in the Unreal Engine environment. Use the scatter3 function to visualize the point cloud data in MATLAB.
function UpdateImpl(world) [pc,~] = read(world.Actors.Lidar); [m,n,~] = size(pc); points = reshape(pc,m*n,3); scatter3(points(:,1), points(:,2), points(:,3)); end
Version History
Introduced in R2024bSet the CoordinateSystem argument and
property of the sim3d.sensors.Lidar object to represent the coordinate system for actor
transformation in the 3D environment.
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.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- 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)