Main Content

Device Localization in Wireless Systems

Localizing an active wireless device based on measurements from an array of spatially separated wireless sensors with known positions has been an increasingly important problem in current and next-generation wireless localization systems. Time of arrival (TOA) and time difference of arrival (TDOA) are commonly used measurements for wireless localization. This example shows how to build wireless sensor networks, configure and propagate wireless waveforms, and perform TOA/TDOA estimation and localization.

Introduction

The ability to accurately determine the position of a wireless object has become increasingly popular in a variety of applications. As an example, the global positioning system (GPS) and cellular-based localization systems can be used for vehicle navigation and location-based services (such as searching for nearby gas stations, coffee shops, etc.) when a user is outdoors. Similarly, Wi-Fi access points can be used to localize and guide a user to a certain place in a room (such as finding a product in a store or warehouse). Ultra-wideband (UWB) radios can be used to identify the high-accuracy positions of mobile devices like digital car keys when they are in short range.

Wireless localization requires the knowledge of spatially separated sensors with known locations referred to as anchors. In different wireless applications, anchors can be different, e.g., cellular base stations, Wi-Fi access points, UWB anchors, etc.

TOA and TDOA are commonly used measurements that provide distance information for wireless localization. TOA estimation typically assumes that anchors and the device are synchronized. The TOA measurements can be obtained by estimating the time delay from the device to each of the anchors. The TDOA estimation assumes that the anchors are synchronized, but the anchors and the device may not be synchronized. In this case, the TOA measurements are shifted by a common unknown delay, and more suitable measurements are TDOA measurements that provide the differences between the TOA measurements such that the common unknown delay is canceled. In this example, we are going to show the applications of TOA and TDOA for device localization in their suitable wireless localization systems.

Scenario Configuration

In this example, we consider using 5 anchors with known locations to localize a device. We configure the anchors as transmitters and the device as a receiver. The propagation channel is configured as the one-way free space channel.

rng('default');

% RF parameters
fc = 38e9;                                       % Carrier frequency (Hz)
c = physconst('LightSpeed');                     % Speed of propagation (m/s)
bw = 100e6;                                      % Bandwidth (Hz)
sampleRate = bw;                                 % Sample rate (Hz)

% Tx and Rx parameters
Pt = 0.1;                                        % Peak power (W) 
Gtx = 20;                                        % Tx antenna gain (dB)
Grx = 20;                                        % Rx antenna gain (dB) 
NF = 2.9;                                        % Noise figure (dB) 

% Create a transceiver components to simulate waveform propagation
antenna = phased.IsotropicAntennaElement('BackBaffled',false);
transmitter = phased.Transmitter('Gain',Gtx,'PeakPower',Pt);
radiator = phased.Radiator('Sensor',antenna,'OperatingFrequency',fc);
collector = phased.Collector('Sensor',antenna,'OperatingFrequency',fc);
receiver = phased.Receiver('AddInputNoise',true,'Gain',Grx, ...
         'NoiseFigure',NF,'SampleRate',sampleRate);

% Create a one-way free-space propagation channel
channel = phased.FreeSpace('PropagationSpeed',c,'OperatingFrequency',fc, ...
    'SampleRate',sampleRate,'TwoWayPropagation',false);

% Device platform
tgtpos = [8; 4; 0];                              % Device position (m)
tgtvel = [1; -1; 0.5];                           % Device velocity (m/s)
tgtplatform = phased.Platform('InitialPosition',tgtpos,'Velocity',tgtvel); 

% Anchor platform
anchorpos = [0 30 10 20 15; ...
    10 -5 -20 15 10; ...
    4 -10 10 5 -20];                             % Anchor positions (m)
numAnchor = size(anchorpos,2);                   % Number of anchors 
anchorvel = zeros(3,numAnchor);                  % Anchor velocities (m/s)
anchorplatform = phased.Platform('InitialPosition',anchorpos,'Velocity',anchorvel);

Waveform Configuration

A variety of waveforms can be used for wireless localization. Recently, integrated sensing and communication (ISAC) has become increasingly popular for next-generation wireless systems due to its wide applications. Orthogonal frequency division multiplexing (OFDM) waveform, which is commonly used in wireless communications, can be used for wireless localization. In this example, we choose the OFDM waveform for wireless localization. For more information on the application of OFDM waveforms to ISAC, please refer to the example Joint Radar-Communication Using PMCW and OFDM Waveforms.

