Contenuto principale

Generate Training Data for NR SSB Temporal-Domain Beam Prediction

Since R2025a

This example shows how to generate training data for synchronization signal block (SSB) temporal-domain beam prediction. The example helps you set up parameters to simulate 2-D trajectories within an urban macrocell (UMa) scenario, as defined in TR 38.901 and TR 38.843. The example calculates the optimal beam pair for each point along the trajectory based on the measured reference signal received power (RSRP) of each beam pair. For further exploration, you can use these calculated optimal RSRP values and their corresponding beam pairs to train and test a recursive neural network (RNN) for the beam management use case from TR 38.843.

Introduction

Millimeter wave (mmWave) communications require the use of beam management techniques due to the high pathloss and blockage experienced at high frequencies. Beam management consists of a set of Layer 1 (physical layer) and Layer 2 (medium access control) procedures to establish and retain an optimal pair of transmit and receive beams for good connectivity. For simulations of 5G New Radio (NR) beam management procedures, see the NR SSB Beam Sweeping, Neural Network for Beam Selection, and NR Downlink Transmit-End Beam Refinement Using CSI-RS examples.

This example considers temporal-domain beam prediction procedures when a user equipment (UE) connects to an access network node (gNB) and moves within the gNB cell boundaries. In 5G NR, the beam selection procedure for initial access involves beam sweeping, which requires exhaustive searches over all transmitter and receiver beams to select the pair with the strongest RSRP. TR 38.843 refers to this procedure as spatial-domain beam prediction. This process is computationally intensive, especially in mmWave communications with numerous beams. If the UE is moving and needs to find the best beam pair at each point in its trajectory, the process becomes even more computationally demanding.

To minimize exhaustive searches and communication overhead, you can apply machine learning to the spatial-domain and temporal-domain beam prediction problems. The spatial-domain beam prediction problem is a classification task to identify the best beam pair index. The temporal-domain beam prediction problem is a sequence prediction task to forecast the optimal beam pair at a future time.

This example uses these baseline simulation assumptions from TR 38.843 Table 6.3.1-1:

  1. The simulation uses a TR 38.901 system-level channel model.

  2. The UEs are randomly positioned inside the first sector of a three-sector cell.

  3. The UEs follow linear trajectories with constant rotation, as per TDoc R1-2306856, without crossing sector boundaries.

  4. To ensure full coverage, the beam count is based on the beamwidth. By default, the example considers ten transmit beams and seven receive beams, according to the antenna specifications defined in TR 38.843 Table 6.3.1-1.

  5. At each point of each UE trajectory, the example performs SSB-based beam sweeping over all 70 beam pairs and identifies the optimal pair by the highest average RSRP.

Generate Data

To generate new data, you can adjust the useSavedData and SaveData check boxes.

useSavedData = true;
saveData     = false;
if useSavedData
    load nnBP_prm.mat;  % Load beam prediction system parameters
    load nnBP_Data.mat; % Load prerecorded data
else

Configure Scenario

Configure the scenario following the default values in TR 38.843 Table 6.3.1-1.

    prm.NCellID               = 1;
    prm.FrequencyRange        = 'FR2';
    prm.Scenario              = "UMa";

    prm.CenterFrequency       = 30e9; % Hz
    prm.SSBlockPattern        = "Case D"; % Case A/B/C/D/E

    % Number of transmitted blocks. Set it to empty to let the example use
    % the minimum number that ensures a full coverage of the 120-degree
    % sector without overlapping of beams or gaps in the coverage
    prm.NumSSBlocks           = [];

    prm.InterSiteDistance     = 200; % meters
    prm.PowerBSs              = 40; % dBm
    prm.UENoiseFigure         = 10; % UE receiver noise figure in dB

    % Define the method to compute the RSRP: |SSSonly| uses SSS alone and
    % |SSSwDMRS| uses SSS and PBCH DM-RS.
    prm.RSRPMode              = 'SSSwDMRS';

