function egoMap = exampleHelperConstructMultiLayerEgoMap(resolution, width, height, weights)
%exampleHelperConstructMultiLayerEgoMap Create an ego-centric multiLayerMap

% Copyright 2020 The MathWorks, Inc.

    % Create mapLayers for each sensor
    frontLeftLayer  = occupancyMap(width,height,resolution,'LayerName','FrontLeft');
    frontRightLayer = occupancyMap(width,height,resolution,'LayerName','FrontRight');
    rearLayer       = occupancyMap(width,height,resolution,'LayerName','Rear');

    % Create a get callback used to fuse data in the three layers.
    fGet = @(obj, values, varargin)exampleHelperFuseOnGet(frontLeftLayer,frontRightLayer,rearLayer,weights,obj,values,varargin{:});

    % Create a generic mapLayer object whose `getMapData` method fuses data from all
    % three layers.
    fusedLayer = mapLayer(width,height,'Resolution',resolution,'LayerName','FuseLayer','GetTransformFcn',fGet,'DefaultValue',0.5);

    % Combine layers into a multiLayerMap.
    egoMap = multiLayerMap({frontLeftLayer, frontRightLayer, rearLayer, fusedLayer});

    % Set map's grid origin so that the robot is located at the center
    egoMap.GridOriginInLocal = -[diff(egoMap.XLocalLimits) diff(egoMap.YLocalLimits)]/2;
end