-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathSyntheticDataGenerator_Master.m
More file actions
186 lines (158 loc) · 4.19 KB
/
Copy pathSyntheticDataGenerator_Master.m
File metadata and controls
186 lines (158 loc) · 4.19 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
function SyntheticDataGenerator_Master(iRotationOperation,iFrameStep,iCorridorSize)
%% Simulate the function of "Calib_3LRF_PreProc"
% close all;clc;clear;
NUMBER_LRFs=3;
bMyData=0;
if bMyData
PTS_PER_FRAME=1081;
else
PTS_PER_FRAME=1080;
end
timePerFrame_LRF=25; % 25ms per frame
timePerFrame_IMU=100;
RawFilePath = 'E:\SLAM\Data\20180828_sim\';
fileName0='7_0';
%% Set the size of Corridor
% assume the corridor has enough length
if iCorridorSize==1
corridorWidth=2.0;
corridorHeight=2.0;
elseif iCorridorSize==2
corridorWidth=2;
corridorHeight=4;
elseif iCorridorSize==3
corridorWidth=4;
corridorHeight=2;
end
%% Set trajactories (assume that the device axis is parrallel to the world axis when angs equals 0)
t=1:360;
T_traj(:,1)=t.*0 + 1;
T_traj(:,2)=t.*0 + 0;
T_traj(:,3)=t.*0 + 1;
if iCorridorSize==3
T_traj(:,1)=t.*0 + 2;
end
if iRotationOperation==1
% Z360 A
ang_traj(:,1)=0*t;
ang_traj(:,2)=0*t;
ang_traj(:,3)=t;
elseif iRotationOperation==2
% X45Z360 B
ang_traj(:,1)=0*t+45;
ang_traj(:,2)=0*t;
ang_traj(:,3)=t;
elseif iRotationOperation==3
% Xd45Z360 C
ang_traj(:,1)=sin(t*4*pi/180)*45+45;
ang_traj(:,2)=0*t;
ang_traj(:,3)=t;
elseif iRotationOperation==4
% Xd60Yd60Z360 D
ang_traj(:,1)=sin(t*4*pi/180)*45+45;
ang_traj(:,2)=sin(t*4*pi/180)*45+45;
ang_traj(:,3)=t;
elseif iRotationOperation==5
% Xd60Zd120 E
ang_traj(:,1)=(360-t)*45/360;
ang_traj(:,2)=t.*0;
ang_traj(:,3)=sin(t*2*pi/180)*90;
elseif iRotationOperation==6
% RandomPose F
ang_traj=rand(length(t),3)*360;
end
ang_traj=ang_traj.*pi/180;
nGroups=size(ang_traj,1);
% figure,
% subplot(1,2,1),
% plot3(ang_traj(:,1),ang_traj(:,2),ang_traj(:,3),'.');axis equal;
% subplot(1,2,2),
% plot3(T_traj(:,1),T_traj(:,2),T_traj(:,3),'.');axis equal;
%% Set simulation poses and ini poses
ang_LRFs_sim=zeros(3,3);
ang_LRFsIni=zeros(3,3);
ang_LRFs_sim=[
0,0,0;
-80, 0, -35;
80, 0, -150;
];
ang_LRFsIni=[
0,0,0;
-90, 0, -30;
90, 0, -145;
];
T_LRFs_sim=zeros(3,3);
T_LRFsIni=zeros(3,3);
T_LRFs_sim=[
0,0,0;
-0.15, 0.15, -0.2;
0.15, 0.15, -0.5;
];
T_LRFsIni=[
0,0,0;
-0.1, 0.1, -0.2;
0.1, 0.1, -0.5;
];
% ang_LRFs_sim=zeros(3,3);
% ang_LRFsIni=zeros(3,3);
% ang_LRFs_sim=[
% 0,0,0;
% -78, 0.0, -30;
% 85, 0, -137;
% ];
% ang_LRFsIni=[
% 0,0,0;
% -90, 0.0, -30;
% 90, 0, -140;
% ];
% T_LRFs_sim=zeros(3,3);
% T_LRFsIni=zeros(3,3);
% T_LRFs_sim=[
% 0,0,0;
% 0.09, 0.1 -0.39;
% -0.17, 0.06, -0.62;
% ];
% T_LRFsIni=[
% 0,0,0;
% 0.1, 0.05, -0.3;
% -0.1, 0.05, -0.6;
% ];
ang_LRFs_sim_radian=ang_LRFs_sim.*pi/180;
R_LRFs_Simulation=zeros(3,3,3);
for i=1:3
R_LRFs_Simulation(i,:,:)=EulerAngle2RotateMat(ang_LRFs_sim_radian(i,1),ang_LRFs_sim_radian(i,2),ang_LRFs_sim_radian(i,3),'xyz');
end
% IMU
ang_IMU=[0,0,90];
ang_IMU_radian=ang_IMU.*pi/180;
R_IMU_sim=EulerAngle2RotateMat(ang_IMU_radian(1),ang_IMU_radian(2),ang_IMU_radian(3),'xyz');
%% Generate data
poses_LRFs_R=zeros(3,3,3);
poses_LRFs_T=zeros(3,3);
PC_Raw=zeros(NUMBER_LRFs,nGroups,PTS_PER_FRAME,3);
IMU=zeros(nGroups,3,3);
for iGroup=1:iFrameStep:nGroups
% get poses of all the sensors
R_iGroup=EulerAngle2RotateMat(ang_traj(iGroup,1),ang_traj(iGroup,2),ang_traj(iGroup,3),'zxy');
T_iGroup=squeeze(T_traj(iGroup,:));
for iLRF=1:3
[poses_LRFs_R(iLRF,:,:),poses_LRFs_T(:,iLRF)]=...
PoseAddition_RT(squeeze(R_LRFs_Simulation(iLRF,:,:)),squeeze(T_LRFs_sim(iLRF,:))',R_iGroup,T_iGroup');
end
poses_LRFs_T=poses_LRFs_T';
% get synthetic data (LRF)
for iLRF=1:3
PC_Raw(iLRF,iGroup,:,1:2)=SyntheticDataGenerator_LRF(...
inv(squeeze(poses_LRFs_R(iLRF,:,:))),squeeze(poses_LRFs_T(iLRF,:)),corridorWidth,corridorHeight);
end
% get synthetic data (IMU)
IMU(iGroup,:,:)=R_IMU_sim*R_iGroup;
disp(['ÒÑÉú³ÉµÚ' num2str(iGroup) '×é']);
end
%% Save data
% PC_Raw & IMU
fileName_PC=fileName0;
fileFullPath_Data=[RawFilePath 'Data_' fileName_PC '.mat'];
save(fileFullPath_Data,'PC_Raw','IMU');
fileFullPath_LRFsIniPos=[RawFilePath 'LRFsIniPos.mat'];
save(fileFullPath_LRFsIniPos,'ang_LRFsIni','T_LRFsIni');