function exampleHelperPlotUrbanScenario()
% exampleHelperPlotUrbanScenario A helper function for plotting the
% scenario of the urban driving example

% This is a helper function for example purposes and may be removed or
% modified in the future.
%

% Copyright 2019 The MathWorks, Inc.

%% Initialize the required variables
% Number of roads in the scenario
numRoads = 3;

% Number of lanes available at the segments.
% From point A to point B number of roads are 2
% From point B to point D number of roads are 4
% From point D to point goal point number of roads are 2
numLanes = {2, 4, 2};

% Initialize the figure for visualization of scenario
hFigure = figure('units', 'normalized', 'outerposition', [0 0 1 1]);
hPanel = uipanel(hFigure, 'Units', 'Normalized', 'Position', ...
    [0 0 1 1], 'Title','Urban Scenario with Ego and Other Vehicles');
hAxes = axes('Parent', hPanel);

%% Get the required data from base workspace
% Loading pre-computed lane boundaries and otherVehicles information
otherVehicles = evalin('base', 'otherVehicles');
laneBorders = evalin('base', 'laneBoundaries');

%% Plot otherVehicles and lanes information
for i=1:numRoads
    for j=1:numLanes{i}+1
        plot(laneBorders{i}{j}(:, 1), laneBorders{i}{j}(:, 2),...
            'black', 'Parent', hAxes);
        hold on;
    end
end

% Setting up the position and orientation of ego vehicle according to
% the given path
egoInitPose     = [5.1 -1.8];
egoInitYaw      = 0;

egoPolygon = exampleHelperTransformPointtoPolygon(egoInitYaw, egoInitPose);

% Fill Ego vehicle polygon with green color
fill(egoPolygon(1, :), egoPolygon(2, :), 'g', 'Parent', hAxes);

% Setting up the position and orientation of other otherVehicles
% according to the given path
for i=1:numel(otherVehicles)
    vehicleCenter = [otherVehicles(i).Position(1,1) ...
        otherVehicles(i).Position(1,2)];
    vehiclePolygon = exampleHelperTransformPointtoPolygon(otherVehicles(i).Yaw(1), vehicleCenter);
    
    % Fill other vehicle polygon with blue color
    fill(vehiclePolygon(1, :), vehiclePolygon(2, :), 'b', 'Parent', hAxes);
end
% The camera up vector specifies the direction that is oriented up in the
% plot
hAxes.CameraUpVector = [1 0 0];
hold  off;
end

