Design and Implementation of a Magnetic ... Wheel Encoder for a Self-Driving ...

Design and Implementation of a Magnetic Rotary
Wheel Encoder for a Self-Driving Robotic Vehicle
by
Alexander Prodromos Gilbert
zoF
Submitted to the Department of Mechanical Engineering
in partial fulfillment of the requirements for the degree of
Bachelor of Science in Mechanical Engineering
W
OLL
COO
at the
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
June 2015
@
Massachusetts Institute of Technology 2015. All rights reserved.
11
A uthor ................
17
Signature redacted
Department of Mechanical Engineering
May 22, 2015
Certified by........
Signature redacted
...................................................
Jonathan How
Professor of Aeronautics and Astronautics
Thesis Supervisor
Accepted by
Signature redacted
Anette Hosoi
Associate Professor of Mechanical Engineering, Undergraduate Officer
<
2
Design and Implementation of a Magnetic Rotary Wheel
Encoder for a Self-Driving Robotic Vehicle
by
Alexander Prodromos Gilbert
Submitted to the Department of Mechanical Engineering
on May 22, 2015, in partial fulfillment of the
requirements for the degree of
Bachelor of Science in Mechanical Engineering
Abstract
This thesis project aims to help complete the fabrication of a magnetic wheel encoder
for a fleet of autonomous electric vehicles that will provide shuttle service across
MIT's campus. Currently no self-driving vehicles exist for such a function, especially
for mobility on a college campus. In an effort to assist the system's simultaneous localization and mapping (SLAM) algorithm, this magnetic wheel encoder was designed
and implemented to more accurately and directly determine the vehicle's trajectory.
After mounting the magnets and sensors, an algorithm was developed to map the
vehicle's path given raw magnetic field data. Though the open-loop system was not a
perfect map to the actual path taken, this work provides a guideline with more than
enough accuracy for the SLAM algorithm.
Thesis Supervisor: Jonathan How
Title: Professor of Aeronautics and Astronautics
3
Acknowledgments
I would like to thank my thesis advisor Professor Jonathan How, Justin Miller and
the rest of the Aerospace Controls Lab for their guidance and Dr. Barbara Hughey
for her insights on instrumentation and access to her lab's sensor library. I would also
like to thank my family and friends for all their support during my undergraduate
years at MIT.
4
Contents
1
Introduction
11
2
Methodology
15
2.1
2.2
3
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
Magnets: Positioning and spacing . . . . . . . . . . . . . . . .
15
2.1.2
Magnet field sensors
. . . . . . . . . . . . . . . . . . . . . . .
16
2.1.3
Resolution . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
2.1.4
Sensor selection . . . . . . . . . . . . . . . . . . . . . . . . . .
17
2.1.5
M ounting
. . . . . . . . . . . . . . . . . . . . . . . . . . . . .
18
Position Determining Algorithm . . . . . . . . . . . . . . . . . . . . .
18
19
Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
3.1.1
Down and back test. . . . . . . . . . . . . . . . . . . . . . . .
20
3.1.2
Circle test . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
3.1.3
Figure eight test
. . . . . . . . . . . . . . . . . . . . . . . . .
21
23
Conclusion
4.1
.
2.1.1
Results
3.1
4
M aterials
Future Work . . . . . . ..
. . . . . . . . . . . . . . . . . . . . . . . .
5
23
6
List of Figures
2-1
3-1
Positioning and magnitudes of magnets along the inside rim of left
w heel hub . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
16
Typical mapped path of vehicle for each test . . . . . . . . . . . . . .
19
7
8
List of Tables
3.1
Rest and Final Distance (m) and Accuracy of Travelling Straight 50m
and Back .........
3.2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
20
Final Position from Starting Point (m) in X,Y Directions and Accuracy
of Travelling in a Tight Circle . . . . . . . . . . . . . . . . . . . . . .
3.4
20
Rest and Final Positions (m) and Accuracy of Travelling Straight 50m
and B ack
3.3
.................................
21
Final Position from Starting.Point (m) in X,Y Directions and Accuracy
of Travelling in a Figure Eight . . . . . . . . . . . . . . . . . . . . . .
9
21
10
Chapter 1
Introduction
Due to the complexity of the act of driving, an autonomous vehicle must know its
position in space relative to its surroundings above all other functions. If the vehicle is
not 100% sure of its location, it cannot make the best and safest decisions. Currently,
the Self-Driving Robotic Vehicle of the Aerospace Control Laboratory has an inertial measurement unit (IMU), a global positioning system (GPS) and a gyroscope to
help provide data on the absolute position of the vehicle. However, all these provide
non-continuous, derived values of position; as such, they give shoddy-at-best approximations. The system's Simultaneous Localization and Mapping (SLAM) algorithm
requires much more precise measurement of absolute position.
SLAM is the method with which the robotic vehicle analyzes the changes of its
surroundings over time and makes a three-dimensional map of the world around the
vehicle.[11 Using the two planar Light Detection and Ranging (LiDAR) sensors and a
3D VelodyneTM HDL-32E in the front of the vehicle, the distance to objects around
the vehicle are all known.
But to understand how the objects are interacting in
their environment, the vehicle must first know its exact location.
Without precise
knowledge of where it is at all times, the vehicle cannot accurately use SLAM to map
the surrounding world.
There are many technologies that provide measurements of absolute position. The
most popular are those that employ GPS. GPS has become a very commonplace and
handy positioning technology, but with an estimated error of 3.351m,[2] GPS alone
11
would not be able to provide the needed accuracy for this application. GPS technology
also does not function well in or next to buildings, and the MIT prototype vehicle
must be able to provide services in those locations if shuttle routes call for it. The
pedal force sensor on the cart can also be used to determine speed, and from speed,
distance, but such a system would have to be coupled with an additional system
measuring heading from the steering wheel to determine trajectory.
The most accurate position sensor is the PegasemTM Wheel Speed Sensor(WSS).[3]
It is well known that Pegasen1TM provides the most accurate positioning system on the
market, which is why these sensors are implemented on several autonomous vehicles
such as the award winning CajunBot.[4] Unfortunately, each Pegasem T M WSS, even
without the mounting costs, more than $2,000. Given that two encoders are to be
implemented on each vehicle for a fleet of at least 3 carts, this was not a viable option.
Rotary wheel encoders are a common technology in this space, as they are often
inexpensive and easy to implement. Since they are mechanically coupled with the
wheel, a permanent feature of the vehicle, wheel encoders provide assurance and
resolution that wireless technologies cannot compete with. The most common type
of magnetic wheel encoder is optical.
Optical wheel encoders shine light onto a
phtotodiode through slits of the wheel.
This provides unparalleled accuracy and
resolution. Unfortunately, this technology would not be able to function when exposed
the elements the robotic vehicle would encounter (rain, dirt, mud, etc.). Conductive
wheel encoders fail for the same reason.[5]
Magnetic wheel encoders are the next most popular type after optical. Magnetic
fields are largely unaffected by weather or wet conditions. Therefore, the only concern
about magnetic forces on the wheel that could alter the data would be if a piece of
magnetic metal attached itself to a magnet. This is thought to be a rare occurrence.
Bicyclists often incorporate simple magnetic wheel encoders on their back wheel
to measure their speed and distance traveled. Such systems frequentyly use a simple
magnet switch and a series of magnets. By reading when the magnet switch activates
and deactivates, and by anticipating the sequence of magnets, position and speed
data can be deduced. Older car models used similar systems to determine distance
12
traveled. [5] Unfortunately, the encoder is greatly limited by the number of magnets
that can fit on the rim of the wheel hub without having the magnetic fields overlapping
with one another. Another drawback of the magnetic switch model is that to double
the resolution, not only would the number of magnet patterns need to be doubled,
but the number of magnets per pattern would also each need to increase by one.
To avoid cluttering the observed magnetic field, a magnetic field sensor was the
sensor of choice in this project.
Magnetic field sensors detect the magnitude and
direction of the magnetic field.
By taking advantage of this property, a magnetic
field sensor can determine absolute position of the wheel by measuring a single spike
in magnetic field generated by one magnet. Therefore, by using magnets of varying
magnetic strength and direction, a magnetic field sensor was decided upon to be the
sensing instrument of the wheel encoder.
Chapter two describes the materials used in the system as well as how the data
processing algorithm was implemented.
The results from basic testing as well as
an analysis of the accuracy of the system are discussed in detail in chapter four.
Conclusions and possible future expansions to the project are discussed following the
results section.
13
14
Chapter 2
Methodology
2.1
Materials
The magnetic wheel encoder designed and implemented in this thesis consists of three
main components: magnets, magnetic field sensors and a data processing algorithm.
This section explains in detail the design criteria for each and how they were implemented on the vehicle. The vehicle that the system was mounted on was a Polaris®
e4S.
2.1.1
Magnets: Positioning and spacing
The most basic materials used were small rare-earth Mighties Magnets® by Three
by ThreeTM.
These magnets had a diameter and height of 1/4 and 1/16 inches,
respectively, which allowed them to fit snugly inside the lip of the wheel hub without
protruding from the lip. Since they were so small, it was easy to vary the magnitudes
of magnetic field at the varying locations by stacking different number of magnets
and orienting them in different directions. First, the number of magnet locations had
to be determined. To maximize the resolution without making the magnitude peaks
too noisy and cluttered for the algorithm, four magnets were placed along the edge
of the wheel rim equally spaced from one another. With the tire circumference being
1.65m, the resolution of the encoder was 1.65m/4 = 0.41m. Adding more magnets
15
Wheel Rotating
Backward
Wheel Rotating
Forward
-5+
-3mT
-4mT
1+4mT
+3mT
Figure 2-1: Positioning and magnitudes of magnets along the inside rim of left wheel
hub
makes the algorithm less accurate at determining peaks in magnetic magnitude as
the sensor passes each magnet location.
The magnet locations were equally spaced along, as shown in Figure 2-1. The
vantage point of this figure is as if you were looking at the left wheel from underneath
the vehicle.
Looking at the right wheel from underneath the vehicle, the position-
ing would appear flipped vertically as compared to the figure. That way the same
sequence of positions would arise for both the left and right wheels, but with a delay.
2.1.2
Magnet field sensors
2.1.3
Resolution
The next specification to be determined was the resolution and sample frequency
of the magnetic field sensor. The sensor had to be sensitive and fast enough for
the algorithm to accurately determine spikes in magnetic field magnitude.
Since
the vehicle could theoretically drive at speeds up to 40 mph (18m/s), the minimum
resolution of the sensor was calculated through the following relationships. Let smax
denote the maximum speed attainable by the vehicle, d the outer diameter of the tire,
m the number of magnets, T the period of the revolutions, T the time between peaks,
p the minimum data points between points,
16
f
the minimum frequency.
Smax
T
7rd/T
=
=rd/Smax
T/m
T=
f
=PI
The minimum number of data points between peaks p for the algorithm to accurately determinine whether or not that reading is peak in magnetic magnitude is 20.
This value was tested experimentally. Values of p smaller than 20 led to the algorithm
inaccurately determining noise as peaks in rare instances. Given the requirements that
the sensor had to accommodate high speeds while still have large number of samples
between position readings, minimum sample frequency of the sensor was calculated
to be 1kHz.
2.1.4
Sensor selection
The sensor selected was the Vernier® Magnetic Field Sensors primarily due to its high
frequency (10+kHz) and high resolution rating (0.0002mT). The sensing range ( 6.4
mT) made this sensor a perfect match for the magnets selected as the two did not
have to be very far apart to obtain strong readings. The Vernier sensor's convenient
form factor (sturdy, long and cylindrical) made it easy to mount to the back axle
truss. Its low cost also made it attractive as two sensors need to be attached to each
vehicle in the fleet.
Other magnetic field sensors that were available and met the frequency and resolution requirements either did not have as rigid housing, had an inferior sensor range
match with common strong magnets, or were simply too expensive.
17
2.1.5
Mounting
A simple mount was made of 80-20 aluminum to rigidly attach the sensor to the truss
of the vehicle. The sensor was set up perpendicularly from the face of the wheel with
the sensing end 5mm from the closest face of the magnets.
This distance, though
seemingly small, provides plenty of clearance from the tires as the tires are not on
a differential but rather a fixed axle. In the next prototypes, a mount will be either
3D printed or waterjetted and drilled into the truss so that the distance between the
magnets and sensor will be practically fixed.
2.2
Position Determining Algorithm
Two vectors (one from each sensor) of raw magnetic field data received were the only
data needed to determine the path taken by the vehicle.
As the algorithm walks
down the matrix of raw data, it picks out extrema by looking ahead and behind p/2
data points. Because this is the maximum amount the algorithm must look ahead,
the algorithm itself could be easily implemented online with a delay of p/2f seconds.
Every time an extrema is found, its value and the values of the previous two extrema
can be used to determine which position the wheel had just passed, as well as in which
direction the wheel rotating is. Since the magnets are all spread out evenly along the
rim of the hub, speed can be calculated by taking the discrete derivative (or gradient
function) of distance with respect to time. To make the data more continuous and
acheive higher resolution, linear interpolations were performed on the speeds of the
two wheels. Given the difference between the speeds of the two wheels (v - v,) and
the track width (distance between the centers of the back wheels), the vehicle path
was determined.
18
Chapter 3
Results
3.1
Testing
To quantitatively determine the accuracy of the system, the vehicle underwent multiple controlled driving maneuvers. These included a down and back test, a circle
test and a figure eight test. The results of each are listed below. Since the wheel
encoder alone is inherently an open-loop system, meaning once started the system
has no method for correction, the results of these tests will only improve as the wheel
encoder is coupled with the rest of the sensors and SLAM algorithm.
X.mo~sacmm n(Mi)
(a) Down and Back
X4 -D
l*Mn(M)
(b) Circle
XD~aa.tm
(c) Figure Eight
Figure 3-1: Typical mapped path of vehicle for each test
19
3.1.1
Down and back test
The first test performed was a simplified down-and-back test. Starting at rest, the
vehicle traveled in a straight line to a measured 50m, stopped, and drove in reverse
straight back to the starting location. The purpose of this test was to determine how
well the wheel encoder measured forward displacement and reverse displacement.
Table ?? shows the accuracy of both encoders when driving straight a fixed distance,
and coming back in reverse that same distance.
Trial
1
2
3
4
Down
(48.68,
(48.68,
(48.68,
(48.68,
(L,R)
48.68)
48.68)
48.68)
48.68)
Back
(1.238,
(0.825,
(0.825,
(0.825,
(L,R)
1.238)
0.825)
0.825)
0.825)
Error
1.751
1.167
1.167
1.167
Table 3.1: Rest and Final Distance (m) and Accuracy of Travelling Straight 50m and
Back
Trial
1
2
3
4
Rest (X,Y)
(17.61,45.47)
(0.088,49.07)
(-24.46,40.21)
(-1.93,48.42)
Final (X,Y)
(2.698, -0.608)
(-0.6938,0.6745)
(0.672,-1.234)
(1.618 , 0.097)
Displacement Error
2.766
0.968
1.405
1.621
Table 3.2: Rest and Final Positions (m) and Accuracy of Travelling Straight 50m and
Back
3.1.2
Circle test
To test the turning accuracy, tests were performed when the vehicle started at rest,
turned in a tight circle and stopped at the starting location in the same orientation as
it started. The purpose of this test was to determine how well the algorithm tracked
the actual path of the cart. The measured difference in absolute position between the
starting position and final position are listed in Table 3.3.
20
Trial
Final Position (X,Y)
Total Displacement Error
1
2
3
4
(0.1499,0.3087)
(0.1053,0.3671)
(0.0806,-0.08288)
(0.1411,0.3093)
0.343
0.382
0.116
0.340
Table 3.3: Final Position from Starting Point (m) in X,Y Directions and Accuracy of
Travelling in a Tight Circle
3.1.3
Figure eight test
To also test the turning accuracy, tests were performed when the vehicle started at
rest, performed a tight figure eight pattern and stopped at the starting location in the
same orientation as it started. Again, the purpose of this test was to determine how
well the algorithm tracked the actual path of the cart, but with the added complexity
of switching the turning radius mid-test. Taking into consideration the total distance
traveled of each of these tests was 80m . The measured difference in absolute position
between the starting position and final position are listed in Table 3.4.
Trial
Final Position (X,Y)
Total Displacement Error
1
2
3
4
(-3.511,1.464)
(-2.656,3.141)
(-3.389,-2.259)
(-3.136,1.545)
84.97
82.50
80.44
77.35
Table 3.4: Final Position from Starting Point (m) in X,Y Directions and Accuracy of
Travelling in a Figure Eight
21
22
Chapter 4
Conclusion
This thesis outlines the design process and implementation of a magnetic wheel encoder for the Self-Driving Robotic Vehicle Project. With a resolution of 0.41m, the
system successfully was able to determine distance travelled by the two wheels. The
position-determining algorithm also proved that two magnetic wheel encoders were
sufficient to map the path of the vehicle. When processing a path where the vehicle
switches from forwards driving to reverse or vise versa, the algorithm does not follow
the change in heading accurately. While there is much work left to be done to improve
this capability, it can provide the system's SLAM algorithm with more than enough
accuracy.
4.1
Future Work
To integrate the wheel encoder with the rest of the electronics system, the sensor
must be made to run online. Instead of logging the data through LoggerPro and then
using MATLAB to analyze it, the sensor should directly feed processing program
currently used by the vehicle. Molding the position-determining algorithm outlined
in the Chapter to seamlessly integrate with the current system, the algorithm would
be able to run at almost real-time with a lag of p/2 seconds.
This project is currently in the process of being capable to be integrate online. A
new magnetic field sensor, the GY-271 HMC5883L Triple Axis Magnetometer Sensor
23
Module, was purchased that was more sensitive and more accurate than the previous
Vernier model. Connected through an Arduino® to convert 12C to USB, the sensor provides serial data to the computer that can be integrated to the ROS SLAM
software.
To ensure that the same thresholds can be used every time, a rigid mount must be
designed so that the magnetic field sensor is located in the same position with respect
to the magnets. For the next iteration, a more sensitive sensor and more magnet
positions should be incorporated as this could greatly increase resolution.
24
Bibliography
[1] Hugh Durrant-Whyte et al. Simultaneous localisation and mapping (slam): Part
ithe essential algorithms. Technical report, UC Berkeley.
[2] Faa gps performance analysis report. Technical report, William J. Hughes Technical Center, July 2014.
[3] Telescope Control System 3. Pegasem wss wheel speed sensor. Technical report,
Pegasern Messtechnik GmbH.
[41 Cajunbot technology. Technical report, University of Louisiana Lafayette, 2015.
[51 Telescope Control System 3. Encoder primer. Technical report, University of
Hawaii.
25