Configure UE Trajectory

Configure the parameters for generating the UE trajectories. Each UE starts from a random point within the first sector of a three-sector cell and travels in a straight line in a random direction. A trajectory terminates earlier than the maximum time if the UE crosses the sector boundaries or gets too close to the base station (BS), which is at the center of the cell. If the trajectory is shorter than the minimum trajectory duration, the example discards the trajectory and drops a new UE at a different random point with a different random direction of travel. The channel is spatially consistent throughout the trajectory and follows the spatial consistency Procedure A or Procedure B, as detailed in TR 38.901 Section 7.6.3.2.

Specify the parameters that affect the UE trajectory.

    prm.ue.MinDistance2D         = 35; % Minimum 2-D distance between UE and BS in meters
    prm.ue.Speed                 = 30; % km/h
    prm.ue.RotationSpeed         = 10; % RPM
    prm.ue.MaxTrajectoryDuration = 10; % s
    prm.ue.MinTrajectoryDuration = 1; % s
    prm.ue.TimeStep              = 0.1; % s
    prm.ue.SpatialConsistency    = "ProcedureB"; % Spatial consistency setting

Configure Antenna Array

Compute the wavelength based on the center frequency. Disable the elevation sweep.

    c = physconst('LightSpeed');        % Propagation speed
    prm.Lambda = c/prm.CenterFrequency; % Wavelength
    prm.ElevationSweep = false;         % Enable/disable elevation sweep

Define the transmit antenna array as a rectangular array with 4-by-8 cross-polarized elements, as defined in TR 38.901. The example assumes that the base station covers the first of a three-sector cell, as defined in TR 38.901 Table 7.8-1. The first sector is centered at 30 degrees. Because the antenna array points toward the center of the sector, to cover the entire 120-degree sector, set the antenna sweep limits in azimuth.

    % Transmit array
    prm.TransmitAntennaArray = phased.NRRectangularPanelArray( ...
        Size=[4,8,1,1], ...
        Spacing=[0.5,0.5,1,1]*prm.Lambda);

    % Transmit azimuth and elevation sweep limits in degrees
    prm.TxAZlim = [-60 60];
    prm.TxELlim = [-90 0];

Define the transmit antenna downtilt angle in degrees. The default value is defined in TR 38.843 Table 6.3.1-2.

    prm.TxDowntilt = 110;

Define the receive antenna array as a rectangular array with 1-by-4 isotropic cross-polarized elements, as defined in TR 38.901. Because the antenna array pattern is symmetrical and antenna elements are omnidirectional, to cover half of the entire 360-degree space, set the antenna sweep limits in azimuth.

    % Receive array
    % Define two isotropic antenna elements
    p1 = phased.NRAntennaElement( ...
        PolarizationAngle=0, ...
        Beamwidth=[180 180], ...
        SidelobeLevel=[eps eps], ...
        MaximumAttenuation=eps, ...
        MaximumGain=eps);
    p2 = clone(p1);
    p2.PolarizationAngle = 90;
    prm.ReceiveAntennaArray = phased.NRRectangularPanelArray( ...
        Size=[1,4,1,1], ...
        Spacing=[0.5,0.5,1,1]*prm.Lambda, ...
        ElementSet={p1, p2});

    % Receive azimuth and elevation sweep limits in degrees
    prm.RxAZlim = [-90 90];
    prm.RxELlim = [0 90];

Validate the current parameter set.

    prm = validateParams(prm);

Generate Data

Set the number of UE trajectories for data generation. The hGenData38901Channel function randomly positions the specified number of UEs within the first sector boundaries of the cell and generates straight-line trajectories at a random direction for each UE. To generate training data for a neural network for temporal-domain beam prediction, increase the number of trajectories. To generate different training data without changing the number of trajectories, modify the prm.Seed parameter.

    prm.NumTrajectories = 300;
    prm.Seed = 42; % Set random number generator seed for repeatability

