radarDetectionGenerator
Generate radar detections for driving scenario
radarDetectionGenerator is not recommended unless you require C/C++
            code generation. Use drivingRadarDataGenerator instead. For more information, see Version History.
Description
The radarDetectionGenerator
            System object™ generates detections from a radar sensor mounted on an ego vehicle. All
            detections are referenced to the coordinate system of the ego vehicle. You can use the
                radarDetectionGenerator object in a scenario containing actors and
            trajectories, which you can create by using a drivingScenario object. The object can simulate real detections with added
            random noise and also generate false alarm detections. In addition, you can use the
                radarDetectionGenerator object to create input to a multiObjectTracker. When building scenarios using the Driving Scenario
                Designer app, the radar sensors mounted on the ego vehicle are output as
                radarDetectionGenerator objects.
To generate radar detections:
- Create the - radarDetectionGeneratorobject 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?
Creation
Description
sensor = radarDetectionGenerator
sensor = radarDetectionGenerator(Name,Value)radarDetectionGenerator('DetectionCoordinates','Sensor
                        Cartesian','MaxRange',200) creates a radar detection generator
                    that reports detections in the sensor Cartesian coordinate system and has a
                    maximum detection range of 200 meters. Enclose each property name in
                    quotes.
Properties
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.
Unique sensor identifier, specified as a positive integer. This property distinguishes detections that come from different sensors in a multisensor system.
Example: 5
Data Types: double
Required time interval between sensor updates, specified as a positive
                        real scalar. The drivingScenario object calls
                        the radar detection generator at regular time intervals. The radar detector
                        generates new detections at intervals defined by the
                            UpdateInterval property. The value of the
                            UpdateInterval property must be an integer multiple
                        of the simulation time interval. Updates requested from the sensor between
                        update intervals contain no detections. Units are in seconds.
Example: 5
Data Types: double
Location of the radar sensor center, specified as an [x
                            y] vector. The SensorLocation and
                            Height properties define the coordinates of the
                        radar sensor with respect to the ego vehicle coordinate system. The default
                        value corresponds to a radar mounted at the center of the front grill of a
                        sedan. Units are in meters.
Example: [4 0.1]
Data Types: double
Radar sensor height above the ground plane, specified as a positive real
                        scalar. The height is defined with respect to the vehicle ground plane. The
                            SensorLocation and Height
                        properties define the coordinates of the radar sensor with respect to the
                        ego vehicle coordinate system. The default value corresponds to a radar
                        mounted at the center of the front grill of a sedan. Units are in
                        meters.
Example: 0.3
Data Types: double
Yaw angle of radar sensor, specified as a real scalar. The yaw angle is the angle between the center line of the ego vehicle and the downrange axis of the radar sensor. A positive yaw angle corresponds to a clockwise rotation when looking in the positive direction of the z-axis of the ego vehicle coordinate system. Units are in degrees.
Example: -4
Data Types: double
Pitch angle of sensor, specified as a real scalar. The pitch angle is the angle between the downrange axis of the radar sensor and the x-y plane of the ego vehicle coordinate system. A positive pitch angle corresponds to a clockwise rotation when looking in the positive direction of the y-axis of the ego vehicle coordinate system. Units are in degrees.
Example: 3
Data Types: double
Roll angle of the radar sensor, specified as a real scalar. The roll angle is the angle of rotation of the downrange axis of the radar around the x-axis of the ego vehicle coordinate system. A positive roll angle corresponds to a clockwise rotation when looking in the positive direction of the x-axis of the coordinate system. Units are in degrees.
Example: -4
Data Types: double
Azimuth and elevation fields of view of radar sensor, specified as a
                        real-valued 1-by-2 vector of positive values, [azfov
                            elfov]. The field of view defines the angular extent spanned
                        by the sensor. Each component must lie in the interval (0,180]. Targets
                        outside of the field of view of the radar are not detected. Units are in
                        degrees.
Example: [14 7]
Data Types: double
Maximum detection range, specified as a positive real scalar. The radar cannot detect a target beyond this range. Units are in meters.
Example: 200
Data Types: double
Minimum and maximum detection range rates, specified as a real-valued 1-by-2 vector. The radar cannot detect a target out this range rate interval. Units are in meters per second.
Example: [-20 100]
Dependencies
To enable this property, set the HasRangeRate
                            property to true.
Data Types: double
Probability of detecting a target, specified as a positive real scalar
                        less than or equal to one. This quantity defines the probability of
                        detecting target that has a radar cross-section,
                            ReferenceRCS, at the reference detection range,
                            ReferenceRange.
False alarm rate within a radar resolution cell, specified as a positive real scalar in the range [10–7,10–3]. Units are dimensionless.
Example: 1e-5
Data Types: double
Reference range for a given probability of detection, specified as a
                        positive real scalar. The reference range is the range when a target having
                        a radar cross-section specified by ReferenceRCS is
                        detected with a probability of specified by
                            DetectionProbability. Units are in meters.
Data Types: double
Reference radar cross-section (RCS) for given probability of detection,
                        specified as a nonnegative real scalar. The reference RCS is the value at
                        which a target is detected with probability specified by
                            DetectionProbability. Units are in dBsm.
Data Types: double
This property is read-only.
Radar loop gain, specified as a real scalar. Radar loop gain is related to the reported signal-to-noise ratio of the radar, SNR, the target radar cross section, RCS, and target range, R by
SNR = RadarLoopGain + RCS - 40*log10(R)
RadarLoopGain depends on the
                            DetectionProbability,
                            ReferenceRange, ReferenceRCS,
                        and FalseAlarmRate property values. Units are in
                        dB.Data Types: double
Azimuth resolution of the radar, specified as a positive real scalar. The azimuth resolution defines the minimum separation in azimuth angle at which the radar can distinguish two targets. The azimuth resolution is typically the 3dB-downpoint in azimuth angle beamwidth of the radar. Units are in degrees.
Data Types: double
Elevation resolution of the radar, specified as a positive real scalar. The elevation resolution defines the minimum separation in elevation angle at which the radar can distinguish two targets. The elevation resolution is typically the 3dB-downpoint in elevation angle beamwidth of the radar. Units are in degrees.
Dependencies
To enable this property, set the HasElevation
                            property to true.
Data Types: double
Range resolution of the radar, specified as a positive real scalar. The range resolution defines the minimum separation in range at which the radar can distinguish between two targets. Units are in meters.
Data Types: double
Range rate resolution of the radar, specified as a positive real scalar. The range rate resolution defines the minimum separation in range rate at which the radar can distinguish between two targets. Units are in meters per second.
Dependencies
To enable this property, set the HasRangeRate
                            property to true.
Data Types: double
Azimuth bias fraction of the radar, specified as a nonnegative real
                        scalar. The azimuth bias is expressed as a fraction of the azimuth
                        resolution specified in AzimuthResolution. Units are
                        dimensionless.
Data Types: double
Elevation bias fraction of the radar, specified as a nonnegative real
                        scalar. Elevation bias is expressed as a fraction of the elevation
                        resolution specified in ElevationResolution. Units are
                        dimensionless.
Dependencies
To enable this property, set the HasElevation
                            property to true.
Data Types: double
Range bias fraction of the radar, specified as a nonnegative real scalar.
                        Range bias is expressed as a fraction of the range resolution specified in
                            RangeResolution. Units are dimensionless.
Data Types: double
Range rate bias fraction of the radar, specified as a nonnegative real
                        scalar. Range rate bias is expressed as a fraction of the range rate
                        resolution specified in RangeRateResolution. Units are
                        dimensionless.
Dependencies
To enable this property, set the HasRangeRate
                            property to true.
Data Types: double
Enable the radar to measure target elevation angles, specified as
                            false or true. Set this property
                        to true to model a radar sensor that can estimate target
                        elevation. Set this property to false to model a radar
                        sensor that cannot measure elevation.
Data Types: logical
Enable the radar to measure target range rates, specified as
                            false or true. Set this property
                        to true to model a radar sensor which can estimate target
                        range rate. Set this property to false to model a radar
                        sensor that cannot measure range rate.
Data Types: logical
Enable adding noise to radar sensor measurements, specified as
                            true or false. Set this property
                        to true to add noise to the radar measurements.
                        Otherwise, the measurements have no noise. Even if you set
                            HasNoise to false, the object
                        still computes the MeasurementNoise property of each
                        detection.
Data Types: logical
Enable reporting false alarm radar measurements, specified as
                            true or false. Set this property
                        to true to report false alarms. Otherwise, only actual
                        detections are reported.
Data Types: logical
Enable line-of-sight occlusion, specified as true or
                            false. To generate detections only from objects for
                        which the radar has a direct line of sight, set this property to
                            true. For example, with this property enabled, the
                        radar does not generate a detection for a vehicle that is behind another
                        vehicle and blocked from view.
Data Types: logical
Source of maximum number of detections reported by the sensor, specified
                        as 'Auto' or 'Property'. When this
                        property is set to 'Auto', the sensor reports all
                        detections. When this property is set to 'Property', the
                        sensor reports no more than the number of detections specified by the
                            MaxNumDetections property.
Data Types: char | string
Maximum number of detections reported by the sensor, specified as a positive integer. Detections are reported in order of distance to the sensor until the maximum number is reached.
Dependencies
To enable this property, set the
                                MaxNumDetectionsSource property to
                                'Property'.
Data Types: double
Coordinate system of reported detections, specified as one of these values:
- 'Ego Cartesian'— Detections are reported in the ego vehicle Cartesian coordinate system.
- 'Sensor Cartesian'— Detections are reported in the sensor Cartesian coordinate system.
- 'Sensor Spherical'— Detections are reported in a spherical coordinate system. This coordinate system is centered at the radar and aligned with the orientation of the radar on the ego vehicle.
Data Types: char | string
Actor profiles, specified as a structure or as an array of structures. Each structure contains the physical and radar characteristics of an actor.
- If - ActorProfilesis a single structure, all actors passed into the- radarDetectionGeneratorobject use this profile.
- If - ActorProfilesis an array, each actor passed into the object must have a unique actor profile.
To generate an array of structures for your driving scenario, use the actorProfiles function. The table shows the valid structure fields. If you do
    not specify a field, that field is set to its default value. If no actors are passed into the
    object, then the ActorID field is not included.
| Field | Description | 
|---|---|
| ActorID | Scenario-defined actor identifier, specified as a positive integer. | 
| ClassID | Classification identifier, specified as a
                                                  nonnegative integer. 0is
                                                  reserved for an object of an unknown or unassigned
                                                  class. | 
| Length | Length of actor, specified as a positive
                                                  real scalar. The default is 4.7. Units are in
                                                  meters. | 
| Width | Width of actor, specified as a positive
                                                  real scalar. The default is 1.8. Units are in
                                                  meters. | 
| Height | Height of actor, specified as a positive
                                                  real scalar. The default is 1.4. Units are in
                                                  meters. | 
| OriginOffset | Offset of the rotational center of
                                                  the actor from its geometric center, specified as
                                                  an [x
                                                  y
                                                  z] real-valued vector. The
                                                  rotational center, or origin, is located at the
                                                  bottom center of the actor. For vehicles, the
                                                  rotational center is the point on the ground
                                                  beneath the center of the rear axle. The default
                                                  is  | 
| RCSPattern | Radar cross-section pattern of actor,
                                                  specified as a numel(RCSElevationAngles)-by-numel(RCSAzimuthAngles)real-valued matrix. The default is[10
                                                  10; 10 10]. Units are in decibels per
                                                  square meter. | 
| RCSAzimuthAngles | Azimuth angles corresponding to rows of RCSPattern, specified as a
                                                  vector of real values in the range [–180, 180].
                                                  The default is[-180 180].
                                                  Units are in degrees. | 
| RCSElevationAngles | Elevation angles corresponding to rows of RCSPattern, specified as a
                                                  vector of real values in the range [–90, 90]. The
                                                  default is[-90 90]. Units are
                                                  in degrees. | 
For full definitions of the structure fields, see the actor and vehicle functions.
Usage
Syntax
Description
[
                    also returns the number of valid detections reported,
                        dets,numValidDets]
= sensor(actors,time)numValidDets.
[
                    also returns a logical value, dets,numValidDets,isValidTime]
= sensor(actors,time)isValidTime, indicating that
                    the UpdateInterval time has elapsed.
Input Arguments
Scenario actor poses, specified as a structure or structure array.
                            Each structure corresponds to an actor. You can generate these
                            structures using the actorPoses function.
                            You can also create these structures manually.
| Field | Description | 
|---|---|
| ActorID | Scenario-defined actor identifier, specified as a positive integer. | 
| In R2024b: 
 | Front-axle position of the vehicle, specified as a three-element row vector in the form [x y z]. Units are in meters. Note If the driving scenario does not contain a
                                                  front-axle trajectory for at least one vehicle,
                                                  then the  
 | 
| Position | Position of actor, specified as a real-valued vector of the form [x y z]. Units are in meters. | 
| Velocity | Velocity (v) of actor in the x- y-, and z-directions, specified as a real-valued vector of the form [vx vy vz]. Units are in meters per second. | 
| Roll | Roll angle of actor, specified as a real-valued scalar. Units are in degrees. | 
| Pitch | Pitch angle of actor, specified as a real-valued scalar. Units are in degrees. | 
| Yaw | Yaw angle of actor, specified as a real-valued scalar. Units are in degrees. | 
| AngularVelocity | Angular velocity (ω) of actor in the x-, y-, and z-directions, specified as a real-valued vector of the form [ωx ωy ωz]. Units are in degrees per second. | 
For full definitions of the structure fields, see the actor and vehicle
                            functions.
Current simulation time, specified as a nonnegative real scalar. The
                                drivingScenario object
                            calls the radar detection generator at regular time intervals. The radar
                            detector generates new detections at intervals defined by the
                                UpdateInterval property. The value of the
                                UpdateInterval property must be an integer
                            multiple of the simulation time interval. Updates requested from the
                            sensor between update intervals contain no detections. Units are in
                            seconds.
Example: 10.5
Data Types: double
Output Arguments
Radar sensor detections, returned as a cell array of objectDetection objects.
                            Each object contains these fields:
| Property | Definition | 
|---|---|
| Time | Measurement time | 
| Measurement | Object measurements | 
| MeasurementNoise | Measurement noise covariance matrix | 
| SensorIndex | Unique ID of the sensor | 
| ObjectClassID | Object classification | 
| MeasurementParameters | Parameters used by initialization functions of nonlinear Kalman tracking filters | 
| ObjectAttributes | Additional information passed to tracker | 
For Cartesian coordinates, Measurement,
                                MeasurementNoise, and
                                MeasurementParameters are reported in the
                            coordinate system specified by the
                                DetectionCoordinates property of the radarDetectionGenerator. 
For spherical coordinates, Measurement and
                                MeasurementNoise are reported in the spherical
                            coordinate system based on the sensor Cartesian coordinate system.
                                MeasurementParameters are reported in sensor
                            Cartesian coordinates.
Measurement
| DetectionCoordinates Property | Measurement and Measurement Noise Coordinates | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 'Ego Cartesian' | Coordinate Dependence on HasRangeRate 
 | |||||||||||||||
| 'Sensor Cartesian' | ||||||||||||||||
| 'Sensor Spherical' | Coordinate Dependence on HasRangeRate and HasElevation 
 | 
MeasurementParameters
| Parameter | Definition | 
|---|---|
| Frame | Enumerated type indicating the frame used to
                                                report measurements. When Frameis set to'rectangular',
                                                detections are reported in Cartesian coordinates.
                                                WhenFrameis set'spherical', detections are
                                                reported in spherical coordinates. | 
| OriginPosition | 3-D vector offset of the sensor origin from the
                                                ego vehicle origin. The vector is derived from the SensorLocationandHeightproperties specified
                                                in theradarDetectionGenerator. | 
| Orientation | Orientation of the vision sensor coordinate
                                                system with respect to the ego vehicle coordinate
                                                system. The orientation is derived from the Yaw,Pitch, andRollproperties of theradarDetectionGenerator. | 
| HasVelocity | Indicates whether measurements contain velocity or range rate components. | 
| HasElevation | Indicates whether measurements contain elevation components. | 
ObjectAttributes
| Attribute | Definition | 
|---|---|
| TargetIndex | Identifier of the actor, ActorID, that generated the
                                                detection. For false alarms, this value is
                                                negative. | 
| SNR | Detection signal-to-noise ratio in dB. | 
Number of detections, returned as a nonnegative integer.
- When the - MaxNumDetectionsSourceproperty is set to- 'Auto',- numValidDetsis set to the length of- dets.
- When the - MaxNumDetectionsSourceproperty is set to- 'Property',- detsis a cell array with length determined by the- MaxNumDetectionsproperty. No more than- MaxNumDetectionsnumber of detections are returned. If the number of detections is fewer than- MaxNumDetections, the first- numValidDetselements of- detshold valid detections. The remaining elements of- detsare set to the default value.
Data Types: double
Valid detection time, returned as 0 or
                                1. isValidTime is
                                0 when detection updates are requested at times
                            that are between update intervals specified by
                                UpdateInterval.
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)
Examples
Generate detections using a forward-facing automotive radar mounted on an ego vehicle. Assume that there are three targets:
- Vehicle 1 is in the center lane, directly in front of the ego vehicle, and driving at the same speed. 
- Vehicle 2 is in the left lane and driving faster than the ego vehicle by 12 kilometers per hour. 
- Vehicle 3 is in the right lane and driving slower than the ego vehicle by 5 kilometers per hour. 
All positions, velocities, and measurements are relative to the ego vehicle. Run the simulation for ten steps.
dt = 0.1; pos1 = [150 0 0]; pos2 = [160 10 0]; pos3 = [130 -10 0]; vel1 = [0 0 0]; vel2 = [12*1000/3600 0 0]; vel3 = [-5*1000/3600 0 0]; car1 = struct('ActorID',1,'Position',pos1,'Velocity',vel1); car2 = struct('ActorID',2,'Position',pos2,'Velocity',vel2); car3 = struct('ActorID',3,'Position',pos3,'Velocity',vel3);
Create an automotive radar sensor that is offset from the ego vehicle. By default, the sensor location is at (3.4,0) meters from the vehicle center and 0.2 meters above the ground plane. Turn off the range rate computation so that the radar sensor measures position only.
radar = radarDetectionGenerator('DetectionCoordinates','Sensor Cartesian', ... 'MaxRange',200,'RangeResolution',10,'AzimuthResolution',10, ... 'FieldOfView',[40 15],'UpdateInterval',dt,'HasRangeRate',false); tracker = multiObjectTracker('FilterInitializationFcn',@initcvkf, ... 'ConfirmationThreshold',[3 4],'DeletionThreshold',[6 6]);
Generate detections with the radar from the non-ego vehicles. The output
                        detections form a cell array and can be passed directly in to the
                            multiObjectTracker.
