Main Content


Display range detections on bird's-eye plot

Since R2022a



    plotRangeDetection(rangeDetPlotter,ranges,fovs,locations,angles) displays object detections on a bird's-eye-plot from a list of ranges, azimuthal fields of view, sensor mounting locations, and angles. plotRangeDetection displays each object detection as an arc whose radius is the corresponding range value, with arc length proportional to the azimuthal field of view of the sensor. The mounting locations and angles of the sensor determine the center of the arc.

    The range detection plotter, rangeDetPlotter, is associated with a birdsEyePlot object and configures the display of the specified detections.

    To remove all detections associated with detection plotter rangeDetPlotter, call the clearData function and specify rangeDetPlotter as the input argument.

    plotRangeDetection(rangeDetPlotter,ranges,___,labels) displays detections and their labels on a bird's-eye plot in addition to all input arguments from the previous syntax.


    collapse all

    Use a simulated ultrasonic sensor to generate detections for multiple vehicles in a driving scenario.

    Create Driving Scenario

    Create a driving scenario containing a three-lane road using lane specifications.

    scenario = drivingScenario;
    roadCenters = [-120 30 0;-60 0 0;0 0 0; 60 0 0; 120 30 0];
    lspc = lanespec(3);

    Create an ego vehicle that travels in the center lane at a velocity of 30 m/s.

    egovehicle = vehicle(scenario,ClassID=1);
    egopath = [1.5 0 0; 60 0 0; 111 25 0];
    egospeed = 30;

    Add a target vehicle that travels ahead of the ego vehicle at 30.5 m/s in the right lane, and changes lanes close to the ego vehicle.

    ftargetcar = vehicle(scenario,ClassID=1);
    ftargetpath = [8 2; 60 -3.2; 120 33];
    ftargetspeed = 30.5;

    Add a second target vehicle that travels in the left lane at 32m/s.

    ltargetcar = vehicle(scenario,ClassID=1);
    ltargetpath = [-5.0 3.5 0; 60 3.5 0; 111 28.5 0];
    ltargetspeed = 32;

    Display a chase plot from behind the ego vehicle for a 3D view of the scenario..


    Create Ultrasonic Sensors

    Create an ultrasonic sensor mounted at the front of the ego vehicle.

    frontUltrasonic = ultrasonicDetectionGenerator(1,FieldOfView=[70 35]);
    frontUltrasonic.Profiles = actorProfiles(scenario);

    Create a second ultrasonic sensor mounted on the left side of the ego vehicle.

    leftUltrasonic = ultrasonicDetectionGenerator(2,MountingLocation=[0.5 1 0.2],MountingAngles=[90 0 0],FieldOfView=[70 35]);
    leftUltrasonic.Profiles = actorProfiles(scenario);

    Create Bird's-Eye-Plot

    Create a bird's-eye-plot for visualizing the sensor data. Add plotters for visualizing the ultrasonic coverage areas, detections, and points on targets. Use a rangeDetectionPlotter object to visualize ultrasonic detections as arcs and a detectionPlotter object to visualize the closest points on the target as markers. Add plotters to display the lane markings and vehicle outlines.

    % Create bird's eye plot
    bep = birdsEyePlot(XLim=[-20 20],YLim=[-12 12]);
    % Plotters for Coverage areas of two ultrasonic sensors
    fcaPlotter = coverageAreaPlotter(bep,DisplayName="Front Ultrasonic field of view");
    plotCoverageArea(fcaPlotter,frontUltrasonic.MountingLocation(1:2), ...
    lcaPlotter = coverageAreaPlotter(bep,DisplayName="Left Ultrasonic field of view",FaceColor="y");
    plotCoverageArea(lcaPlotter,leftUltrasonic.MountingLocation(1:2), ...
    % Range Detection Plotters for Ultrasonic Detections
    frdPlotter = rangeDetectionPlotter(bep,DisplayName="Front Ultrasonic Ranges");
    lrdPlotter = rangeDetectionPlotter(bep,DisplayName="Left Ultrasonic Ranges",LineStyle=":");
    % Detection plotters for closest points on targets
    fdetPlotter = detectionPlotter(bep,DisplayName="Point-On-Target (Front Ultrasonic)",MarkerFaceColor="r");
    ldetPlotter = detectionPlotter(bep,DisplayName="Point-On-Target (Rear Ultrasonic)",MarkerFaceColor="k");
    % Plotters for vehicle and target outlines, lane markings
    olPlotter = outlinePlotter(bep);
    lmPlotter = laneMarkingPlotter(bep,DisplayName="Lane markings");

    Run the Simulation and Generate Detections

    Run the scenario simulation. At each timestep:

    1. Obtain the ground truth target poses, and generate detections for the two ultrasonic sensors.

    2. Obtain and display the target outlines and lane markings.

    3. When there are valid detections, display the detections and the corresponding points-on-targets generated by the ultrasonic sensor.

    while advance(scenario)
        tgtpose = targetPoses(egovehicle);
        [fobdets,fisValid] = frontUltrasonic(tgtpose,scenario.SimulationTime);
        [lobdets,lisValid] = leftUltrasonic(tgtpose,scenario.SimulationTime);
        [objposition,objyaw,objlength,objwidth,objoriginOffset,color] = targetOutlines(egovehicle);
        plotOutline(olPlotter,objposition,objyaw,objlength,objwidth, ...
        [lmv,lmf] = laneMarkingVertices(egovehicle);
        if ~isempty(fobdets) && fisValid
            franges = fobdets{1}.Measurement;
        if ~isempty(lobdets) && lisValid
            lranges = lobdets{1}.Measurement;

    Input Arguments

    collapse all

    Range detection plotter, specified as a rangeDetectionPlotter object. This object is stored in the Plotters property of a birdsEyePlot object and configures the display of the specified detections in the bird's-eye plot. To create this object, use the rangeDetectionPlotter function.

    Range values of detected objects, specified as a 1-by-M real-valued vector. M is the number of detected objects. Each range value is the distance from the sensor to the detected object in vehicle coordinates. The range values are plotted as arcs whose radii are the corresponding range values, with arc lengths proportional to the azimuthal fields of view values of the sensors. Units are in meters.

    Azimuthal fields of view of the sensors, specified as an 1-by-M real-valued vector. Each element is the azimuthal field of view of the sensor that measured the corresponding range value in ranges. Units are in degrees.

    Mounting locations of the sensors, specified as an M-by-3 real-valued matrix. Each row is the mounting location of the sensor that measured the corresponding range value in ranges, and is of the form [x y z]. Units are in meters.

    Mounting angles of the sensors, specified as an M-by-3 real-valued matrix. Each row is the mounting angle of the sensor that measured the corresponding range value in ranges, and is of the form [zyaw ypitch xroll]. Units are in degrees.

    Detection labels, specified as an M-element string array or M-element cell array of character vectors. M is the number of detected objects. The labels correspond to the locations in the ranges vector. By default, detections do not have labels. To remove all annotations and labels associated with the detection plotter, use the clearData function.

    Version History

    Introduced in R2022a