Main Content

showDynamicMap

Plot dynamic occupancy grid map

Description

showDynamicMap(tracker) plots the dynamic occupancy grid map in the local coordinates. The static cells are shown using grayscale images, in which the grayness represents the occupancy probability of the cell. The dynamic cells are shown using HSV (hue, saturation, and value) values on an RGB colormap:

  • Hue — The orientation angle of the velocity vector divided by 360. As hue increases from 0 to 1, the color changes in the order of red to orange, yellow, green, cyan, blue, magenta, and back to red.

  • Saturation — The Mahalanobis distance (d) between the velocity distribution of the grid cell and the zero velocity. A cell with d > 4 is drawn with full saturation.

  • Value — The occupancy probability of the cell.

example

showDynamicMap(tracker,Name,Value) specifies options using one or more name-value pair arguments. Enclose each Name in quotes. For example, showDynamicMap(myTracker,"PlotVelocity",true) plots the dynamic map for myTracker with velocity plotting enabled.

Examples

collapse all

Create a tracking scenario.

scene = trackingScenario('UpdateRate',5,'StopTime',5);
rng(2021); % For reproducible results

Add a platform with a mounted lidar sensor to the tracking scenario.

plat = platform(scene);
lidar = monostaticLidarSensor(1,'DetectionCoordinates','Body','HasOrganizedOutput',false);

Add two targets with random positions and velocities to the scenario. Also, define the trajectory, mesh, and dimension of each platform.

for i = 1:2
    target = platform(scene);
    x = 50*(2*rand - 1);
    y = 50*(2*rand - 1);
    vx = 5*(2*rand - 1);
    vy = 5*(2*rand - 1);
    target.Trajectory.Position = [x y 0];
    target.Trajectory.Velocity = [vx vy 0];
    % Align the orientation of the target with the direction of motion.
    target.Trajectory.Orientation = quaternion([atan2d(vy,vx),0,0],'eulerd','ZYX','frame');
    target.Mesh = extendedObjectMesh('sphere');
    target.Dimensions = struct('Length',4,'Width',4,'Height',2,'OriginOffset',[0 0 0]);
end

Define the configuration of the lidar sensor.

config = trackingSensorConfiguration(1,...
    'SensorLimits',[-180 180;0 100],...
    'SensorTransformParameters',struct,...
    'IsValidTime',true);

Create a grid-based tracker.

tracker = trackerGridRFS('SensorConfigurations',config,...
    'AssignmentThreshold',5,...
    'MinNumCellsPerCluster',4,...
    'ClusteringThreshold',3);

Advance the scenario and run the tracker with the lidar data.

while advance(scene)
   
    time = scene.SimulationTime;
    
    % Generate point cloud.
    tgtMeshes = targetMeshes(plat);
    [ptCloud, config] = lidar(tgtMeshes, time);
    
    % Format the data for the tracker.
    sensorData = struct('Time',time,...
        'SensorIndex',1,...
        'Measurement',ptCloud',...
        'MeasurementParameters',struct...
        );    
    % Update the tracker using the sensor data.
    tracks = tracker(sensorData, time);
end

Show the dynamic map.

showDynamicMap(tracker)
xlabel('x (m)');
ylabel('y (m)');

Figure contains an axes object. The axes object contains 2 objects of type image, surface.

Input Arguments

collapse all

Grid-based RFS tracker, specified as a trackerGridRFS object.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: showDynamicMap(myTracker,"PlotVelocity",false) plots the dynamic map for myTracker with velocity plotting enabled.

Enable velocity plotting, specified as true or false. When specified as true, the velocity vector for each dynamic cell is plotted at the center of the grid cell. The length of the plotted vector represents the magnitude of the velocity.

Parent axes on which to plot the map, specified as an Axes handle.

Enable updating from previous map, specified as true or false. When specified as true, the function plots the map via a lightweight update to the previous map in the figure. When specified as false, the function plots a new map on the figure every time.

Enable inverted colors on the map, specified as true or false. When specified as false, the function plots empty space in white and occupied space in black. When specified as ture, the function plots empty space in black and occupied space in white.

Extended Capabilities

Version History

Introduced in R2020b