gloomyandy wrote:Ok so here is some actual data.
Haha! Looks like I'm not the only one who spent an enjoyable evening collecting data
I constructed a simple bot and programmed it to record its bearing before and after completing a number of laps of my kitchen floor. The bearing was measured both using the compass (readings taken before and after when the motors were off) and odometry. I also measured the bearing using a protractor, using my kitchen tiles as a reference. These are well lined up and I estimate that the protractor measurements are accurate to ground truth within 2 degrees.
The first experiment was to make the robot do a small turn on the spot. The delta (bearing at end minus bearing at start) was recorded as follows:
Code: Select all
Compass Odo Protractor
133 127 134
132 128 132
133 127 132
133 129 132
132 128 132
I then made the robot travel a lap of the kitchen (more or less) and the results for the delta were:
Code: Select all
Compass Odo Protractor
26 28 40
44 30 46
40 29 42
26 14 24
38 25 36
33 23 34
34 25 34
42 30 40
Something appears to have gone wrong with the measurement of the first run, but the others show the compass within 2 degrees of the protractor and the odometry reading consistently about 10 degrees lower.
The next set of results are for two laps of the kitchen:
Code: Select all
Compass Odo Protractor
52 32 50
47 26 46
36 13 34
37 14 36
33 8 30
31 5 30
25 3 24
20 358 16
This shows a similar relationship between the compass and protractor readings, but now the odometry readings are consistently about 20 degrees lower. This suggests a systematic accumulation of errors and to test this I ran the experiment again, but with all right turns turned into left turns (again, two laps of the kitchen):
Code: Select all
Compass Odo Protractor
185 216 176
181 216 176
187 224 186
193 229 192
194 228 194
Indeed, the odometry readings now show a consistently high value. Also note that for the first two runs the compass and protractor readings differ by a lot more than usual. This is probably because on those runs the robot finished within about 70cm of my oven (which is effectively a big lump of metal). For the remaining runs I ensured that the robot started and finished at least 1m away from any metal objects (as had been done for all previous experiments).
This is all very encouraging for the compass - it demonstrates a consistent accuracy of a couple of degrees. How do we explain the reports of poor performance then? One explanation could be stray magnetic fields, but another is the fact that the compass has to be horizontal when taking readings. To show the effect of this, I mounted it in a couple of different ways which held the compass at different angles relative to the horizontal (but all at the same bearing) and just recorded the value received from the sensor whilst the robot was stationary. The results are as follows
Code: Select all
Angle Reading
0 165
53 172
-53 14
53 172
0 165
-53 11
I repeated the experiment a few times to ensure that mounting and re-mounting of the compass was not to blame.
The results are striking. In particular, it appears that if the compass is pointed downwards it goes way off. This is a likely explanation for poor results from the sensor, and demonstrates that it needs to be carefully mounted or calibrated to take the effect into account.
Matt