GPS BASED AUTONOMOUS CAR NAVIGATION
GPS BASED AUTONOMOUS CAR NAVIGATION SYSTEM
Minhas Thaker
B.E., Gujarat University, India, 2008
PROJECT
Submitted in partial satisfaction of
the requirements for the degree of
MASTER OF SCIENCE
in
ELECTRICAL AND ELECTRONIC ENGINEERING
at
CALIFORNIA STATE UNIVERSITY, SACRAMENTO
FALL
2010
GPS BASED AUTONOMOUS CAR NAVIGATION SYSTEM
A Project
by
Minhas Thaker
Approved by:
________________________________, Committee Chair
Jing Pang, Ph.D.
________________________________, Second Reader
Preetham Kumar, Ph.D.
_________________________
Date
ii
Student: Minhas Thaker
I certify that this student has met the requirements for format contained in the University
format manual and that this project is suitable for shelving in the Library and credit is to
be awarded for the Project
__________________________, Graduate Coordinator
Preetham Kumar, Ph.D.
Department of Electrical and Electronic Engineering
iii
___________________
Date
Abstract
of
GPS BASED AUTONOMOUS CAR NAVIGATION SYSTEM
by
Minhas Thaker
Autonomous car navigation system based on GPS (Global Positioning System) is
a new and promising technology, which uses real time geographical data received from
several GPS satellites such as longitude, latitude, speed and course to help navigate a car.
The goal of the project is to make a auto-navigational car model that can route through
known or pre-programmed co-ordinates autonomously without any human involvement.
The project discusses how GPS readings of the current and destination points are
used to compute the distance and direction of the destination and thereby navigating the
car on the set path. It also discusses how the car must maintain its direction by
automatically correcting its course based on new GPS data received. The project
discusses various issues that were encountered and solved throughout the course of the
project.
The project is coded in C, developed and compiled in AVR studio software and is
implemented on a Atmel ATmega328 microcontroller. The project utilizes EM408 SiRF
Star III/LP single based chipset GPS engine board receiver manufactured by GlobalSat
Technology Corp., Taiwan and sold by USGlobalSat Inc, USA. The output of the GPS
iv
receiver is a standard NMEA signal which is decoded by the microcontroller to get
necessary geographical parameters. Once the microcontroller has the required data, it can
compute the direction of movement and thereby navigate the car. Also, the inherent logic
steers the car in case the car deviates more than a certain degree from its course. The car
that is referred to in this project is 4WD dc-motor controlled robot car.
__________________________, Committee Chair
Jing Pang, Ph.D.
__________________________
Date
v
ACKNOWLEDGMENTS
I would like to present deep and sincerest gratitude to Dr. Jing Pang for providing
me with an opportunity to work on this project. This project has immensely helped me to
get exposure to the emerging technology of GPS navigation. I thank her for providing all
the necessary resources, help and support for the project.
I would also like to thank Dr. Preetham Kumar for reviewing my project report
and providing timely feedback and valuable suggestions to improve my report.
I am truly thankful to the faculty and staff members of the Department of
Electrical and Electronics Engineering at California State University, who have been
instrumental directly as well as indirectly in making this project successful.
Lastly, I would like to thank my family and friends for providing immense
support, strength and motivation throughout the course of my project.
Minhas Thaker
vi
TABLE OF CONTENTS
Page
Acknowledgments.............................................................................................................. vi
List of tables ....................................................................................................................... ix
List of figures ...................................................................................................................... x
Chapter
1. INTRODUCTION .......................................................................................................... 1
1.1. Introduction to GPS Based Autonomous Navigation .............................................. 1
1.2. Purpose of the Project .............................................................................................. 1
1.3. Significance of the Project ....................................................................................... 2
1.4. Organization of the Report....................................................................................... 3
2. INTRODUCTION OF GPS ............................................................................................ 4
2.1. GPS Overview ......................................................................................................... 4
2.2. GPS Satellite Constellations .................................................................................... 6
2.3. GPS Working ........................................................................................................... 8
2.4. Reference Surfaces and the Geodetic Coordinate System ..................................... 11
2.5. NMEA Protocol ..................................................................................................... 14
3. WAYPOINT NAVIGATION ....................................................................................... 17
3.1. Introduction to Waypoint Navigation .................................................................... 17
3.2. GPS Noise .............................................................................................................. 17
3.3. EM408 Pin Configuration and Connection with ATmega328 .............................. 17
3.4. Analysis of GPS Readings ..................................................................................... 19
4. ATMEGA328 MICROCONTROLLER ....................................................................... 24
4.1. Introduction to Atmega328 .................................................................................... 24
vii
4.2. Approach ................................................................................................................ 25
4.3. Algorithm ............................................................................................................... 27
4.4. Computing Distance and Direction of Destination Point ...................................... 30
5. EXPERIMENTAL RESULTS...................................................................................... 33
5.1. Plotting the Waypoints on a Map........................................................................... 33
5.2. Plotting the Path Traversed By the Car.................................................................. 34
6. CONCLUSION ............................................................................................................. 36
Bibliography ..................................................................................................................... 37
viii
LIST OF TABLES
Page
1. Table 2.2.1 GPS satellite constellation ........................................................................... 7
2. Table 2.4.1 Reference systems and associated ellipsoids ............................................. 12
3. Table 2.5.1 General NMEA sentences .......................................................................... 15
4. Table 2.5.2 RMC sentence format ................................................................................ 16
5. Table 3.4.1 Tabulating mean and standard deviation for GPS readings ....................... 22
ix
LIST OF FIGURES
Page
1. Figure 2.1.1 GPS segments ............................................................................................. 6
2. Figure 2.3.1 Determining position of receiver by triangulation of three satellites ....... 10
3. Figure 2.4.1 Geodetic latitude and longitude ................................................................ 13
4. Figure 2.4.2 Geodetic height ......................................................................................... 14
5. Figure 3.3.1 EM408 GPS receiver ................................................................................ 18
6. Figure 3.3.2 Pin connection of ATmega328 with GPS receiver ................................... 19
7. Figure 3.4.1 Bar-plot of standard deviation for latitude and longitude readings .......... 21
8. Figure 3.4.2 Mappings Points A, B, C and D on Google Maps .................................... 21
9. Figure 3.4.3 Gaussian distribution of latitude and longitude readings ......................... 23
10. Figure 4.1.1 Pin diagram of ATmega328 DIP ............................................................ 24
11. Figure 4.1.2 Internal architecture of ATmega328 microcontroller ............................. 25
12. Figure 4.2.1 Car mounted with GPS receiver and microcontroller ............................. 26
13. Figure 4.3.1 Algorithm ................................................................................................ 29
14. Figure 4.4.1 Calculating deviation from actual course ............................................... 32
15. Figure 5.1.1 Plot of point A, B, C and D on a map ..................................................... 33
16. Figure 5.2.1 Plot of actual path vs. path traversed by the car ..................................... 35
x
1
Chapter 1
INTRODUCTION
1.1. Introduction to GPS Based Autonomous Navigation
Autonomous navigation broadly refers to any technique, approach or method,
which can be utilized to safely navigate a vehicle (terrestrial, marine, airborne or deep
space), on its own in a static or dynamic environment without any intervention by a
human controller. Autonomous navigation is a way to help achieve better route planning,
path prediction, smoother maneuverability in dynamic environments and thereby
achieving optimized fuel efficiency and enhanced human comfort. The approach of GPS
based autonomous navigation utilizes a GPS receiver that receives signals from a
constellation of GPS satellites. The receiver then computes its position on the earth
surface. A navigation algorithm then computes other parameters such as direction and
distances that aid in autonomous navigation.
1.2. Purpose of the Project
The purpose of the project is to develop an algorithm that takes in inputs from a
GPS receiver and using those inputs to successfully navigate a car through a set of known
points also known as waypoints. This type of navigation is also called terrestrial waypoint
navigation or in general, waypoint navigation [1]. Waypoint navigation is also used in
marine navigation which is also based on the same concept. The car described here is a
4WD dc-motor controlled robot car. In general it would be referred as a car, not to be
confused with a real passenger car. The overall process is divided into three parts. In the
first part, when the car is at the start waypoint the GPS receiver tries to get a fix on
2
visible GPS satellites and compute current latitude and longitude. In the second part, the
algorithm in the microcontroller computes the direction of the destination waypoint from
the current waypoint and drives the car. In the third step, the algorithm steers the car in
case it deviates from its main course. These steps repeat itself after reaching the
destination and navigates to next waypoint.
1.3. Significance of the Project
GPS based autonomous navigation is a very rapidly developing technology.
Researchers have developed several techniques for navigation under a variety of external
environments. Such techniques utilizes robots that have a variety of sensors to sense
external environment such as proximity sensors, ultrasound sensors, and a camera as
shown in [2]. This project utilizes a GPS receiver to help navigate through fixed
waypoints. Autonomous navigation was implemented in the mars exploration rover.
Therein they implemented features such as tracking ground features, terrain mapping and
obstacle avoidance, mentioned in [3]. Autonomous navigation also finds its application in
defense research.
This project focuses on researching a technique of terrestrial navigation as to
learn about GPS receivers, its signals, understanding how such data can help to navigate a
car, and then interface all components together. It will help in understanding general GPS
satellite system and standard GPS protocols. Developing such a technique is useful
towards researching new domains of navigation applications.
3
1.4. Organization of the Report
Chapter 2 focuses on basic introduction of GPS, its general understanding, GPS
satellite constellations, and standard GPS navigation. It describes how latitude and
longitude coordinates are computed by a GPS receiver. It also describes general geodetic
coordinate system and NMEA protocol, a standard for GPS receiver output messages.
Chapter 3 gives overview about the waypoint navigation, GPS receiver used in
the project, its configuration and wiring with ATmega328 microcontroller. It explains
how GPS coordinate readings were taken and statistically evaluated for precision
measurement.
Chapter 4 talks about the ATmega328 controller, design steps, and the algorithm
developed for navigation.
Chapter 5 describes the experimental result; it displays output results from the
GPS receiver and is plotted in a map showing waypoints. . A map of proposed path and
actual path are plotted and how to smooth out car steering control is discussed.
Chapter 6 focuses on the conclusion and future work
4
Chapter 2
INTRODUCTION OF GPS
2.1. GPS Overview
GPS, the Global Positioning System, is a constellation of satellites that provides a
user with an accurate position on the surface of the earth. This satellite based navigation
system was developed by the U.S. Department of Defense (DoD) in early 1970s. It was
first intended for military use but later it was made available to civilian users. GPS can
provide precise position and time information to a user anywhere in the world. It is a one
way system i.e. a user can only receive signals but cannot send signals to the satellite.
This type of configuration is needed due to security reasons as wells as to serve unlimited
number of users [1]. The GPS system consists of three main segments:
1. Space segment
2. Control segment
3. User segment
The space segment consists of a constellation of 24 satellites in fixed orbits
around the earth. Each satellite continuously transmits GPS signals to the earth, which
consist of two carrier frequencies, digital codes, and navigation message. The carrier
frequency and codes are used in determining distance of the satellite from the receiver.
The navigation message consists of information like satellite location and clock
compensation [1].
The control segment includes a network of tracking stations. These tracking
stations continuously monitor the satellite orbit; checks satellite clock, atmospheric
5
conditions, satellite almanac, provide necessary compensation for clock error, and upload
data to satellites. The OCS (Operational Control System) consists of one master control
station (MCS), several monitor stations, and ground control stations. The MCS is located
in the United States at Shriever Air Force Base, Colorado Springs, Colorado [1] [4].
The user segment consists of all civilian and military users. A GPS receiver can
lock on to any visible satellites and can determine its location on earth’s surface. GPS
system was first conceived for military usage such as navigating in remote terrains and
coordinating military activities. With addition of civilian access to GPS signals, it is used
in various applications such as surveying, mapping, hiking, and vehicular navigation [4].
Figure 2.1.1 shows the three segments of a GPS system. The GPS satellites transmit
signals at two carrier frequencies. One of them is called L1 carrier which generates
carrier frequencies at 1575.42 MHz, while the other is called L2 carrier which generates
frequencies at 1227.60 MHz [4]. The master control station uploads data to the satellites
via ground using frequencies in S-band (2 GHz to 4 GHz).
6
Figure 2.1.1 GPS segments [1]
2.2. GPS Satellite Constellations
At present (as of October 2010) there are total of 32 satellites orbiting around
earth in circular orbits [5]. The satellites are placed in six orbits labeled A to F, inclined
at 55◦ with respect to the equator and at a height of approximately 20,200 km [4].
Nominally there are 24 satellites in GPS constellation, thus having 4 satellites in each
orbit. Since there are more than 24 satellites, an orbit can contain more than 4 satellites.
The control sites are located at various places all over the globe to monitor and control
the path of satellites. The GPS satellites are categorized into six sequences of Block I, II,
IIA, IIR, II-M and IIF. Each satellite is identified by its unique SVN (Space Vehicle
7
Number) [1]. Table 2.2.1 shows the sequence number, SVN and the orbital plane of
current GPS satellites.
Orbital
Sequence
SVN
Orbital Plane
Sequence
SVN
Plane
II-10
23
E5
IIR-7
54
E4
II-11
24
D2-F
IIR-8
56
B1
II-14
26
F2-F
IIR-9
45
D3
II-15
27
A6
IIR-10
47
E2
II-21
39
A1
IIR-11
59
C3
II-23
34
D4
IIR-12
60
F4
II-24
36
C5
IIR-12
61
D1
II-25
33
C2
IIR-M-1
53
C4
II-26
40
E6
IIR-M-2
52
A2
II-27
30
B2-1
IIR-M-3
58
B4
II-28
38
A3
IIR-M-4
55
F2
IIR-2
43
F3
IIR-M-5
57
C1
IIR-3
46
D2
IIR-M-6
48
A4
IIR-4
51
E1
IIR-M-7
49
B1-F
IIR-5
44
B3
IIR-M-8
50
E3
IIR-6
41
F1
IIF-1
62
B2
Table 2.2.1 GPS satellite constellation [5]
8
2.3. GPS Working
When a GPS receiver locks on to a satellite it will perform three basic steps:
1. Measure distance from the satellite to the receiver.
2. Determine the position of the receiver by triangulation.
3. Synchronize GPS receiver clock to the satellite.
The GPS receiver will measure the time taken by a signal from a satellite to reach
the receiver. It is assumed that the receiver clock is synchronized with the satellite clock
at this time. The time is then multiplied with the velocity of light c, to get the distance
between the satellite and the receiver, shown in equation 2.3.1. Getting precise time
measurement is achieved by a method of pseudo random code. Pseudo random code is a
complex sequence of ‘on’, ‘off’ pulses. Each satellite has its own pseudo random code,
hence the receiver cannot accidently pick up signals from a different satellite and all
satellites can operate on the same frequency. The method works as follows. Both the
satellite and the receiver will start generating pseudo random code at the same time. The
satellite signal will carry this code in sequence as a part of the GPS signal. The receiver
then computes how late a particular pseudo code was received compared to the code
generated by it. This is how the GPS receiver determines the time taken by a signal to
travel from satellite to receiver [1].
9
d = c × t ……..…………………….……………………………………….. (2.3.1)
where d is distance of receiver from satellite,
c is velocity of light, 299792458 m/s,
t is the time taken for signal from satellite to reach receiver.
The receiver computes its distance (r1) from one satellite. With measurement from
one satellite, the receiver can be anywhere on a sphere with its center as a satellite and
radius r1 as shown in figure 2.3.1a. Further on, taking another distance measurement (r2)
from the second satellite, the receiver can be on the intersection of two spheres as shown
in figure 2.3.1b. On taking the third distance measurement (r3) from the third satellite, the
receiver precisely lies on two points, which are the intersection points of three spheres as
shown in figure 2.3.1c. One of the two points will lie out farther in space compared to the
other; hence the former can be rejected. The point left is the position of the receiver on
the earth surface [6].
For the above two steps it is assumed that the receiver clock is in synchronization
with the satellite clock. The satellite clocks are atomic clocks hence they are very precise,
but they also tend to give rise to timing errors. Control centers continuously monitor the
satellite clocks and send correcting signals from time to time. The satellite in turn sends
these corrections to the receiver as a part of its signal to synchronize the receiver clock
and correct the distance measured. Also, it is impossible to have a precise clock at the
receiver end and will give rise to receiver clock error. As a result, the spheres in figure 1c
would not intersect at one point. A fourth parameter dT (receiver clock error) has to be
included in the equation to calculate the distances. To solve four unknowns, four
10
equations are required; hence distance measurement from one more satellite is needed as
shown in equations 2.3.2 to 2.3.5 On solving this equation for X, Y, Z and dT,
coordinates of the receiver on the earth surface can be found [6].
Figure 2.3.1 Determining position of receiver by triangulation of three satellites [6]
11
r1=
( X − x1 ) 2 + (Y − y1 ) 2 + ( Z − z1 ) 2 − cdT ………..………....…………… (2.3.2)
r2=
( X − x2 ) 2 + (Y − y2 ) 2 + ( Z − z2 ) 2 − cdT .............................................(2.3.3)
r3=
( X − x3 ) 2 + (Y − y3 ) 2 + ( Z − z3 ) 2 − cdT ………….…………………… (2.3.4)
r4=
( X − x4 ) 2 + (Y − y4 ) 2 + ( Z − z4 ) 2 − cdT ………………………………. (2.3.5)
where r1,r2,r3,r4 are distances of receiver from satellite 1, 2, 3 and 4 respectively,
X,Y,Z are three dimensional Cartesian coordinates of receiver,
(x1,y1,z1), (x2,y2,z2), (x3,y3,z3) and (x4,y4,z4) are the coordinates of satellites
1,2,3 and 4 respectively, transmitted as part of GPS signal,
c is velocity of light, 299792458 m/s,
dT is the receiver clock error.
2.4. Reference Surfaces and the Geodetic Coordinate System
Earth’s topographic surface is highly uneven, which makes accurate
measurements of geodetic data highly error prone. Geodesists have formulated two
reference systems that approximate the surface of the earth. These are called Geoid and
Ellipsoid. A Geoid is a surface at mean sea-level used to represent height on a map. An
ellipsoid is a mathematical approximation of earth surface. WGS-84, NAD 83 and GRS
80 are some common reference ellipsoid used [1] [7]. WGS-84 is an acronym of World
Geodetic System of 1984. It is a reference ellipsoid used by the U.S. Department of
Defense. The National Geospatial Intelligence Agency maintains and constantly enhances
the WGS-84 reference standard. NAD 83 which stands for North American Datum for
12
1983 is another reference ellipsoid used mainly in North America. It is based on the
ellipsoid of Geocentric Reference System of 1980 (GRS 80). Table 2.4.1 shows the
common reference system used and the ellipsoid values.
Reference System
Ellipsoid
a(m)
1/f
WGS 84
WGS 84
6378137.0
298.257223563
NAD 83
GRS 80
6378137.0
298.257222101
NAD 27
Clarke 1866
6378206.4
294.9786982
Table 2.4.1 Reference systems and associated ellipsoids [1]
Geodetic Coordinate system is a three dimensional coordinate system in which a
point on earth’s surface is represented by three quantities latitude (ϕ), longitude (λ) and
geodetic height (h). The coordinate system has three axis, the z axis coincides with
rotational axis of the ellipsoid, x and y axis lie on the equatorial plane. Latitude of a point
is defined as an angle between the normal drawn at the ellipsoid and the equatorial plane.
Longitude of a point is the angle between the Prime Meridian which passes through
Greenwich and the meridian ellipse that contains the point. Geodetic height is the
distance between the point on the earth surface and the point on the ellipsoid along the
line perpendicular to the ellipsoid [1] [7].
As shown in figure 2.4.1, consider a point P on the surface of the earth. The earth
surface is approximated as an ellipsoid. Point P’ is a point on the ellipsoid exactly below
point P. A normal to the ellipsoid is drawn from point P and intersects the equatorial
plane. The angle made by the normal to the plane is the latitude (ϕ) of the point. The
meridian, at point P, makes an angle (λ) with the Greenwich meridian on the equatorial
13
plane. This angle is the latitude of point P. Now considering figure 2.4.2, the distance
between point P and P’ gives the geodetic height of the point.
There are also other coordinate systems to determine location of a point on earth’s
surface. A coordinate system can be converted to other using mathematical equations.
These coordinates can also be projected on a map using various projection techniques [7].
Figure 2.4.1 Geodetic latitude and longitude [7]
14
Figure 2.4.2 Geodetic height [8]
2.5. NMEA Protocol
National Marine Electronics Association is a group of electronics dealers, which
has standardized an interface protocol for electrical signaling and data transmission in
marine electronic equipments. This project uses NMEA 0183 format of GPS receiver
output. A common GPS receiver outputs data streams based on NMEA 0183 format.
Each NMEA sentence starts with a “$” sign and ends with a carriage return-line feed
<CR><LF>. The “$” is followed by a five character address field (e.g. $GPRMC), of
which the first two characters define the talker and the last three determine NMEA
sentence. There are 8 basic types of NMEA output messages or sentences [9]. Table 2.5.1
shows some general NMEA sentences.
15
NMEA
sentence
Description
GGA
GPS fixed data
GLL
Geographic position - Latitude/Longitude
GSA
GNSS DOP and active satellites
GSV
GNSS satellites in view
MSS
MSK receiver signal
RMC
Recommended minimum specific GNSS data
VTG
Course over ground and ground speed
ZDA
SiRF timing message
Table 2.5.1 General NMEA sentences [9]
16
This project utilizes RMC NMEA sentence. Table 2.5.2 shows detailed
description of the RMC sentence.
Name
Example
Message ID
$GPRMC
RMC protocol header
UTC time
161229.487
hhmmss.sss
Status
A
Latitude
3723.2475
ddmm.mmmm
N/S indicator
N
N= north or S = south
Longitude
12158.3416
ddmm.mmmm
E/W indicator
E
E = east or W = west
Speed over ground
0.13
Knots
309.62
Degrees
Course over
ground
Date
V = not valid data
A
Checksum
*10
True
Ddmmyy
Degrees
Mode
Description
A = valid data
120509
Magnetic Variation
<CR><LF>
Units
E = east or W = west
A=autonomous, D=DGPS,
E=DR
End of message termination
Table 2.5.2 RMC sentence format [9]
17
Chapter 3
WAYPOINT NAVIGATION
3.1. Introduction to Waypoint Navigation
A waypoint in general is a coordinate that identifies a point in 3-dimensional
space. For terrestrial application it is generally defined using latitude and longitude
coordinates. For aviation applications it is defined using latitude, longitude and altitude.
Waypoint navigation is a technique by which a user can navigate from one waypoint to
another. Generally, a GPS receiver is used to compute the direction of destination
waypoint from current position and help navigate the user. Waypoint navigation is
generally used by surveyors to layout points and lines and mariners to navigate in open
sea [1] [10].
3.2. GPS Noise
The GPS signal is constantly affected with errors and noise. These errors and
noise can affect the computed coordinates by the GPS receiver. Noise and error signal
can creep into the GPS signal at any level starting from the satellite to the receiver.
Ionosphere and Troposphere refraction at signal propagation level, and clock bias and
multipath at the receiver level account for major error in GPS data [4].
3.3. EM408 Pin Configuration and Connection with ATmega328
This project utilizes EM408 receivers manufactured by GlobalSat Technology
Corporation. Figure 3.3.1 shows the EM408 receiver. EM408 GPS engine board is a
SiRF Star III chipset based receiver, supports WAAS, EGNOS and MSAS augmentation,
features an integrated patch antenna and supports NMEA 0183 data protocol.
18
Pin explanation:
1. Enable/Disable: On/Off.
2. VCC: 3.3 DC supply
3. TX: Transmit channel output.
4. RX: Receive channel input for receiving software commands.
5. GND: Provides ground to the engine board.
Figure 3.3.2 shows connection of GPS receiver to ATmega328 board. Enable, RX
and TX pins were connected to ATmega328 pins 2, 3 and 4 respectively. GND and VCC
pins were connected to GND and VCC (3.3) pins of ATmega328.
Figure 3.3.1 EM408 GPS receiver
19
Figure 3.3.2 Pin connection of ATmega328 with GPS receiver
3.4. Analysis of GPS Readings
Several GPS readings were taken at point A, B, C and D, located in the facultystaff parking lot, at an interval of one hour. Thereafter, mean and standard deviation were
computed to determine precision of GPS readings. The results obtained are shown in
table 3.4.1. A bar graph showing standard deviation in meters is shown in figure 3.4.1.
Mean latitude and longitude coordinates of points A, B, C and D are plotted on a map as
20
shown in figure 3.4.2. Gaussian response of latitude and longitudes readings for all points
is shown in figure 3.4.3, using the mean and standard deviation from table 3.4.1.
The latitude and longitude readings were fairly precise with a standard deviation
ranging from 0.92 meter to 2.26 meters. For latitude readings, Point B had the lowest
standard deviation while point D had the highest standard deviation. For longitude
readings, Point C had the lowest standard deviation while point A had the highest
standard deviation. Overall longitude readings showed less deviation compared to
latitude readings. Equation 3.4.1 was used for converting standard deviation in degrees to
standard deviation in meter.
1'' of φd = 30 m
1'' of λd = 30*cos (φ ) m
……………………...……………………………… (3.4.1)
where ϕd is latitude standard deviation,
λd is longitude standard deviation,
ϕ is mean latitude for the point,
21
Figure 3.4.1 Bar-plot of standard deviation for latitude and longitude readings
Figure 3.4.2 Mappings Points A, B, C and D on Google Maps
22
Latitude(ϕ)
Longitude(λ)
Mean
38.5603182128
-121.4210546807
Standard Deviation (deg)
0.0000104313
0.0000158458
Standard Deviation (m)
1.1265828691
1.3381948275
Mean
38.5603597584
-121.4208304601
Standard Deviation (deg)
0.0000085694
0.0000140004
Standard Deviation (m)
0.9254949024
1.1823422272
Mean
38.5607323646
-121.4210119247
Standard Deviation (deg)
0.0000125592
0.0000125281
Standard Deviation (m)
1.3563896801
1.0580017803
Mean
38.5606722938
-121.4211874816
Standard Deviation (deg)
0.0000210007
0.0000154879
Standard Deviation (m)
2.2680759935
1.3079614379
Point A
Point B
Point C
Point D
Table 3.4.1 Tabulating mean and standard deviation for GPS readings
23
Figure 3.4.3 Gaussian distribution of latitude and longitude readings
24
Chapter 4
ATMEGA328 MICROCONTROLLER
4.1. Introduction to Atmega328
Atmega328 is a high performace, low power, 8-bit CMOS microcontroller,
manufactured by Atmel. It is based on modified Harvard AVR RISC architecture. It
features 32K bytes of Flash, 1K bytes of EEPROM, and 2K bytes of RAM memory. It
also has an optional boot code section where in a bootloader program can be loaded.
Hence the feature of in-system programming can also be attained. Atmega328 is
generally programmed through AVR studio. AVR studio is the Integrated Deeopment
Environemt (IDE) for Atmel microcontrollers [11]. Figure 4.1.1 shows the pin diagram of
ATmega328 microcontroller. The AVR RISC architecture is shown in figure 4.1.2.
Figure 4.1.1 Pin diagram of ATmega328 DIP [11]
25
Figure 4.1.2 Internal architecture of ATmega328 microcontroller [11]
4.2. Approach
Point A, B, C and D were the waypoints and the car had to navigate from point A
to point D, passing through point B and C. The car must maintain its couse of travel
while navigating through waypoints. An algorithm was developed to constantly compute
the car’s direction of travel to true direction of travel. For any deviation in the difference
26
between the above two for more than certain allowable limit would steer the car
appropriately compensating for the deviation.
Figure 4.2.1 Car mounted with GPS receiver and microcontroller
27
Figure 4.2.1 shows the car used in this project which was mounted with GPS
receiver, ATmega328 board, and related circuitry of H-bridge motor controller with
separate power supply for the motors and the board. The car was 4-wheel-drive; hence an
appropriate differential drive mechanism was used to move the car forward, backward,
left and right. The GPS receiver constantly supplied GPS coordinates, course and speed
data to the board. The board computed the direction of travel, i.e. weather to go forward,
take left or right and provided appropriate signals as input to the H-bridge motor
controller. The motor controller in turn drove the motors. The combination of direction of
rotation of motors drove the motor forward, backward, left or right.
4.3. Algorithm
The project implemented feature of waypoint navigation, using GPS coordinate
readings to continuously compute its current direction, distance from the waypoint and
true direction. From time to time it corrected itself from any deviation from true
direction. Below mentioned are the basic steps implemented for the project. Figure 4.3.1
shows the algorithm.
1. Collect coordinates readings of all waypoints from the GPS receiver
2. Store the coordinates of waypoints into memory (of controller or GPS receiver)
3. Collect coordinates of current position
4. Compute the distance and direction of the next waypoint
5. Start navigating in the set direction
6. Steer car in case it deviates from its course
7. Repeat steps iii to vi until all waypoints are reached
28
In step (i), points A, B, C and D were first decided and multiple readings of
latitude and longitude were recorded. The mean of those readings were then used as fixed
waypoints for the project. The mean latitude and longitude readings are tabulated in table
3.4.1 and are mentioned here. Point A: 38.5603182128, -121.4210546807, Point B:
38.5603597584,-121.4208304601, Point C: 38.5607323646, -121.4210119247, Point D:
38.5606722938, -121.4211874816. These coordinate points were stored in program
structure. Whenever a particular waypoint was achieved, next coordinate point was
loaded into main program.
The car was kept a little further away from point A. The GPS receiver took 30-40
seconds which is its cold start time to get first readings of the car’s current location. The
reason to keep car away from point A was to determine whether the start point A was
successfully reached by the car when kept randomly anywhere on the track.
Step (iv) is explained in detail in section 4.5. This part of the algorithm
determines the distance and direction of next waypoint. Step (v) is driving motors straight
or steer left or right based on the computer direction. Whenever the car reached the
waypoint in vicinity of 1m, it would consider that particular waypoint had been achieved
and move on to next waypoint. As our GPS coordinates showed a precision standard
deviation of around 1m, it was decided to consider all points a distance of 1m from
waypoint as the waypoint itself.
29
Figure 4.3.1 Algorithm
30
4.4. Computing Distance and Direction of Destination Point
This project assumed a spherical model of earth surface. As the trajectory for
navigation was limited to few hundreds of meters only, there was a very less chance of a
positional error. Equation 4.4.1 gave the distance between two coordinates (ϕ1, λ1) and
(ϕ2 ,λ2) in meters. Here R is radius of the earth, which was assumed to be constant as the
spherical model of earth surface was under consideration. Also, it is assumed that the
positional accuracy of a waypoint achieved would be equal to or less than 1 meter.
Hence, if the car reached anywhere in 1 meter radius circle, it was assumed that the
waypoint was achieved.
d = R.cos −1 (sin φ1.sin φ2 + cos φ1.cos φ2 .cos(λ2 − λ1 )) ……….………..…… (4.4.1)
where d = distance between two points
R = radius of earth 6371000 m
Equation 4.4.2 gave the direction of next waypoint at coordinate (ϕ2 ,λ2) from
current position (ϕ1, λ1). This equation gave the direction in range from –π to +π, with 0
degrees set in north direction.
31
θ=
atan2 ( sin ( ∆λ ) .cos (φ 2 ) , cos (φ1) .sin (φ 2 ) − sin (φ1) .cos (φ 2 ) .cos ( ∆λ ) ) (4.4.2)
x>0

 y
