-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab4.html
More file actions
381 lines (313 loc) · 18.7 KB
/
Lab4.html
File metadata and controls
381 lines (313 loc) · 18.7 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<meta name="description" content="" />
<meta name="author" content="" />
<title>ECE 4160: Lab 4</title>
<link rel="icon" type="image/x-icon" href="assets/img/favicon.ico" />
<!-- Font Awesome icons (free version)-->
<script src="https://use.fontawesome.com/releases/v6.1.0/js/all.js" crossorigin="anonymous"></script>
<!-- Google fonts-->
<link href="https://fonts.googleapis.com/css?family=Saira+Extra+Condensed:500,700" rel="stylesheet" type="text/css" />
<link href="https://fonts.googleapis.com/css?family=Muli:400,400i,800,800i" rel="stylesheet" type="text/css" />
<!-- Core theme CSS (includes Bootstrap)-->
<link href="css/styles.css" rel="stylesheet" />
</head>
<body id="page-top">
<!-- Navigation-->
<nav class="navbar navbar-expand-lg navbar-dark bg-primary fixed-top" id="sideNav">
<a class="navbar-brand js-scroll-trigger" href="#page-top">
<span class="d-block d-lg-none">Eshita Sangani</span>
<span class="d-none d-lg-block"><img class="img-fluid img-profile rounded-circle mx-auto mb-2" src="assets/profile.jpg" alt="..." /></span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav">
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="index.html">About</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab1.html">Lab 1</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab2.html" >Lab 2</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab3.html">Lab 3</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab4.html" style="color: rgb(31, 78, 47);">Lab 4</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab5.html">Lab 5</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab6.html">Lab 6</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab7.html">Lab 7</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab8.html">Lab 8</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab9.html">Lab 9</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab10.html">Lab 10</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab11.html">Lab 11</a></li>
<li class="nav-item"><a class="nav-link js-scroll-trigger" href="Lab12.html">Lab 12</a></li>
</ul>
</div>
</nav>
<!-- Page Content-->
<section class="resume-section" id="experience">
<div class="resume-section-content">
<h2 class="mb-2">Lab 4 <span class="text-primary">IMU Sensor</span></h2>
<p class="mb-5">
The purpose of this lab was to gain familiarity with IMU sensors, another of
the sensors that we will equip our robot with as well beginning
the run stunts on our robot.
</p>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">IMU Setup</h3>
<p>
The IMU measures angular rate and force/acceleration by an
object - we focus on the accelerometer + gyroscope data.
I conncected the IMU to the Artemis using a QWICC connector
as seen in the image below.
</p>
<p>
<img src="assets/qwicc.jpg" alt="..." width="55%" />
</p>
<p>
I began by installing the SparkFun 9DOF IMU Breakout -
ICM 20948 library and using the Example1_Basics example.
This prints out the raw accelerometer and gyroscope values,
which can be visualized through the serial plotter. In this
example, the AD0_VAL is used to change the address of an IMU
if multiple IMU's are used. In this case, we are only using
1 IMU so the AD0_VAL should be set to 1.
</p>
<p>
When running this example, I noticed that one of the
acceleration readings is consistently high - displaying
gravity - while the others are close to 0 as seen in the
video. The acceleration usually changes with rotation.
The gyroscope measures the lateral movement (rotation
about the axes), also does not feel the effect of gravity,
and is very sensitive to little movements.
</p>
<p>
<img src="assets/example1basis.jpg" alt="..." width="55%" />
</p>
<p>
For debugging purposes, I added a visual indicator to see
if the board is running/is stuck. It will blink three times
if the Artemis has turned on with a slight delay.
</p>
<p>
<script src="https://gist.github.com/eshitasangani/0eb8fcfd712456b3f0576e9c93bb12e8.js"></script>
</p>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">ACCELERROMETER</h3>
<p>
In order to convert the accelerometer data to pitch and roll, I used
the sample code from the IMU lecture as a base. Pitch is the
rotation around the X axis and roll is the rotation around the Y axis
and can be calculated as seen below.
</p>
<p>
Pitch: θ = atan2(x_accel , z_accel)
</p>
<p>
Roll: 𝜙 = atan2(y_accel, z_accel)
</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rymEHaL91Ek"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
<p>
I then visualized the output at -90, 0, and 90 degrees for pitch and roll.
</p>
<p>
<!-- insert image here -->
<img src="assets/pitch-90.jpg" alt="..." width="55%" />
</p>
<p>
<!-- insert image here -->
<img src="assets/pitch90.jpg" alt="..." width="55%" />
</p>
<p>
<!-- insert image here -->
<img src="assets/roll-90.jpg" alt="..." width="55%" />
</p>
<p>
<!-- insert image here -->
<img src="assets/roll90.jpg" alt="..." width="55%" />
</p>
<h4 class="mb-0"> Accelerometer Noise </h3>
<p>
However, the accelerometer is very noisy, especailly if the RC car is running, because of the noise
from the motors. I ran an FFT on that data - resulting in not too much noise. This led me to use
a low pas filter to make the accelerometer more sensitive to that noise when it is on the car.
The FFT analysis is shown below. Transforming the data from time domain to frequency domain helped show the
that the frequency with the most noise was around 0.1 Hz, showing the effect of the low pass filter.
Through this, the frequency found was under .1 Hz, illustrating that the noise was reduced.
</p>
<p>
The first two images are the time and frequency domain of pitch.
</p>
<p>
<img src="assets/timedomain.jpg" alt="..." width="55%" />
</p>
<p>
<img src="assets/freq.jpg" alt="..." width="55%" />
</p>
<p>
The second two images are the time and frequency domain of roll.
</p>
<p>
<img src="assets/timeroll.jpg" alt="..." width="55%" />
</p>
<p>
<img src="assets/freqroll.jpg" alt="..." width="55%" />
</p>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">GYROSCOPE</h3>
<p>
In addition to using the accelerometer, I used a gyroscope to
measure the angular rate. I was able to calculate yaw - the
rotation around a vertical axis - in addition to pitch and roll.
I calculated these measures using these equations:
</p>
<p>
pitch_g = pitch_g + myICM.gyrX()*dt;
</p>
<p>
roll_g = roll_g + myICM.gyrY()*dt;
</p>
<p>
yaw_g = yaw_g + myICM.gyrZ()*dt;
</p>
<p>
When I rotated the board about either the x, y, or z axis, I could
see the yaw, pitch, roll change accordingly.
</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/4_u0KXu9pdo"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">Complementary Filter</h3>
<p>
When using the gyroscope, there is an accumulation of error over time while
the accelerometer is more susceptible to noise.
In order to combine the benefits of both the accelerometer
and gyroscope, I implemented a complementary filter using
the below equations:
</p>
<p>
pitch_ga = (pitch+myICM.gyrX()*dt)*0.8 + pitch_a*0.2;
</p>
<p>
roll_ga = (roll+myICM.gyrY()*dt)*0.8 + roll_a*0.2;
</p>
<p>
When using the complementary filter, I noticed that
I still have some noise because my alpha value was 0.8,
as I wanted to get the most accurate readings which came
at the cost of noise. My readings became more accurate when
implementing the complementary filter as it combined
the best parts of using the gyroscope and accelerometer.
</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/AjrlvxOb5CQ"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">Sampling Data</h3>
<p>
When getting the data from the IMU, I wanted to make sure that
we didn't want to wait for the IMU data to be ready and would
only want to check if the data is ready for every iteration
of the main loop(), and store it in the corresponding array
accordingly. I stored the time stamped IMU data
in 3 arrays - time, pitch, and roll, which can be seen below.
</p>
<p>
I wanted to integrate my lab 3 code with this lab
and be able to send TOF + IMU data at once. Previously,
I only had one BLE string characteristic that would receive
all the data but since the TOF + IMU had very different sampling
rates, I created another characteristic to ensure that
both could be checked for and called at the same time.
</p>
<p>
<script src="https://gist.github.com/eshitasangani/b80380687b38d2ccd9038786b4fc3653.js"></script>
</p>
<p>
In addition, I then captured 5s of IMU + TOF data from the
sensors and then sent it over bluetooth to my computer -
this is illustrated below.
</p>
<p>
<script src="https://gist.github.com/eshitasangani/1b0dfd604c456684c69756dd866941cb.js"></script>
</p>
<p>
<img src="assets/tofimu.jpg" alt="..." width="55%" />
</p>
<p>
<img src="assets/plottofimu.jpg" alt="..." width="55%" />
</p>
</p>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">Cut the Coord!</h3>
<p>
Now, I cut the coord and integrated everything together!
Instead of connecting the Artemis to my computer,
I connected a 650 mAh battery to my Artemis and a 850 mAh
battery to the robot to power its motor drivers. I wanted to
ensure the motor drivers had the most powerful battery because
of how much power it consumes in comparison to the Artemis.
I also ensured that I was still able to receive bluetooth
data when the power was connected.
</p>
<p>
After cutting the cord, this is what the new hardware setup looked
like.
</p>
<p>
<img src="assets/coord.jpg" alt="..." width="55%" />
</p>
</div>
</div>
<div class="d-flex flex-column flex-md-row justify-content-between mb-5">
<div class="flex-grow-1">
<h3 class="mb-0">Record a Stunt!</h3>
<p>
Fast Robot in action! I finally ran the robot - it took me
some time to get used to the controls but it definitely
was a speedy robot.
</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/JZYJbsv7hXY"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
<p>
After practing the current robot, I taped on my Artemis + sensors
+ battery onto the car and tried recording a stunt as well. When recording
this stunt, the floors were pretty grippy leading to constant turning as
seen below.
</p>
<iframe width="560" height="315" src="https://www.youtube.com/embed/5twgvXwwqWs"
title="YouTube video player" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
allowfullscreen></iframe>
</div>
</div>
</div>
</section>
<!-- Bootstrap core JS-->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Core theme JS-->
<script src="js/scripts.js"></script>
</body>
</html>