Some would argue that adding tilt
compensation is going overboard and that small
educational bots do not need it. If you want a more
accurate heading, use:
dir = compass.avg_heading(mydeclination, 5)
# 5 is the number of samples to average
Unfortunately, as we cannot mount the compass
and accelerometer perfectly flat (with respect to the
floor), the error can be quite large (easily more than
five degrees) without tilt compensation, even after
we account for magnetic declination.
Sadly, even with correction for magnetic
declination and tilt compensation, we will still be
disturbed by the wiring and metal present in a
house. However, the results should at least be
repeatable within the same house. This can easily be
demonstrated by using a compass app on your
phone, or an actual old-school compass.
Turning Berry in a circle and occasionally tilting
him presented better results when
tilt compensation was applied.
Mission
Accomplished
In the next column, I will:
• Add wheel encoders so I can
track distance traveled
• Add an HC-SR04 ultrasonic
ranger as it has a four meter range
compared to the 1.5 meter range of
the current infrared sensor (I may
remove the short-range IR sensor)
• Let Berry run loose in my lab
so he can start mapping it! SV
COMPONENT & PRE-WIRED LEDS • LED BULBS • LED LIGHT ENGINES •
For the finest in robots,
parts, and services, go to
www.servomagazine.
com and click on
Robo-Links. ;; ;;;;;;;;;;;;
SERVO 12.2016 45