init commit
This commit is contained in:
parent
ae9e489224
commit
8c6a73a01f
|
|
@ -1,3 +1,4 @@
|
|||
calibration_data/
|
||||
iw/iw
|
||||
iw/*~
|
||||
iw/*.o
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in `seq 1 5000`; do
|
||||
sudo /usr/sbin/iw wlp58s0 measurement ftm_request config_entry | tail -n +3 >> result_$1
|
||||
sleep 0.1
|
||||
done
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
figure(1);
|
||||
clf; hold on;
|
||||
|
||||
desired_result = [60:30:1200, 120, 170, 200, 430, 1000, 1300:100:2000];
|
||||
mean_result = zeros(size(desired_result));
|
||||
diff_result = zeros(size(desired_result));
|
||||
all_data = [];
|
||||
for i = 1:length(desired_result)
|
||||
dist = desired_result(i);
|
||||
filename = ['calibration_data/result_', num2str(dist), 'cm.txt'];
|
||||
|
||||
fileID = fopen(filename, 'r');
|
||||
sizeData = [9 Inf];
|
||||
formatSpec = [...
|
||||
'Target: %x:%x:%x:%x:%x:%x, status: %d, ',...
|
||||
'rtt: %d psec, distance: %d cm\n'...
|
||||
];
|
||||
data = fscanf(fileID, formatSpec, sizeData);
|
||||
data(:, data(7, :) ~= 0) = [];
|
||||
data(:, data(9, :) < -1000) = [];
|
||||
fclose(fileID);
|
||||
|
||||
fprintf('distance: %d:\n', dist);
|
||||
fprintf('* mean: %.2fcm\n', mean(data(9, :)));
|
||||
fprintf('* median: %.2fcm\n', median(data(9, :)));
|
||||
|
||||
cdfplot(data(9, :));
|
||||
|
||||
mean_result(i) = mean(data(9, :));
|
||||
all_data = [all_data, [data(9, :); dist * ones(1, length(data(9, :)))]];
|
||||
diff_result(i) = desired_result(i) - mean_result(i);
|
||||
end
|
||||
|
||||
figure(2); clf;
|
||||
scatter(all_data(1, :), all_data(2, :), '.');
|
||||
params = polyfit(all_data(1, :), all_data(2, :), 1)
|
||||
fitted_data = params(1) * all_data(1, :) + params(2);
|
||||
hold on;
|
||||
plot(all_data(1, :), fitted_data, '-')
|
||||
|
|
@ -0,0 +1 @@
|
|||
34:f6:4b:5e:69:1f bw=20 cf=2462 retries=5 asap
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
|
||||
import os
|
||||
import argparse
|
||||
|
||||
from numpy import min, max, median, mean, std
|
||||
|
||||
|
||||
def wrapper(args):
|
||||
if not args['filepath'] or not os.path.isfile(args['filepath']):
|
||||
return
|
||||
results = []
|
||||
with open(args['filepath']) as f:
|
||||
for line in f:
|
||||
tmp = line.rstrip().split(', ')
|
||||
status = int(tmp[1].split(' ')[1])
|
||||
if status is not 0:
|
||||
continue
|
||||
psec = int(tmp[2].split(' ')[1])
|
||||
distance = int(tmp[3].split(' ')[1])
|
||||
if distance < -1000:
|
||||
continue
|
||||
results.append(distance * args['args'][0] + args['cali'][1])
|
||||
print('statics of results')
|
||||
print('* num of valid data: {0}'.format(len(results)))
|
||||
print('* min: {0:.2f}cm'.format(min(results)))
|
||||
print('* max: {0:.2f}cm'.format(max(results)))
|
||||
print('* mean: {0:.2f}cm'.format(mean(results)))
|
||||
print('* median: {0:.2f}cm'.format(median(results)))
|
||||
print('* std: {0:.2f}cm'.format(std(results)))
|
||||
|
||||
|
||||
def main():
|
||||
p = argparse.ArgumentParser(description='iw parser')
|
||||
p.add_argument(
|
||||
'filepath',
|
||||
help="input file path for result"
|
||||
)
|
||||
p.add_argument(
|
||||
'--cali',
|
||||
nargs=2,
|
||||
default=(0.9084, 526.8163),
|
||||
type=float,
|
||||
help="calibrate final result"
|
||||
)
|
||||
try:
|
||||
args = vars(p.parse_args())
|
||||
except Exception as e:
|
||||
print(e)
|
||||
sys.exit()
|
||||
wrapper(args)
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
|
||||
for i in `seq 1 10`; do
|
||||
sudo /usr/sbin/iw wlp58s0 measurement ftm_request config_entry | tail -n +3 >> result_$1
|
||||
sleep 0.1
|
||||
done
|
||||
Loading…
Reference in New Issue