% Configure OFDM waveform
N = 1024;                                        % Number of subbands (OFDM data carriers)
M = 8;                                           % Number of channel samples (OFDM symbols)
freqSpacing = bw/N;                              % Frequency spacing (Hz)
tsym = 1/freqSpacing;                            % OFDM symbol duration  (s)
maxDelay = 200e-9;                               % Maximum delay (s)
rmax = maxDelay*c;                               % Maximum range of interest (m)
tcp = range2time(rmax);                          % Duration of the CP (s)
Ncp = ceil(sampleRate*tcp);                      % Length of the CP in subcarriers
tcp = Ncp/sampleRate;                            % Adjusted duration of the CP (s)
tWave = tsym + tcp;                              % OFDM symbol duration with CP (s)
Ns = N + Ncp;                                    % Number of subcarriers in one OFDM symbol

Channel Estimation

The TOA/TDOA estimation is based on obtaining the delay information after passing the waveforms into the wireless channel. Such delay information is contained in the channel. Thus, channel estimation is an essential step to obtain the TOA/TDOA information.

The channel estimation requires using the known reference waveform to remove the waveform contributions in the received signal to obtain a channel estimate with delay information. The delay information can be represented in linear phase shifts over subbands with uniform frequency spacing. Consider a line-of-sight propagation of a single waveform over a flat-fading channel, the frequency-domain channel estimate x with an adjacent-subband frequency spacing Δf and a propagation delay τ is assumed to follow the exponential signal model

x=h*a+n,

where x is an N-by-1 vector representing the frequency-domain channel estimate on N subbands, h is the channel coefficient, a is an N-by-1 vector with the n-th element given as a(n)=exp(-j2πnΔfτ), and n is an N-by-1 noise vector.

This section shows how to transmit and receive OFDM waveforms and how to perform OFDM channel estimation based on the received signal to obtain the delay information. We consider using binary phase-shift keying (BPSK) digital modulation on each OFDM data carrier. We assume there is no interference between signals from different anchors to the device. This can be achieved using medium access control (MAC) layer scheduling such as time-division multiplexing (TDM).

% Estimated channel
X = cell(1,numAnchor);

% Flag to indicate if Communications Toolbox is licensed
useCommunicationsToolbox  = false;

% OFDM waveform propagation and channel estimation
for idxAnchor = 1:numAnchor
    % BPSK symbol on each data carrier
    bpskSymbol = randi([0,1],[N M])*2-1;             
    
    % Modulate OFDM waveform with BPSK modulation on each data carrier
    if useCommunicationsToolbox
        % OFDM modulated signal with cyclic prefix
        sigmod = ofdmmod(bpskSymbol,N,Ncp); %#ok<UNRCH>
        % Reshape OFDM modulated signal
        sig = reshape(sigmod,Ns,M);                  
    else
        % OFDM symbols
        sigmod = ifft(ifftshift(bpskSymbol,1),[],1);
        % OFDM symbols with cyclic prefix
        sig = sigmod([end-Ncp+(1:Ncp),1:end],:);     
    end

    % Power-normalized OFDM signal
    sig = sig/max(abs(sig),[],'all');

    % Initialize estimated channel
    x = complex(zeros(size(sig)));

    % Transceiver chain
    for m = 1:M
        % Update radar and device positions
        [tx_pos,tx_vel] = anchorplatform(tWave);
        [rx_pos,rx_vel] = tgtplatform(tWave);

        % Calculate the transmit angle
        [~,txang] = rangeangle(rx_pos,tx_pos(:,idxAnchor)); 

        % Transmitted signal
        txsig = transmitter(sig);

        % Radiate signal towards the receiver 
        radtxsig = radiator(txsig(:,m),txang); 

        % Propagate the signal
        chansig = channel(radtxsig,tx_pos(:,idxAnchor),rx_pos, ...
            tx_vel(:,idxAnchor),rx_vel);

        % Calculate the receive angle
        [~,rxang] = rangeangle(tx_pos(:,idxAnchor),rx_pos);

        % Collect signal at the receive antenna
        rxsig = collector(chansig,rxang);

        % Receive signal at the receiver
        x(:,m) = receiver(rxsig);
    end

    if useCommunicationsToolbox
        % Remove the cyclic prefix 
        xrmvcp = x((Ncp+1):(Ncp+N),:); %#ok<UNRCH>

        % Demodulate the received OFDM signal
        xdemod = fftshift(fft(xrmvcp,[],1),1);
    else
        xvec = reshape(x,Ns*M,1);

        % Remove the cyclic prefix and demodulate the received OFDM signal
        xdemod = ofdmdemod(xvec,N,Ncp,Ncp);
    end

    % Remove BPSK symbol on each data carrier
    X{idxAnchor} = xdemod./bpskSymbol;

    % Reset platforms for the next anchor
    reset(anchorplatform);
    reset(tgtplatform);