Generate the data for each UE trajectory.

    disp("Generating data...")
    [optBeamPairIdx,rsrpMat,data] = hGenData38901Channel(prm);
    disp("Finished generating data.")

Save the generated data.

    if saveData
        save('nnBP_prm.mat','prm');
        save('nnBP_Data.mat','optBeamPairIdx','rsrpMat','data');
    end
end

Plot UE Trajectories

Plot the first ten generated trajectories within the first sector of the cell, as defined in TR 38.901.

numTrajectoriesToPlot = 10;
plotTrajectories(data,prm.InterSiteDistance,numTrajectoriesToPlot);

Figure contains an axes object. The axes object with title UEs 2-D Trajectories, xlabel X Axis (m), ylabel Y Axis (m) contains 41 objects of type line, quiver. One or more of the lines displays its values using only markers These objects represent Cell boundaries, Trajectory, Transmitter.

Plot Spatial 38.901 Scenario

Plot the simulated TR 38.901 scenario showing transmit antennas (Tx), receive antennas (Rx), and determined beams for a few trajectory points that correspond to UE 1. In case of strong non-line-of-sight (NLOS) clusters in the channel, the beam pair that maximizes the RSRP value can point slightly off from each other. Different heights between the base station and the UE can also affect the visualization. By default, the example shows only the optimal beams for each chosen point in the trajectory.

ue = 1;
numPointsToView = 3;
plotBeams(prm,data,optBeamPairIdx,ue,numPointsToView);

Figure contains an axes object. The axes object with title UE 1, xlabel X Axis (m), ylabel Y Axis (m) contains 22 objects of type line, patch, surface. One or more of the lines displays its values using only markers These objects represent Tx antenna elements, Tx antenna panel, Rx antenna elements, Rx antenna panel, t=0s - Tx beam 4 (Optimal), t=0s - Rx beam 1 (Optimal), LOS direction, t=3.1s - Tx beam 6 (Optimal), t=3.1s - Rx beam 1 (Optimal), t=6.2s - Tx beam 8 (Optimal), t=6.2s - Rx beam 1 (Optimal).

Further Exploration

This example shows you how to generate data for the temporal-domain beam selection task for a 5G NR system. The example enables you to specify the number of UEs moving within a sector by using the spatially consistent channel defined in TR 38.901. To see the impact of the channel on the beam selection in this example, experiment with different scenarios, trajectory parameters, antenna elevation sweeping, and number of transmit and receive beams.

For further exploration, use the generated training and testing data to build and explore the benefit of a neural network for a temporal-domain beam prediction task, as specified in TR 38.843.

References

  1. 3GPP TR 38.843, "Study on Artificial Intelligence (AI)/Machine Learning (ML) for NR air interface" 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

  2. 3GPP TR 38.901, "Study on channel model for frequencies from 0.5 to 100 GHz" 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

  3. TDoc R1-2306856, Intel Corporation, "Evaluation for AI/ML Beam Management", 3GPP TSG RAN WG1 #114, Toulouse, France, Aug 21st – 25th, 2023.

Local Functions

