Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
liecn committed Jul 23, 2022
0 parents commit 7a26df3
Show file tree
Hide file tree
Showing 235 changed files with 1,226 additions and 0 deletions.
159 changes: 159 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# Latex
*.synctex.gz
*.aux
*.bbl
*.log
*.fls
*.blg
*.fdb_latexmk
*.out
*.zip
mobicom2020.pdf

# vscode
.vscode/
.vscode-test/
*.vsix

#matlab
*.mexmaci64
*.asv
*.m~

#others
*.DS_Store
backup/

*.mexmaci64
*.mexw64
dataset/
50 changes: 50 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# WiVelo

This repository contains scripts and instructions for reproducing the experiments in our SECON'22 paper "
WiVelo: Fine-grained Walking Velocity Estimation for Wi-Fi Passive Tracking".
<!-- [PyramidFL: Fine-grained Data and System Heterogeneity-aware Client Selection for Efficient Federated Learning](https://www.usenix.org/conference/osdi21/presentation/lai)". -->

# Overview

* [Demo Dataset](#dataset)
* [Repo Structure](#repo-structure)
* [Instructions](#instructions)
* [Acknowledgements](#acknowledgements)
* [Contact](#contact)

# dataset

#### Download datasets. We provide 144 CSI traces with 2 WiFI receivers from 3 users, 6 tracks, and 4 instances from https://drive.google.com/drive/folders/1XNAKy_SXm-bF929IUvcokgSlsOiuLd2E?usp=sharing

# Repo Structure
<pre>/WiVelo
├ [DIR] wivelo_dataset
├ [DIR] CSI
├ [DIR] GROUNDTRUTH
└ [DIR] FEATURE
├ [DIR] code
</pre>

# Instructions |
``` matlab
% remember to add the utility functions in ./util/
cd code
matlab generate_ground_truth % generate ground truth files
matlab main % generate features and results, function generate_demo_real_trail() in line 110 will generate the real traces, its ground truth, locations of WiFi transmitter and receiver.
```

# Notes
please cite our paper if you think the source codes are useful in your research project.
```bibtex
@inproceedings{wivelo_secon22,
author = {Li, Chenning and Liu, Li and Cao, Zhichao and Zhang, Mi},
title = {WiVelo: Fine-grained Walking Velocity Estimation for Wi-Fi Passive Tracking},
year = {2022},
booktitle = {Proceedings of IEEE SECON},
}
```

# Contact
Zhichao Cao by [email protected]
43 changes: 43 additions & 0 deletions code/generate_ground_truth.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
clear;
clc;
close all;
%% Parameter Setting

% Set Parameters for Data Description
total_track = 6;
total_instance = 4;

% Set Parameters for Loading Data
data_root = 'D:\papers\WiVelo\dataset\';

%% Set Path for Saving Data
ground_truth_dir = [data_root,'GROUNDTRUTH\'];
if ~exist(ground_truth_dir)
mkdir(ground_truth_dir);
end
foot_size=0;
ground_truth_list=cell(total_track,1);

ground_truth_list{1}=[1.8,1.2+foot_size;1.8,1.8;1.8,2.4;1.8,3;1.8,3.6;1.8,4.2-foot_size];
ground_truth_list{2}=[1.8-foot_size,4.2;1.2,4.2;0.6,4.2;0,4.2;-0.6,4.2;-1.2,4.2;-1.8+foot_size,4.2;];
ground_truth_list{3}=[1.8-foot_size,1.2;1.2,1.2;0.6,1.2;0,1.2;0,1.8;0,2.4;0,3;0,3.6;0,4.2-foot_size;];
ground_truth_list{4}=[1.2,1.2+foot_size;1.2,1.8;1.2,2.4;1.2,3;0.6,3;0,3;-0.6,3;-1.2,3;-1.2,2.4;-1.2,1.8;-1.2,1.2+foot_size;];
ground_truth_list{5}=[1.8,1.5+foot_size;1.8,1.8;1.559,2.7;0.9,3.359;0,3.6-foot_size];
ground_truth_list{6}=[1.2-foot_size,1.2;0.6,1.2;0,1.2;-0.6,1.2;-1.2,1.2;-0.6,1.8;-0,2.4;0.6,3;1.2,3.6;0.6,3.6;0,3.6;-0.6,3.6;-1.2+foot_size,3.6;];

%% Signal Processing and Feature Extraction
for track_index = 1:total_track
for instance_index = 1:total_instance
ground_truth=ground_truth_list{track_index};
if mod(instance_index,2)==0
ground_truth=flipud(ground_truth);
end
groundtruth_path = [num2str(track_index),...
'-', num2str(instance_index)];
disp(['Loading ', groundtruth_path])
save([ground_truth_dir,groundtruth_path, '.mat'],'ground_truth');
end
% scatter3(ground_truth(:,1),ground_truth(:,2),1:size(ground_truth,1));
% hold on;
end
disp([ground_truth_dir,'is finished'])
115 changes: 115 additions & 0 deletions code/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
clear;
clc;
close all;
%% Set Parameters for Transceivers
wave_length = 299792458 / 5.825e9;
sample_rate=1000;
n_receivers = 2; % Receiver count
n_antennas = 3; % Antenna count for each receiver
n_subcarriers=30;

%% Set Parameters for Data Description
total_user=12;
total_track = 6;
total_instance = 4;

%% Set Parameters for Signal Processing
half_n_virtual_antennas=48;

virtual_antenna_step=32;
half_time_delay_window=40;
time_delay_window_step=5;
half_time_window=48;
subcarrier_step=4;
sample_step=128;
time_delay_offset=5;
time_delay_header=half_n_virtual_antennas+(time_delay_offset-1)*time_delay_window_step+1;
%% Set Parameters for Anchor Selection
search_range=5;
reward_weight=0.5;
compensation_factor=2.5;
ellipse_weight=0.5;

%% fine-tune parameter
det_threshold=0.1;
translation_scaling=2;

%% Antenna Setting
antenna_spacing=0.2;
antenna_mid_left=-2.4;
antenna_mid_right=2.4;
antenna_coords1 = [antenna_mid_left+antenna_spacing,0;antenna_mid_left,0;antenna_mid_left-antenna_spacing,0];
antenna_coords2 = [antenna_mid_right-antenna_spacing,0;antenna_mid_right,0;antenna_mid_right+antenna_spacing,0];
T = [0,0];

%% Set Parameters for Loading Data
data_root = 'D:\papers\WiVelo\dataset/';
csi_dir = [data_root,'CSI/'];

%% Set Path for Loading Groundtruth
groundtruth_dir = [data_root,'GROUNDTRUTH/'];
if ~exist(groundtruth_dir)
mkdir(groundtruth_dir);
end
%% Set Path for Loading Feature
feature_dir = [data_root,'FEATURE/'];
if ~exist(feature_dir)
mkdir(feature_dir);
end

%% Signal Processing and Feature Extraction
for user_index=[1,8,12]
for track_index = 1:total_track
for instance_index = 1:total_instance
data_file_name = [num2str(user_index), '-1-', num2str(track_index),'-', num2str(instance_index)];
%% load ground truth
groundtruth_path = [num2str(track_index),...
'-', num2str(instance_index)];
disp(["Loading ",groundtruth_path])
load([groundtruth_dir,groundtruth_path, '.mat']);

feature_path = [feature_dir, data_file_name, '.mat'];

disp(["Loading ",feature_path])
if ~exist(feature_path)
%% Signal pre-processing
tic;
csi_data= extract_csi_power([csi_dir, data_file_name],n_receivers, n_antennas, n_subcarriers);
[csi_data,time_sampling]= denoised_csi(csi_data,n_receivers, half_time_window,sample_rate);
%% voting for anchor sequence
[correlation_val,distribution_val,time_matrix] = correlation_profile(csi_data, time_sampling,n_receivers,n_antennas,n_subcarriers,subcarrier_step,sample_step,half_n_virtual_antennas, half_time_delay_window,virtual_antenna_step,time_delay_window_step,time_delay_offset,half_time_window);
[node_sequence,observing_phase_shift]= voting_hopping_sequence(correlation_val,distribution_val,n_receivers,det_threshold);
%% tracking virtual sequence
real_trail = tracking_hopping_node(node_sequence);
real_trail=real_trail./max(abs(real_trail(:)))*compensation_factor+ground_truth(1,:);
save(feature_path, 'real_trail', 'observing_phase_shift','time_matrix');
else
load(feature_path);
end

feature_path = [feature_dir, data_file_name, '_trace','.mat'];

disp(["Loading ",feature_path])
if ~exist(feature_path)
n_sampling_for_trail=size(real_trail,1);
disp(data_file_name)
%% Translation
anchor_time_pick_sequence= anchor_selection(observing_phase_shift,time_matrix,search_range,reward_weight);
all_scaler=(anchor_time_pick_sequence*sample_rate-(time_delay_header+sample_step*(0:n_sampling_for_trail-1)'))/sample_step;
dir_sequence=(real_trail(2:n_sampling_for_trail,1:2)-real_trail(1:n_sampling_for_trail-1,1:2));
physical_dis=zeros(n_sampling_for_trail-1,1);
for hop_index = 2:n_sampling_for_trail
%% nomodel setting
[~,physical_dis(hop_index)] = go_to_next(antenna_coords1, antenna_coords2, T, real_trail(hop_index-1,:), dir_sequence(hop_index-1,1), dir_sequence(hop_index-1,2));
real_trail(hop_index,:)=real_trail(hop_index-1,:)+dir_sequence(hop_index-1,:)*(ellipse_weight*physical_dis(hop_index)./all_scaler(hop_index)+(1-ellipse_weight)*translation_scaling);
end
save(feature_path, 'real_trail','anchor_time_pick_sequence');
else
load(feature_path);
end
generate_demo_real_trail((track_index-1)*total_instance+instance_index,real_trail,ground_truth);
end
end
end

disp(['All finished'])
16 changes: 16 additions & 0 deletions code/util/anchor_selection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
function time_sequence = anchor_selection(observing_phase_shift, time_matrix,search_range,reward_weight)
% path_matched = graph_mapping(ftp, plcr_list, path_sample_rate, sample_rate)
% extracts path from spectrogram
%
% FTP : The spectrogram.
% ftp_list : tha path value candidates.
% path_sample_rate : Sampling rate of PLCR series.
% SAMPLE_RATE : Sampling rate of spectrogram.
%
% path_matched : Path matched.
a=observing_phase_shift{1};
b=observing_phase_shift{2};
sampling=min(size(a,2),size(b,2));
observing_phase_shift_mean=(a(:,1:sampling)+b(:,1:sampling))/2;
time_sequence=dynamic_observation_path(observing_phase_shift_mean, time_matrix{1},search_range,reward_weight);
end
Loading

0 comments on commit 7a26df3

Please sign in to comment.