end

TOA Estimation and Localization

In this section, we consider the case where the device is perfectly synchronized with the anchors. In this case, by performing spectrum analysis on the channel estimates, we can obtain the TOA spectrum to detect the TOA measurements. These TOA measurements correspond to the true ranges between the device and anchors and can be used for TOA localization.

Two spectrum analysis methods can be used for TOA estimation: FFT and MUSIC. FFT is a fast but low-resolution algorithm, while MUSIC is a more expensive but high-resolution algorithm. For MUSIC spectrum analysis, if the number of channel samples M is not large enough, the covariance matrix used for MUSIC processing is not full rank and MUSIC estimation can fail. In this case, consider enabling forward-backward averaging and increasing the value of spatial smoothing to increase the rank of the covariance matrix for MUSIC processing. Notice that the high-resolution MUSIC method is not always guaranteed to achieve better TOA estimation accuracy than the FFT method, because it's more sensitive to errors in limited observation time (the number of channel samples M), particularly in cases of low signal-to-noise ratio (SNR). In general, the accuracy of the MUSIC method depends on multiple factors, such as the SNR, the number of channel samples M, whether forward-backward averaging is enabled, the value of spatial smoothing, etc. Depending on the system configurations, the choice of MUSIC or FFT is a compromise between good resolution and stability.

Next, we use phased.TOAEstimator system object to estimate TOA by configuring the 'Measurement' property to 'TOA'. The spectrum analysis method is configured as FFT. We can change the spectrum analysis method to see its impact on the TOA localization accuracy shown at the end of this section.

% Spectrum analysis method
spectrumMethod = "FFT";
 
% Configure TOA estimator
if strcmp(spectrumMethod,'FFT') 
    toaEstimator = phased.TOAEstimator('PropagationSpeed',c, ...
        'Measurement','TOA','SpectrumMethod',spectrumMethod, ... 
        'VarianceOutputPort',true,'DelayOffsetInputPort',true); 
else % 'MUSIC'
    toaEstimator = phased.TOAEstimator('PropagationSpeed',c, ...
        'Measurement','TOA','SpectrumMethod',spectrumMethod, ... 
        'VarianceOutputPort',true,'DelayOffsetInputPort',true, ...
        'ForwardBackwardAveraging',true,'SpatialSmoothing',ceil(N/2)); %#ok<UNRCH>
end

Since the device and the anchors are assumed to be perfectly synchronized, the synchronization error between the device and the anchors is 0. We can change the value of the synchronization error configured below to see how it affects the TOA localization accuracy shown at the end of this section.

% Synchronization error in seconds
delayoffset = 0;

% TOA estimation
[Y,var] = toaEstimator(X,freqSpacing,delayoffset);

Viewing the TOA spectrum for an anchor can provide us better insights on how well the TOA is estimated for the anchor. In the ideal case, the first peak on the TOA spectrum is chosen as the TOA estimate. We can view the TOA estimation result for an anchor using plotTOASpectrum.

% Plot TOA spectrum for anchor 1
figure
plotTOASpectrum(toaEstimator,freqSpacing,'AnchorIndex',1,'MaxDelay',maxDelay);

Figure contains an axes object. The axes object with title FFT TOA Spectrum, xlabel TOA (ns), ylabel Power (dB) contains 2 objects of type line. One or more of the lines displays its values using only markers These objects represent TOA Spectrum, TOA Estimate.

Once we have the TOA estimates, the TOA estimation variances, and known anchor positions, we can use toaposest to estimate device position.

% Obtain TOA position estimate
tgtposest = toaposest(Y,var,anchorpos);

We visualize the accuracy of the TOA localization below.

% View TOA position estimate
helperPlotTOADevicePositions(c,Y,tgtposest,anchorpos,tgtpos);

Figure contains an axes object. The axes object with xlabel x-axis (meters), ylabel y-axis (meters) contains 8 objects of type line. One or more of the lines displays its values using only markers These objects represent Anchor Positions, Target Position, TOA Position Estimate, Trilateration Circles.

We can also check the accuracy of the TOA localization using root mean square error (RMSE).

% RMSE of the TOA position estimate
RMSE = rmse(tgtposest,tgtpos);
disp(['RMS Localization error = ', num2str(RMSE), ' meters.'])
RMS Localization error = 0.45496 meters.

TDOA Estimation and Localization

In this section, we consider the case where the anchors are not synchronized with the device but are mutually synchronized among themselves. In this case, since there exists synchronization error between the transmitter and the receiver, the resulting TOA spectrum estimate is a time-shifted version of the true TOA spectrum. Thus, the TOA measurements obtained from the TOA spectrum estimates are time-shifted measurements corresponding to the pseudo-ranges between the device and anchors (i.e., the true ranges plus the same unknown constant). Using one TOA measurement from an anchor as a reference, we can obtain TDOA measurements by subtracting the reference TOA measurement from TOA measurements of other anchors. The resulting TDOA measurements have no common unknown synchronization error because the error is canceled during the subtraction. Then, these TDOA measurements can be used for TDOA localization.

Next, we use phased.TOAEstimator system object to estimate the above-mentioned TOA-based TDOA measurements by configuring the 'Measurement' property to 'TDOA'. The spectrum analysis method is configured as MUSIC. We can change the spectrum analysis method to see its impact on the TDOA localization accuracy shown at the end of this section.

% Spectrum analysis method
spectrumMethod = "MUSIC";
 
% Configure TDOA estimator
if strcmp(spectrumMethod,'FFT') 
    tdoaEstimator = phased.TOAEstimator('PropagationSpeed',c, ...
        'Measurement','TDOA','SpectrumMethod',spectrumMethod, ... 
        'VarianceOutputPort',true,'DelayOffsetInputPort',true); %#ok<UNRCH>
else % 'MUSIC'
    tdoaEstimator = phased.TOAEstimator('PropagationSpeed',c, ...
        'Measurement','TDOA','SpectrumMethod',spectrumMethod, ... 
        'VarianceOutputPort',true,'DelayOffsetInputPort',true, ...
        'ForwardBackwardAveraging',true,'SpatialSmoothing',ceil(N/2)); 
end

Since the anchors are assumed to be synchronized, the synchronization error between the asynchronous device and the synchronous anchors is the same for all anchors. We ideally configure the common synchronization error in the input of the TDOA estimator. The TDOA estimation and localization accuracy do not change with the change of the common synchronization error.

% Common synchronization error in seconds
delayoffset = 100e-9;

% TDOA estimation
[Y,var] = tdoaEstimator(X,freqSpacing,delayoffset);

Once we have the TDOA estimates, the TDOA estimation variances, and known anchor positions, we can use tdoaposest to estimate device position.

% Obtain TDOA position estimate
tgtposest = tdoaposest(Y,var,anchorpos);

We visualize the accuracy of the TDOA localization below.

% View TDOA position estimate
helperPlotTDOADevicePositions(c,Y,tgtposest,anchorpos,tgtpos)

Figure contains an axes object. The axes object with xlabel x-axis (meters), ylabel y-axis (meters) contains 7 objects of type line. One or more of the lines displays its values using only markers These objects represent Anchor Positions, Target Position, TDOA Position Estimate, Hyperbola Curves.

We can also check the accuracy of the TDOA localization using RMSE.

% RMSE of the TDOA position estimate
RMSE = rmse(tgtposest,tgtpos);
disp(['RMS Localization error = ', num2str(RMSE), ' meters.'])
RMS Localization error = 0.48412 meters.

Summary

In this example, we considered localizing a device in two common wireless localization systems. In the first system where the anchors and the device are synchronized, we showed how to perform TOA estimation and TOA localization using phased.TOAEstimator and toaposest. In the second system where the anchors and the device are not synchronized but the anchors are mutually synchronized, we showed how to perform TOA-based TDOA estimation and TDOA localization using phased.TOAEstimator and tdoaposest. In both systems, we adopted OFDM waveform due to its wide use in wireless communications.

References

[1] Andreas F. Molisch. Wireless Communications: From Fundamentals to Beyond 5G, 3rd Edition, 2023

[2] Reza Zekavat and R. Michael Buehrer, Handbook of Position Location: Theory, Practice, and Advances, 2019

See Also

| |