Skip to content

Commit ea16e9d

Browse files
authored
Merge pull request #6 from Wireless-Information-Networking/develop
Develop
2 parents 54f0a83 + e5f40ad commit ea16e9d

File tree

1,249 files changed

+1216765
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,249 files changed

+1216765
-0
lines changed

MATLAB/antenna_array_processing.m

Lines changed: 457 additions & 0 deletions
Large diffs are not rendered by default.

MATLAB/process_experimental_data.m

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
%% ===================================================================== %%
2+
% ---------------------- RFID CSV DATA PROCESSING ---------------------- %
3+
% Author: Nedal M. Benelmekki %
4+
% Date (DD/MM/YYYY): 11/07/2025 %
5+
% %
6+
% Description: %
7+
% Batch process RFID AoA experiment CSV files, obtained from a COTS RFID %
8+
% System (Zebra FX7500, AN480 WB Antenna, Belt tag) into a structured %
9+
% MATLAB dataset. %
10+
% %
11+
% Input: %
12+
% - Filepath to the experimental data's base directory. %
13+
% %
14+
% Output: %
15+
% - rfid_array_data.mat: Structured MATLAB dataset containing processed %
16+
% phase, RSSI, and phasor data for each measurement configuration %
17+
% ======================================================================= %
18+
19+
%% STEP 0: Clean Workspace
20+
clear; % Clear all variables from workspace
21+
clc; % Clear console/command window
22+
23+
%% STEP 1: Configuration
24+
dataDir = 'filepath'; % TODO: Set base directory path for CSV files
25+
tagID = '000233b2ddd9014000000000'; % Target RFID tag ID
26+
c = 3e8; % Speed of light approximation [m/s]
27+
% Alt.: c = physconst('LightSpeed'); % Speed of light, requires Antenna Toolbox [m/s]
28+
29+
%% STEP 2: Load Files
30+
fileList = dir(fullfile(dataDir, '**', '*.csv')); % Recursive search for files in subdirectories, see README.md documentation to understand the file structure and naming convention
31+
fprintf('Found %d CSV files.\n', length(fileList)); % Debug message: display number of files found
32+
33+
%% STEP 3: Transfer Data
34+
allData = []; % Initialize storage array
35+
for i = 1:length(fileList) % Loop through each found file in STEP 2.
36+
fname = fileList(i).name; % Get the filename
37+
fpath = fullfile(fileList(i).folder, fname); % Full path to the file
38+
try
39+
% STEP 3.1: Parse filename
40+
tokens = regexp(fname, '(\d+)_(\d+\.\d)_(\d+\.\d+)_(\d+\.\d+)_(\-?\d+\.\d+).csv', 'tokens'); % Regex to extract date, f0, D, L, W from filename
41+
if isempty(tokens) % Check if regex matched + error handling
42+
warning('Skipping file (cannot parse): %s', fname);
43+
continue;
44+
end
45+
tokens = tokens{1}; % Extract tokens from the cell array
46+
dateStr = tokens{1}; % Date string in format YYYYMMDD
47+
f0 = str2double(tokens{2}) * 1e6; % Carrier frequency, f0, in Hz
48+
D = str2double(tokens{3}); % Vertical distance, D, in m
49+
L = str2double(tokens{4}); % Antenna separation, L, in m
50+
W = str2double(tokens{5}); % Horizontal tag position, W, in m
51+
lambda = c / f0; % Wavelength, lambda, in m
52+
% STEP 3.2: Load CSV
53+
T = readtable(fpath); % Load CSV file into a table
54+
% STEP 3.3: Check required columns
55+
requiredCols = {'phase', 'peakRssi', 'antenna', 'idHex'}; % Define required columns
56+
if ~all(ismember(requiredCols, T.Properties.VariableNames)) % Verify if all required columns are present
57+
warning('Skipping file (missing columns): %s', fname); % Error handling (skip the file)
58+
continue;
59+
end
60+
% STEP 3.4: Filter by antenna and tag ID
61+
t1 = T(T.antenna == 1 & strcmp(T.idHex, tagID), :); % Filter for Antenna 1
62+
t2 = T(T.antenna == 2 & strcmp(T.idHex, tagID), :); % Filter for Antenna 2
63+
% STEP 3.5: Sanity check
64+
if height(t1) < 3 || height(t2) < 3 % Ensure there are enough data points for processing
65+
warning('Not enough data in file: %s', fname); % Error handling (skip the file)
66+
continue;
67+
end
68+
% STEP 3.6: Unwrap and convert phase to radians
69+
phi1 = unwrap(deg2rad(t1.phase)); % Unwrap phase for Antenna 1 and convert to radians
70+
phi2 = unwrap(deg2rad(t2.phase)); % Unwrap phase for Antenna 2 and convert to radians
71+
% STEP 3.7: Convert RSSI to linear power scale
72+
rssi1 = t1.peakRssi; % Peak RSSI for Antenna 1
73+
rssi2 = t2.peakRssi; % Peak RSSI for Antenna 2
74+
mag1 = sqrt(10.^(rssi1 / 10)); % Convert RSSI to linear scale for Antenna 1
75+
mag2 = sqrt(10.^(rssi2 / 10)); % Convert RSSI to linear scale for Antenna 2
76+
% STEP 3.8: Create phasors
77+
phasor1 = mag1 .* exp(1j * phi1); % Create phasor for Antenna 1
78+
phasor2 = mag2 .* exp(1j * phi2); % Create phasor for Antenna 2
79+
% STEP 3.9: Save entry
80+
entry = struct(); % Initialize a new entry structure
81+
entry.filename = fname; % Store filename
82+
entry.date = dateStr; % Store date string
83+
entry.f0 = f0; % Store carrier frequency
84+
entry.lambda = lambda; % Store wavelength
85+
entry.D = D; % Store vertical distance
86+
entry.L = L; % Store antenna separation
87+
entry.W = W; % Store horizontal tag position (offset)
88+
entry.phi1 = phi1; % Store unwrapped phase for Antenna 1
89+
entry.phi2 = phi2; % Store unwrapped phase for Antenna 2
90+
entry.rssi1 = rssi1; % Store RSSI for Antenna 1
91+
entry.rssi2 = rssi2; % Store RSSI for Antenna 2
92+
entry.phasor1 = phasor1; % Store phasor for Antenna 1
93+
entry.phasor2 = phasor2; % Store phasor for Antenna 2
94+
% STEP 3.10: Append to array + Confirmation
95+
allData = [allData; entry]; % Append the new entry to the allData array
96+
fprintf('Processed: %s\n', fname); % Debug message: display processed file name
97+
catch ME
98+
warning('Error processing file %s: %s', fname, ME.message); % Error handling: catch any errors during processing
99+
continue;
100+
end
101+
end
102+
103+
%% STEP 4: Save Output
104+
save('rfid_array_data.mat', 'allData');
105+
fprintf('\n Saved processed data to rfid_array_data.mat (%d valid entries).\n', length(allData));

README.md

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,148 @@
11
# Bayesian-Enhanced-AoA-Estimator
2+
23
AoA estimator for passive UHF RFID based on Bayesian regression and classical antenna array signal processing. Combines physics-informed priors with Pyro-based uncertainty quantification.
4+
5+
## 📊 Dataset Structure
6+
7+
### 📂 File Naming Convention
8+
9+
All measurement files follow this standardized naming pattern:
10+
11+
**File Naming Convention**:
12+
`YYYYMMDD_FFF.F_D.DDD_L.LLL_W.WWW.csv`
13+
14+
**Explanation of Components**:
15+
16+
- `YYYYMMDD` — Date of the experiment (for tracking only; does not affect the measurement).
17+
- `FFF.F` — Operating frequency in MHz (e.g., 865.7 for 865.7 MHz). Used to compute λ.
18+
- `D.DDD` — Vertical distance `D` in meters (e.g., 0.700 for 0.700 m).
19+
- `L.LLL` — Inter-antenna spacing `L` in meters (e.g., 0.287 for 0.287 m).
20+
- `W.WWW` — Horizontal offset `W` in meters (can be negative, zero, or positive).
21+
22+
---
23+
24+
### 📁 Directory Structure
25+
26+
The dataset is organized into a hierarchical directory structure as follows:
27+
28+
```
29+
Distance 1/
30+
├── Replica 1/
31+
│ ├── Frequency 1/
32+
│ ├── Frequency 2/
33+
│ ├── Frequency 3/
34+
│ └── Frequency 4/
35+
├── Replica 2/
36+
│ ├── Frequency 1/
37+
│ ├── Frequency 2/
38+
│ ├── Frequency 3/
39+
│ └── Frequency 4/
40+
└── Replica 3/
41+
├── Frequency 1/
42+
├── Frequency 2/
43+
├── Frequency 3/
44+
└── Frequency 4/
45+
Distance 2/
46+
├── Replica 1/
47+
│ ├── Frequency 1/
48+
│ ├── Frequency 2/
49+
│ ├── Frequency 3/
50+
│ └── Frequency 4/
51+
├── Replica 2/
52+
│ ├── Frequency 1/
53+
│ ├── Frequency 2/
54+
│ ├── Frequency 3/
55+
│ └── Frequency 4/
56+
└── Replica 3/
57+
├── Frequency 1/
58+
├── Frequency 2/
59+
├── Frequency 3/
60+
└── Frequency 4/
61+
Distance 3/
62+
├── Replica 1/
63+
│ ├── Frequency 1/
64+
│ ├── Frequency 2/
65+
│ ├── Frequency 3/
66+
│ └── Frequency 4/
67+
├── Replica 2/
68+
│ ├── Frequency 1/
69+
│ ├── Frequency 2/
70+
│ ├── Frequency 3/
71+
│ └── Frequency 4/
72+
└── Replica 3/
73+
├── Frequency 1/
74+
├── Frequency 2/
75+
├── Frequency 3/
76+
└── Frequency 4/
77+
```
78+
79+
**Explanation**:
80+
81+
- **Distance X/**: Represents different vertical distances `D`.
82+
- **Replica X/**: Represents repeated measurements for the same distance.
83+
- **Frequency X/**: Represents measurements taken at different operating frequencies.
84+
85+
## 🧮 MATLAB Implementation
86+
87+
The repository contains MATLAB scripts for processing RFID data and implementing various AoA estimation algorithms:
88+
89+
### 📄 `process_experimental_data.m`
90+
91+
A preprocessing script that:
92+
93+
- Batch processes RFID experiment CSV files from a COTS RFID system (Zebra FX7500, AN480 WB Antenna, Belt tag)
94+
- Parses filenames to extract experimental parameters (frequency, distance, antenna spacing, etc.)
95+
- Unwraps phase measurements and converts to radians
96+
- Transforms RSSI values to linear power scale
97+
- Creates complex phasors for antenna signals
98+
- Organizes data into a structured MATLAB dataset (`rfid_array_data.mat`)
99+
100+
### 📄 `antenna_array_processing.m`
101+
102+
A comprehensive end-to-end RFID AoA estimation pipeline that:
103+
104+
- Implements multiple estimation methods:
105+
- Phase-difference estimation
106+
- Classical Delay-and-Sum beamforming (unweighted & RSSI-weighted)
107+
- MUSIC algorithm for high-resolution AoA
108+
- Multi-frequency fusion with confidence metrics
109+
- Provides extensive visualization:
110+
- AoA vs. tag position plots
111+
- Spectral analysis and comparison
112+
- 3D beam pattern visualization
113+
- Heatmap representations
114+
- Performs error analysis and method comparison
115+
- Outputs organized figures and complete analysis reports
116+
117+
## 📁 Repository Structure
118+
119+
The repository is organized with the following key directories:
120+
121+
### `/MATLAB`
122+
123+
Contains all MATLAB implementation scripts:
124+
125+
- `process_experimental_data.m`: Preprocessing script for raw CSV data
126+
- `antenna_array_processing.m`: Complete end-to-end AoA analysis pipeline
127+
128+
### `/figures`
129+
130+
Stores generated visualization outputs from the analysis:
131+
132+
- AoA estimation plots
133+
- Spectral analysis visualizations
134+
- 3D beam pattern representations
135+
- Method comparison charts
136+
- Error analysis visualizations
137+
138+
Example figures are included to demonstrate the expected output format.
139+
140+
### `/results`
141+
142+
Contains processed data and analysis results:
143+
144+
- `rfid_array_data.mat`: Preprocessed dataset ready for analysis
145+
- `complete_analysis.mat`: Comprehensive results from all estimation methods
146+
- Performance metrics and statistical evaluations
147+
148+
Example result files are provided to illustrate the data structure.

0 commit comments

Comments
 (0)