arctan  x 
 

y ≥ 0, x < 0

 y
π + arctan  
x


 y  y < 0, x < 0

…………….………..……… (4.4.3)
atan2( y, x) = −π + arctan  x 

y > 0, x =
0
π
2
 π
y < 0, x =
0
−
 2
undefined
y 0,=
x 0
=
The GPS receiver computed fresh latitude, longitude, course and speed readings
at a rate of 1 sec. Hence the values of direction and angle θ were constantly updated. Due
to uneven track surface and constantly changing GPS readings, often the car would tend
to deviate from its set course towards destination waypoint. The algorithm measured such
deviation and if that deviation were to go above or below +45 and -45 respectively, the
car was made to take a 45 degree left or a right. The deviation was measured as the
numeric difference of angle θ and the course of travel obtained from GPS receiver. The
algorithm also updated the deviation with new values of θ and course. Figure 4.4.1
illustrates the scenario.
A log file of all latitude, longitude, course and speed readings of GPS receiver
was maintained, in addition to logging the distance and deviation computed by the
controller. The latitude, longitude readings were extracted from the file and were used to
plot a map as described in section 5.1 and 5.2.
32
Figure 4.4.1 Calculating deviation from actual course
33
Chapter 5
EXPERIMENTAL RESULTS
5.1. Plotting the Waypoints on a Map
The mean values of latitude and longitudes coordinates shown in table 3.4.1 are
plotted on a map, shown in figure 5.1.1. The average distance between point A and point
B is 20 m, between point B and point C is 44 m and between point C and point D is 17 m.
Considering the precise GPS readings, such distance between the points does not
generate any errors in navigation.
Figure 5.1.1 Plot of point A, B, C and D on a map
34
5.2. Plotting the Path Traversed By the Car
The actual path traversed in comparison to actual path, by the car is shown in
figure 5.2.1. Initially, the car takes 2 turns around point A in order to lock on first
waypoint. Thereafter it sets off towards point B, its course of direction is not exactly in
line with the direction of point B. The algorithm detects as the deviation moves beyond
45 degrees and then turns car to right. This continues till car is on its set course and
finally reaches in 1 meter vicinity of point B. At point B again it takes whole 360 degree
turn to lock point B and head towards point C. The car sets in direction of point C,
intermediately corrected for its course and reaches point C. Again the car takes 360
degree turn and heads towards point D. Point D is the last waypoint, hence the car stops
on reaching in vicinity of point D. Thus, the car successfully navigates from point A to
point D, via points B and C.
35
Figure 5.2.1 Plot of actual path vs. path traversed by the car
36
Chapter 6
CONCLUSION
It was observed that at any time, a current course reading would be largely
different from the previous reading. Hence the path traversed by the car is not smooth.
There are other factors such as uneven surface that affects the traversed path. Distance
between point B and point C is fairly greater compared to other distances. It can be seen
that the car navigates smoothly on path from point B to C compared to path between
points A to B and C to D. This response can be smoothed by filtering the GPS data
received or by getting augmented GPS coordinates. Certain filters like Kalman filters are
used in robotics to smooth out the movement of the car. Secondly use of GPS
augmentation methods like DPGS or WAAS can also help improve the actual response.
37
BIBLIOGRAPHY
[1] A. El-Rabbany, “Introduction to GPS: the Global Positioning System”, 2nd ed.,
Boston, MA, Artech House, 2006.
[2] M. Betke and L. Gurvits, “Mobile Robot Localization Using Landmarks,” 1994 IEEE
Proc. on International Conference of Robotics and Automation, Volume 1, Munich,
1994, pp. 135-142.
[3] M. Maimone, A. Johnson, Y. Cheng, R. Willson, and L. Matthies, “Autonomous
Navigation Results from the Mars Exploration Rover (MER) Mission", 9th
International Symposium on Experimental Robotics, Singapore, 2004, pp. 3-13.
[4] B. Hofmann-Wellenhof, H. Lichtenegger, and J. Collins, “Global Positioning System,
theory and practice”, 5th ed., New York, Sprincer-Verlag, 2001.
[5] R.
Langley,
“Navstar
GPS
Constellation
Status”
[Online].
Available:
http://gge.unb.ca/Resources/GPSConstellationStatus.txt
[6] R. Langley, “The Mathematics of GPS”, GPS World, vol. 2, no. 7, July/August1991.
[7] R. Knippers, “Geometric Aspects of Mapping”, educational notes, International
Institute for Geo-Information Science and Earth Observation (ITC), Enschede,
August 2009.
[8] R. Foster, “Basic Geodesy”, National Geospatial-Intelligence Agency, May 2005.
[9] SiRF Technology Inc., “NMEA Referene Manual”, rev. 1.3, January 2005.
[10] T. Davison, “Navigation Companion”, John Wiley & Sons, 2007.
[11] Atmel Corporation, “ATmega48A/48PA/88A/168A/328/328P Summary”, rev. C,
August 2010.
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising