drivingRadarDataGenerator
Generate radar sensor detections or track reports from driving scenario or RoadRunner Scenario
Since R2021a
Description
The drivingRadarDataGenerator
System object™ generates detections or track reports of targets from an automotive radar sensor
model. Use this object to generate sensor data from a driving scenario containing actors and
trajectories, which you can create by using a drivingScenario
object. When creating scenarios using the Driving Scenario
Designer app, the radar sensors mounted on the ego vehicle are output as
drivingRadarDataGenerator
objects.
The drivingRadarDataGenerator
object can simulate clustered or unclustered detections
with added random noise and also generate false alarm detections. You can fuse the generated
detections with other sensor data and track objects using a multiObjectTracker
object. You can also output tracks directly from the
drivingRadarDataGenerator
object. To configure whether targets are output as clustered
detections, unclustered detections, or tracks, use the TargetReportFormat
property.
You can also use the drivingRadarDataGenerator
object with vehicle
actors in RoadRunner Scenario simulation. First you must create a SensorSimulation
object to interface sensors with RoadRunner Scenario and then register the lidar as a sensor model using the addSensors
object function before simulation.
To generate radar detection or track reports:
Create the
drivingRadarDataGenerator
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?
Creation
Syntax
Description
creates a
radar sensor that reports clustered detections and uses default property values.rdr
= drivingRadarDataGenerator
sets the rdr
= drivingRadarDataGenerator(id
)SensorIndex
property to id
.
sets properties using
one or more name-value pairs. Enclose each property name in quotes. For example,
rdr
= drivingRadarDataGenerator(___,Name,Value
)drivingRadarDataGenerator('TargetReportFormat','Tracks','FilterInitializationFcn',@initcvkf)
creates a radar sensor that generates track reports by using a tracker that is initialized
by a constant-velocity linear Kalman filter.
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.
Sensor IdentificationSensorIndex
— Unique sensor identifier
0
(default) | positive integer
Unique sensor identifier, specified as a positive integer. Use this property to distinguish
between detections or tracks that come from different sensors in a multisensor system.
Specify a unique value for each sensor. If you do not update
SensorIndex
from the default value of 0
,
then the radar returns an error at the start of simulation.
Data Types: double
UpdateRate
— Sensor update rate (Hz)
10
(default) | positive real scalar
Sensor update rate, in hertz, specified as a positive real scalar. The reciprocal of the update rate must be an integer multiple of the simulation time interval. The radar generates new reports at intervals defined by this reciprocal value. Any sensor update requested between update intervals contains no detections or tracks.
Data Types: double
MountingLocation
— Sensor location on ego vehicle (m)
[3.4 0 0.2]
(default) | 1-by-3 real-valued vector of form [x
y
z]
Sensor location on the ego vehicle body frame, in meters, specified as a 1-by-3 real-valued vector of the form [x y z]. This property defines the coordinates of the sensor along the x-axis, y-axis, and z-axis relative to the ego vehicle origin, where:
The x-axis points forward from the vehicle.
The y-axis points to the left of the vehicle.
The z-axis points up from the ground.
The default value corresponds to a radar that is mounted at the center of the front grill of a sedan.
For more details on the ego vehicle coordinate system, see Coordinate Systems in Automated Driving Toolbox.
Data Types: double
MountingAngles
— Mounting rotation angles of radar (deg)
[0 0 0]
(default) | 1-by-3 real-valued vector of form [zyaw
ypitch
xroll]
Mounting rotation angles of the radar, in degrees, specified as a 1-by-3 real-valued vector of form [zyaw ypitch xroll]. This property defines the intrinsic Euler angle rotation of the sensor around the z-axis, y-axis, and x-axis with respect to the ego vehicle body frame, where:
zyaw, or yaw angle, rotates the sensor around the z-axis of the ego vehicle.
ypitch, or pitch angle, rotates the sensor around the y-axis of the ego vehicle. This rotation is relative to the sensor position that results from the zyaw rotation.
xroll, or roll angle, rotates the sensor about the x-axis of the ego vehicle. This rotation is relative to the sensor position that results from the zyaw and ypitch rotations.
These angles are clockwise-positive when looking in the forward direction of the z-axis, y-axis, and x-axis, respectively. If you visualize sensor data from a bird's-eye view perspective, then the yaw angle is counterclockwise-positive because you are viewing the data in the negative direction of the z-axis, which points up from the ground.
For more details on this coordinate system, see Coordinate Systems in Automated Driving Toolbox.
Data Types: double
HasElevation
— Enable radar to measure target elevation angles
false
or 0
(default) | true
or 1
Enable the radar to measure target elevation angles, specified as a logical
0
(false
) or 1
(true
). Set this property to true
to model a
radar sensor that can estimate target elevation.
Data Types: logical
HasRangeRate
— Enable radar to measure target range rates
true
or 1
(default) | false
or 0
Enable the radar to measure target range rates, specified as a logical 1
(true
) or 0
(false
). Set
this property to true
to model a radar sensor that can measure range
rates from target detections.
Data Types: logical
HasNoise
— Enable addition of noise to radar sensor measurements
true
or 1
(default) | false
or 0
Enable the addition of noise to radar sensor measurements, specified as a logical
1
(true
) or 0
(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 measurement noise
covariance matrix reported in the MeasurementNoise
property of the
generated object detections output, dets
, represents the
measurement noise that is added when HasNoise
is
true
.
Data Types: logical
HasFalseAlarms
— Enable creating false alarm radar detections
true
or 1
(default) | false
or 0
Enable creating false alarm radar measurements, specified as a logical 1
(true
) or 0
(false
). Set
this property to true
to report false alarms. Otherwise, the radar
reports only actual detections.
Data Types: logical
HasOcclusion
— Enable line-of-sight occlusion
true
or 1
(default) | false
or 0
Enable line-of-sight occlusion, specified as a logical 1
(true
) or 0
(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
MaxNumReportsSource
— Source of maximum for number of detection or track reports
'Auto'
(default) | 'Property'
Source of the maximum for the number of detection or track reports, specified as one of these options:
'Auto'
— The sensor reports all detections or tracks.'Property'
— The sensor reports the first N valid detections or tracks, where N is equal to theMaxNumReports
property value.
MaxNumReports
— Maximum number of detections or tracks
50
(default) | positive integer
Maximum number of detections or tracks that the sensor reports, specified as a positive integer. The sensor reports detections in the order of increasing distance from the sensor until reaching this maximum number.
Dependencies
To enable this property, set the MaxNumReportsSource
property
to 'Property'
.
Data Types: double
TargetReportFormat
— Format of generated target reports
'Clustered detections'
(default) | 'Tracks'
| 'Detections'
Format of generated target reports, specified as one of these options:
'Clustered detections'
— The sensor generates target reports as clustered detections, where each target is reported as a single detection that is the centroid of the unclustered target detections. The sensor returns clustered detections as an array ofobjectDetection
objects, as described in thedets
output argument.'Tracks'
— The sensor generates target reports as tracks, which are clustered detections that have been processed by a tracking filter. The sensor returns tracks as an array ofobjectTrack
objects, as described in thetracks
output argument.'Detections'
— The sensor generates target reports as unclustered detections, where each target can have multiple detections. The sensor returns unclustered detections as an array ofobjectDetection
objects, as described in thedets
output argument.
DetectionCoordinates
— Coordinate system of reported detections
'Body'
(default) | 'Sensor rectangular'
| 'Sensor spherical'
Coordinate system of reported detections, specified as one of these options:
'Body'
— Detections are reported in the rectangular body system of the ego vehicle.'Sensor rectangular'
— Detections are reported in the rectangular body system of the radar sensor.'Sensor spherical'
— Detections are reported in a spherical coordinate system that is centered at the radar sensor and aligned with the orientation of the radar on the ego vehicle.
AzimuthResolution
— Azimuth resolution of radar (deg)
4
(default) | positive real scalar
Azimuth resolution of the radar, in degrees, specified as a positive scalar. The azimuth resolution defines the minimum separation in azimuth angle at which the radar can distinguish between two targets. The azimuth resolution is typically the 3 dB downpoint of the azimuth angle beamwidth of the radar.
Data Types: double
ElevationResolution
— Elevation resolution of radar (deg)
5
(default) | positive real scalar
Elevation resolution of the radar, in degrees, specified as a positive real scalar. The elevation resolution defines the minimum separation in elevation angle at which the radar can distinguish between two targets. The elevation resolution is typically the half-power beamwidth of the elevation angle beamwidth of the radar.
Dependencies
To enable this property, set the HasElevation
property to true
.
Data Types: double
RangeResolution
— Range resolution of radar (m)
2.5
(default) | positive real scalar
Range resolution of the radar, in meters, specified as a positive real scalar. The range resolution defines the minimum separation in range at which the radar can distinguish between two targets.
Data Types: double
RangeRateResolution
— Range rate resolution of radar (m/s)
0.5
(default) | positive real scalar
Range rate resolution of the radar, in meters per second, 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.
Dependencies
To enable this property, set the HasRangeRate
property to
true
.
Data Types: double
AzimuthBiasFraction
— Azimuth bias fraction of radar
0.1
(default) | nonnegative scalar
Azimuth bias fraction of the radar, specified as a nonnegative scalar. Azimuth bias is expressed as a fraction of the azimuth resolution specified in the AzimuthResolution
property. This value sets a lower bound on the azimuthal accuracy of the radar and is dimensionless.
Data Types: double
ElevationBiasFraction
— Elevation bias fraction of radar
0.1
(default) | nonnegative scalar
Elevation bias fraction of the radar, specified as a nonnegative scalar. Elevation bias is expressed as a fraction of the elevation resolution specified by the ElevationResolution
property. This value sets a lower bound on the elevation accuracy of the radar and is dimensionless.
Dependencies
To enable this property, set the HasElevation
property to true
.
Data Types: double
RangeBiasFraction
— Range bias fraction
0.05
(default) | nonnegative scalar
Range bias fraction of the radar, specified as a nonnegative scalar. Range
bias is expressed as a fraction of the range resolution specified by the
RangeResolution
property. This property sets a lower bound on
the range accuracy of the radar and is dimensionless.
Data Types: double
RangeRateBiasFraction
— Range-rate bias fraction
0.05
(default) | nonnegative scalar
Range-rate bias fraction of the radar, specified as a nonnegative scalar.
Range-rate bias is expressed as a fraction of the range-rate
resolution specified by the RangeRateResolution
property. This
property sets a lower bound on the range rate accuracy of the radar and is
dimensionless.
Dependencies
To enable this property, set the HasRangeRate
property to
true
.
Data Types: double
DetectionProbability
— Probability of detecting target
0.9
(default) | scalar in range (0, 1]
Probability of detecting a target, specified as a scalar in the range (0, 1]. This
property defines the probability of detecting a target with a radar cross-section (RCS),
ReferenceRCS
, at the reference detection range,
ReferenceRange
.
Data Types: double
ReferenceRange
— Reference range for given probability of detection (m)
100
(default) | positive real scalar
Reference range for the given probability of detection and the given reference radar
cross-section (RCS), in meters, specified as a positive real scalar. The
reference range is the range at which a target having a radar
cross-section specified by the ReferenceRCS
property is detected
with a probability of detection specified by the
DetectionProbability
property.
Data Types: double
ReferenceRCS
— Reference radar cross-section for given probability of detection (dBsm)
0
(default) | real scalar
Reference radar cross-section (RCS) for a given probability of detection and reference range,
in decibel square meters, specified as a real scalar. The reference
RCS is the RCS value at which a target is detected with a probability
specified by DetectionProbability
at the specified
ReferenceRange
value.
Data Types: double
FalseAlarmRate
— False alarm report rate
1e-6
(default) | positive real scalar in range [10–7, 10–3]
False alarm report rate within each radar resolution cell, specified as a positive real scalar
in the range [10–7, 10–3]. Units
are dimensionless. The object determines resolution cells from the
AzimuthResolution
and RangeResolution
properties and, when enabled, from the ElevationResolution
and
RangeRateResolution
properties.
Data Types: double
CenterFrequency
— Center frequency of radar band (Hz)
77e9
(default) | positive real scalar
Center frequency of the radar band, in hertz, specified as a positive scalar.
Data Types: double
FieldOfView
— Angular field of view of radar (deg)
[20 5]
| 1-by-2 positive real-valued vector of form [azfov elfov]
Angular field of view of radar, in degrees, specified as a 1-by-2 positive
real-valued vector of the form [azfov elfov]
. The field of view
defines the total angular extent spanned by the sensor. The azimuth field of view,
azfov
, must lie in the interval (0, 360]. The elevation field of
view, elfov
, must lie in the interval (0, 180].
Data Types: double
RangeLimits
— Minimum and maximum range of radar (m)
[0 150]
(default) | 1-by-2 nonnegative real-valued vector of form [min max]
Minimum and maximum range of radar, in meters, specified as a 1-by-2 nonnegative
real-valued vector of the form [min max]
. The radar does not detect
targets that are outside this range. The maximum range, max
, must be
greater than the minimum range, min
.
RangeRateLimits
— Minimum and maximum range rate of radar (m/s)
[-100 100]
(default) | 1-by-2 real-valued vector of form [min max]
Minimum and maximum range rate of radar, in meters per second, specified as a 1-by-2
real-valued vector of the form [min max]
. The radar does not detect
targets that are outside this range rate. The maximum range rate,
max
, must be greater than the minimum range rate,
min
.
Dependencies
To enable this property, set the HasRangeRate
property to
true
.
RadarLoopGain
— Radar loop gain
real scalar
This property is read-only.
Radar loop gain, specified as a real scalar. RadarLoopGain
depends on the
values of the DetectionProbability
,
ReferenceRange
, ReferenceRCS
, and
FalseAlarmRate
properties. Radar loop gain is a function of the
reported signal-to-noise ratio of the radar, SNR, the target radar
cross-section, RCS, and the target range, R, as
described by this equation:
SNR = RadarLoopGain
+
RCS –
40log10(R)
SNR and RCS are in decibels and
decibel square meters, respectively, R is in meters, and
RadarLoopGain
is in decibels.
Data Types: double
FilterInitializationFcn
— Kalman filter initialization function
@initcvekf
(default) | function handle | character vector | string scalar
Kalman filter initialization function, specified as a function handle or as a character vector or string scalar of the name of a valid Kalman filter initialization function.
The table shows the initialization functions that you can use to specify FilterInitializationFcn
.
Initialization Function | Function Definition |
---|---|
initcaabf | Initialize constant-acceleration alpha-beta Kalman filter |
initcvabf | Initialize constant-velocity alpha-beta Kalman filter |
initcakf | Initialize constant-acceleration linear Kalman filter. |
initcvkf | Initialize constant-velocity linear Kalman filter. |
initcaekf | Initialize constant-acceleration extended Kalman filter. |
initctekf
| Initialize constant-turnrate extended Kalman filter. |
initcvekf | Initialize constant-velocity extended Kalman filter. |
initcaukf
| Initialize constant-acceleration unscented Kalman filter. |
initctukf | Initialize constant-turnrate unscented Kalman filter. |
initcvukf | Initialize constant-velocity unscented Kalman filter. |
You can also write your own initialization function. The function must have the following syntax:
filter = filterInitializationFcn(detection)
objectDetection
object. The output of this function must be a tracking filter object, such as trackingKF
, trackingEKF
, trackingUKF
, or trackingABF
.To guide you in writing this function, you can examine the details of the supplied functions from within MATLAB®. For example:
type initcvekf
Dependencies
To enable this property, set the TargetReportFormat
property to 'Tracks'
.
Data Types: function_handle
| char
| string
ConfirmationThreshold
— Threshold for track confirmation
[2 3]
(default) | 1-by-2 vector of positive integers
Threshold for track confirmation, specified as a 1-by-2 vector of positive integers of the
form [M N]
. A track is confirmed if it receives at least
M
detections in the last N
updates.
M
must be less than or equal to N
.
When setting
M
, take into account the probability of object detection for the sensors. The probability of detection depends on factors such as occlusion or clutter. You can reduceM
when tracks fail to be confirmed or increaseM
when too many false detections are assigned to tracks.When setting
N
, consider the number of times you want the tracker to update before it makes a confirmation decision. For example, if a tracker updates every 0.05 seconds, and you want to allow 0.5 seconds to make a confirmation decision, setN = 10
.
Example: [3 5]
Dependencies
To enable this property, set the TargetReportFormat
property to 'Tracks'
.
Data Types: double
DeletionThreshold
— Threshold for track deletion
[5 5]
(default) | 1-by-2 vector of positive integers
Threshold for track deletion, specified as a 1-by-2 vector of positive integers of the form
[P R]
. If a confirmed track is not assigned to any detection
P
times in the last R
tracker updates, then
the track is deleted. P
must be less than or equal to
R
.
To reduce how long the radar maintains tracks, decrease
R
or increaseP
.To maintain tracks for a longer time, increase
R
or decreaseP
.
Example: [3 5]
Dependencies
To enable this property, set the TargetReportFormat
property to 'Tracks'
.
Data Types: double
TrackCoordinates
— Coordinate system of reported tracks
'Body'
(default) | 'Sensor'
Coordinate system of reported tracks, specified as one of these options:
'Body'
— Tracks are reported in the rectangular body system of the ego vehicle.'Sensor'
— Tracks are reported in the rectangular body system of the radar sensor.
Dependencies
To enable this property, set the TargetReportFormat
property
to 'Tracks'
.
Profiles
— Actor profiles
structure | array of structures
Actor profiles, specified as a structure or as an array of structures. Each structure contains the physical and radar characteristics of an actor.
If
ActorProfiles
is a single structure, all actors passed into thedrivingRadarDataGenerator
object use this profile.If
ActorProfiles
is 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. 0 is
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.
Data Types: struct
Usage
Syntax
Description
Generate Detections
These syntaxes apply when you set the TargetReportFormat
property to 'Clustered detections'
or
'Detections'
.
[
also returns the number of valid detections reported,
dets
,numReports
] = rdr(targets
,simTime
)numReports
.
[
also returns a logical value, dets
,numReports
,isValidTime
] = rdr(targets
,simTime
)isValidTime
, indicating whether
simTime
is a valid time for generating detections. If
simTime
is an integer multiple of the reciprocal of the UpdateRate
property value, then isValidTime
is
1
(true
).
Generate Tracks
These syntaxes apply when you set the TargetReportFormat
property to 'Tracks'
.
[
also returns the number of valid tracks reported,
tracks
,numReports
] = rdr(targets
,simTime
)numReports
.
[
also returns a logical value, tracks
,numReports
,isValidTime
] = rdr(targets
,simTime
)isValidTime
, indicating whether
simTime
is a valid time for generating tracks. If
simTime
is an integer multiple of the reciprocal of the UpdateRate
property value, then isValidTime
is
1
(true
).
Input Arguments
targets
— Target actor poses
structure | structure array
Target actor poses, specified as a structure or structure array. Each structure
corresponds to the pose of a target actor relative to the ego vehicle. To generate
these structures, use the targetPoses
function. You can also
create these structures manually. Do not include the ego vehicle pose in the structure
array.
This table shows the required fields for the structures.
Field | Description |
---|---|
ActorID | Scenario-defined actor identifier, specified as a positive integer. |
ClassID | Classification identifier, specified as a nonnegative integer. 0
represents an object of an unknown or unassigned class. |
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 scalar. Units are in degrees. |
Pitch | Pitch angle of actor, specified as a real scalar. Units are in degrees. |
Yaw | Yaw angle of actor, specified as a real 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. |
simTime
— Current simulation time
nonnegative real scalar
Current simulation time, in seconds, specified as a nonnegative real scalar.
Example: 10.5
Data Types: double
Output Arguments
dets
— Generated detections
cell array of objectDetection
objects
Generated detections, returned as a cell array of objectDetection
objects. Each object contains these properties:
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 rectangular coordinates, Measurement
and
MeasurementNoise
are reported in the rectangular coordinate
system specified by the DetectionCoordinates
property of the
drivingRadarDataGenerator
object.
For spherical coordinates, Measurement
and
MeasurementNoise
are reported in the spherical coordinate
system, which is based on the sensor rectangular coordinate system.
Measurement
and
MeasurementNoise
DetectionCoordinates Value | Measurement and
MeasurementNoise Coordinates | |||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
'Body' |
Coordinate Dependence on
| |||||||||||||||
'Sensor rectangular' | ||||||||||||||||
'Sensor spherical' |
Coordinate Dependence on
|
For ObjectAttributes
, this table describes the additional
information used for tracking.
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. |
For MeasurementParameters
, the measurements are relative to
the parent frame. When you set the DetectionCoordinates
property
to 'Body'
, the parent frame is the ego vehicle body. When you set
DetectionCoordinates
to 'Sensor rectangular'
or 'Sensor spherical'
, the parent frame is the sensor.
MeasurementParameters
Parameter | Definition |
---|---|
Frame | Enumerated type indicating the frame used to report measurements. When
Frame is set to 'rectangular' ,
detections are reported in rectangular coordinates. When
Frame is set to 'spherical' ,
detections are reported in spherical coordinates. |
OriginPosition | 3-D vector offset of the sensor origin from the parent frame origin. |
OriginVelocity | Velocity of the sensor coordinate system with respect to the parent frame. |
Orientation | Orientation of the radar sensor coordinate system with respect to the parent frame. |
IsParentToChild | Logical scalar indicating if Orientation performs a
frame rotation from the parent coordinate frame to the child coordinate
frame. When IsParentToChild is false, then
Orientation performs a frame rotation from the child
coordinate frame to the parent coordinate frame. |
HasAzimuth | Indicates whether measurements contain azimuth components. |
HasElevation | Indicates whether measurements contain elevation components. |
HasRange | Indicates whether measurements contain range components. |
HasVelocity | Indicates whether measurements contain velocity or range rate components. |
tracks
— Generated tracks
objectTrack
array | structure array
Generated tracks, returned as an objectTrack
array in
MATLAB and a structure array in generated code. In generated code, the field
names of the returned structure are same as the property names of the
objectTrack
object.
The sensor returns only confirmed tracks, which are tracks
that satisfy the confirmation threshold specified in the ConfirmationThreshold
property. For these tracks, the
IsConfirmed
property of the object or field of the structure is
true
.
Data Types: struct
| object
numReports
— Number of reported detections or tracks
nonnegative integer
Number of reported detections or tracks, returned as a nonnegative integer.
numReports
is equal to the length of dets
when generating detections and tracks
when generating
tracks.
Data Types: double
isValidTime
— Valid time for generating reports
0
| 1
Valid time for generating reports, returned as a logical 0
(false
) or 1
(true
).
If isValidTime
is 0
(false
), then the reports returned by dets
(for generated detections) or tracks
(for generated tracks) are
invalid because the sensor generated them at a time that is inconsistent with the
sensor update rate.
The sensor generates reports only when the current simulation time,
simTime
, is an integer multiple of the time interval at which
the sensor generates reports. This time interval is equal to the reciprocal 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)
Specific to drivingRadarDataGenerator
Examples
Generate Radar Detections and Tracks of Multiple Vehicles
Use a radar sensor to generate clustered detections, unclustered detections, and tracks of multiple vehicles in a driving scenario.
Create Driving Scenario
Create an empty driving scenario and add a two-lane, 100-meter road segment. Separate the lanes by using dashed lane markings.
scenario = drivingScenario('SampleTime',0.02); roadCenters = [0 0 0; 100 0 0]; marking = [laneMarking('Solid') laneMarking('Dashed') laneMarking('Solid')]; laneSpecification = lanespec([1 1],'Marking',marking); road(scenario,roadCenters,'Lanes',laneSpecification);
Add the ego vehicle. The vehicle travels 90 meters in the right lane at a constant speed of 20 meters per second.
ego = vehicle(scenario,'ClassID',1,'Position',[5 -1.8 0]); egoWaypoints = [ego.Position; ... (ego.Position(1) + 90) ego.Position(2:3)]; egoSpeed = 20; % m/s smoothTrajectory(ego,egoWaypoints,egoSpeed)
Add the target vehicles that the radar can generate detections and tracks from.
The first vehicle is a car that starts 10 meters in front of the ego vehicle and travels along the lane at a constant speed of 30 meters per second.
The second vehicle is a truck that travels in the left lane at a constant speed of 30 meters per second.
car = vehicle(scenario,'ClassID',1,'Position',[ego.Position(1)+10 -1.8 0]); carWaypoints = [car.Position; ... (car.Position(1) + 75) car.Position(2:3)]; carSpeed = 30; % m/s smoothTrajectory(car,carWaypoints,carSpeed) truck = vehicle(scenario,'ClassID',2,'Position',[5 1.8 0], ... 'Length',8.2,'Width',2.5,'Height',3.5); truckWaypoints = [truck.Position; ... (truck.Position(1) + 90) truck.Position(2:3)]; truckSpeed = 30; % m/s smoothTrajectory(truck,truckWaypoints,truckSpeed)
Plot the driving scenario and pause to allow time for the plot to update.
plot(scenario) while advance(scenario) pause(scenario.SampleTime) end
Create Radar Sensor
Create a radar sensor with a maximum range of 100 meters and mount it to the front mirror of the ego vehicle. Configure the sensor to update at the same rate as the sample time of the scenario. Specify for the radar to use the target profiles of the car and truck for generating data.
close(gcf) maxRange = 100; % m frontMirror = [ego.FrontOverhang 0 (ego.Height-0.1)]; profiles = actorProfiles(scenario); targetProfiles = profiles(2:end); id = 1; rdr = drivingRadarDataGenerator(id,'UpdateRate',1/scenario.SampleTime, ... 'MountingLocation',frontMirror, ... 'RangeLimits',[0 maxRange], ... 'Profiles',targetProfiles)
rdr = drivingRadarDataGenerator with properties: SensorIndex: 1 UpdateRate: 50 MountingLocation: [0.9000 0 1.3000] MountingAngles: [0 0 0] FieldOfView: [20 5] RangeLimits: [0 100] RangeRateLimits: [-100 100] DetectionProbability: 0.9000 FalseAlarmRate: 1.0000e-06 Use get to show all properties
Create Bird's-Eye Plot
Create a bird's-eye plot for visualizing the sensor data. Add plotters for visualizing the lane markings, vehicle outlines, and radar coverage area. Use the helperPlotScenario
function to plot these aspects of the scenario. This helper function is defined at the end of the example.
bep = birdsEyePlot('XLim',[0 60],'YLim',[-35 35]); lmPlotter = laneMarkingPlotter(bep,'Tag','lm','DisplayName','Lane markings'); olPlotter = outlinePlotter(bep,'Tag','ol'); caPlotter = coverageAreaPlotter(bep, ... 'Tag','ca', ... 'DisplayName','Radar coverage area', ... 'FaceColor','red','EdgeColor','red'); helperPlotScenario(bep,rdr,ego)
Generate Clustered Detections
Use the radar to generate clustered detections of the target vehicles. Visualize these detections on the bird's-eye plot. At each simulation time step, the radar generates only one detection per target.
clusterDetPlotter = detectionPlotter(bep, ... 'DisplayName','Clustered detections', ... 'MarkerEdgeColor','red', ... 'MarkerFaceColor','red'); restart(scenario) while advance(scenario) simTime = scenario.SimulationTime; targets = targetPoses(ego); [dets,numDets,isValidTime] = rdr(targets,simTime); helperPlotScenario(bep,rdr,ego) if isValidTime && numDets > 0 detPos = cell2mat(cellfun(@(d)d.Measurement(1:2),dets, ... 'UniformOutput',false)')'; plotDetection(clusterDetPlotter,detPos) end end
Generate Unclustered Detections
Use the radar to generate unclustered detections of the target vehicles. Visualize these detections on the bird's-eye plot. At each simulation time step, the radar generates multiple detections per target.
clearData(clusterDetPlotter) release(rdr) rdr.TargetReportFormat = "Detections"; detPlotter = detectionPlotter(bep, ... 'DisplayName','Unclustered detections', ... 'MarkerEdgeColor','red'); restart(scenario) while advance(scenario) simTime = scenario.SimulationTime; targets = targetPoses(ego); [dets,numDets,isValidTime] = rdr(targets,simTime); helperPlotScenario(bep,rdr,ego) if isValidTime && numDets > 0 detPos = cell2mat(cellfun(@(d)d.Measurement(1:2),dets, ... 'UniformOutput',false)')'; plotDetection(detPlotter,detPos) end end
Generate Tracks
Use the radar to generate tracks of the target vehicles. Visualize these tracks and the track history on the bird's-eye plot.
clearData(detPlotter) release(rdr) rdr.TargetReportFormat = "Tracks"; historyDepth = 20; tPlotter = trackPlotter(bep,'DisplayName','Tracks', ... 'HistoryDepth',historyDepth); restart(scenario) while advance(scenario) simTime = scenario.SimulationTime; targets = targetPoses(ego); [tracks,numTracks,isValidTime] = rdr(targets,simTime); helperPlotScenario(bep,rdr,ego) if isValidTime && numTracks > 0 trackPos = cell2mat(arrayfun(@(t)t.State(1:2:end),tracks, ... 'UniformOutput', false)')'; plotTrack(tPlotter,trackPos(:,1:2)) end end
Close the bird's-eye plot, restart the scenario, and release the radar sensor.
close(gcf) restart(scenario) release(rdr)
Supporting Functions
helperPlotScenario
plots the lane markings and vehicle outlines of the ego vehicle on the bird's-eye plot. It also plots the coverage area of the radar sensor.
function helperPlotScenario(bep,radar,ego) % Plot lane markings lmPlotter = findPlotter(bep,'Tag','lm'); [lmv,lmf] = laneMarkingVertices(ego); plotLaneMarking(lmPlotter,lmv,lmf) % Plot vehicle outlines olPlotter = findPlotter(bep,'Tag','ol'); [position,yaw,length,width,originOffset,color] = targetOutlines(ego); plotOutline(olPlotter,position,yaw,length,width, ... 'OriginOffset',originOffset,'Color',color) % Plot radar coverage area caPlotter = findPlotter(bep,'Tag','ca'); plotCoverageArea(caPlotter,radar.MountingLocation(1:2), ... radar.RangeLimits(2),radar.MountingAngles(1), ... radar.FieldOfView(1)) end
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Usage notes and limitations:
For driving scenario workflows, the
drivingRadarDataGenerator
System object supports standalone deployment using MATLAB Coder™, and also for Simulink® Real-Time™ targets.See System Objects in MATLAB Code Generation (MATLAB Coder).
Version History
Introduced in R2021a
See Also
Objects
objectDetection
|objectTrack
|drivingScenario
|multiObjectTracker
|visionDetectionGenerator
|lidarPointCloudGenerator
|insSensor
Functions
Blocks
Apps
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)