main content

use theaterplot to visualize radar scenario -凯发k8网页登录

this example shows how to use the theaterplot object to visualize various aspects of a radar scenario.

introduction

is an efficient tool for visualizing various aspects of a radar scenario. it is composed of a primary object, which hosts the plotting environment based on a parent axes, and plotters to plot the desired aspects of features from the radar scenario.

this figure shows a structural representation of a theaterplot object.

the parent property specifies the axes on which the theater plot is enabled. you can specify the parent axes of a theater plot during object creation. if you do not specify a parent axes, theaterplot creates a new figure and uses the current axes of the created figure as its parent property. you can also set the axes limits of the parent axes using the xlimits, ylimits, and zlimits properties by using name-value arguments during object creation. set the units of measurement for each axes using the axesunits property.

the plotters property holds plotters that you added to the theaterplot object.

  • — plot platforms in a radar scenario

  • — plot trajectories in a radar scenario

  • — plot orientation of platforms in a radar scenario

  • — plot sensor coverage and sensor beams in a radar scenario

  • — plot sensor detections in a radar scenario

  • — plot tracks in a radar scenario

  • — plot surfaces in a radar scenario

you can specify visual elements and effects for each plotter during the creation of the plotter. each plotter is also paired with a theaterplot object function, which you need to call to plot the results. for example, a coverageplotter is paired with a object function that shows the sensor coverage.

this example showcases a few plotters for visualizing a radar scenario. theaterplot can work efficiently with a radarscenario object even though you do not necessarily need a radarscenario object to use the theaterplot object.

create theaterplot and radarscenario objects

create a radarscenario object and a theaterplot object.

simulationduration = 100;
scene = radarscenario('stoptime',simulationduration);
tp = theaterplot('xlimits',[-250 250],'ylimits',[-250 250],'zlimits',[0 120]);
view(3);grid on;

create trajectory plotter and platform plotter for target

create a waypoint trajectory for a target platform.

timeofarrival = [0  simulationduration];
waypoints = [100 -100 10; 100 100 80];
trajectory = waypointtrajectory(waypoints,timeofarrival);

add a cuboid target platform that follows the specified trajectory. first add a target platform to the radar scenario.

target = platform(scene,'trajectory',trajectory,'dimensions', ...
    struct('length',35,'width',15,'height',5.5,'originoffset',[0 0 0]));

then add a trajectoryplotter object to the theaterplot object, and use the plottrajectory function to plot the waypoint trajectory.

trajplotter = trajectoryplotter(tp,'displayname','trajectory','color','k','linewidth',1.2);
plottrajectory(trajplotter,{trajectory.waypoints})

tip you can plot multiple same-type features (platforms, trajectories, orientations, coverages, detections, or tracks) together using one plotter. for example, you can plot multiple trajectories together by specifying a cell array of waypoints as the second argument of the plottrajectory function. see the syntax description of for more details.

define a plotter for the target platform.

targetplotter = platformplotter(tp,'displayname','target', ...
    'marker','s','markeredgecolor','g','markersize',2);
plotplatform(targetplotter,target.position, ...
    target.dimensions,quaternion(target.orientation,'rotvecd'))

you can add graphical objects other than the plotter objects on the theaterplot by directly plotting on the parent axes of the theaterplot object. put a circle marker at the origin.

hold on
plot3(tp.parent,0,0,0,'color','k','marker','o','markersize',4)

create platform with mounted radar sensor

add a tower platform to the scenario.

tower = platform(scene,'position',[-100,0,0],'dimensions', ...
    struct('length',5,'width',5,'height',30,'originoffset',[0 0 -15]));

display the tower using a platform plotter.

towerplotter = platformplotter(tp,'displayname','tower','marker','s','markersize',2);
plotplatform(towerplotter,tower.position,tower.dimensions,quaternion(tower.orientation,'rotvecd'))

mount a monostatic radar to the top of the tower.

radar = radardatagenerator(1,'detectionmode','monostatic', ...
    'updaterate',5, ...
    'mountinglocation',[0, 0, 30], ...
    'fieldofview',[4, 30],...
    'mechanicalazimuthlimits',[-60 60], ...
    'mechanicalelevationlimits',[0 0], ...
    'haselevation',true, ...
    'rangeresolution',200, ...
    'azimuthresolution',20, ...
    'elevationresolution',20);
tower.sensors = radar;

add a coverageplotter and plot the coverage and initial beam for the monostatic radar. when plotting the coverage, the plotcoverage object function requires a second argument that specifies the configuration of the sensor coverage. obtain the configuration by using the coverageconfig function on the radar scenario scene.

radarplotter = coverageplotter(tp,'color','b','displayname','radar beam');
plotcoverage(radarplotter,coverageconfig(scene))

create a detection plotter to plot the detections that the radar generates.

detplotter = detectionplotter(tp,'displayname','detection','markerfacecolor','r','markersize',4);

run scenario and update theater plot

iterate through the radar scenario and generate radar detections. plot the platform, radar coverage, and detections.

rng(2019) % for repeatable results
while advance(scene)
    % plot target.
    plotplatform(targetplotter,target.position, ...
        target.dimensions,quaternion(target.orientation,'rotvecd'))
    % plot sensor coverage.
    plotcoverage(radarplotter,coverageconfig(scene))
    % extract target pose from the view of the tower and use the extracted
    % pose to generate detections.
    poseintower = targetposes(tower);
    [detections, numdets] = radar(poseintower,scene.simulationtime);
    detpos = zeros(numdets,3);
    detnoise = zeros(3,3,numdets);
    % obtain detection pose relative to the scenario frame. also, obtain
    % the covariance of the detection.
    for i=1:numdets
        a = detections;
        detpos(i,:) = tower.trajectory.position   detections{i}.measurement';
        detnoise(:,:,i) = detections{i}.measurementnoise;
    end
    % plot any generated detections with the covariance ellipses.
    if ~isempty(detpos)
        plotdetection(detplotter,detpos,detnoise)
    end
end

figure contains an axes object. the axes object with xlabel x (m), ylabel y (m) contains 7 objects of type line, patch. one or more of the lines displays its values using only markers these objects represent trajectory, target, tower, radar beam, detection.

you can zoom in on the detection in the figure to visualize the plotted covariance ellipses of the generated detections.

summary

in this example, you learned about the organization of a theaterplot object. you also learned how to visualize a simple radar scenario using the theaterplot object.

网站地图