radar scenario tutorial -凯发k8网页登录
this example shows how to construct and visualize a simple radar scenario programmatically using the radarscenario
, theaterplot
, and radardatagenerator
objects.
scenario setup
to begin, create an empty radar scenario. all scenario properties have default values. the scenario does not contain any platform by default.
scenario = radarscenario
scenario = radarscenario with properties: isearthcentered: 0 updaterate: 10 simulationtime: 0 stoptime: inf simulationstatus: notstarted platforms: {} surfacemanager: [1x1 radar.scenario.surfacemanager] atmospheremanager: [1x1 radar.scenario.atmospheremanager]
adding platforms
a scenario is comprised of objects, called platforms, upon which you may mount sensors and emitters. to add a platform, use the platform
object function. here you create a simple tower.
tower = platform(scenario)
tower = platform with properties: platformid: 1 classid: 0 position: [0 0 0] orientation: [0 0 0] dimensions: [1x1 struct] trajectory: [1x1 kinematictrajectory] poseestimator: [1x1 inssensor] emitters: {} sensors: {} signatures: {[1x1 rcssignature]}
platform identification
when you first construct a platform, it has a platformid
, which is a unique identifier you can use to identify the platform. the scenario assigns platform identifiers in the order that the platforms are created. you can specify a classid
to denote the platform's classification. for example, here you use a 3 to denote a tower.
tower.classid = 3;
platform signatures
sensors can detect platforms. for radar sensors, a relevant signature is the radar cross-section (rcs). by default a uniform rcs signature is used:
tower.signatures{1}
ans = rcssignature with properties: enablepolarization: 0 pattern: [2x2 double] azimuth: [-180 180] elevation: [2x1 double] frequency: [0 1.0000e 20] fluctuationmodel: swerling0
load predefined cylinder rcs data and use the data to define the rcs of the tower platform.
load('rcscylinderexampledata.mat','cylinder'); tower.signatures{1} = rcssignature('pattern', cylinder.rcsdbsm, ... 'azimuth', cylinder.azimuth, 'elevation', cylinder.elevation, ... 'frequency', cylinder.frequency);
platform dimensions
by default, platforms have no dimensions and are modeled as point targets. you may optionally specify the length, width, and height to denote the extent of the object, along with an offset of the body frame origin from its from its geometric center. you can specify platform dimensions using the dimensions
property.
you specify the dimensions of the tower like this:
tower.dimensions = struct( ... 'length', 10, ... 'width', 10, ... 'height', 60, ... 'originoffset', [0 0 30]);
the tower has a length, width, and height of 10, 10, and 60 meters. the origin offset of [0 0 30] indicates that its body frame origin (rotational center) is 30 meters in the positive z-direction of the platform's local body axis.
platform trajectories
you can obtain a platform's current position and orientation through its position
and orientation
properties. you can obtain more information about platforms using the scenario's platformposes method:
scenario.platformposes
ans = struct with fields: platformid: 1 classid: 3 position: [0 0 0] velocity: [0 0 0] acceleration: [0 0 0] orientation: [1x1 quaternion] angularvelocity: [0 0 0]
you can specify a platform's position and orientation over time using its trajectory
property. you can specify the trajectory of a platform using a kinematictrajectory
, waypointrajectory
, or geotrajectory
object.
by default, a platform consists of a static kinetictrajectory
that whose body axis is perfectly centered and aligned with the scenario axes:
tower.trajectory
ans = kinematictrajectory with properties: samplerate: 100 position: [0 0 0] orientation: [1x1 quaternion] velocity: [0 0 0] accelerationsource: 'input' angularvelocitysource: 'input'
to obtain a pitch angle of 4 degrees, you use the orientation
property of the trajectory object. specify the orientation using a quaternion obtained from euler angles.
tyaw = 0; tpitch = 4; troll = 0; tower.trajectory.orientation = quaternion([tyaw tpitch troll],'eulerd','zyx','frame');
axes conventions
most examples in radar toolbox, use a "north-east-down" convention. this means that the x-axis points towards north, the y-axis points toward east, and the z-axis points downwards. also, the x-, y-, and z- directions of the local body frame are the forward, right, and downward directions, respectively.
visualizing a scenario
the theaterplot
object provides an interface to plot objects dynamically in a 3-d scene. you may use standard matlab axes plotting methods to add or remove annotations to the theater plot's axes, which you can obtain via its parent
property.
use a platformplotter
to plot platforms.
as expected, the tower is centered at the origin in ned coordinates with a pitch of 4 degrees.
tplot = theaterplot('xlim',[-50 50],'ylim',[-50 50],'zlim',[-100 0]); pplotter = platformplotter(tplot,'displayname','tower'); pose = platformposes(scenario); towerpose = pose(1); towerdims = tower.dimensions; plotplatform(pplotter, towerpose.position, towerdims, towerpose.orientation); set(tplot.parent,'ydir','reverse', 'zdir','reverse'); view(tplot.parent, -37.5, 30)
adding sensors to platforms
to add a radar sensor to the platform, you can add a radardatagenerator
object on the platform by using its sensors
property.
keep in mind that in a ned coordinate system, the "z" direction points down. therefore, if you want to mount a radar at the top of the tower, you should set its "z" position to -60 meters.
the radardatagenerator
has the option to report detections in scenario coordinates. reporting detections in scenario coordinates makes it easier to compare the generated detections with the positions of the objects in the scenario.
towerradar = radardatagenerator('sensorindex', 1, ... 'updaterate', 10, ... 'mountinglocation', [0 0 -60], ... 'scanmode', 'no scanning', ... 'hasins', true, ... 'targetreportformat', 'detections', ... 'detectioncoordinates', 'scenario'); tower.sensors = towerradar;
visualizing coverage areas
to see sensor coverages in a scenario, you use a coverage plotter and plot the coverage configuration of the scenario. you can widen the theater plot's range by adjusting the limits of its internal axes:
tplot.xlimits = [-5000 5000]; tplot.ylimits = [-5000 5000]; tplot.zlimits = [-1000 0]; covplotter = coverageplotter(tplot,'displayname','sensor coverage'); plotcoverage(covplotter, coverageconfig(scenario));
platform signatures
you can add other platforms in the scenario and adjust parameters that affect how other sensors observe the platforms. you can use an rcssignature
to model what the radar mounted on the tower would see.
the following code creates a helicopter and sets its radar cross section omnidirectionally to a value of 40 dbsm.
helicopter = platform(scenario); helicopter.dimensions = struct( ... 'length',30, ... 'width', .1, ... 'height', 7, ... 'originoffset',[0 8 -3.2]); helicopter.signatures = rcssignature( ... 'pattern',[40 40; 40 40], ... 'elevation',[-90; 90], ... 'azimuth',[-180,180]);
you can mount more than one sensor to any platform by placing the sensors in a cell array before assigning to the sensors
property.
helicopter.sensors = { ... radardatagenerator('sensorindex', 2, ... 'updaterate', 20, ... 'mountinglocation', [22 0 0], ... 'mountingangles', [-5 0 0], ... 'scanmode', 'no scanning', ... 'hasins', true, ... 'targetreportformat', 'detections', ... 'detectioncoordinates', 'scenario'), ... radardatagenerator('sensorindex', 3, ... 'updaterate', 30, ... 'mountinglocation', [22 0 0], ... 'mountingangles', [5 0 0], ... 'scanmode', 'no scanning', ... 'hasins', true, ... 'targetreportformat', 'detections', ... 'detectioncoordinates', 'scenario')};
platform motion and animation
you can arrange for the helicopter to cross the path of the radar beam. this shows how to make the helicopter follow a straight 100-meter path at a constant velocity with an elevation of 250 meters for seven seconds:
helicopter.trajectory = waypointtrajectory([2000 50 -250; 2000 -50 -250],[0 7]);
platform motion across time is performed by using a while-loop and calling the scenario's advance
method.
you can plot all the platforms positions, orientations and dimensions in the loop:
profiles = platformprofiles(scenario); dimensions = vertcat(profiles.dimensions); while advance(scenario) poses = platformposes(scenario); positions = vertcat(poses.position); orientations = vertcat(poses.orientation); plotplatform(pplotter, positions, dimensions, orientations); plotcoverage(covplotter, coverageconfig(scenario)); % to animate more slowly uncomment the following line % pause(0.01) end
detecting platforms
in the example above, you added three radars with different update rates: the tower has an update rate of 10 hz, and the helicopter had two radars with update rates of 20 hz and 30 hz, respectively.
the scenario can be placed into a mode in which the call to advance
updates the time of simulation as needed to update each of the sensors it contains. you can achieve this by setting the updaterate
of the scenario to zero.
scenario.updaterate = 0;
to show the simulation time, add a ui control to the figure.
fig = ancestor(tplot.parent,'figure'); timereadout = uicontrol(fig,'style','text','horizontalalignment','left','position',[0 0 200 20]); timereadout.string = "simulationtime: " scenario.simulationtime;
now the proper sensor times can be reached. you can use detect
to get the detections available by each sensor within the loop. detections can be shown by constructing a detectionplotter
object.
dplotter = detectionplotter(tplot,'displayname','detections');
you can run the same simulation again by restarting it and modifying it to report detections.
the detected positions for a radardatagenerator
can be extracted from the detection measurement
field:
restart(scenario); while advance(scenario) timereadout.string = "simulationtime: " scenario.simulationtime; detections = detect(scenario); % extract column vector of measurement positions alldetections = [detections{:}]; if ~isempty(alldetections) measurement = cat(2,alldetections.measurement)'; else measurement = zeros(0,3); end plotdetection(dplotter, measurement); poses = platformposes(scenario); positions = vertcat(poses.position); orientations = vertcat(poses.orientation); plotplatform(pplotter, positions, dimensions, orientations); plotcoverage(covplotter, coverageconfig(scenario)); end
notice that the update time of simulation increments non-uniformly to the times required by each of the sensors.
summary
in this example, you learned how to construct and visualize a simple scenario and obtain detections generated by a radar data generator.