-
Notifications
You must be signed in to change notification settings - Fork 0
/
IMU_Logging.ino
176 lines (139 loc) · 3.74 KB
/
IMU_Logging.ino
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
173
174
175
176
void IMULogData(){
slowFindName();
SdFile::dateTimeCallback(dateTime);
if (!file.open(fileName, O_CREAT | O_WRITE | O_EXCL)) { // We attemp to open the file
error("file.open");
DEBUGSERIAL.println(" Slow file.open error");
}
else{
startTimeLogImu=millis(); // We save the start time to start at 0
Aquisition("IMU Logging",fileName); // Diplsay the screen of aquisition data
IMUWriteHeader();
DEBUGSERIAL.println(" A");
while (!rightButtonPressed){
refreshImuDatas();
IMUsdWriteData();
if (!file.sync() || file.getWriteError()) {
error("write error");
DEBUGSERIAL.println(" Slow write error error");
}
}
file.close();
ResetButton();
SlowSavingStats(fileName);
}
ResetButton();
}
void IMUWriteHeader() {
file.print("T (ms)");
file.print(";");
//Linear accel
file.print("linaAccel x");
file.print(";");
file.print("linaAccel y");
file.print(";");
file.print("linaAccel z");
file.print(";");
//Accel Data
file.print("accel x");
file.print(";");
file.print("accel y");
file.print(";");
file.print("accel z");
file.print(";");
//Gravity
file.print("gravit x");
file.print(";");
file.print("gravit y");
file.print(";");
file.print("gravit z");
file.print(";");
//Orientation
file.print("orient x");
file.print(";");
file.print("orient y");
file.print(";");
file.print("orient z");
file.print(";");
//Angle velocity
file.print("angleVelo x");
file.print(";");
file.print("angleVelo y");
file.print(";");
file.print("angleVelo z");
file.print(";");
//Magneto data
file.print("magnet x");
file.print(";");
file.print("magnet y");
file.print(";");
file.print("magnet z");
file.print(";");
// Put the temperature
file.print("temperature(C)");
file.print(";");
// Put the pressure
file.print("Pressure(hPa)");
file.print(";");
// Put the altitude
file.print("Altitude(m)");
file.print(";");
file.println();
}
void IMUsdWriteData(){
// Put the time
file.print((IMU_data.timestamp)-startTimeLogImu);
file.print(";");
//Linear accel
file.print(IMU_data.linearAcceleration.x);
file.print(";");
file.print(IMU_data.linearAcceleration.y);
file.print(";");
file.print(IMU_data.linearAcceleration.z);
file.print(";");
//Accel Data
file.print(IMU_data.acceleration.x);
file.print(";");
file.print(IMU_data.acceleration.y);
file.print(";");
file.print(IMU_data.acceleration.z);
file.print(";");
//Gravity
file.print(IMU_data.gravity.x);
file.print(";");
file.print(IMU_data.gravity.y);
file.print(";");
file.print(IMU_data.gravity.z);
file.print(";");
//Orientation
file.print(IMU_data.orientation.x);
file.print(";");
file.print(IMU_data.orientation.y);
file.print(";");
file.print(IMU_data.orientation.z);
file.print(";");
//Angle velocity
file.print(IMU_data.gyro.x);
file.print(";");
file.print(IMU_data.gyro.y);
file.print(";");
file.print(IMU_data.gyro.z);
file.print(";");
//Magneto data
file.print(IMU_data.magnetic.x);
file.print(";");
file.print(IMU_data.magnetic.y);
file.print(";");
file.print(IMU_data.magnetic.z);
file.print(";");
// Put the temperature
file.print(IMU_data.temperature);
file.print(";");
// Put the pressure
file.print(IMU_data.pressure);
file.print(";");
// Put the altitude
file.print(IMU_data.altitude);
file.print(";");
file.println();
}