-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathWriteData.m
122 lines (109 loc) · 4.86 KB
/
WriteData.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
save(strcat(output_data_path,'/',output_name,'-matlab_data.mat'));
write_fix = false;
write_interp = false;
write_noise = true;
%% fixed_data write out
if write_fix
bar = waitbar(0,'fixed data write out');
[nrows,~] = size(fixed_data);
file_path = strcat(output_data_path,'/oxts-fixed/data/');
mkdir(file_path);
timestamp_file = strcat(...
datestr(...
datetime(...
fix(imu_unsync_timestamp_sec_init + imu_unsync_timestamp_nsec_init+fixed_data(:,1)),...
'ConvertFrom','posixtime'),...
'yyyy-mm-dd HH:MM:SS.'),...
num2str(fix(1e9*abs(mod(imu_unsync_timestamp_nsec_init + fixed_data(:,1), 1))),'%09d'));
timestamp_posix = strcat(num2str(fix(imu_unsync_timestamp_sec_init + imu_unsync_timestamp_nsec_init+fixed_data(:,1))),...
'.',...
num2str(fix(1e9*abs(mod(imu_unsync_timestamp_nsec_init + fixed_data(:,1), 1))),'%09d'));
fid_allin1 = fopen(strcat(output_data_path,'/oxts-fixed/data.txt'),'w');
for i = 1:nrows
fid = fopen(strcat(file_path, num2str(i-1,'%010d'), '.txt'),'w');
fprintf(fid,'%.14g ',fixed_data(i,2:end));
fclose(fid);
fprintf(fid_allin1,'%s,',timestamp_posix(i,:));
fprintf(fid_allin1,'%.14g,',fixed_data(i,2:end-1));
fprintf(fid_allin1,'%.14g\n',fixed_data(i,end));
str=['fixed data write out: ',num2str(100*i/nrows),'%'];
waitbar(i/nrows,bar,str);
end
fclose(fid_allin1);
fid = fopen(strcat(output_data_path,'/oxts-fixed/timestamps.txt'),'w');
for i = 1:size(timestamp_file,1)
fprintf(fid,'%s\n',timestamp_file(i,:));
end
fclose(fid);
close(bar);
end
%% interped_data write out
if write_interp
bar = waitbar(0,'interp data write out');
[nrows,~] = size(interped_data);
file_path = strcat(output_data_path,'/oxts-interped/data/');
mkdir(file_path);
timestamp_file = strcat(...
datestr(...
datetime(...
fix(imu_unsync_timestamp_sec_init + imu_unsync_timestamp_nsec_init+interped_data(:,1)),...
'ConvertFrom','posixtime'),...
'yyyy-mm-dd HH:MM:SS.'),...
num2str(fix(1e9*abs(mod(imu_unsync_timestamp_nsec_init + interped_data(:,1), 1))),'%09d'));
timestamp_posix = strcat(num2str(fix(imu_unsync_timestamp_sec_init + imu_unsync_timestamp_nsec_init+interped_data(:,1))),...
'.',...
num2str(fix(1e9*abs(mod(imu_unsync_timestamp_nsec_init + interped_data(:,1), 1))),'%09d'));
fid_allin1 = fopen(strcat(output_data_path,'/oxts-interped/data.txt'),'w');
for i = 1:nrows
fid = fopen(strcat(file_path, num2str(i-1,'%010d'), '.txt'),'w');
fprintf(fid,'%.14g ',interped_data(i,2:end));
fclose(fid);
fprintf(fid_allin1,'%s,',timestamp_posix(i,:));
fprintf(fid_allin1,'%.14g,',interped_data(i,2:end-1));
fprintf(fid_allin1,'%.14g\n',interped_data(i,end));
str=['interp data write out: ',num2str(100*i/nrows),'%'];
waitbar(i/nrows,bar,str);
end
fclose(fid_allin1);
fid = fopen(strcat(output_data_path,'/oxts-interped/timestamps.txt'),'w');
for i = 1:size(timestamp_file,1)
fprintf(fid,'%s\n',timestamp_file(i,:));
end
fclose(fid);
close(bar);
end
%% noised_data write out
if write_noise
bar = waitbar(0,'noised data write out');
[nrows,~] = size(noised_data);
file_path = strcat(output_data_path,'/oxts-',output_name,'/data/');
mkdir(file_path);
timestamp_file = strcat(...
datestr(...
datetime(...
fix(imu_unsync_timestamp_sec_init + imu_unsync_timestamp_nsec_init+noised_data(:,1)),...
'ConvertFrom','posixtime'),...
'yyyy-mm-dd HH:MM:SS.'),...
num2str(fix(1e9*abs(mod(imu_unsync_timestamp_nsec_init + noised_data(:,1), 1))),'%09d'));
timestamp_posix = strcat(num2str(fix(imu_unsync_timestamp_sec_init + imu_unsync_timestamp_nsec_init+noised_data(:,1))),...
'.',...
num2str(fix(1e9*abs(mod(imu_unsync_timestamp_nsec_init + noised_data(:,1), 1))),'%09d'));
fid_allin1 = fopen(strcat(output_data_path,'/oxts-',output_name,'/data.txt'),'w');
for i = 1:nrows
fid = fopen(strcat(file_path, num2str(i-1,'%010d'), '.txt'),'w');
fprintf(fid,'%.14g ',noised_data(i,2:end));
fclose(fid);
fprintf(fid_allin1,'%s,',timestamp_posix(i,:));
fprintf(fid_allin1,'%.14g,',noised_data(i,2:end-1));
fprintf(fid_allin1,'%.14g\n',noised_data(i,end));
str=['noised data write out: ',num2str(100*i/nrows),'%'];
waitbar(i/nrows,bar,str);
end
fclose(fid_allin1);
fid = fopen(strcat(output_data_path,'/oxts-',output_name,'/timestamps.txt'),'w');
for i = 1:size(timestamp_file,1)
fprintf(fid,'%s\n',timestamp_file(i,:));
end
fclose(fid);
close(bar);
end