simTime = 0;
nsteps = 10;
for k = 1:nsteps
    dets = radar([car1 car2 car3],simTime);
    [confirmedTracks,tentativeTracks,allTracks] = updateTracks(tracker,dets,simTime);Move the cars one time step and update the multi-object tracker.
    simTime = simTime + dt;
    car1.Position = car1.Position + dt*car1.Velocity;
    car2.Position = car2.Position + dt*car2.Velocity;
    car3.Position = car3.Position + dt*car3.Velocity;
endUse birdsEyePlot to create an overhead view of the
                        detections. Plot the sensor coverage area. Extract the X
                        and Y positions of the targets by converting the
                            Measurement fields of the cell array into a
                            MATLAB® array. Display the detections on the bird's-eye plot.
BEplot = birdsEyePlot('XLim',[0 220],'YLim',[-75 75]); caPlotter = coverageAreaPlotter(BEplot,'DisplayName','Radar coverage area'); plotCoverageArea(caPlotter,radar.SensorLocation,radar.MaxRange, ... radar.Yaw,radar.FieldOfView(1)) detPlotter = detectionPlotter(BEplot,'DisplayName','Radar detections'); detPos = cellfun(@(d)d.Measurement(1:2),dets,'UniformOutput',false); detPos = cell2mat(detPos')'; if ~isempty(detPos) plotDetection(detPlotter,detPos) end

Extended Capabilities
Usage notes and limitations:
See System Objects in MATLAB Code Generation (MATLAB Coder).
Version History
Introduced in R2017aThe radarDetectionGenerator
                System object and Radar Detection Generator block are not recommended
                unless you require C/C++ code generation. Instead, use the drivingRadarDataGenerator
                System object and Driving
                        Radar Data Generator, respectively. These new radar sensors provide
                additional properties for modeling radar sensors, including the ability to generate
                tracks and clustered detections.
There are no current plans to remove the radarDetectionGenerator System object or Radar Detection Generator block. MATLAB code and Simulink® models that use these features will continue to run. You can still import radarDetectionGenerator objects into the Driving Scenario Designer app. However, the app updates the parameters of the imported sensor to reflect the parameters of a drivingRadarDataGenerator object. In addition, when you export a scenario containing a radarDetectionGenerator sensor to MATLAB code or to a Simulink model, the app exports the sensor as a drivingRadarDataGenerator object or Driving Radar Data Generator block, respectively.
In MATLAB code, replace all instances of radarDetectionGenerator with drivingRadarDataGenerator. In addition, update all radarDetectionGenerator properties with their equivalent drivingRadarDataGenerator properties, as shown in the table. The properties not listed in the table are either specific only to drivingRadarDataGenerator or identical in both objects.
| radarDetectionGeneratorProperties | Equivalent drivingRadarDataGeneratorProperties | 
|---|---|
| 
 | 
 | 
| 
 
 | 
 | 
| 
 
 
 | 
 | 
| 
 | RangeLimits | 
| 
 | 
 | 
| 
 | 
 | 
| 
 | 
 | 
This table shows sample code for creating a drivingRadarDataGenerator object instead of a radarDetectionGenerator object.
| Discouraged Usage | Recommended Replacement | 
|---|---|
| radar = radarDetectionGenerator( ... 'SensorLocation',[-1 0], ... 'Height',0.2, ... 'Yaw',180, ... 'Pitch',0, ... 'Roll',0, ... 'MaxRange',50); | radar = drivingRadarDataGenerator( ... 'MountingLocation',[-1 0 0.2], ... 'MountingAngles',[180 0 0], ... 'RangeLimits',[0 50]); | 
To generate detections from target poses at each simulation time step, replace the dets = radarDetectionGenerator(targets,time) syntax with dets = drivingRadarDataGenerator(targets,time).
In Simulink models, replace all Radar Detection Generator blocks with Driving Radar Data Generator blocks. In the Driving Radar Data Generator blocks, update the parameter values in the same way you would update the drivingRadarDataGenerator property values described in the Update Code section.
If your model contains a separate block that clusters detections, you can remove it because the Driving Radar Data Generator block clusters detections by default.
For example, in this model, the Sensor Simulation subsystem outputs concatenated detections from Radar Detection Generator blocks into a separate block that clusters the detections.

In this model, the Sensor Simulation subsystem outputs concatenated, clustered detections from Driving Radar Data Generator blocks directly into the next part of the model pipeline.

See Also
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.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)