function prm = validateParams(prm) %#ok<*DEFNU>
    % Validate user specified parameters and return updated parameters
    %
    % Only cross-dependent checks are made for parameter consistency.

    if strcmpi(prm.FrequencyRange,'FR1')
        if prm.CenterFrequency > 7.125e9 || prm.CenterFrequency < 410e6
            error(['Specified center frequency is outside the FR1 ', ...
                'frequency range (410 MHz - 7.125 GHz).']);
        end
        if strcmpi(prm.SSBlockPattern,'Case D') ||  ...
                strcmpi(prm.SSBlockPattern,'Case E')
            error(['Invalid SSBlockPattern for selected FR1 frequency ' ...
                'range. SSBlockPattern must be one of ''Case A'' or ' ...
                '''Case B'' or ''Case C'' for FR1.']);
        end
        if (prm.CenterFrequency <= 3e9) && (length(prm.SSBTransmitted)~=4)
            error(['SSBTransmitted must be a vector of length 4 for ' ...
                'center frequency less than or equal to 3 GHz.']);
        end
        if (prm.CenterFrequency > 3e9) && (length(prm.SSBTransmitted)~=8)
            error(['SSBTransmitted must be a vector of length 8 for ', ...
                'center frequency greater than 3 GHz and less than ', ...
                'or equal to 7.125 GHz.']);
        end
    else % 'FR2'
        if prm.CenterFrequency > 52.6e9 || prm.CenterFrequency < 24.25e9
            error(['Specified center frequency is outside the FR2 ', ...
                'frequency range (24.25 GHz - 52.6 GHz).']);
        end
        if ~(strcmpi(prm.SSBlockPattern,'Case D') || ...
                strcmpi(prm.SSBlockPattern,'Case E'))
            error(['Invalid SSBlockPattern for selected FR2 frequency ' ...
                'range. SSBlockPattern must be either ''Case D'' or ' ...
                '''Case E'' for FR2.']);
        end
    end

    % Verify that there are multiple TX and Rx antennas
    prm.NumTx = getNumElements(prm.TransmitAntennaArray);
    prm.NumRx = getNumElements(prm.ReceiveAntennaArray);
    if prm.NumTx==1 || prm.NumRx==1
        error(['Number of transmit or receive antenna elements must be', ...
            ' greater than 1.']);
    end

    % Number of beams at transmit end
    % Assume a number of beams so that the beams span the entire 120-degree
    % sector, with a maximum of 64 beams, as mentioned in TR 38.843 Table
    % 6.3.1-1
    % Assume the number of transmitted blocks is the same as the number of
    % beams at transmit end
    if prm.FrequencyRange=="FR1"
        maxNumSSBBlocks = 8;
    else % FR2
        maxNumSSBBlocks = 64;
    end
    if isempty(prm.NumSSBlocks)
        % The number of blocks/beams is automatically generated as the
        % minimum need to span the 120-degree sector
        azTxBW = beamwidth(prm.TransmitAntennaArray,prm.CenterFrequency,Cut='Azimuth');
        numAZTxBeams = round(diff(prm.TxAZlim)/azTxBW);

        if prm.ElevationSweep
            % If elevation sweep is enabled, consider elevation as well in
            % the computation of the number of blocks/beams needed.
            elTxBW = beamwidth(prm.TransmitAntennaArray,prm.CenterFrequency,'Cut','Elevation');
            numELTxBeams = round(diff(prm.TxELlim)/elTxBW);
        else
            numELTxBeams = 1;
        end

        prm.NumTxBeams = min(numAZTxBeams*numELTxBeams, maxNumSSBBlocks);
        prm.NumSSBlocks = prm.NumTxBeams;
    else
        % The number of blocks/beams is defined by the user
        if prm.NumSSBlocks>maxNumSSBBlocks
            error("Invalid number of SSB blocks. For " + prm.FrequencyRange + ...
                ", there can be only up to " + maxNumSSBBlocks + " blocks.");
        end
        prm.NumTxBeams = prm.NumSSBlocks;
    end
    prm.SSBTransmitted = [ones(1,prm.NumTxBeams) zeros(1,maxNumSSBBlocks-prm.NumTxBeams)];

    % Number of beams at receive end
    % Assume a number of beams so that the beams cover the full azimuth
    % sweep, with a maximum of 8 beams, as mentioned in TR 38.843 Table
    % 6.3.1-1.
    azRxBW = beamwidth(prm.ReceiveAntennaArray,prm.CenterFrequency,Cut='Azimuth');
    numAZRxBeams = round(diff(prm.RxAZlim)/azRxBW);
    if prm.ElevationSweep
        % If elevation sweep is enabled, consider elevation as well in
        % the computation of the number of blocks/beams needed.
        elRxBW = beamwidth(prm.ReceiveAntennaArray,prm.CenterFrequency,'Cut','Elevation');
        numELRxBeams = round(diff(prm.RxELlim)/elRxBW);
    else
        numELRxBeams = 1;
    end
    prm.NumRxBeams = min(numAZRxBeams*numELRxBeams, 8);

    % Select SCS based on SSBlockPattern
    switch lower(prm.SSBlockPattern)
        case 'case a'
            scs = 15;
            cbw = 10;
            scsCommon = 15;
        case {'case b', 'case c'}
            scs = 30;
            cbw = 25;
            scsCommon = 30;
        case 'case d'
            scs = 120;
            cbw = 100;
            scsCommon = 120;
        case 'case e'
            scs = 240;
            cbw = 200;
            scsCommon = 120;
    end
    prm.SCS = scs;
    prm.ChannelBandwidth = cbw;
    prm.SubcarrierSpacingCommon = scsCommon;

    % Set up SSBurst configuration
    txBurst = nrWavegenSSBurstConfig;
    txBurst.BlockPattern = prm.SSBlockPattern;
    txBurst.TransmittedBlocks = prm.SSBTransmitted;
    txBurst.Period = 20;
    txBurst.SubcarrierSpacingCommon = prm.SubcarrierSpacingCommon;
    prm.TxBurst = txBurst;

    % Validate UE parameters for trajectory generation
    switch prm.Scenario
        case 'UMi'
            min_d_2D = 10; % Minimum BS-UE 2-D distance for UMi in meters (TR 38.901 Table 7.2-1)
        case 'UMa'
            min_d_2D = 35; % Minimum BS-UE 2-D distance for UMa in meters (TR 38.901 Table 7.2-1)
        case 'RMa'
            min_d_2D = 35; % Minimum BS-UE 2-D distance for RMa in meters (TR 38.901 Table 7.2-3)
        otherwise
            error("This example supports trajectory generation only for 'UMi', 'UMa', and 'RMa' scenarios.");
    end
    if prm.ue.MinDistance2D < min_d_2D
        error("Minimum BS-UE 2-D distance for trajectory generation (" + prm.ue.MinDistance2D + ...
            " meters) must be greater than or equal to the minimum distance defined in TR 38.901 for " + ...
            prm.Scenario + " (" + min_d_2D + " meters).");
    end

    if prm.ue.MinTrajectoryDuration > prm.ue.MaxTrajectoryDuration
        error("Maximum trajectory duration (" + prm.ue.MaxTrajectoryDuration + ...
            "s) must be greater than or equal to the minimum trajectory duration (" + ...
            prm.ue.MinTrajectoryDuration + " s).");
    end
end

function plotTrajectories(data,ISD,numTrajToPlot)
    % Plot UE 2-D trajectories within the cell boundaries

    arguments
        % Data structure containing the UE trajectory and the BS position
        data
        % Value of intersite distance, used to plot the cell boundaries
        ISD (1,1)
        % Optional. Number of trajectories to plot. Set it to empty to plot
        % the trajectory of all UEs stored in the first input DATA. The
        % default is empty ([]).
        numTrajToPlot (1,:) = [];
    end

    numData = numel(data);
    if isempty(numTrajToPlot) || numTrajToPlot>numData
        numTrajToPlot = numData;
    end

    f = figure;
    theme(f,'auto');

    % Plot the cell boundaries
    [sitex,sitey] = h38901Channel.sitePolygon(ISD);
    cell_plot = plot(sitex,sitey,LineStyle='--',SeriesIndex='none');
    hold on;

    % Plot the 2-D trajectory of each UE
    for ue = 1:numTrajToPlot
        trajectory = data(ue).Trajectory;
        posBS = data(ue).PosBS;

        % Plot arrows along the trajectory to show the direction of travel
        pos = trajectory.Position;
        vel = trajectory.VelocityDirection;
        pointsQuiver = round(numel(pos(:,1))/3)*[0 1 2] + 1;
        q = quiver(pos(pointsQuiver,1),pos(pointsQuiver,2),vel(pointsQuiver,1),vel(pointsQuiver,2),SeriesIndex=4,ColorMode='auto');
        q.MaxHeadSize = 0.8;
        q.AutoScaleFactor = 0.5;

        % Plot the trajectory
        traj_plot = plot(pos(:,1),pos(:,2),LineStyle='-',SeriesIndex=1);
        plot(pos(1,1),pos(1,2),LineStyle='none',Marker='o',SeriesIndex=1);

        % Plot the base station
        bs_plot = plot(posBS(:,1),posBS(:,2),LineStyle='none',Marker='^',SeriesIndex=3);
    end

    % Adjust plot details and add legend
    box on;
    xlabel("X Axis (m)");
    ylabel("Y Axis (m)");
    xlim([min(sitex)-10 max(sitex)+10]);
    ylim([min(sitey)-10 max(sitey)+10]);
    axis('square');
    title("UEs 2-D Trajectories");
    l = legend([cell_plot, bs_plot, traj_plot],"Cell boundaries","Transmitter","Trajectory");
    l.Location = "bestoutside";
    hold off;
end

function plotBeams(prm,data,optBeamPairIdx,ue,numPointsToView)
    % Plot spatial 38.901 scenario for the given UE.

    plotAllBeams = false;
    dataView = data(ue);
    pointsToView = round(numel(dataView.Trajectory.Position(:,1))/numPointsToView)*(0:(numPointsToView-1)) + 1;
    thisTime = dataView.Trajectory.Time;
    thisPos = dataView.Trajectory.Position;

    % Plot the beams at each chosen point in the trajectory
    f = figure;
    ax = axes(f);
    for idx = 1:numPointsToView
        hold(ax,"on");
        thisPoint = pointsToView(idx);
        legend_tmp = hPlotSpatial38901Scene(prm,dataView,optBeamPairIdx{ue},plotAllBeams,thisPoint,ax);
        if idx==1
            legendObjects = legend_tmp.LegendObjects;
            legendText = legend_tmp.LegendText;
        else
            legend_common = matches(legend_tmp.LegendText,{'Transmit antenna elements','Transmit antenna panel', ...
                'Receive antenna elements','Receive antenna panel','LOS direction'});
            legendObjects = cat(2,legendObjects,legend_tmp.LegendObjects(~legend_common));
            legendText = cat(2,legendText,legend_tmp.LegendText(~legend_common));
        end
    end

    % Add datatip at each chosen point in the trajectory showing the time
    % in the trajectory
    hold(ax,"on");
    p = plot(ax,thisPos(pointsToView,1),thisPos(pointsToView,2),'o');
    p.DataTipTemplate.DataTipRows(2) = [];
    p.DataTipTemplate.DataTipRows(1).Label = "Time(s)";
    p.DataTipTemplate.DataTipRows(1).Value = @(x)thisTime(x==thisPos);
    for idx = 1:numPointsToView
        thisPoint = pointsToView(idx);
        datatip(p,thisPos(thisPoint,1),thisPos(thisPoint,2),Location="northwest");
    end

    if ~prm.ElevationSweep
        % Show 2-D plot only
        view(2);
    end
    hold(ax,"off");

    % Add legend and title
    legendText = replace(legendText,["Transmit","Receive","- Optimal beam"],["Tx","Rx","(Optimal)"]);
    optBeamsLegIds = find(contains(legendText,"(Optimal)"));
    for idx = 1:numPointsToView
        % Add time to the legend for the optima beams
        legId = optBeamsLegIds((idx-1)*2 + [1 2]);
        legendText(legId) = cellfun(@(x)(['t=', num2str(thisTime(pointsToView(idx))), 's - ', x]),legendText(legId),UniformOutput=false);
    end
    legend(ax,legendObjects,legendText,Location="bestoutside");
    title(ax,"UE " + ue);
end

See Also

Topics