final graduadtion book( autonomous car)
TRANSCRIPT
Alexandria University
Faculty of Engineering
Communication and Electronics Department
B. Eng. Final Year Project
Sensor based Autonomous car By:
Mennatallah Hany Hosny
Nancy Mohamed Abdou
Nagwan fawzyHassan
Nada Ashraf Megahed
Nermeen Mohamed Rmdan
Nehal Salah El-kony
Nourhan Abdelnaser Farrag
Supervised by:
Dr. Mohammed Morsy Farag
I
ACKNOWLEDGMENT
First and foremost, we thank Allah Almighty who paved path for us, in
achieving the desired goal.
We would like to express our sincere gratitude to our mentor
Dr. Mohammed Morsy Farag for the continuous support of our studies
and research, for his patience, motivation, enthusiasm, and immense
knowledge.
His guidance helped us in all the time for achieving the goals of our
graduation project.
We could not have imagined having a better advisor and mentor for our
graduation project.
Our thanks and appreciations also go to our colleagues in developing the
project and people who have willingly helped us out with their abilities.
Finally, an honorable mention goes to our parents, brothers, sisters and
families. Words cannot express how grateful we are. Your prayer for us
was what sustained us thus far. Without helps of the particular that
mentioned above, we would face many difficulties while doing this.
II
ABSTRACT
Whether you call them self-driving, driverless, automated, or autonomous, these
vehicles are on the move. Recent announcements by Google (which drove over
500,000 miles on its original prototype vehicles) and other major automakers indicate
the potential for development in this area. Driverless cars are often discussed as
“disruptive technology” with the ability to transform transportation infrastructure,
expand access, and deliver benefits to a variety of users. Some observers estimate
limited availability of driverless cars by 2020 with wide availability to the public by
2040.
The following sections describe the development and implementation of an
autonomous car model with some features. It provides a history of autonomous cars
and describes the entire development process of such cars.
The development of our prototype was completed through the use of two controllers;
Raspberry pi and Arduino.
The main parts of our model include the Raspberry pi, Arduino controller board,
motors, Ultrasonic sensors, Infrared sensors, optical encoder, X-bee module, and
lithium-ion batteries.
It also describes speed control of the car motion by the means of a process known as
PID tuning to make correct adjustments to the behavior of the vehicle.
III
Table of content 1. Introduction………………………………………………........ 1
1.1 History…………………………………………………….... 2
1.2 Why autonomous car is important…………………………. 4
1.2.1 Benefits of self-driving cars………………………….. 4
1.3 What are autonomous and automated vehicles…………….. 5
1.4 Advanced driver assistance system………………………… 7
1.5 Project description …………………………………………. 7
1.5.1 Auto parking………………………………………..… 7
1.5.2 Adaptive cruise control……………………………….. 7
1.5.3 Lane keeping………………………………………….. 8
1.5.4 Lane departure……………………………………….... 8
1.5.5 Indoor positioning system…………………………….. 8
1.5.6 Connected car…………………………………………… 8
1.6 Related work…………………………………………………. 9
2.Car Design……………………………………………… 12
2.1 First car design……………………………………………….. 13
2.1.1 Four WD robot ………………………………………… 13
2.1.1.1 specifications ………………………………….. 13
2.1.1.2 Real shots ……………………………………… 14
2.1.1.3 Drawbacks ……………………………………... 14
2.1.1.4 Overcoming Drawbacks ………………………. 14
2.1.2 Second trial …………………………………………….. 14
2.1.2.1 specifications ………………………………….... 15
2.1.2.2 Real shots ……………………………………….. 16
2.1.2.3 Drawbacks ……………………………………… 17
2.1.2.4 Overcoming Drawbacks …………………………17
2.1.3 Final design ……………………………………………...17
2.1.3.1 Body ……………………………………………...17
2.1.3.2 Side covers ……………………………………….18
2.1.3.3 Front and back covers …………………………….19
2.1.3.4 Cover ………………………………………………20
2.1.3.5 Real shots ………………………………………….20
2.1.3.6 Drawbacks ……………………………………… 20
2.2 Car wheel drive ………………………………………………………21
2.2.1 Types of wheel drive …………………………………………...21
2.2.2 Advantages of this configurations ……………………………...21
IV
2.3 Car steering …………………………………………………………….22
2.3.1 Basic geometry …………………………………………………...22
2.3.2 Our mechanism …………………………………………………...22
2.3.3 Servo motor modifications ………………………………………...23
2.4 Second car design ……………………………………………………….24
2.4.1 Final design ……………………………………………………….24
2.4.2 Real shots ………………………………………………………….24
2.5 Motors ……………………………………………………………………24
2.5.1 DC motor ………………………………………………………….25
2.5.1.1 DC motor fundamentals …………………………………..25
2.5.1.2 DC motor principle ……………………………………….25
2.5.1.3 Controlling DC motor …………………………………….26
2.5.2 Servo motor……………………………………………………….. 28
2.5.2.1 Servo motor features ……………………………………….28
2.5.2.2 Servo motor mechanism ……………………………………29
2.5.2.3 Inside Servo motor ………………………………………….30
2.5.2.4 Servo motor with Arduino …………………………………..31
3 Microcontrollers and Hardware ………………………………... 33
3.1 Microcontrollers ………………………………………………………… 34
3.1.1 Arduino ……………………………………………………………. 34
3.1.1.1 Introduction ………………………………………………... 34
3.1.1.2 Arduino Mega ……………………………………………... 36
3.1.2 Raspberry pi ……………………………………………………….. 39
3.1.2.1 Design ……………………………………………………… 39
3.1.2.2 ARM 1176 processor ……………………………………… 39
3.1.2.3 Features …………………………………………………….. 40
3.1.2.4 Performance ………………………………………………… 40
3.1.2.5 Function supported in Hardware ……………………………. 40
3.1.2.6 Comparison ………………………………………………….. 41
3.2 Hardware …………………………………………………………………… 42
3.2.1 Ultrasonic sensor ……………………………………………………. 42
3.2.1.1 Introduction ……………………………………………………42
3.2.1.2 Features ………………………………………………………...42
3.2.1.3 Connection with Arduino ………………………………………43
3.2.1.4 Connection with raspberry pi …………………………………43
3.2.2 Infrared tracking sensor ………………………………………………..44
3.2.2.1 Introduction …………………………………………………….44
3.2.2.2 Theory of operation ……………………………………………44
3.2.2.3 Features and pins ……………………………………………….45
V
3.2.2.4 Arduino connection …………………………………………..46
3.2.3 Optical encoder ……………………………………………………….46
3.2.3.1 Introduction …………………………………………………..46
3.2.3.2 Specifications ………………………………………………….47
4 Adaptive cruise control 48
4.1 Definitions………………………………………………………………….. 49
4.2 Introduction ………………………………………………………………….49
4.3 Applications ………………………………………………………………….50
4.3.1 Theory of operations ……………………………………………………50
4.3.2 Sensor options …………………………………………………………..50
4.3.2.1 LIDAR …………………………………………………………..51
4.3.2.2 RADAR ………………………………………………………….51
4.3.2.3 Fusion sensor …………………………………………………….51
4.3.2.4 Ultrasonic sensor ………………………………………………..52
4.4 Algorithm ……………………………………………………………………..53
4.5 Implementation and testing …………………………………………………..54
4.5.1 Steps ……………………………………………………………………..54
4.6 Designing a control system …………………………………………………...55
4.6.1 Design in real systems …………………………………………………..55
4.6.2 Design in our system …………………………………………………….55
4.6.3 Controllers ……………………………………………………………….55
4.6.3.1 P controller ……………………………………………………...55
4.6.3.2 PI Controller ……………………………………………………..56
4.6.3.3 PD Controller …………………………………………………....57
4.6.3.4 PID controller ……………………………………………………57
4.6.4 Definitions of terminologies …………………………………………….60
4.6.5 Distance-speed PID ……………………………………………….61
4.6.6 Speed PID ………………………………………………………….62
4.7 Application in real car …………………………………………………………67
5 Lane keeping …………………………………………………………..68
5.1 Introduction ……………………………………………………………………69
5.2 History …………………………………………………………………………69
5.3 Timeline of available systems …………………………………………………69
5.4 Application in real Car …………………………………………………….......71
5.5 Limitations of Lane keeping system …………………………………………..72
5.6 Prototyping of lane keeping …………………………………………………..72
5.6.1 Basic components ………………………………………………………..72
VI
5.6.2 Algorithm ……………………………………………………………….72
5.6.3 Implementation and testing ……………………………………………..73
5.6.4 Limitations of implemented model …………………………………….77
5.7 Conclusion …………………………………………………………………….77
6 Lane departure ………………………………………………………..78 6.1 Definition ………………………………………………………………….......79
6.2 Introduction …………………………………………………………………...80
6.3 Basic components ……………………………………………………………...80
6.4 Implementation ………………………………………………………………..80
6.5 Algorithm ……………………………………………………………………...81
6.5.1 Concept ………………………………………………………………….81
6.5.2 Algorithm ……………………………………………………………….82
6.6 Application in real car …………………………………………………………82
7 Integrating function …………………………………………………...83
7.1 Algorithm ……………………………………………………………………...84
7.2 Implementation ………………………………………………………………..86
8 Auto parking …………………………………………………………87
8.1 Definitions …………………………………………………………………..88
8.2 Introduction ………………………………………………………………….88
8.3 Application …………………………………………………………………..88
8.4 Hardware …………………………………………………………………….89
8.5 Parking types ………………………………………………………………..103
8.6 Parallel parking ………………………………………………………………104
8.6.1 Parallel parking steps …………………………………………………..104
8.6.2 Algorithm ………………………………………………………………107
8.7 Perpendicular parking ………………………………………………………..108
8.7.1 Steps ……………………………………………………………………108
8.7.2 Perpendicular parking Algorithm ………………………………………108
8.8 Tuning methods ………………………………………………………………109
9 Indoor positioning system ………………………………………....110
9.1 Introduction ………………………………………………………………..111
9.2 Indoor positioning Algorithm ……………………………………………..113
9.2.1 Angle of arrival ………………………………………………………113
9.2.2 Time of arrival ……………………………………………………….114
9.2.3 Time difference of arrival ……………………………………………114
VII
9.2.4 Received signal strength …………………………………………….115
9.2.4.1 Log distance path loss model ………………………………..116
9.3 Available positioning systems …………………………………………….116
9.3.1 Infrared base system …………………………………………………116
9.3.2 Ultrasound base system ……………………………………………...118
9.3.2.1 Ultrasound system application ………………………………118
9.3.3 Ultra-wide band ……………………………………………………...119
9.3.4 Appling radio frequency based system ………………………………119
9.3.4.1 Indoor positioning system using RFID ……………………… 120
9.3.4.2 Indoor positioning system using ZigBee ……………………. 122
10 Connected Car ……………………………………………………. 124
10.1 Definition ……………………………………………………………….. 125
10.2 Function Description ……………………………………………………. 125
10.3 Implementation tools ……………………………………………………. 126
10.3.1 Arduino Yun ……………………………………………………... 126
10.3.2 Web-cam …………………………………………………………. 126
10.4 Steps of implementation………………………………………………….. 127
10.5 Results ……………………………………………………………………. 128
11 Conclusion …………………………………………………………. 129
12 References ………………………………………………………….. 131
VIII
List of Figures Figure 1-1 Google car (Page 9)
Figure 1-2 Progression of automated vehicle technologies (Page 10)
Figure 2-1 Four WD robot (Page 14)
Figure 2-2 Four WD real shot (Page 14)
Figure 2-3 Second design trial AutoCad design. (Page 15)
Figure 2-4 Second car trial real shots. (Page 16)
Figure 2-5 Second car trial connection. (Page 17)
Figure 2-6 Final car design. (Page 17)
Figure 2-7 Final car side covers. (Page 18)
Figure 2-8 Final car front and back covers. (Page 19)
Figure 2-9 Final car cover. (Page 20)
Figure 2-10 Final car real shots. (Page 20)
Figure 2-11 Types of wheel drive. (Page 21)
Figure 2-12 Final car inside view. (Page 21)
Figure 2-13 Final car center of turning circle. (Page 22)
Figure 2-14 Old car design servomotor mechanism. (Page 23)
Figure 2-15 Last car design servomotor. (Page 23)
Figure 2-16 Second car real shots. (Page 24)
Figure 2-17 DC motor theory. (Page 25)
Figure 2-18 Dual H-bridge. (Page 26)
Figure 2-19 Second car motors connection. (Page 27)
Figure 2-20 First car motor connection. (Page 28)
Figure 2-21 Servo motor mechanism. (Page 29)
Figure 2-22 Inside servo motor diagram. (Page 30)
Figure 2-23 Inside servo motor real shot. (Page 31)
Figure 2-24 Connection of servo motor with Arduino. (Page 32)
Figure 3-1 Arduino types. (Page 36)
Figure 3-2 Arduino mega. (Page 36)
IX
Figure 3-3 Rpi memory management. (Page 39)
Figure 3-4 Ultrasonic sensor. (Page 42)
Figure 3-5 Ultrasonic sensor connection with Arduino. (Page 43)
Figure 3-6 Ultrasonic sensor connection with Rpi. (Page 43)
Figure 3-7 Infrared sensor. (Page 44)
Figure 3-8 Infrared sensor pins. (Page 45)
Figure 3-9 IR sensor connection with Arduino. (Page 46)
Figure 3-10 Optical Encoder. (Page 46)
Figure 4-1 Adaptive cruise control in real cars. (Page 50)
Figure 4-2 Operation of LIDAR. (Page 51)
Figure 4-3 Operation of fusion sensor. (Page 52)
Figure 4-4 Operation of ultrasonic sensor. (Page 52)
Figure 4-5 Feedback control system. (Page 53)
Figure 4-6 PID theory. (Page 59)
Figure 4-7 Graph showing PID definition of terminologies. (Page 60)
Figure 4-8 Graph showing dead time. (Page 61)
Figure 4-9 On and off switching method of motor. (Page 63)
Figure 4-10 Unit-step response of a plant. (Page 63)
Figure 4-11 S-shaped response curve. (Page 64)
Figure 4-12 Closed-loop system with a proportional controller. (Page 65)
Figure 4-13 Sustained oscillation with period Pcr. (Page 65)
Figure 4-14 step response of motor. (Page 66)
Figure 4-15 step response with tangent. (Page 66)
Figure 4-16 system performance. (Page 67)
Figure 5-1 Lane-keeping system structure. (Page 71)
Figure 5-2 Lane-keeping flowchart. (Page 73)
Figure 5-3 Showing first car design length. (Page 74)
Figure 5-4 First track material. (Page 74)
Figure 5-5 Final track path and material. (Page 75)
X
Figure 5-6 Final car design length. (Page 76)
Figure 5-7 New connection of Dual H-bridge. (Page 76)
Figure 6-1 Lane departure flow chart. (Page 82)
Figure 7-1 Lane keeping and Lane departure flag. (Page 84)
Figure 7-2 Merging flow chart. (Page 85)
Figure 8-1 H-bridge used with auto parking. (Page 89)
Figure 8-2 Male to male jumpers. (Page 89)
Figure 8-3 Raspberry pi. (Page 89)
Figure 8-4 Second car DC motor. (Page 89)
Figure 8-5 Ultrasonic sensor of second car. (Page 90)
Figure 8-6 Battery holder and batteries. (Page 90)
Figure 8-7 Resistance in second car connection (Page 90)
Figure 8-8 Mini breadboard. (Page 90)
Figure 8-9 Second car DC motor connection. (Page 91)
Figure 8-10 Raspberry pi GPIO. (Page 93 )
Figure 8-11 PWM. (Page 94)
Figure 8-12 Voltage divider circuit. (Page 96)
Figure 8-13 Ultrasonic sensor connection with Rpi. (Page 97)
Figure 8-14 Ultrasonic sensor pins. (Page 98)
Figure 8-15 Ultrasonic real shot connection with Rpi. (Page 98)
Figure 8-16 Second car final shot. (Page 101)
Figure 8-17 Testing ultrasonic code. (Page 102)
Figure 8-18 Parallel parking. (Page 103)
Figure 8-19 Perpendicular parking. (Page 103)
Figure 8-20 Angle parking. (Page 104)
Figure 8-21 Finding parking area. (Page 104)
Figure 8-22 Step 1 for parallel parking. (Page 105)
Figure 8-23 Step 2 for parallel parking. (Page 105)
Figure 8-24 Rest of step 2 for parallel parking. (Page 105)
XI
Figure 8-25 Step 3 for parallel parking. (Page 106)
Figure 8-26 Step 4 for parallel parking. (Page 106)
Figure 8-27 Parallel parking detect space state diagram. (Page 107)
Figure 8-28 Parallel parking state diagram. (Page 107)
Figure 8-29 Perpendicular parking state diagram. (Page 108)
Figure 8-30 Car moving forward for enough space. (Page 109)
Figure 8-31 Sensing perpendicular parking area dimensions. (Page 109)
Figure 9-1 Positioning Satellite in the orbit. (Page 111)
Figure 9-2 Localization systems. (Page 112)
Figure 9-3 Triangulation. (Page 113)
Figure 9-4 An antenna array. (Page 113)
Figure 9-5 The length of the arrows corresponds to the arrival time at receiver P. (Page 114)
Figure 9-6 Positioning based on TDOA measurements. (Page 114)
Figure 9-7 Position measuring. (Page 116)
Figure 9-8 Positioning systems. (Page 116)
Figure 9-9 Infrared base system positioning (Page 117)
Figure 9-10 Ultrasound system application. (Page 118)
Figure 9-11 RFID. (Page 120)
Figure 9-12 RFID reader. (Page 121 )
Figure 9-13 Arduino yun. (Page 121)
Figure 9-14 Layout of the 3 by 3 Grid RFID Positioning System. (Page 122)
Figure 9-15 Zigbee modules. (Page 123)
Figure 10-1 Arduino Yun WiFi connection. (Page 126)
Figure 10-2 uploaded image on drop+box. (Page 128)
1
Introduction
Chapter 1
2
1.1 History
1930s
An early representation of the autonomous car was Norman Bell Geddes's Futurama exhibit
sponsored by General Motors at the 1939 World's Fair, which depicted electric cars powered
by circuits embedded in the roadway and
controlled by radio.
1950s
In 1953, RCA Labs successfully built a miniature
car that was guided and controlled by wires that
were laid in a pattern on a laboratory floor. The
system sparked the imagination of Leland M.
Hancock, traffic engineer in the Nebraska
Department of Roads, and of his director, L. N.
Ress, state engineer. The decision was made to
experiment with the system in actual highway
installations. In 1958, a full size system was successfully demonstrated by RCA Labs and the
State of Nebraska on a 400-foot strip of public highway just outside Lincoln, Neb.
1980s
In the 1980s, a vision-guided Mercedes-Benz robotic van, designed by Ernst Dickmanns and
his team at the Bundeswehr University Munich in Munich, Germany, achieved a speed of 39
miles per hour (63 km/h) on streets without traffic. Subsequently, EUREKA conducted the
€749 million Prometheus Project on autonomous vehicles from 1987 to 1995.
1990s
In 1991, the United States Congress passed the ISTEA Transportation Authorization bill,
which instructed USDOT to "demonstrate an automated vehicle and highway system by
1997." The Federal Highway Administration took on this task, first with a series of Precursor
Systems Analyses and then by establishing the National Automated Highway System
Consortium (NAHSC). This cost-shared project was led by FHWA and General Motors, with
Caltrans, Delco, Parsons Brinkerhoff, Bechtel, UC-Berkeley, Carnegie Mellon University,
and Lockheed Martin as additional partners. Extensive systems engineering work and
research culminated in Demo '97 on I-15 in San Diego, California, in which about 20
automated vehicles, including cars, buses, and trucks, were demonstrated to thousands of
onlookers, attracting extensive media coverage. The demonstrations involved close-headway
platooning intended to operate in segregated traffic, as well as "free agent" vehicles intended
to operate in mixed traffic.
3
2000s
The US Government funded three military efforts known as Demo I (US Army), Demo II
(DARPA), and Demo III (US Army). Demo III (2001) demonstrated the ability of unmanned
ground vehicles to navigate miles of difficult off-road terrain, avoiding obstacles such as
rocks and trees. James Albus at the National Institute for Standards and Technology provided
the Real-Time Control System which is a hierarchical control system. Not only were
individual vehicles controlled (e.g. Throttle, steering, and brake), but groups of vehicles
had their movements automatically coordinated in response to high level goals. The Park
Shuttle, a driverless public road transport system, became operational in the Netherlands in
the early 2000s.In January 2006, the United Kingdom's 'Foresight' think-tank revealed a
report which predicts RFID-tagged driverless cars on UK's roads by 2056 and the Royal
Academy of Engineering claimed that driverless trucks could be on Britain's motorways by
2019.
Autonomous vehicles have also been used in mining. Since December 2008, Rio Tinto Alcan
has been testing the Komatsu Autonomous Haulage System – the world's first commercial
autonomous mining haulage system – in the Pilbara iron ore mine in Western Australia. Rio
Tinto has reported benefits in health, safety, and productivity. In November 2011, Rio Tinto
signed a deal to greatly expand its fleet of driverless trucks. Other autonomous mining
systems include Sandvik Automine’s underground loaders and Caterpillar Inc.'s autonomous
hauling.
In 2013, on July 12, VisLab conducted another pioneering test of autonomous vehicles,
during which a robotic vehicle drove in downtown Parma with no human control,
successfully navigating roundabouts, traffic lights, pedestrian crossings and other common
hazards.
In 2011, the Freie Universität Berlin developed two autonomous cars to drive in the inner
city traffic of Berlin in Germany. Led by the AUTONOMOS group, the two vehicles Spirit
of Berlin and made in Germany handled intercity traffic, traffic lights and roundabouts
between International Congress Centrum and Brandenburg Gate. It was the first car licensed
for autonomous driving on the streets and highways in Germany and financed by the German
Federal Ministry of Education and Research.
The 2014 Mercedes S-Class has options for autonomous steering, lane keeping,
acceleration/braking, parking, accident avoidance, and driver fatigue detection, in both city
traffic and highway speeds of up to 124 miles (200 km) per hour.
Released in 2013, the 2014 Infiniti Q50 uses cameras, radar and other technology to deliver
various lane-keeping, collision avoidance and cruise control features. One reviewer
remarked, "With the Q50 managing its own speed and adjusting course, I could sit back and
simply watch, even on mildly curving highways, for three or more miles at a stretch adding
that he wasn't touching the steering wheel or pedals.
4
Although as of 2013, fully autonomous vehicles are not yet available to the public, many
contemporary car models have features offering limited autonomous functionality. These
include adaptive cruise control, a system that monitors distances to adjacent vehicles in the
same lane, adjusting the speed with the flow of traffic lane which monitors the vehicle's
position in the lane, and either warns the driver when the vehicle is leaving its lane, or, less
commonly, takes corrective actions, and parking assist, which assists the driver in the task of
parallel parking
1.2 Why autonomous car is important
1.2.1 Benefits of Self-Driving Cars
1. Fewer accidents
The leading cause of most automobile accidents today is driver error. Alcohol, drugs,
speeding, aggressive driving, over-compensation, inexperience, slow reaction time,
inattentiveness, and ignoring road conditions are all contributing factors. Given some
40 percent of accidents can be traced to the abuse of drugs and or alcohol, self-driving
cars would practically eliminate those accidents altogether.
2. Decreased (or Eliminated) Traffic Congestion
One of the leading causes of traffic jams is selfish behavior among drivers. It has been
shown when drivers space out and allow each other to move freely between lanes on
the highway, traffic continues to flow smoothly, regardless of the number of cars on
the road.
3. Increased Highway Capacity
There is another benefit to cars traveling down the highway and communicating with
one another at regularly spaced intervals. More cars could be on the highway
simultaneously because they would need to occupy less space on the highway
4. Enhanced Human Productivity
Currently, the time spent in our cars is largely given over to simply getting the car and
us from place to place. Interestingly though, even doing nothing at all would serve to
increase human productivity. Studies have shown taking short breaks increase overall
productivity.
You can also finish up a project, type a letter, monitor the progress of your kid’s
schoolwork, return phone calls, take phone calls safely, text until your heart’s content,
read a book, or simply relax and enjoy the ride .
5. Hunting For Parking Eliminated
Self-driving cars can be programmed to let you off at the front door of your
destination, park themselves, and come back to pick you up when you summon them.
You’re freed from the task of looking for a parking space, because the car can do it all
5
6. Improved Mobility For Children, The Elderly, And The Disabled
Programming the car to pick up people, drive them to their destination and Then Park
by themselves, will change the lives of the elderly and disabled by providing them
with critical mobility.
7. Elimination of Traffic Enforcement Personnel
If every car is “plugged” into the grid and driving itself, then speeding,—along with
stop sign and red light running will be eliminated. The cop on the side of the road
measuring the speed of traffic for enforcement purposes? Yeah, they’re gone. Cars
won’t speed anymore. So no need to Traffic Enforcement Personnel.
8. Higher Speed Limits
Since all cars are in communication with one another, and they’re all programmed to
maintain a specific interval between one another, and they all know when to expect
each other to stop and start, the need to accommodate human reflexes on the highway
will be eliminated. Thus, cars can maintain higher average speeds.
9. Lighter, More Versatile Cars
The vast majority of the weight in today’s cars is there because of the need to
incorporate safety equipment. Steel door beams, crumple zones and the need to build
cars from steel in general relate to preparedness for accidents. Self-driving cars will
crash less often, accidents will be all but eliminated, and so the need to build cars to
withstand horrific crashes will be reduced. This means cars can be lighter, which will
make them more fuel-efficient
1.3 What Are Autonomous and Automated Vehicles Technological advancements are creating a continuum between conventional, fully human-
driven vehicles and automated vehicles, which partially or fully drive themselves and which
may ultimately require no driver at all. Within this continuum are technologies that enable a
vehicle to assist and make decisions for a human driver. Such technologies include crash
warning systems, adaptive cruise control (ACC), lane keeping systems, and self-parking
technology.
• Level 0 (no automation):
The driver is in complete and sole control of the primary vehicle functions (brake, steering,
throttle, and motive power) at all times, and is solely responsible for monitoring the roadway
and for safe vehicle operation.
• Level 1 (function-specific automation):
Automation at this level involves one or more specific control functions; if multiple functions
are automated, they operate independently of each other. The driver has overall control, and
is solely responsible for safe operation, but can choose to cede limited authority over a
6
primary control (as in ACC); the vehicle can automatically assume limited authority over a
primary control (as in electronic stability control); or the automated system can provide
added control to aid the driver in certain normal driving or crash-imminent situations (e.g.,
dynamic brake support in emergencies).
• Level 2 (combined-function automation):
This level involves automation of at least two primary control functions designed to work in
unison to relieve the driver of controlling those functions. Vehicles at this level of
automation can utilize shared authority when the driver cedes active primary control in
certain limited driving situations. The driver is still responsible for monitoring the roadway
and safe operation, and is expected to be available for control at all times and on short notice.
The system can relinquish control with no advance warning and the driver must be ready to
control the vehicle safely.
• Level 3 (limited self-driving automation):
Vehicles at this level of automation enable the driver to cede full control of all safety-critical
functions under certain traffic or environmental conditions, and in those conditions to rely
heavily on the vehicle to monitor for changes in those conditions requiring transition back to
driver control. The driver is expected to be available for occasional control, but with
sufficiently comfortable transition time
• Level 4 (full self-driving automation):
The vehicle is designed to perform all safety-critical driving functions and monitor roadway
conditions for an entire trip. Such a design anticipates that the driver will provide destination
or navigation input, but is not expected to be available for control at any time during the trip.
This includes both occupied and unoccupied vehicles.
Our project can be considered as level 1 or level 2 type.
7
1.4 Advanced Driver Assistance System (ADAS)
A rapid growth has been seen worldwide in the development of Advanced Driver Assistance
Systems (ADAS) because of improvements in sensing, communicating and computing
technologies.
ADAS aim to support drivers by either providing warning to reduce risk exposure, or
automating some of the control tasks to relieve a driver from manual control of a vehicle.
From an operational point of view, such systems are a clear departure from a century of
automobile development where drivers have had control of all driving tasks at all times.
ADAS could replace some of the human driver decisions and actions with precise machine
tasks, making it possible to eliminate many of the driver errors which could lead to accidents,
and achieve more regulated and smooth vehicle control with increased capacity and
associated energy and environmental benefits.
Autonomous ADAS systems use on-board equipment, such as ranging sensors and
machine/computer vision, to detect surrounding environment.
The main advantages of such an approach are that the system operation does not rely on
other parties and that the system can be implemented on the current road infrastructure.
Now many systems have become available on the market including Adaptive Cruise Control
(ACC), Forward Collision Warning (FCW) and Lane Departure Warning systems, and many
more are under development. Currently, radar sensors are widely used in the ADAS
applications for obstacle detection. Compared with optical or infrared sensors, the main
advantage of radar sensors is that they perform equally well during day time and night time,
and in most weather conditions. Radar can be used for target identification by making use of
scattering signature information.
It is widely used in ADAS for supporting lateral control such as lane departure warning
systems and lane keeping systems.
Currently computer vision has not yet gained a large enough acceptance in automotive
applications. Applications of computer vision depend much on the capability of image
process and pattern recognition (e.g. artificial intelligence). The fact that computer vision is
based on a passive sensory principle creates detection difficulties in conditions with adverse
lighting or in bad weather situations.
1.5 Project description
1.5.1 Auto-parking
The aim of this function is to design and implement self-parking car system that moves a
car from a traffic lane into a parking spot through accurate and realistic steps which can be
applied on a real car.
1.5.2 Adaptive cruise control (ACC)
Also radar cruise control, or traffic-aware cruise control is an optional cruise control system
for road vehicles that automatically adjusts the vehicle speed to maintain a safe distance from
vehicles ahead. It makes no use of satellite or roadside infrastructures nor of any cooperative
8
support from other vehicles. Hence control is imposed based on sensor information from on-
board sensors only.
1.5.3 Lane Keeping Assist
It is a feature that in addition to Lane Departure Warning System automatically takes steps
to ensure the vehicle stays in its lane. Some vehicles combine adaptive cruise control with
lane keeping systems to provide additional safety. A lane keeping assist mechanism can
either reactively turn a vehicle back into the lane if it starts to leave or proactively keep the
vehicle in the center of the lane. Vehicle companies often use the term "Lane Keep(ing)
Assist" to refer to both reactive Lane Keep Assist (LKA) and proactive Lane Centering
Assist (LCA) but the terms are beginning to be differentiated
1.5.4 Lane departure
Our car moves using adaptive cruise control according to distance of front vehicle .If front
vehicle is very slow and will cause our car to slow down the car will start to check the lane
next to it and then depart to the next lane in order to speed up again.
1.5.5 Indoor Positioning system
An indoor positioning system (IPS) is a system to locate objects or people inside a building
using radio waves, magnetic fields, acoustic signals, or other sensory information collected
by mobile devices. There are several commercial systems on the market, but there is no
standard for an IPS system.
IPS systems use different technologies, including distance measurement to nearby anchor
nodes (nodes with known positions, e.g., Wi-Fi access points), magnetic positioning, dead
reckoning. They either actively locate mobile devices and tags or provide ambient location or
environmental context for devices to get sensed. The localized nature of an IPS has resulted
in design fragmentation, with systems making use of various optical, radio, or even acoustic
technologies.
1.5.6 Connected car
The aim of this function is:
Take a picture with a webcam plugged into the Arduino Yun
Upload the image to drop box using Python
9
1.6 Related work
The appearance of driverless and automated vehicle technologies offers enormous
opportunities to remove human error from driving. It will make driving easier, improve road
safety, and ease congestion. It will also enable drivers to choose to do other things than
driving during the journey.
It is the first driverless electric car prototype built by Google to test self-driving car project. It
looks like a Smart car, with two seats and room enough for a small amount of luggage
Figure 1-1 Google car
It operates in and around California, primarily around the Mountain View area where Google
has its headquarters.
It move two people from one place to another without any user interaction. The car is called
by a smartphone for pick up at the users location with the destination set. There is no steering
wheel or manual control, simply a start button and a big red emergency stop button. In front
of the passengers there is a small screen showing the weather and the current speed. Once
the journey is done, the small screen displays a message to remind you to take your personal
belongings. Seat belts are also provided in car to protect the passengers from the primary
systems fails; plus that emergency stop button that passengers can hit at any time.
Powered by an electric motor with around a 100 mile range, the car uses a combination of
sensors and software to locate itself in the real world combined with highly accurate digital
maps. A GPS is used, just like the satellite navigation systems in most cars, lasers and
cameras take over to monitor the world around the car, 360-degrees.
The software can recognize objects, people, cars, road marking, signs and traffic lights,
obeying the rules of the road. It can even detect road works and safely navigate around them
10
The new prototype has more sensors fitted to it that can see further (up to 600 feet in all
directions)
The simultaneous development of a combination of technologies has brought about this
opportunity. For example, some current production vehicles now feature adaptive cruise
control and lane keeping technologies which allow the automated control of acceleration,
braking and steering for periods of time on motorways, major A-roads and in congested
traffic. Advanced emergency braking
Systems automatically apply the brakes to help drivers avoid a collision. Self-parking
systems allow a vehicle to parallel or Reverse Park completely hands free. Developments in
vehicle automation technology in the short and medium term will move us closer to the
ultimate scenario of a vehicle which is completely “driverless”.
Figure 1-2 progression of automated vehicle technologies
11
VOLVO autonomous CAR
semi-autonomous driving features:
sensors can detect lanes and a car in front of it.
Button in the steering wheel to let the system know I want it to use
Adaptive Cruise Control with Pilot Assist.
If the XC90 lost track of the lanes, it would ask the driver to handle steering duties with a
ping and a message in the dashboard. This is called the Human-machine interface
BMW autonomous CAR
A new i-Series car will include forms of automated driving and
digital connectivity most likely Wi-Fi, high-definition digital maps,
sensor technology, cloud technology and artificial intelligence.
Nissan autonomous CAR
Nissan vehicles in the form of Nissan’s Safety Shield-inspired
technologies. These technologies can monitor a nearly 360-degree view
around a vehicle for risks, offering warnings to the driver and taking
action to help avoid crashes if necessary.
12
Car Design
Chapter 2
13
2.1 First car design
In this section, we will talk about the trials that we passed by till reaching our last prototype
concerning the first car in our project. This car performs some functions of our project such
as the adaptive cruise control (ACC), lane keeping and lane departure.
2.1.1 Four WD Robot (Acrylic with 4 Motors and 4 Wheels)
The 4WD robot consists of four gear-motors with 65mm diameter wheels. The chassis plates
contain numerous cuts and holes for mounting sensors, microcontrollers and other hardware.
The space between the plates is ideal for batteries or more components.
2.1.1.1 Specifications
1) Motors Suggested Voltage:4.5V DC (work
well from 3-6V)
No load Speed:90±10rpm
No Load
Current:190mA(max.250mA)
Torque:800gf.cm (Minimum)
Stall current approximately 1A
2) Wheels 65mm diameter, 30mm width
Plastic rims with solid rubber tires
3) Chassis Laser cut acrylic
Metal standoffs
Top and bottom plates are both
110mm long x 174mm wide Figure 2-1 four WD robot
14
2.1.1.2 Real Shots
Figure 2-2 four WD real shot
2.1.1.3 Drawbacks
1) The 4WD robot uses four wheels with four Dc motors which is not similar to a real car.
2) The steering mechanism is not accurate, which causes many problems while working.
3) The robot size is very small which is not stable and can be easily broken.
2.1.1.4 Overcoming the drawbacks
1) Implementing a mechanical design to serve our needs
2) Using servo motor with steering mechanism to give stable steering while turning left or
right.
2.1.2 Second Trial
The mechanical design is considered as one of the most important parts in our project
because:
1- Without a good design the car may fail in accomplishing its tasks.
15
2- The body carries all the electrical components, if the body might fail to withstand the
stresses.
2.1.2.1 Specifications
1) Main body: length= 360 mm, width=140 mm, aspect ratio between length and width is
similar to Honda Jazz – 2011.
Figure 2-3 second design trial AutoCad design
2) Motors
*Servo motor.
*DC motor with dual H-bridge.
3) Wheels
* 4 rubber wheels.
* Plastic rims with solid rubber tires.
Front wheel place
Front fixing slots
Servo position
Back fixing slots
Driving motor
position
Side fixing slots
16
4) Chassis * Laser cut acrylic.
* 3D holders for the IR sensor.
2.1.2.2 Real Shots
First shot shows the servomotor with the front wheel, Arduino card, and back wheel with the
driving DC motor.
Figure 2-4 second car trial real shots
It’s obvious that the length to width ratio could cause problem during the turns.
17
The car with all components on and connected.
Figure 2-5 second car trial connection
2.1.2.3 Drawbacks
1- The car bulk loaded with all other parts makes it hard to take turn.
2- The sharp edge in the front wheel position, causes friction with the wheels and, makes
it hard to take turns.
3- The position of servomotor and the main front wheel link connection was weak.
2.1.2.4 Overcoming these problems
Modifying the original design by changing the length to 260 mm and keep the width 140
mm, that led to better performance in taking turns
2.1.3 Final Design
2.1.3.1 Body
Figure 2-6 final car design
Fillet to overcome
wheel friction with the
body
18
2.1.3.2 Side Covers
The height of the side cover is 114 mm and length was 360 mm then reduced to 260 mm to
fit the modified, as following there are two figures, on the right hand side is the right cover,
on the left hand side is the left cover.
Figure 2-7 final car side covers
The side covers are used to overcome the modification draw back, the
sides provide the area required to fix the rest of components without any problems.
Ultrasound
sensors slots
The cover
fixing slots
Front wheels
slots
Arduino cable slot
The Base
fixing slots
Back wheels
slots
19
2.1.3.3 The Front and Back Covers
The dimensions are 140 mm width and 114 mm height, provided with slots to fix the
ultrasound sensors.
Figure 2-8 final car front and back covers
The ultrasound sensor
slots
Side slots
Cover slots
Base slots
20
2.1.3.4 Cover
The cover
dimensions
are 260 mm
length and
140 mm
width. The
cover
function is to
keep all the
small and
other
components
inside.
We notice that the design is not aerodynamically considered, that’s because the project target
is the control and apply the function, not to study the aerodynamic effects of cars.
2.1.3.5 Real shots
Figure 2-10 final car real shots
2.1.3.6 Drawback
The compact size causes another expected problem, there are many components require more
space, and the total area is reduced.
Figure 2-9 final car cover
21
2.2 Car Wheel Drive
2.2.1 Types of wheel drive
Figure 2-11 types of wheel drive
Our car is using rear-wheel-drive.
2.2.2 Advantages of this configuration:
1- Even weight distribution.
2- Better control at the turns.
3- Better steering radius.
Wheel drive
two-wheel drive
front drive
rear drivefour-wheel
drive
Figure 2-12 final car inside view
22
2.3 Car Steering
2.3.1 Basic geometry
The basic aim of steering is to ensure that the wheels are pointing in the desired directions.
This is typically achieved by a series of linkages, rods, pivots and gears. One of the
fundamental concepts is that of caster angle – each wheel is steered with a pivot point ahead
of the wheel; this makes the steering tend to be self-centering towards the direction of travel.
Figure 2-13 final car center of turning circle
23
2.3.2 Our mechanism
It is controlled automatically by a servomotor
connected directly to the main link.
Shown in the picture the old mechanism, it’s
obvious that the orientation of the
servomotor is not correct.
The servomotor at this position doesn’t give
all the desired angles.
So modifications are made.
2.3.3 Servomotor
modifications
Modifications are made to ensure
better performance in turns, the new
mechanism is less heavy, more
flexible with turns. As shown in
following image.
The servomotor in the new position
gives all the angles and transfer more
torque.
Servomotor in the
new position
Servomotor in the
old position Figure 2-14 old car design servomotor mechanism
Figure 2-15 last car design servomotor
24
2.4 Second car design
We are going to talk about the design of the second car used in our project and the trials till
reaching the last prototype. The second car performs the auto-parking function in our project.
It passed by nearly the same trials as the first car but concerning the final design, it was not
the same. So we will discuss the final design in the following lines.
2.4.1 Final design
The final design of the second car is an RC car. The RC car is the best choice for
implementing the auto-parking function because all the above designs did not help in
fulfilling the function correctly.
2.4.2 Real shots
Figure 2-16 second car real shots
2.5 Motors
The motor is the primary tool for creating motion. At its simplest use, you can use it to make
something spin. With a little more mechanical work, using gears and other mechanical
devices, you can use a motor to make something move, vibrate, rise, fall, roll, creep, or
perform almost any other type of motion that does not require precise positioning. There are
several different kinds of motors: servos, stepper motors, or unidirectional DC motors. In this
section, we will talk about DC and servo motors and how they can be. Simple motors are
good for designs that need motion forward or backward, like a remote control car or a fan,
but not for things that need to move to a precise position, like a robotic arm or anything that
points or moves something to a controlled position.
25
2.5.1 DC Motor
D. C motors are seldom used in ordinary applications because all electric supply companies
furnish alternating current. However, for special applications such as in steel mills, mines
and electric trains, it is advantageous to convert alternating current into direct current in order
to use DC motors. The reason is that speed/torque characteristics of DC motors are much
more superior to that of AC motors. Therefore, it is not surprising to note that for industrial
drives, DC motors are as popular as 3-phase induction motors. Like DC generators, dc
motors are also of three types. (series-wound , shunt-wound and compound wound). The use
of a particular motor depends upon the mechanical load it has to drive. Motors are all around
us; just look inside moving toys, and you’ll find a number of excellent motors and gears. Any
electronics supplier will have a wide range of motors that will suit many purposes from
spinning small objects to driving large loads
2.5.1.1 D.C Motor Fundamentals
DC motors consist of rotor (or armature), commentator, brushes, rotating shaft and bearings,
stator with permanent magnet. The principle of operation with a simple two-pole dc motor:
The torque is produced by the fact that like field poles attracts and unlike poles repel.
2.5.1.2 DC Motor Principle
It is a machine that converts DC power into mechanical power. Its operation is based on the
principle that when a current carrying conductor is placed in a magnetic field, the conductor
experiences a mechanical force. Basically, there is no constructional difference between a
DC motor and a DC generator. The same DC machine can be run as generator motor.
Figure 2-17 DC motor theory
26
2.5.1.3 Controlling DC Motor
First we have to mention that the Dc motor used in our project was taken from RC toy car
and we repurpose it to match our needs and design for both cars. Here we will talk briefly
about controlling the motor and its connection with the Arduino.
1) H-Bridge
An H bridge is an electronic circuit that enables voltage to be supplied to the DC motor and
control its direction. This circuit is often used in robotics and other applications.
1.1 L298 Dual Motor Driver Module This driver module is based on L298N H-bridge, a
high current, high voltage dual full bridge driver manufactured by ST Company. It
can drive up to 2 DC motors 2A each. The driver can control both motor RPM and
direction of rotation.
The RPM is controlled using PWM input to
ENA or ENB pins, while rotation direction
is controlled by supplying high and low
signal to EN1-EN2 for the first motor or
EN3-EN4 for second motor. This Dual H-
Bridge driver is capable of driving voltages
up to 46V.
1.2 Features
Dual H bridge drive (can drive 2 DC
motors).
Chip L298N.
Logical voltage 5V.
Drive voltage 5V-35V.
Logic current 0mA-36mA.
Drive current 2A (For each DC motor)).
Weight 30gm.
Size: 43*43*27mm.
Figure 2-18 Dual H-bridge
27
1.3 Driver connection with Arduino
It has 8 pins:
1- GND.
2- + 5 V (power for driver (not motor)).
3- ENA: Motor enable for Motor A (high/low).
4, 5- IN1, IN2: pins control Motor A direction of rotation (one is high and the other is low).
6-ENB: Motor enable for Motor B (high/low).
7, 8- IN3, IN4: These pins define Motor B direction of rotation (one is high and the other is
low).
The following figures show the exact connection with Arduino.
It is obvious that the first connection is when connecting two motors with the driver and this
happened in the second car (RC car).
Figure 2-19 second car motors connection
While the first car connection is using only one motor and connecting it with the driver as
shown in the following connection.
28
Figure 2-20 first car motor connection
2.5.2 Servo motor
Unlike dc motors, with servo motors you can position the motor shaft at a specific position
(angle) using control signal. The motor shaft will hold at this position as long as the control
signal not changed. This is very useful for controlling robot arms, unmanned airplanes
control surface or any object that you want it to move at certain angle and stay at its new
position. Servo motors may be classified according to size or torque that it can withstand into
mini, standard and giant servos. Usually mini and standard size servo motors can be powered
by Arduino directly with no need to external power supply or driver. Usually servo motors
come with arms (metals or plastic) that are connected to the object required to move. In our
project we used a TowerPro MG995 servo motor and in the following lines we will show its
features in brief.
2.5.2.1 Servo motor features
Model: TowerPro MG995 Metal Servo.
Dimensions: :4.07*1.97*4.29cm.
Speed: 0.2sec/60° (4.8V).
Torque: 10kg-cm.
Rated Voltage: 4.8-7.2V.
29
2.5.2.2 Servo Motor mechanism
Servo motor has 3 wires:
Black wire: GND (ground).
RED wire: +5v.
Colored wire: control signal.
The third pin (colored wire) accepts the control signal which is a pulse-width modulation
(PWM) signal which can be easily produced by all micro- controllers and Arduino board. It
accepts the signal from your controller that tells it the turn angle. The control signal is fairly
simple compared to that of a stepper motor. It is just a pulse of varying lengths. The length of
the pulse corresponds to the angle by which the motor turns to.
Figure 2-21 servo motor mechanism
30
2.5.2.3 Inside Servo Motor
Did you ever wonder how the servo motors looks from inside? Have a look at figure 2-22
and figure 2-23. A servo motor was taken apart to show the internal parts. You can see a
regular dc motor connected to a gear box and a potentiometer that gives the feedback for
angle position. This is represented by the diagram below.
Figure 2-22 inside servo motor diagram
31
Figure 2-23 inside servo motor real shot
2.5.2.4 Servo Motor with Arduino
Standard servo motor control using Arduino is extremely easy. This is because the Arduino
software comes with a sample servo sketch and servo Library that will get you up and
running quickly.
Connect the black wire from the servo to the GND pin on Arduino.
Connect the red wire from servo to the +5V pin on Arduino.
Connect the third wire (usually orange or yellow) from the servo to a digital
pin on Arduino.
32
Figure 2-24 Connection of servo motor with Arduino
33
Microcontroller and Hardware
Chapter 3
34
3.1 Micro Controllers A Microcontroller (sometimes abbreviated µC, or MCU) is a small computer on a single
integrated circuit containing a processor core, memory, and programmable input/output
peripherals. Program memory in the form of NOR flash or OTP ROM is also often included
on chip, as well as a typically small amount of RAM. Microcontrollers are designed for
embedded applications, in contrast to the microprocessors used in personal computers or
other general purpose applications.
Microcontrollers are used in automatically controlled products and devices, such as
automobile engine control systems, implantable medical devices, remote controls, office
machines, appliances, power tools, toys and other embedded systems. By reducing the size
and cost compared to a design that uses a separate microprocessor, memory, and input/output
devices, microcontrollers make it economical to digitally control even more devices and
processes. Mixed signal microcontrollers are common, integrating analog components
needed to control non-digital electronic systems.
Some microcontrollers may use four-bit words and operate at clock rate frequencies as low as
4 kHz, for low power consumption (single-digit mille watts or microwatts). They will
generally have the ability to retain functionality while waiting for an event such as a button
press or other interrupt, power consumption while sleeping (CPU clock and most peripherals
off) may be just Nano watts, making many of them well suited for long lasting battery
applications. Other microcontrollers may serve performance-critical roles, where they may
need to act more like a digital signal processor (DSP), with higher clock speeds and power
consumption.
3.1.1 Arduino 3.1.1.1 Introduction
1. What is Arduino?
Arduino is a tool for making computers that can sense and control more of the
physical world than your desktop computer. It’s an open-source physical computing
platform based on a simple microcontroller board, and a development environment
for writing software for the board. Arduino can be used to develop interactive objects,
taking inputs from a variety of switches or sensors, and controlling a variety of lights,
motors, and other physical outputs. Arduino projects can be stand-alone, or they can
be communicate with software running on your computer (e.g. Flash, Processing,
MaxMSP.) The Arduino programming language is an implementation of Wiring, a
similar physical computing platform, which is based on the Processing multimedia
programming environment.
2. Why Arduino?
There are many other microcontrollers and microcontroller platforms available for
physical computing. Parallax Basic Stamp, Netmedia's BX-24, Phidgets, MIT's
35
Handy board, and many others offer similar functionality. All of these tools take the
messy details of microcontroller programming and +wrap it up in an easy-to-use
package.
Arduino also simplifies the process of working with microcontrollers, but it offers
some advantage for teachers, students, and interested amateurs over other systems:
• Inexpensive
Arduino boards are relatively inexpensive compared to other microcontroller
platforms. The least expensive version of the Arduino module can be
assembled by hand, and even the pre-assembled Arduino modules cost less
than $50
• Cross-platform
The Arduino software runs on Windows, Macintosh OSX, and Linux operating
systems. Most microcontroller systems are limited to Windows.
• Simple, clear programming environment
The Arduino programming environment is easy-to-use for beginners, yet
flexible enough for advanced users to take advantage of as well. For teachers,
it's conveniently based on the Processing programming environment, so
students learning to program in that environment will be familiar with the look
and feel of Arduino
• Open source and extensible software
The Arduino software is published as open source tools, available for
extension by experienced programmers. The language can be expanded
through C++ libraries, and people wanting to understand the technical details
can make the leap from Arduino to the AVR C programming language on
which it's based. Similarly, you can add AVR-C code directly into your
Arduino programs if you want to.
• Open source and extensible hardware
The Arduino is based on Atmel's ATMEGA8 and ATMEGA168
microcontrollers. The plans for the modules are published under a Creative
Commons license, so experienced circuit designers can make their own
version of the module, extending it and improving it. Even relatively
inexperienced users can build the breadboard version of the module in order to
understand how it works and save money.
36
3. Types of Arduino
There are different types of Arduino to choose from.
3.1.1.2 Arduino mega
Figure 3-2 Arduino mega
1. Overview
The Arduino Mega 2560 is a microcontroller board based on the ATmega2560 It has
54 digital input/output pins (of which 15 can be used as PWM outputs), 16 analog
inputs, 4 UARTs (hardware serial ports), a 16 MHz crystal oscillator, a USB
connection, a power jack, an ICSP header, and a reset button. It contains everything
needed to support the microcontroller; simply connect it to a computer with a USB
cable or power it with a AC-to-DC adapter or battery to get started. The Mega is
compatible with most shields designed for the Arduino Duemilanove or Diecimila.
2. Power
The Arduino Mega can be powered via the USB connection or with an external power
supply. The power source is selected automatically. External (non-USB) power can
come either from an AC-to-DC adapter (wallwart) or battery. The adapter can be
connected by plugging a 2.1mm centerpositive plug into the board’s power jack.
Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER
connector. The board can operate on an external supply of 6 to 20 volts. If supplied
Figure 3-1 Arduino types
37
with less than 7V, however, the 5V pin may supply less than five volts and the board
may be unstable. If using more than 12V, the voltage regulator may overheat and
damage the board. The recommended range is 7 to 12 volts. The power pins are as
follows:
1. VIN.
The input voltage to the Arduino board when it’s using an external power source
(as opposed to 5 volts from the USB connection or other regulated power source).
You can supply voltage through this pin, or, if supplying voltage via the power
jack, access it through this pin.
2. 5V.
This pin outputs a regulated 5V from the regulator on the board. The board can
be supplied with power either from the DC power jack (7 - 12V), the USB
connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the
5V or 3.3V pins bypasses the regulator, and can damage your board. We don’t
advise it.
3. 3V3.
A 3.3 volt supply generated by the on-board regulator. Maximum current draw is
50 mA.
4. GND. Ground pins.
3. Memory
The ATmega2560 has 256 KB of flash memory for storing code (of which 8 KB is
used for the bootloader), 8 KB of SRAM and 4 KB of EEPROM (which can be read
and written with the EEPROM library).
4. Input and Output
Each of the 54 digital pins on the Mega can be used as an input or output, using
pinMode(), digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each
pin can provide or receive a maximum of 40 mA and has an internal pull-up resistor
(disconnected by default) of 20-50 kOhms. In addition, some pins have specialized
functions:
1. Serial: 0 (RX) and 1 (TX); Serial 1: 19 (RX) and 18 (TX); Serial 2: 17 (RX)
and 16 (TX); Serial 3: 15 (RX) and 14 (TX). Used to receive (RX) and transmit (TX)
TTL serial data. Pins 0 and 1 are also connected to the corresponding pins of the
ATmega16U2 USB-to-TTL Serial chip.
2. External Interrupts: 2 (interrupt 0), 3 (interrupt 1), 18 (interrupt 5), 19
(interrupt 4), 20 (interrupt 3), and 21 (interrupt 2). These pins can be configured to
trigger an interrupt on a low value, a rising or falling edge, or a change in value. See
the attachInterrupt() function for details.
38
3. PWM: 2 to 13 and 44 to 46. Provide 8-bit PWM output with the analog-
Write() function.
4. SPI: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS). These pins support SPI
communication using the SPI library. The SPI pins are also broken out on the ICSP
header, which is physically compatible with the Uno, Duemilanove and Diecimila.
5. LED: 13. There is a built-in LED connected to digital pin 13. When the pin is
HIGH value, the LED is on, when the pin is LOW, it’s off.
6. TWI: 20 (SDA) and 21 (SCL). Support TWI communication using theWire
library. Note that these pins are not in the same location as the TWI pins on the
Duemilanove or Diecimila. The Mega2560 has 16 analog inputs, each of which
provide 10 bits of resolution (i.e. 1024 different values). By default they measure
from ground to 5 volts, though is it possible to change the upper end of their range
using the AREF pin and analogReference() function. There are a couple of other pins
on the board:
1. AREF. Reference voltage for the analog inputs. Used with analogReference().
2. Reset. Bring this line LOW to reset the microcontroller. Typically used to add
a reset button to shields which block the one on the board.
5. Communication
The Arduino Mega2560 has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The AT mega 2560 provides
four hardware UARTs for TTL (5V) serial communication. An ATmega16U2 (AT
mega 8U2 on the revision 1 and revision 2 boards) on the board channels one of these
over USB and provides a virtual com port to software on the computer (Windows
machines will need a .inf file, but OSX and Linux machines will recognize the board
as a COM port automatically. The Arduino software includes a serial monitor which
allows simple textual data to be sent to and from the board. The RX and TX LEDs on
the board will flash when data is being transmitted via the
ATmega8U2/ATmega16U2 chip and USB connection to the computer (but not for
serial communication on pins 0 and 1). A Software Serial library allows for serial
communication on any of the Mega2560’s digital pins. The ATmega2560 also
supports TWI and SPI communication. The Arduino software includes a Wire library
to simplify use of the TWI bus; see the documentation for details. For SPI
communication, use the SPI library
6. Programming
The Arduino Mega can be programmed with the Arduino software (download). The
ATmega2560 on the Arduino Mega comes preburned with a bootloader that allows
39
you to upload new code to it without the use of an external hardware programmer. It
communicates using the original STK500 protocol (reference, C header files).
7. Automatic (Software) Reset
Rather then requiring a physical press of the reset button before an upload, the
Arduino Mega2560 is designed in a way that allows it to be reset by software running
on a connected computer. One of the hardware flow control lines (DTR) of the
ATmega8U2 is connected to the reset line of the ATmega2560 via a 100 nano-farad
capacitor. When this line is asserted (taken low), the reset line drops long enough to
reset the chip. The Arduino software uses this capability to allow you to upload code
by simply pressing the upload button in the Arduino environment. This means that the
bootloader can have a shorter timeout, as the lowering of DTR can be well-
coordinated with the start of the upload.
3.1.2 Raspberry Pi
3.1.2.1 Design
The Raspberry Pi is a single-board computer developed in the UK by the Raspberry
Pi. The Raspberry Pi is a credit-card sized computer that plugs into your TV and a
keyboard. It’s a capable little PC which can be used for many of the things that your
desktop PC does, like spreadsheets, word-processing and games.
The design is based around a Broadcom BCM2835 SoC, which includes an
ARM1176JZF-S 700 MHz processor and 512 Megabytes of RAM.
The design does not include a built-in hard disk or solid-state drive, instead relying on
an SD card for booting and long-term storage. This board is intended to run Linux
kernel based operating systems.
3.1.2.2 ARM1176 PROSESSOR
The ARM1176™ applications processors deployed broadly in
devices ranging
from smart phones to digital TV's delivering media and
browser performance, a secure computing environment, and
performance up to 1GHz in low cost designs.
The ARM1176 is still actively being licensed for application
processor and baseband processor designs due to its maturity,
low level of implementation risk, and low implementation cost
Figure 3-3 Rpi memory management
40
3.1.2.3 Features
• Low risk and fast time to market
• High performance in low-cost designs
• Physically addressed caches for multi-tasking performance
• Broad OS support, multiple Linux distributions, amazing ARM ecosystem
• Full Internet experience
• Low Power Leadership
• 93% of flops are clock gated
3.1.2.4 Performance
The ARM1176 processor performance reaches up to 1GHz and beyond in 40G, and
can reach 1GHz in 65nm with overdrive voltages.
3.1.2.5 Functions supported in hardware
• Multiplication, addition, and multiply-accumulate ( various variants)
• Division and square root operation (multi-cycle, not pipelined)
• Comparisons and format conversions
• Operations can be performed on short vectors (From assembler only)
• Separate pipelines allow load/store and MAC operations to occur
simultaneously with divide/square root unit operation
• Clock gated and/or power completely removed
41
3.1.2.6 Comparison
42
3.2 Hardware
3.2.1 Ultrasonic sensor
3.2.1.1 Introduction Distance measurement sensor is a low cost full functionality solution for distance
measurement applications. The module is based on the measurement of time flight of
ultrasonic pulse, which is reflected by an object. The distance to be measured mainly
depends on the speed of ultrasonic waves in space or air –which is a constant and the
flight time of the pulse. The module performs these calculations and outputs a pulse
width depends on the measured distance, this pulse is easily interfaced to any
microcontroller.
Figure 3-4 ultrasonic sensor
3.2.1.2 Features
• Supply voltage +5Vdc
• Supply Current 10mA
• Measurement distance Range from 2cm to 400cm.
• Input trigger pulse is 5V TTL compatible (5 μs minimum). Output echo
pulse is 5V TTL compatible. Size 44.5mm W x 20mm H x 15mm D.
• Interface connector 4-pin header SIP, 0.1” spacing.
• Operating temperature range 0° - 70° C.
43
3.2.1.3 Connection with Arduino
Figure 3-5 ultrasonic sensor connection with Arduino
3.2.1.4 Connection with Raspberry pi
Figure 3-6 ultrasonic sensor connection with Rpi
44
3.2.2 Infrared line tracking sensor
3.2.2.1 Introduction
Line tracking is the most basic function of smart mobile robot. This new generation of
line tracking sensors is developed to be the robot's powerful copilot all the way. It
will guide it robot by telling white from black quickly and accurately, via TTL signal.
With a drawn path and good programming can ensure results that are far more
consistent than if the robot was simply told where to go without any reference.
Figure 3-7 infrared sensor
3.2.2.2 Theory of operation It consists two parts
1) IR emitting LED
2) IR sensitive phototransistor.
The IR Reflectance sensors work best when they are close to the surface of the
ground. It should be about 1/8" above the ground. This is an optimal distance for the
IR transmitter to illuminate the surface below and measure the reflected light.
It works by transmitting a beam of IR light downward toward the surface. If the
detector is over a white surface, the reflected light is received by the detector and
outputs a HIGH signal. When the sensor is over a black surface where the light is
absorbed or not reflected, the IR detector outputs a LOW signal. The IR Sensor
module provides a value inversely dependent to the amount of reflected IR light.
So it can output digital signal to a microcontroller so the robot can reliably follow a
black line on a white background, or vice versa
45
3.2.2.3 Features and Pins
Small size.
5V DC power supply.
Indicator LED.
Digital output.
Distance: up to 3 cm
Size: 3.5 x 1cm
Applicable to a variety of platforms including Arduino / AVR / ARM /PIC
** Pin Definition
GND: Ground
OUT: Output (HIGH when line is black and LOW when line is white)
VCC: 3.3-5 VDC
Figure 3-8 infrared sensor pins
46
3.2.2.4 Arduino connection
Figure 3-9 1R sensor connection with Arduino
3.2.3 Optical encoder
Figure 3-10 optical encoder
3.2.3.1 Introduction
The encoder kit consists of two 8-pole magnets with rubber hubs and two hall-
effect sensors terminated with 150mm (6 inch) cable and 3 pin female servo
headers.
The magnets have 4 north poles and 4 south poles and are strong enough that the
sensor can detect the poles from more than 3mm (1/8inch). This means that the
sensors do not need to be precisely mounted to detect the poles. The rubber hubs will
press fit over most small motor and drive shafts used in low power gearboxes. A
small screw may also be used to attach the magnets in some cases.
47
The hall-effect sensors will work on voltages from 3V to 24V and include reverse polarity
protection. It can work with any Arduino compatible controller and use the processors internal
pullup resistors eliminating the need for any external components or wiring
3.2.3.2 Specifications
• Supply voltage: 3V-24V
• Supply current: 4mA per sensor
• Output voltage: 26V maximum
• Output current: 25mA continuous
• Output type: Open drain
48
Adaptive Cruise Control
Chapter 4
49
4.1 Definitions
Adaptive Cruise Control (ACC): An enhancement to a conventional cruise control system
which allows the ACC vehicle to follow a forward vehicle at an appropriate distance.
4.2 Introduction
A big issue on busy roads is traffic jams. There are campaigns that ask people not to travel
during peak hours and to travel together in one car, but they don’t have the desired effect.
This raises the demand for a technical solution. If the amount of cars can’t be reduced, the
vehicle throughput of the road must be increased to solve the traffic jams. This can be done
by reducing the inter-vehicle distance, but this will immediately lead to unsafe situations
caused by the slow response time of human beings. To overcome this slow response time, a
technical solution can be introduced, which controls the throttle and brake of the car. An
implementation of such a system which is used more and more these days, is ACC.
The goal of such a system is to keep a constant distance to its predecessor, or to keep a
constant speed if the constant distance could only be achieved if the maximum speed must be
exceeded. Using this technique, it is possible to create a vehicle string with all cars driving
safely in the platoon while being comfortable for the passenger in the car
An ‘Adaptive Cruise Control’ (ACC) system developed as the next generation assisted the
driver to keep a safe distance from the vehicle in front. This system is now available only in
some luxury cars like Mercedes S-class, Jaguar and Volvo trucks the U.S. Department of
transportation and Japan’s ACAHSR have started developing ‘Intelligent Vehicles’ that can
communicate with each other with the help of a system called ‘Cooperative Adaptive Cruise
Control’
50
4.3 Application
4.3.1 Theory of operation
Adaptive Cruise Control (ACC) is an advancement of cruise control system. It’s an
automotive feature allows the vehicle to adopt set vehicle's speed to the traffic environment.
A sensor system is attached to the front of the vehicle which is used to detect former slow
moving vehicles are in the ACC vehicle's path. If a foregoing slow moving vehicle detected
by the sensor system in the ACC vehicle’s path, then the ACC system will automatically
slows its speed to maintain a safe distance.
If the system detects that the ahead vehicle gets higher speed than ACC vehicle cruise speed
or no longer in the ACC vehicle's path, then automatically ACC system will stimulate back
the vehicle speed to its pre-set cruise control speed.
This action of control system allows the ACC vehicle to self-governing slow down and
speeds up with traffic without arbitration from the driver
Figure 4-1 Adaptive cruise control in real cars
4.3.2 Sensor options
currently four means of object detection are technically feasible and applicable in a vehicle
environment .They are
1. RADAR
2. LIDAR
3. Vision sensor
4. ULTRASONIC SENSOR
The first ACC system used LIDAR sensor.
51
4.3.2.1 LIDAR (Light Detection and Ranging)
The first ACC system introduced by Toyota used this method. By measuring the beat
frequency difference between a Frequency Modulated Continuous light Wave (FMCW) and
its reflection
Figure 4-2 operation of LIDAR
Most of the current ACC systems are based on 77GHz RADAR sensors.
The RADAR systems have the great advantage that the relative velocity can be measured
directly, and the performance is not affected by heavy rain and fog. LIDAR system is of low
cost and provides good angular resolution although these weather conditions restrict its use
within a 30 to 40 meters range.
4.3.2.2 RADAR (Radio Detection and Ranging)
RADAR is an electromagnetic system for the detection and location of reflecting objects like
air crafts, ships, space crafts or vehicles. It is operated by radiating energy into space and
detecting the echo signal reflected from an object (target) the reflected energy is not only
indicative of the presence but on comparison with the transmitted signal, other information of
the target can be obtained. The currently used ‘Pulse Doppler RADAR’ uses the principle of
‘Doppler effect’ in determining the velocity of the target
4.3.2.3 Fusion sensor
The new sensor system introduced by Fujitsu Ten Ltd. and Honda through their PATH
program includes millimeter wave radar linked to a 640x480 pixel stereo camera with a 40
degree viewing angle. These two parts work together to track the car from the non-moving
objects. While RADAR target is the car’s rear bumper, the stereo camera is constantly
52
captures all objects in its field of view
Figure 4-3 operation of fusion sensor
The image processor measures the distances to the objects through triangulation method.
This method includes an algorithm based on the detection of the vertical edges and distance.
Incorporating both the 16-degree field of view of radar and 40-degree field of view of camera
enhances the performance in tight curves
4.3.2.4 Ultrasonic sensor
Depend on measuring distance between our car and front car by sending and receiving
ultrasonic waves and measure time taken by wave between sending and receiving
according to distance car takes action to speed up or slow down
Figure 4-4 operation of ultrasonic sensor
53
Ultrasonic sensors are capable of detecting most objects — metal or nonmetal, clear or
opaque, liquid, solid, or granular — that have sufficient acoustic reflectivity. Another
advantage of ultrasonic sensors is that they are less affected by condensing moisture than
photoelectric sensors.
A downside to ultrasonic sensors is that sound absorbing materials, such as cloth, soft rubber,
flour and foam, make poor target objects.
In our project we used Ultrasonic sensor because it is the most suitable sensor according to
size, cost and availability
4.4 Algorithm
First a safe distance is set this is the distance our car wants to keep with the front vehicles
(the reference).
Second cruise speed is set this is the speed the car will maintain at free driving.
Figure 4-5 feedback control system
Figure 4-6 PID theory
54
Controller here is Arduino microcontroller its function is to take values of distance read by
sensor and control speed and distance according to values set
When the car start and the function is activated it starts to take readings from ultrasonic
sensor and act according to these readings
we here have two cases:
1) If distance is bigger than safe distance
This means that the car can move freely with the cruise speed as there is no car in its way
speed is controlled by speed PID in order to make car maintain this speed while cruising
2) If distance is less than safe distance
This mean that the car will slow down to maintain safe distance
how much the car will slow down is controlled by PID
3) If distance is less than critical distance then the car will stop
4.5 Implementation and testing
4.5.1 Steps
The hardware used to implement this function is the DC motor and ultrasonic sensor
the steps we made was:
1) Testing accuracy of the sensor we have and writing code to calculate the distance that it
sees
2) Connecting DC motor , we started first with a simple code to move car and test different
speeds to see how the car responds
3) Then we made our code using fuzzy control so that for every range of distance the car will
move with a certain speed
4) After that we started adding a controller to our system as shown in flow chart
5) we started reading about different controllers then decided to use PID for our system
6) Then we started tuning parameters to reach the ones suitable for us after that testing its
response
7) Since our system has no model and considered a black box tuning need to be done
experimentally
8) There is different tuning methods in our system we used two methods
Distance speed PID we used trial and error method
Speed PID we used Ziegler-Nicholas
9) Then testing response
55
4.6 Designing a control system
4.6.1 Design in real systems
To design any control system:
1) Choose design specification needed
2) Set a mathematical model for system
3) Then tune parameter and check performance of system, if the system specification reached
then the parameters are the right ones but if specifications not reached then retune parameters
4.6.2 Design in our system
1) We didn’t set any specification because what was important for us is speed of response
2) Our system doesn’t have a model so we consider it a black box
3) We will tune parameters by method that doesn’t need transfer function
4) Before tuning we need to choose the type of controller that we will use
4.6.3 Controllers
Before introducing various controllers, it is very important to know why we use controllers
and why they are important.
1. Controllers improve steady state accuracy by decreasing the steady state errors.
2. As the steady state accuracy improves, the stability also improves.
3. Help in reducing the offsets produced in the system.
4. Maximum overshoot of the system can be controlled using these controllers.
5. They also help in reducing the noise signals produced in the system.
6. Slow response of the over damped system can be made faster with the help of these
controllers.
4.6.3.1 P Controller
P controller is mostly used in first order processes with single energy storage to stabilize the
unstable process. The main usage of the P controller is to decrease the steady state error of
the system. As the proportional gain factor K increases, the steady state error of the system
decreases. However, despite the reduction, P control can never manage to eliminate the
steady state error of the system. As we increase the proportional gain, it provides smaller
amplitude and phase margin and larger sensitivity to the noise. We can use this controller
only when our system is tolerable to a constant steady state error. In addition, it can be easily
concluded that applying P controller decreases the rise time and after a certain value of
reduction on the steady state error, increasing K only leads to overshoot of the system
response.
Mathematical equation:
56
Advantages
1. Proportional controller helps in reducing the steady state error, thus makes the system
more stable.
2. Slow response of the over damped system can be made faster with the help of these
controllers.
Disadvantages
1. Due to presence of these controllers there are some offsets in the system.
2. Proportional controllers also increase the maximum overshoot of the system.
4.6.3.2 PI controller
P-I controller is mainly used to eliminate the steady state error resulting from P controller.
However, in terms of the speed of the response and overall stability of the system, it has a
negative impact. This controller is mostly used in areas where speed of the system is not an
issue.
Mathematical equation:
Removing the sign of proportionality we have,
Advantages
PI controller fuses the properties of the P and I controllers. It shows a maximum overshoot
and settling time similar to the P controller but no steady-state error.
Disadvantages
Since P-I controller has no ability to predict the future errors of the system it cannot decrease
the rise time and eliminate the oscillations.
57
4.6.3.3 P-D Controller
The aim of using P-D controller is to increase the stability of the system by improving
control since it has an ability to predict the future error of the system response. In order to
avoid effects of the sudden change in the value of the error signal, the derivative is taken
from the output response of the system variable instead of the error signal. Therefore, D
mode is designed to be proportional to the change of the output variable to prevent the
sudden changes occurring in the control output resulting from sudden changes in the error
signal. In addition D directly amplifies process noise therefore D-only control is not used.
Mathematical equation:
Removing the sign of proportionality we have,
Advantages
Smaller maximum overshoot due to the 'faster' D action compared with other controller
types.
A steady-state error is visible, which is smaller than in the case of the P controller. This is
because the PD controller generally is tuned to have a larger gain Kc due to the positive
phase shift of the D action.
4.6.3.4 P-I-D Controller
P-I-D controller has the optimum control dynamics including zero steady state error, fast
response (short rise time), no oscillations and higher stability. The necessity of using a
derivative gain component in addition to the PI controller is to eliminate the overshoot and
the oscillations occurring in the output response of the system.
Mathematical equation:
Advantages
1-One of the main advantages of the P-I-D controller is that it can be used with higher order
processes including more than single energy storage.
58
2- Zero steady state error.
The advantage of PID controller is its feasibility and easy to be implemented. The PID
gains can be designed based upon the system parameters if they can be achieved or estimated
precisely. Moreover, the PID gain can be designed just based on the system tracking error
and treats the system to be "black box" if the system parameters are unknown. However, PID
controller generally has to balance all three-gain impact to the whole system and may
compromise the transient response, such as settling time, overshoots, and oscillations. If the
system parameters cannot be precisely estimated or achieved, the designed PID gains may
not resist the uncertainties and disturbances, and thus present low robustness. Even though
the PID gains can be well-designed, the PID controller still has low robust ability compared
with the robust controller when the system encounters to multiple challenges from the
operating environment of the system, such as temperature, weather, power surge, and so on.
-PID is widely used in automotive and in general applications and has several sources.
So we decided to use PID controller. The PID controller has three tunable parameters, whose sum constitutes the adjustable
variable (AV). The summation of proportional, integral, and derivative terms gives the output
of the PID controller. Defining u(t) as the controller output, the final form of the PID design
Where,
Kp: Proportional gain, a tuning parameter
Ki : Integral gain, a tuning parameter
Kd: Derivative gain, a tuning parameter
E : Error = SP- PV
T : Time or instantaneous time
S : set point
C.S : control signal
O : Output
The basic idea behind a PID controller is to read a sensor, then compute the desired actuator
output by calculating proportional, integral, and derivative responses and summing those
three components to compute the output. First we need to know what a closed loop system is
and some of the terminologies associated with it.
59
PID Theory
Figure 4-6 PID block diagram
Proportional Response The proportional component depends only on the difference between the set point and the
process variable. This difference is referred to as the Error term. The proportional gain (Kc)
determines the ratio of output response to the error signal. For instance, if the error term has a
magnitude of 10,
a proportional gain of 5 would produce a proportional response of 50. In general, increasing
the proportional gain will increase the speed of the control system response. However, if the
proportional gain is too large, the process variable will begin to oscillate. If Kc is increased
further, the oscillations will become larger and the system will become unstable and may
even oscillate out of control.
Integral Response The integral component sums the error term over time. The result is that even a small error
term will cause the integral component to increase slowly. The integral response will
continually increase over time unless the error is zero, so the effect is to drive the Steady-
State error to zero. Steady-State error is the final difference between the process variable and
set point. A phenomenon called integral windup results when integral action saturates a
controller without the controller driving the error signal toward zero.
Derivative Response The derivative component causes the output to decrease if the process variable is increasing
rapidly. The derivative response is proportional to the rate of change of the process variable.
Increasing the derivative time (Td) parameter will cause the control system to react more
strongly to changes in the error term and will increase the speed of the overall control system
response. Most practical control systems use very small derivative time (Td), because the
Derivative Response is highly sensitive to noise in the process variable signal. If the sensor
feedback signal is noisy or if the control loop rate is too slow, the derivative response can
make the control system unstable
60
4.6.4 Definition of Terminologies
The control design process begins by defining the performance requirements. Control system
performance is often measured by applying a step function as the set point command
variable, and then measuring the response of the process variable. Commonly, the response is
quantified by measuring defined waveform characteristics such as:
-Rise Time is the amount of time the system takes to go from 10% to 90% of the steady-
state, or final, value.
-Percent Overshoot is the amount that the process variable overshoots the final value,
expressed as a percentage of the final value.
-Settling time is the time required for the process variable to settle to within a certain
percentage (commonly 5%) of the final value.
-Steady-State Error is the final difference between the process variable and set point.
Note that the exact definition of these quantities will vary in industry and academia.
Figure 4-7 graph showing PID definition of terminologies
After using one or all of these quantities to define the performance requirements for a control
system, it is useful to define the worst case conditions in which the control system will be
expected to meet these design requirements. Often times, there is a disturbance in the system
that affects the process variable or the measurement of the process variable.
In some cases, the response of the system to a given control output may change over time or
in relation to some variable. A nonlinear system is a system in which the control parameters
that produce a desired response at one operating point might not produce a satisfactory
response at another operating point. For instance, a chamber partially filled with fluid will
exhibit a much faster response to heater output when nearly empty than it will when nearly
full of fluid. The measure of how well the control system will tolerate disturbances and
61
nonlinearities is referred to as the robustness of the control system.
Some systems exhibit an undesirable behavior called dead time. Dead time is a delay
between when a process variable changes, and when that change can be observed. For
instance, if a temperature sensor is placed far away from a cold water fluid inlet valve, it will
not measure a change in temperature immediately if the valve is opened or closed. Dead time
can also be caused by a system or output actuator that is slow to respond to the control
command, for instance, a valve that is slow to open or close.
Loop cycle is also an important parameter of a closed loop system. The interval of time
between calls to a control algorithm is the loop cycle time. Systems that change quickly or
have complex behavior require faster control loop rates.
Figure 4-8 graph showing dead time
4.6.5 Distance speed PID
When distance detected by sensor is less than the desired safe distance the car will slow
down but by what value …, this is why PID is used to control speed of car according to
distance
PID has a set point which is X , an input which is reading from ultrasonic , tuning parameters
Kp Ki Kd , and an output which is the speed of car
when distance decrease the speed decrease by a certain amount if this amount is not enough
to reach the safe desired distance the speed will decrease again and will increase if distance
detected increase
there is a limit of speeds set for the PID to have as an output
for example: if the cruise speed is Y
then the limits for PID output will be from 0 to a value less than Y
62
Trial and error method Tuning method
Trial and Error Method: It is a simple method of PID controller tuning. While system or
controller is working, we can tune the controller. In this method, first we have to set Ki and
Kd values to zero and increase proportional term (Kp) until system reaches to oscillating
behavior. Once it is oscillating, adjust Ki (Integral term) so that oscillations stops and finally
adjust D to get fast response.
By following the previous steps using Arduino codes and Matlab to graph the performance of
the dc motor, we obtained the values of kp, ki and kd
kp=4, ki=0.02 and kd=0.01
4.6.6 Speed PID Theory of DC motor speed control
The speed of a DC motor is directly proportional to the supply voltage, so if we reduce the
supply voltage from 12 Volts to 6 Volts, the motor will run at half the speed. How can this be
achieved when the battery is fixed at 12 Volts?
The speed controller works by varying the average voltage sent to the motor. It could do this
by simply adjusting the voltage sent to the motor, but this is quite inefficient to do. A better
way is to switch the motor's supply on and off very quickly. If the switching is fast enough,
the motor doesn't notice it, it only notices the average effect.
When you watch a film in the cinema, or the television, what you are actually seeing is a
series of fixed pictures, which change rapidly enough that your eyes just see the average
effect - movement. Your brain fills in the gaps to give an average effect.
Now imagine a light bulb with a switch. When you close the switch, the bulb goes on and is
at full brightness, say 100 Watts. When you open the switch it goes off (0 Watts). Now if you
close the switch for a fraction of a second, then open it for the same amount of time, the
filament won't have time to cool down and heat up, and you will just get an average glow of
50 Watts. This is how lamp dimmers work, and the same principle is used by speed
controllers to drive a motor. When the switch is closed, the motor sees 12 Volts, and when it
is open it sees 0 Volts. If the switch is open for the same amount of time as it is closed, the
motor will see an average of 6 Volts, and will run more slowly accordingly.
As the amount of time that the voltage is on increases compared with the amount of time that
it is off, the average speed of the motor increases.
This on-off switching is performed by power MOSFETs. A MOSFET (Metal-Oxide-
Semiconductor Field Effect Transistor) is a device that can turn very large currents on and
off under the control of a low signal level voltage.
The time that it takes a motor to speed up and slow down under switching conditions is
dependent on the inertia of the rotor (basically how heavy it is), and how much friction and
63
load torque there is. The graph below shows the speed of a motor that is being turned on and
off fairly slowly.
Figure 4-9 On and off switching method of motor
You can see that the average speed is around 150, although it varies quite a bit. If the supply
voltage is switched fast enough, it won’t have time to change speed much, and the speed will
be quite steady. This is the principle of switch mode speed control. Thus the speed is set by
PWM – Pulse Width Modulation.
Ziegler Nicholas tuning method
Ziegler–Nichols Rules for Tuning PID Controllers. Ziegler and Nichols proposed rules for
determining values of the proportional gain integral time and derivative time based on the
transient response characteristics of a given plant. Such determination of the parameters of
PID controllers or tuning of PID controllers can be made by engineers on-site by experiments
on the plant. There are two methods called Ziegler–Nichols tuning rules: the first method and
the second method
First Method
In the first method, we obtain experimentally the response of the plant to a unit-step input, as
shown in Figure 4-10 .If the plant involves neither integrator(s) nor dominant complex-
conjugate poles, then such a unit-step response curve may look S-shaped, as shown in Figure
4-11 .This method applies if the response to a step input exhibits an S-shaped curve. Such
step-response curves may be generated experimentally or from a dynamic simulation of the
plant. The S-shaped curve may be characterized by two constants, delay time L and time
constant T. The delay time and time constant are determined by drawing a tangent line at the
inflection point of the S-shaped curve and determining the intersections of the tangent line
with the time axis and line c(t)=K, as shown in Figure 4-11
Figure 4-10 Unit-step response of a plant.
64
Figure 4-11 S-shaped response curve.
The transfer function C(s)/U(s) may then be approximated by a first-order system with a
transport lag as follows:
Ziegler and Nichols suggested to set the values of and according to the formula
The PID controller tuned by the first method of Ziegler–Nichols rules gives:
Thus, the PID controller has a pole at the origin and double zeros at s=–1/L.
Second Method. In the second method, we first set and Using the proportional control
action only see Figure 4-12 increase Kp from 0 to a critical value Kcr at which the output
first exhibits sustained oscillations.(If the output does not exhibit sustained oscillations
for whatever value Kp may take, then this method does not apply.)
65
Figure 4-12 Closed-loop system with a proportional controller.
Figure 4-13 Sustained oscillation with period Pcr
Thus, the critical gain Kcr and the corresponding period are experimentally determined
(see Figure 4-13). Ziegler and Nichols suggested that we set the values of the parameters
and according to the formula shown
The PID controller tuned by the second method of Ziegler–Nichols rules gives:
Thus, the PID controller has a pole at the origin and double zeros at s =4/Pcr .
Thus, we used first method of Ziegler Nicholas tuning as the system step response is S-
shaped and followed its steps by using Arduino and Matlab
1-we give dc motor pwm=255 by Arduino code to draw RPM with time by using Matlab
code.
66
Figure 4-14 step response of motor.
2-use Matlab code to smooth the curve and draw tangent to get T and L
Figure 4-15 step response with tangent.
T=164 L =6.7
3-calculate kp,ki and kd
we get from equations Kp=29.3 Ki=2.18 Kd=98
67
4-put calculated values of PID constants in PID code to control the motor to check the motor
response with these values by Matlab graph.
Figure 4.16 system performance.
4.7 Application in real cars
The driver selects the desired speed and sets the distance to be maintained to the vehicle
ahead. This gap can be set at several distances, adapting to the driving situation and
individual driving style. Standard ACC can be activated from speeds of around 30 km/h (20
mph) upwards and can support the driver, primarily on cross-country journeys or on
freeways.
A radar sensor monitors the driving situation ahead of the vehicle. The sensor transmits radar
waves that are reflected by objects in front of the vehicle. Based on the reflected signals,
ACC can detect preceding vehicles by calculating distance, direction and relative speed of
the vehicle ahead. In addition, ACC predicts the course of its own vehicle and can then
decide whether any of the vehicles ahead are relevant for distance control.
As long as the road ahead is clear, ACC maintains the speed set by the driver. If ACC detects
a preceding vehicle at lower speed, it adjusts the speed to match the vehicle ahead, ensuring
that the predefined minimum distance is kept. At lower speed deviations this can be realized
by reducing acceleration. If the detected vehicle is slower, ACC moderately brakes the
vehicle
If the preceding vehicle increases speed or clears the lane, ACC accelerates up to the desired
preset speed.
68
Lane Keeping
Chapter 5
69
5.1 Introduction
Many single-vehicle roadway departure (SVRD) accidents take place in uncritical traffic
situations and good weather conditions. According to accident data over the last 10 years
from German roadways that 14.5 percent of all accidents were due to unintended lane
departure, 35 per cent of these with deadly consequences. Reasons for lane departure are
many and range from the driver’s inability to control the vehicle (for example, on account of
severe weather conditions) to lack of attention, drowsiness, and intoxication or illness
leading to the loss of lane- keeping control.
Lane Keeping is a feature that in addition to Lane Departure Warning System automatically
takes steps to ensure the vehicle stays in its lane. Some vehicles combine adaptive cruise
control with lane keeping systems to provide additional safety.
A lane keeping mechanism can either
reactively turns a vehicle back into the lane if it
starts to leave or proactively keep the vehicle in
the center of the lane. Vehicle companies often
use the term "Lane Keeping" to refer to both
reactive Lane Keep and proactive Lane
Centering but the terms are beginning to be
differentiated.
5.2 History
The first production lane departure warning system in Europe was developed by the United
States company Iteris for Mercedes Actros commercial trucks. The system debuted in 2000,
and is now available on most trucks sold in Europe.
In 2002, the Iteris system became available on Freightliner Trucks' North American vehicles.
In both these systems, the driver is warned of unintentional lane departures by an
audible rumble strip sound generated on the side of the vehicle drifting out of the lane. No
warnings are generated if, before crossing the lane, an active turn signal is given by the
driver.
5.3 Timeline of available systems
1992: Mitsubishi Motors began offering a camera-assisted lane-keeping support system on
the Mitsubishi Debonair sold in Japan.
2001: Nissan Motors began offering a lane-keeping support system on the Cima sold in
Japan.
2002: Toyota introduced its Lane Monitoring System on models such as the Cardina
and Alphard sold in Japan; this system warns the driver if it appears the vehicle is beginning
to drift out of its lane. In 2004, Toyota added a Lane Keeping Assist feature to the Crown
Majesta which can apply a small counter-steering force to aid in keeping the vehicle in its
70
lane. In 2006, Lexus introduced a multi-mode Lane Keeping Assist system on the LS 460,
which utilizes stereo cameras and more sophisticated object- and pattern-recognition
processors. This system can issue an audiovisual warning and also (using the Electric Power
Steering or EPS) steer the vehicle to hold its lane. It also applies counter-steering torque to
help ensure the driver does not over-correct or "saw" the steering wheel while attempting to
return the vehicle to its proper lane. If the radar cruise control system is engaged, the Lane
Keep function works to help reduce the driver's steering-input burden by providing steering
torque; however, the driver must remain active or the system will deactivate.
2003: Honda launched its Lane Keep Assist System (LKAS) on the Inspire. It provides up to
80% of steering torque to keep the car in its lane on the highway. It is also designed to make
highway driving less cumbersome, by minimizing the driver's steering input. A camera,
mounted at the top of the windshield just above the rear-view mirror, scans the road ahead in
a 40-degree radius, picking up the dotted white lines used to divide lane boundaries on the
highway. The computer recognizes that the driver is "locked into" a particular lane, monitors
how sharp a curve is and uses factors such as yaw and vehicle speed to calculate the steering
input required.
2004: In 2004, the first passenger-vehicle system available in North America was jointly
developed by Iteris and Valeo for Nissan on the Infiniti FX and (in 2005) the M vehicles. In
this system, a camera (mounted in the overhead console above the mirror) monitors the lane
markings on a roadway. A warning tone is triggered to alert the driver when the vehicle
begins to drift over the markings.
2005: Citroën became the first in Europe to offer LDWS on its 2005 C4 and C5 models, and
its C6. This system uses infrared sensors to monitor lane markings on the road surface, and a
vibration mechanism in the seat alerts the driver of deviations.
2007: In 2007, Audi began offering its Audi Lane Assist feature for the first time on the Q7.
This system, unlike the Japanese "assist" systems, will not intervene in actual driving; rather,
it will vibrate the steering wheel if the vehicle appears to be exiting its lane. The LDW
System in Audi is based on a forward-looking video-camera in its visible range, instead of
the downward-looking infrared sensors in the Citroën. Also in 2007, Infiniti offered a newer
version of its 2004 system, which it called the Lane Departure Prevention (LDP) system.
This feature utilizes the vehicle stability control system to help assist the driver maintain lane
position by applying gentle brake pressure on the appropriate wheels.
2008: General Motors introduced Lane Departure Warning on its 2008 model-
year Cadillac STS, DTS and Buick Lucerne models. The General Motors system warns the
driver with an audible tone and a warning indicator on the dashboard. BMW also introduced
Lane Departure Warning on the 5 series and 6 series, using a vibrating steering wheel to
warn the driver of unintended departures. In late 2013 BMW updated the system with Traffic
Jam Assistant appearing first on the redesigned X5, this system works below 25
mph. Volvo introduced the Lane Departure Warning system and the Driver Alert Control on
its 2008 model-year S80, the V70 and XC70 executive cars. Volvo's lane departure warning
system uses a camera to track road markings and sound an alarm when drivers depart their
71
lane without signaling. The systems used by BMW, Volvo and General Motors are based on
core technology from Mobileye.
2009: Mercedes-Benz began offering a Lane Keeping Assist function on the new E-class.
This system warns the driver (with a steering-wheel vibration) if it appears the vehicle is
beginning to leave its lane. Another feature will automatically deactivate and reactivate if it
ascertains the driver is intentionally leaving his lane (for instance, aggressively cornering). A
newer version will use the braking system to assist in maintaining the vehicle's lane. In 2013
on the redesigned S-class Mercedes began Distronic Plus with Steering Assist and Stop &Go
Pilot.
2010: Kia Motors offered the 2011 Cadenza premium sedan with an optional Lane Departure
Warning System (LDWS) in limited markets. This system uses a flashing dashboard icon and
emits an audible warning when a white lane marking is being crossed, and emits a louder
audible warning when a yellow-line marking is crossed. This system is canceled when a turn
signal is operating, or by pressing a deactivation switch on the dashboard; it works by using
an optical sensor on both sides of the car.
Fiat is also launching its Lane Keep Assist feature based on TRW's lane keeping assist
system (also known as the Haptic Lane Feedback system). This system integrates the lane-
detection camera with TRW's electric power-steering system; when an unintended lane
departure is detected (the turn signal is not engaged to indicate the driver's desire to change
lanes), the electric power-steering system will introduce a gentle torque that will help guide
the driver back toward the center of the lane. Introduced on the Lancia Delta in 2008, this
system earned the Italian Automotive Technical Association's Best Automotive Innovation of
the Year Award for 2008. Peugeot introduced the same system as Citroën in its new 308.
5.4 Application in real cars Lane keeping (LK) system is one of the important technologies in the development of
advanced safety vehicle (ASV).
The lane keeping system mainly consists
of three parts: lane departure detection,
lane keeping control algorithm and
electric power steering system.
The lane departure detection module of
the lane keeping system uses a
CCD camera fixed on the windscreen
behind the rearview mirror to take
roadway image in front of the car. Such
that these images are being processed to extract the lane marking and decide the essential
lane model such as lateral
displacement and curvature.
Figure 5-1 Lane-keeping system structure
72
The processed image is 2D that is being transformed into 3D space information, since the
system has to locate lane markings and the preceding vehicle in the image coordinates.
Those images are considered to be an input to the lane keeping controller. Lane keeping
controller will process them and calculate the steering angle and torque value through lane
keeping control algorithm. Finally, the motor of electric power steering will be controlled
according to the steering angle and torque command. This electric power steering system
consists of a torque sensor, an electric motor, a reduction gear, a column and a rack–pinion
mechanism.
5.5 Limitations of Lane keeping Systems in real cars
Modern lane departure warning systems are more reliable than earlier iterations of the
technology, but even the most advanced examples have limitations. These systems often rely
on visual information to track the relative position of a vehicle within its lane, so anything
that obscures the lane markers will render the technology useless. That means you usually
can’t depend on your LDW or LKS in heavy rain, snow, or if there is excessive glare from
the sun. Also lane keeping cannot be used in some other conditions because doing so may
result in several accidents such as: roads with sharp edges, when entering a sharp curve into
an interchange or junction, the stereo cameras’ field of view is obstructed.
5.6 Prototyping of Lane-keeping
Our prototype is a simulation of what happens in a real car by using an electrical car with
some electrical components.
5.6.1 Basic components:
1. Servo motor.
(Changes the angle of rotation to take the correct decision among road curvatures)
2. DC motor.
3. Dual H-bridge.
4. 2- Line tracking sensor (Detecting lane markings).
5.6.2 Algorithm
In the following lines, we are going to state the algorithm that we are going to follow to
implement this feature.
We have two infrared line tracking sensors that are handled in the two front sides of the car
(one on the front left side and one on the front right side). Those two sensors are always
checking the white lines in both sides. When any of the two sensors detects a white line (The
white line is an indication for the lane markings), an action is taken according to this
detection. This action is set inside an interrupt service routine so that the sensors give fast
response. For example, if the right sensor detects the white line, the car turns left till moving
73
away from the line and then move forward until being straight. If the other left sensor detects
the line, it performs the same action as the right sensor but turn right. While if the car is
moving straight and none of the two sensors detects the white line, the car do not enter the
interrupt service routine and keep moving forward with the set speed of the function and do
not turn right or left. The following figure shows the flowchart of our algorithm.
Figure 5-2 Lane-keeping flowchart
5.6.3 Implementation and testing
First, we tested the most important hardware components that are used to fulfill the feature in
a right performance. And as mentioned above, this function is mainly based on the servo
motor and the IR line tracking sensor.
The type and the theory of operation of the servo motor was typically as mentioned in
chapter two and testing it was by checking its zero position and getting its maximum left and
right angles. Concerning the IR line tracking sensor, we have two sensors that were fixed on
both front sides of our car beside the wheels. The testing phase of the sensor, was by
checking if it is correctly can differentiate between the white and black colors of the track
model. This type of sensor reads 1 if it detects white and 0 if it detects black.
Second, we decided to implement this feature firstly on only one side of the car and after
approaching this implementation and overcoming all the problems faced we did the same
steps and solutions on the other side.
74
Third, we started working on this function by the first car mechanical design that was long
and unstable. Concerning the track we worked on leather and drew the initial path of the
track as shown:
Figure 5-3 Showing first car design length.
Figure 5-4 first track material
Unfortunately, this step faced a problem that the sensor response was very slow and not
accurate such that whenever it detects the lane markings it takes some time before taking the
decision to go back to the lane or its center. We overcame this problem by adding some
modifications in the code. Those modifications were adding the reaction to the sensor
reading in an interrupt service routine so whenever it detects a line it directly goes and apply
what is required in the routine. The following is a shot of our code which shows how we
solved this problem.
75
Fourth, we continued working with the same car with the same material but there occurred
another problem which was because the car goes out of lane when steering or taking the
curvature of the path and also the car was very slow. We found that those problems were
because of two main reasons. The first reason, the car design length was very long and it was
not similar to any aspects ratio of any real car while the second reason was that the car
wheels friction to the path material was not suitable to implement our feature. So overcoming
those problems was by two things. The solution of the first problem was changing the car
design by minimizing its length to meet the aspects ratio of a real car. While for the second
problem was by changing the track material to vinyl banner which helped to solve the
previous problem. The following figures will show the final car design and final track
material.
Figure 5-5 final track path and material
76
Figure 5-6 final car design length.
Fifth, we worked with the previous results but there was a final problem (steering problem)
which appears clearly when the car is taking the shown curvature when it turns, it stops. So it
was obvious that this problem is a result of low torque of the Dc motor such that it does not
have enough power to push the motor to take the curvature and move with the set speed.
Before mentioning this problem solution, we firstly have to talk about the source of current
given to Dc motor. Dc motor mainly gets its current from the Dual h bridge that was
mentioned before in chapter 3 by connecting our motor to one channel only but we changed
the connection of the motor to the driver by connecting the two channels together then taking
a wire to the battery which means that the total current that is supported by the bridge is
totally given to the motor. By increasing current the torque problem is solved. The following
figure shows the new connection of the Dual H-bridge:
Figure 5-7 new connection of Dual H-bridge.
After solving all the above problems, the feature performance was typically as required.
Finally, we implemented the function of lane keeping on the right side of the car. It
performed well as the left sensor.
77
5.6.4 Limitations of the implemented model
1. The inaccuracy of the used IR sensor.
2. The system will not perform well when facing sharp edges and this problem typically
appears in real cars as Subaru motors and they are working to solve this problem in
the near future.
5.7 Conclusion
The previous implemented prototype has succeeded in performing a good analogy between
the real system in passenger cars and our model. This analogy was validated by the means of
software and hardware components. Also the implemented system results show the system
can keep our car model driven within the lane center area, and further more prevent it from
any collisions caused by the unintentional lane departure.
78
Lane departure
Chapter 6
79
6.1 Definition
A lane change has been defined as a deliberate and substantial shift in the lateral position of a
vehicle (Chovan et al., 1994). Worrall and Bullen (1970) described a lane change in three
parts: the head portion is the time and distance required for a vehicle to move from a straight-
ahead path to the first intercept of the lane line. The actual lane change starts when a vehicle
first encroaches on the lane line between the original and destination lanes. The maneuver
ends once the vehicle has completely crossed that line. The tail portion of the maneuver is the
time and distance required for a vehicle to return to a straight-ahead path in the destination
lane after crossing the lane line. Another view, offered by Van Winsum et al. (1999),
describes three sequential phases of the lane-change maneuver based on steering. The first
phase is an initial turn of the steering wheel to a maximum angle. The second phase begins
when the steering wheel is turned in the opposite direction and ends when the vehicle
heading approaches a maximum that occurs when the steering wheel angle passes through
zero (straight-ahead). During the third phase, the steering wheel is turned to a maximum
angle in the opposite direction to
stabilize the vehicle in the new
lane. This definition is useful when
only steering data is available.
However, lane changes performed
in curves may not be captured if
the driver does not reverse the
angle of the steering wheel.
Consideration for road geometry is
also required to operationally define a lane change. Wierwille (1984) described a lane change
in two parts. A heading deviation is introduced by a steering input that results in buildup of
lateral deviation. As the vehicle approaches the correct lateral position in the adjacent lane,
the heading deviation is removed by applying a steering correction in the direction opposite
that of the initial steering input. Lane changes can occur for a variety of reasons, such as
entering the roadway (merging), preparing to exit the roadway, anticipating vehicles merging
onto the roadway, anticipating a slowing lead vehicle, a change in the number of lanes
available, and swerving to avoid a forward crash threat such as a rapidly decelerating lead
vehicle. One of the most common types of lane change is a maneuver in which a driver
changes lanes to pass a slower lead vehicle to maintain current speed (Fancher, 1999;
Hetrick, 1997).
80
6.2 Introduction
Transportation researchers estimate that lane change crashes account for 4 to 10% of all
crashes (Barr & Najm, 2001; Eberhard et al., 1994; Wang & Knipling, 1994; Young,
Eberhard & Moffa, 1995). Research has revealed that most drivers in lane change crashes did
not attempt an avoidance maneuver; this suggests that the driver did not see or was unaware
of the presence of another vehicle or crash hazard (Chovan, Tijerina, Alexander &
Hendricks, 1994; Eberhard et al.; Tijerina, 1999). According to Knipling (1993), 75% of lane
change/merge crashes involve a recognition failure by the driver. Thus, to reduce lane change
crashes, it would seem that drivers must be made aware of impending hazards before lane
change initiation (Chovan et al.; Tijerina). The general objective of our project was to
perform lane change according to some data. This data was sent from some sensors to the car
and as a result our car takes the correct decision.
6.3 Basic components
1. Servo motor
2. Dc motor
3. Dual H-bridge.
4. Five ultrasonic sensors
*The front sensor is used to check the distance of the front target
*The two right side sensors are used to check the clearance distance of the right lane.
*The two left side sensors have the same function of the right ones but for the left
lane.
5. Two infrared line tracking sensors
*One sensor in the left and one in the right side. If any of them becomes high the
function of the lane departure stops according to the direction of motion.
6.4 Implementation
We implemented the lane departure code alone before merging without taking into
consideration other functions or codes:
First we began to implement a code just to make the car go straight in the middle of the lane
then turn right to find out the angle fits changing the car lane, we tried several angles to find
the perfect angle fits several positions of changing the lane.
Second we thought about how to stop the car from turning right, how the car will know that
it is in the new lane and should go straight in the middle of it. This could be implemented by
using the white line separates between the new lane and the old one as when the car turns
right to change the lane it steps above the white line and the IR sensor gives high so at this
moment the car goes straight for a while and then left to be in the middle of the new lane.
After this step we have already reached how the car will change its lane correctly.
81
Third we added the condition or the cause that will make the car change its lane, when the
distance measured by the front ultrasonic is small (less than 30 cm) for two successive times
it takes the action of lane departure, we checked the condition with changing the lane.
Fourth we did the same steps for the left side of the car.
Fifth we thought about what if the next lane is not empty or there is a car in it and our car
couldn’t change its lane, we used four sensors (two for the right side and two for the left side)
in the car body to add a condition for checking the lanes to find whether they are empty and
the car can make lane departure or not, so the car should stay on its lane and follow ACC
commands, if the front sensor’s distance is less than thirty cm it goes and check both sides’
sensors to find which lane is empty and goes to it (right lane or left lane) by following lane
departure steps if there is no empty lane it stays in its lane and doesn’t change it.
Sixth we merged all the conditions and the lane departure implemented correctly and did its
function as supposed.
6.5 Algorithm
6.5.1 Concept
-In real life a car change lanes if there is another car in front of it and distance between the
two cars is very small or that car is really slowing down the driver then checks next lanes if
one of them is empty he changes lane if not then he stays in his lane
-Similarly this is what our car is doing as shown in figure
82
6.5.2 Algorithm
Figure 6-1 lane departure flow chart
Microcontroller checks front distance periodically .If it’s in the range between 50 and 30 it
increases the counter by one each time but if it is not in this range it will put counter to zero.
As counter equals to 10 (10 successive times distance between 30 and 50 ) the car will
change lanes but before it does it has to decide which lane it will turn to so it checks first its
left sides if it is empty then change to left lane happens and then assign counter value to
zero , if it isn’t empty then checks right side if it is empty then change to right lane happens
and assign counter value to zero. If both lanes are busy then car remain in its lane moving
according to ACC
Change lane function
In change lane left the car want to move to its left lane so car starts turning left until the right
IR sensor detects lane which means that the whole car left its lane then car moves right then
straight to adjust its position
6.6 Applications in real life
Lane departure has not been implemented yet in real cars only lane departure warning for
lane keeping was implemented and most of the modern cars has it.
Companies are working hard to implement lane departure in the near future by research and
experiments; we will see lane departure in our real life very soon.
83
Integrating Functions
Chapter 7
84
Merging
Integration of three functions to work properly together and protect the car from collision by
adaptive cruise control (ACC), keeps car inside its lane by lane keeping and avoid traffic jam
by lane departure without any conflict between the codes.
7.1 Algorithm
Figure 7-1 lane keeping and lane departure flag flow chart
As IR sensor in right or left side reads high (on white lane line) Arduino executes ISR and
check whether lane_dep flag is 0 or 1.If lane_dep=1 the car does nothing and resume what it
was doing. If lane_dep=0 it makes lane keeping and follow its algorithm.
85
Figure 7-2 merging flow chart
The main function by which the car goes is ACC and according to the distance of front
ultrasonic decisions are made, interrupt_en is a variable act as a flag to differentiate between
moving straight with set speed or make lane keeping with fixed speed as this speed is
assigned by ACC.
If distance is bigger than set point it goes to check interrupt_en flag whether it is 0 or 1. If
interrupt_en=1 and IR sensor is high it follows lane keeping algorithm with constant speed .If
interrupt_en =0 car moves with set speed in straight direction according to ACC.
86
7.2 Implementation
First we started to merge lane keeping and ACC by using variable as a flag to differentiate
between ACC and lane keeping, making ACC responsible for speeds and lane keeping
responsible for directions.
Second we added lane departure, to stop lane keeping while lane departure. We used variable
as a flag always low for lane keeping and becomes high when lane departure condition
fulfilled.
According to these flags car knows which track to follow and no conflicts occur.
By integration between 3 functions we succeeded in making a car that is almost capable of
driving itself without a driver and do its functions well.
87
Auto parking
Chapter 8
88
8.1 Definitions
Too lazy to park (or just not very good at it)? Then let an automatic parking system remove
the effort and stress.
The aim of this function is to design and implement self-parking car system that moves a car
from a traffic lane into a parking spot through accurate and realistic steps which can be
applied on a real car.
8.2 Introduction
Self-Parking is an automatic parking system found in modern cars. It makes use of various
sensors, cameras, ...etc., to get information about the surroundings of a car and then use
complex processing algorithms to park the car parallel, perpendicular or angle parking based
on space without the help of the drive .Our project will be a miniature model of a real life car
which will sense the availability of parking space by using sensor and park itself
automatically parallel and perpendicular in the available parking area.
8.3 Application
Many car drivers today face a problem in parking their cars. Self-parking car can park into
smaller spaces than most drivers can manage it on their own. This makes it easier for people
to find parking spaces, and allows the same number of cars to take up small spaces. When
someone parallel parks, they often block a lane of traffic for at least a few seconds. If they
have problems getting into the spot, this can last for several minutes and seriously hold up
traffic. We have tried to handle this problem in our project by making an automated parking
car which parks itself. Auto parking is function in Google-self driving car.
89
8.4 Hardware
8.4.1Materials needed
L298N Dual H-Bridge Motor Controller module
Male to Male jumper wires
Raspberry Pi.
A DC Motor , 7-12v
Figure 8-1 H-bridge used with auto parking
Figure 8-2 male to male jumpers
Figure 8-3 Raspberry pi
Figure 8-4 second car DC motor
90
Ultrasonic sensor.
4 x AA or AAA battery holder and batteries.
1kΩ Resistor
2kΩ Resistor
Mini breadboard
Figure 8-5 ultrasonic sensor of second car
Figure 8-6 battery holder and batteries
Figure 8-7 resistance in second car connection
Figure 8-8 mini breadboard
91
8.4.2 Connection DC Motor
It consists of two DC motors were the first type widely used, since they could be powered
from existing direct-current lighting power distribution systems.
8.4.3 Connection through H-bridge
We'll start with the Dual H-Bridge Motor driver.
Figure 8-9 second car DC motor connection
So, depending on which GPIO pin we activate, it will out out +12V or -12V on the A output
or the B output. In the picture above, the motor is connected to the A output. If we wanted to
use a DC motor, we could use both A and B outputs, and change the code to pulse the GPIO
pins accordingly. For now, we're just using one output to a plain 5-12V DC motor.
Pins:
Out 1: Motor A lead out
Out 2: Motor A lead out
Out 3: Motor B lead out
Out 4: Mo (Can actually be from 5v35v, just marked as 12v)
GND: Ground
5v: 5v input (unnecessary if your power source is 7v35v, if the power source
is 7v35v then it can act as a 5v out)
EnA: Enables PWM signal for Motor A In1: Enable Motor A
In2: Enable Motor A
In3: Enable Motor B
92
In4: Enable Motor B
EnB: Enables PWM signal for Motor B
What is an "H-Bridge" and how does a DC motor change direction?
When you hook a dc motor up to + wire on one lead and - wire on the other lead, the
motor turns a certain direction. When you switch the wires to other leads, the motor turns the
other direction. But how do we "electronically" switch the electric polarity using
circuits. ANSWER: H-Bridge.
The circuits for H-Bridges are non-trivial for the beginner. The L298N module is a simple
ready to rock and roll "dual" H-bridge circuit board. That means you have the ability to
control TWO motors in either direction.
8.4.4 Connection of the battery
By using the power from batteries to run motors too. Purchase 6V DC batteries, (NOTE:
batteries are already DC power) to drive motors.
NEVER USE RASPBERRY PI built in power to DRIVE motors.
Dc motor sizing:
The power to your motor needs to match. The motors we have are 6V DC hobby motors. If
you're building something for real rather than just a quick learning tutorial like this one.
Make sure you match you power drive to the motor requirements. Every motor needs
different drive voltages. If you have less voltage than the motor needs then the motor will be
under powered and may not turn what you want or might burn your power supply out, or
worst start melting stuff. If your power supply is too high like for example you put 9 or 12
volts into a 6 volt motor, then the motor will turn really fast and hard. You see people hack
their kids toy race cars with bigger batteries, the cars go fast and have a ton more power than
the default design. These tricks always come at a costs for safety, reliability, and component
breaking (melting, fires etc.).
In our simple getting a motor to turn tutorial, a 5vDC old phone charger will suffice to drive
a 6v motor.
8.4.5 Connector wires for driving the direction on the motor with Raspberry Pi:
The "GPIO" pins on the Raspberry PI will be used to "trigger" the l298n direction.
93
Figure 8-10 Raspberry pi GPIO
There are TWO pins per motor. One pin drives the power, + to one lead when the pin is
activated.
If you have a PI2 or the newer B+ then there is a different pin layout for that. I did this one
with the older base model B.
I like the pin outs that show the actual unit so you can rotate it to match the one on your desk
next to your machine and get the correct pins. I'm always spatially screwing up, so I'll end up
hooking up the wrong pins and on the raspberry pi, the two wrong pins together could cause
the poor thing to burn out or at least only crash and reboot (this has happened to me many
times, so far lucky not the burn the PI up yet).
We used a bread board to make the wire connections easier.
1- Hook Raspberry USB micro charger up to your standard PI input.
2- Hook 2nd power supply for your DC motor up to the + - on the bread board.
8.4.6 Control Motor speed by PWM
By using Pulse Width Modulation (or PWM) is a technique for controlling power. We use it
here to control the amount of power going to the motor and hence how fast it spins.
94
Figure 8-11 PWM
Every 1/500 of a second, the PWM output will produce a pulse. The length of this pulse
controls the amount of energy that the motor gets. No pulse at all and the motor will not
turn, a short pulse and it will turn slowly. If the pulse is active for half the time, then
the motor will receive half the power it would if the pulse stayed high until the next
pulse came along
Using PWM in RPi.GPIO To create a PWM instance:
p = GPIO.PWM (channel, frequency)
To start PWM:
p.start (dc) # where dc is the duty cycle (0.0 <= dc <= 100.0)
To change the frequency:
p.ChangeFrequency (freq) # where freq is the new frequency in Hz
To change the duty cycle:
p.ChangeDutyCycle (dc) # where 0.0 <= dc <= 100.0
To stop PWM:
p.stop ()
Note that PWM will also stop if the instance variable 'p' goes out of scope.
Concept of software PWM:
By changing voltage of battery then change voltage of motor and control its speed by duty
cycle
95
8.4.7 Connection of ultrasonic sensor Range Sensor on the Raspberry Pi
A basic ultrasonic sensor consists of one or more ultrasonic transmitters (basically speakers),
a receiver, and a control circuit. The transmitters emit a high frequency ultrasonic sound,
which bounce off any nearby solid objects. Some of that ultrasonic noise is reflected and
detected by the receiver on the sensor. That return signal is then processed by the control
circuit to calculate the time difference between the signal being transmitted and received.
This time can subsequently be used, along with some clever math, to calculate the distance
between the sensor and the reflecting object.
The HC-SR04 Ultrasonic sensor we’ll be using for the Raspberry Pi has four pins:
ground (GND), Echo Pulse Output (ECHO), Trigger Pulse Input (TRIG), and 5V Supply
(Vcc). We power the module using Vcc, ground it using GND, and use our Raspberry Pi to
send an input signal to TRIG, which triggers the sensor to send an ultrasonic pulse. The pulse
waves bounce off any nearby objects and some are reflected back to the sensor. The sensor
detects these return waves and measures the time between the trigger and returned pulse, and
then sends a 5V signal on the ECHO pin. ECHO will be “low” (0V) until the sensor is
triggered when it receives the echo pulse. Once a return pulse has been located ECHO is set
“high” (5V) for the duration of that pulse. Pulse duration is the full time between the sensor
outputting an ultrasonic pulse, and the return pulse being detected by the sensor receiver. Our
Python script must therefore measure the pulse duration and then calculate distance from
this.
96
Using Voltage Dividers:
The sensor output signal (ECHO) on the HC-SR04 is rated at 5V. However, the input pin on
the Raspberry Pi GPIO is rated at 3.3V. Sending a 5V signal into that unprotected 3.3V input
port could damage your GPIO pins, which is something we want to avoid! We’ll need to use
a small voltage divider circuit, consisting of two resistors, to lower the sensor output voltage
to something our Raspberry Pi can handle.
A voltage divider consists of two resistors (R1 and R2) in series connected to an input
voltage (Vin), which needs to be reduced to our output voltage (Vout). In our circuit, Vin
will be ECHO, which needs to be decreased from 5V to our Vout of 3.3V.
The following circuit and simple equation can be
applied to many applications where a voltage
needs to be reduced. If you don’t want to learn the
techy bit, just grab 1 x 1kΩ and 1 x 2kΩ resistor.
So, we’ll use a 1kΩ for R1 and a 2kΩ resistor as R2
as shown:
Figure 8-12 voltage divider circuit
97
Assemble the Circuit
We’ll be using four pins on the Raspberry Pi
for this project: GPIO 5V [Pin 2]; Vcc (5V
Power), GPIO GND [Pin 6]; GND (0V Ground), GPIO 23 [Pin 16]; TRIG (GPIO Output)
and GPIO 24 [Pin 18]; ECHO (GPIO Input)
:
Figure 8-13 ultrasonic sensor connection with Rpi
98
Steps
1. Plug four of your male to female jumper wires into the
pins on the HC-SR04 as follows: Red; Vcc, Blue; TRIG,
Yellow; ECHO and Black; GND.
2. Plug Vcc into the positive rail of your breadboard, and
plug GND into your negative rail.
3. Plug GPIO 5V [Pin 2] into the positive rail, and GPIO
GND [Pin 6] into the negative rail
4. Plug TRIG into a blank rail, and plug that rail into GPIO
23 [Pin 16]. (You can plug TRIG directly into GPIO 23 if
you want).
5. Plug ECHO into a blank rail, link another blank rail
using R1 (1kΩ resistor)
6. Link your R1 rail with the GND rail using R2 (2kΩ
resistor). Leave a space between the two resistors.
7. Add GPIO 24 [Pin 18] to the rail with your R1 (1kΩ resistor). This GPIO pin needs to sit
between R1 and R2
That's it! Our HC-SR04 sensor is connected to our Raspberry Pi as shown:
Figure 8-15 ultrasonic real shot connection with Rpi.
Figure 8-14 ultrasonic sensor pins
99
Sensing with Python
Now that we’ve hooked our Ultrasonic Sensor up to our Pi, we need to program a Python
script to detect distance.
The Ultrasonic sensor output (ECHO) will always output low (0V) unless it’s been triggered
in which case it will output 5V (3.3V with our voltage divider!). We therefore need to set one
GPIO pin as an output, to trigger the sensor, and one as an input to detect the ECHO voltage
change.
First, import the Python GPIO library, import our time library (so we make our Pi wait
between steps) and set our GPIO pin numbering.
Import RPi.GPIO as GPIO
import time
GPIO.setmode (GPIO.BCM)
Next, we need to name our input and output pins, so that we can refer to it later in our Python
code.
We’ll name our output pin (which triggers the sensor) GPIO 23 [Pin 16] as TRIG, and our
input pin (which reads the return signal from the sensor) GPIO 24 [Pin 18] as ECHO.
TRIG = 23
ECHO = 24
we’ll then print a message to let the user know that distance measurement is in progress. . . .
Print "Distance Measurement in Progress"
Next, set your two GPIO ports as either inputs or outputs as defined previously.
GPIO.setup (TRIG, GPIO.OUT)
GPIO.setup (ECHO, GPIO.IN)
then, ensure that the Trigger pin is set low, and give the sensor a second to settle.
GPIO.output (TRIG, False)
print "Waiting for Sensor to settle"
time. Sleep(2)
The HC-SR04 sensor requires a short 10uS pulse to trigger the module, which will cause the
sensor to start the ranging program (8 ultrasound bursts at 40 kHz) in order to obtain an echo
response. So, to create our trigger pulse, we set out trigger pin high for 10uS then set it low
again.
GPIO.output (TRIG, True)
time. Sleep (0.00001)
GPIO.output(TRIG, False)
Now that we’ve sent our pulse signal we need to listen to our input pin, which is connected to
ECHO.
The sensor sets ECHO too high for the amount of time it takes for the pulse to go and come
back, so our code therefore needs to measure the amount of time that the ECHO pin stays
high. We use the “while” string to ensure that each signal timestamp is recorded in the
correct order.
100
The time.time () function will record the latest timestamp for a given condition. For example,
if a pin goes from low to high, and we’re recording the low condition using the time.time ()
function, the recorded timestamp will be the latest time at which that pin was low.
Our first step must therefore be to record the last low timestamp for ECHO (pulse_start) e.g.
just before the return signal is received and the pin goes high.
While GPIO.input (ECHO) ==0:
pulse_start = time.time ()
Once a signal is received, the value changes from low (0) to high (1), and the signal will
remain high for the duration of the echo pulse. We therefore also need the last high
timestamp for ECHO (pulse_end).
While GPIO.input (ECHO) ==1:
pulse_end = time.time ()
we can now calculate the difference between the two recorded timestamps, and hence the
duration of pulse (pulse_duration).
pulse_duration = pulse_end - pulse_start
with the time it takes for the signal to travel to an object and back again, we can calculate the
distance using the following formula.
The speed of sound is variable, depending on what medium it’s travelling through, in
addition to the temperature of that medium. However, some clever physicists have calculated
the speed of sound at sea level so we’ll take our baseline as the 343m/s. If you’re trying to
measure distance through water,
This is where you’re falling down – make sure you’re using the right speed of sound!
We also need to divide our time by two because what we’ve calculated above is actually the
time it takes for the ultrasonic pulse to travel the distance to the object and back again. We
simply want the distance to the object! We can simplify the calculation to be completed in
our Python script as follows:
We can plug this calculation into our Python script:
distance = pulse_duration x 17150
Now we need to round our distance to 2 decimal places (for neatness!)
Distance = round (distance, 2)
Then, we print the distance. The below command will print the word “Distance:” followed
101
by the distance variable, followed by the unit “cm”
print "Distance:” distance,"cm"
Finally, we clean our GPIO pins to ensure that all inputs/outputs are reset
GPIO.cleanup ()
Using three ultrasonic sensor to get Information about the surroundings of a car
Two in the front side and back side of the car the last one in the back of
Figure 8-16 second car final shot
102
Testing:
Figure 8-17 testing ultrasonic code
103
8.5 Parking types
The first thing you have to consider is the size of the car you are driving. This is major for
calculating distances. Depending on whether you are doing parallel or perpendicular parking.
1- Parallel parking
Parallel parking is a method of parking a
vehicle parallel to the road, in line with other
parked vehicles. Parallel parking usually
requires initially driving slightly past the
parking space, parallel to the parked vehicle in
front of that space, keeping a safe distance,
then followed by reversing into that space.
Subsequent position adjustment may require
the use of forward and reverse.
2- Perpendicular parking
Perpendicular parking is done at
a 90-degree angle to the curb.
Perpendicular spaces make
maneuvering the vehicle more
difficult than angle parking, but
the procedure requires fewer
steps than parallel parking.
Perpendicular parking is similar
to angle parking, but requires
greater care in turning. You will
find perpendicular parking in
most parking lots, which
normally
provide spaces marked in a 90-
degree angle to the curb or a
building.
Figure 8-18 parallel parking
Figure 8-19 perpendicular parking
104
3- Angle parking.
Angle parking is similar to perpendicular parking,
except the cars are aligned in an angle. Normally
the angle is aligned with the direction cars
approach the parking space. It makes it a lot easier
to drive into the parking space in contrast to
perpendicular parking, where the parking space is
at a 90 degree angle. With angle parking there is a
gentler turn. Not only is it easier to park, but it’s
also faster and the parking spaces are smaller,
making it possible to add more parking spaces in
the same size area. Normally you see angle paring
inside parking garages and on streets that are wide
enough to have room left for the traffic to pass.
8.6 Parallel Parking
Parallel parking is considered to be one of the
hardest skills for new drivers to learn and is a
required part of most road tests. Parallel parking enables the driver to park a vehicle in a
smaller space than would be true of forward parking. Driving forward into a parking space on
the side of a road is typically not possible unless two successive parking spaces are empty.
New drivers learn to use reference points to align themselves in relation to the car in front of
the space, to determine the proper angle for backing, and to determine when to turn the
steering wheel while backing.
8.6.1 Parallel Parking steps
Detecting Space
When front-side and back-side sensors detect enough space at the same time
Figure 8-21 finding parking area
Find a suitable space. Look for a space you can safely get your car into without hitting
another car. It's best to find a space that's a few feet (a meter or so) longer than your car.
Steps for parking:
Figure 8-20 angle parking
105
1- Stop at the same side in the front car by sensing two side sensors
Claim the space and position yourself to back in. When you see the space, signal toward it
and slow down. Approaching quickly, or in a truck, in which case you should brake gently at
first so they can see the lights and slow down safely. Pull up next to the car in front of the
space (or, at the end of the row of cars, where that car would be), close beside it and with the
middle of your car (the "B-pillar" between the doors) even with the rear of the next car.
2- Turning motor back-right by 45 degree.
Figure 8-23 step 2 for parallel parking
Turn and prepare to back in. Shift your vehicle into reverse to make sure the street behind
you is clear of traffic before you begin to back up.
Figure 8-24 rest of step 2 for parallel parking
Look over your other shoulder at the space to assess the gap. Turn the steering wheel hard
right, creating a 45 degree angle. When reversing, think of pushing (the top of) the wheel the
way you want the car to go.
Figure 8-22 step 1 for parallel parking
106
3- Stop turning motor back when its corner was in the same line with the front car
Figure 8-25 step 3 for parallel parking
Back most of the way in. Release the brakes and slowly begin turning somewhat sharply and
backing in to the space. While backing into the space often check in front of and around your
car. Continue until the rear wheel facing the curb is nearly as close as the final distance
desired from it (no more than 1 foot (30 cm) ultimately being desirable) and the rear end of
the car is still a few feet (about a meter) from the car behind.
4- Turning motor back-left until detecting Space Park in the right way
Figure 8-26 step 4 for parallel parking
Straighten out as you finish pulling in. Turn the steering wheel to the left once the rear of
your vehicle is mostly in the space, still going backward. (In a loose space, a good time to
make the switch is when your front bumper is next to the rear bumper of the car in front.)
You'll maneuver completely into the space and straighten out your car at the same time.
107
8.6.2 Algorithm:
Detect Space
Figure 8-27 parallel parking detect space state diagram
parking Algorithm:
8.7
Figure 8-28 parallel parking state diagram
108
8.7 Perpendicular parking
Remember the two important rules when parking is move slow and turn fast. Also remember
to always look behind when your car is moving in reverse.
8.7.1 Steps:
1. Detecting space by using side-front sensor if it detects enough space for parking, the
car will start parking.
2. Turning motor Front-left until back sensor measures small distance.
3. Turning motor Back-right until side-back sensor detects good space far from the
another car.
4. Turning motor front until the back sensor detect the end of parking space.
8.7.2 Perpendicular Parking Algorithm
Figure 8-29 perpendicular parking state diagram
109
8.8 Tuning method
We made a lot of Trials and there are a lot of error methods because of Problems:
o Due to mechanical design the turning curve is big with respect to the car
size!!
o Also RC car has small turning wheels which makes the curve inaccurate.
Solved by:
o Moving forward for enough space.
These will require plenty of extra room to complete the turn. Semi-trucks/vehicles with
trailers will turn backwards opposite the direction you turn your wheel
Figure 8-30 car moving forward for enough space
General sense of the dimensions of the area you will be parking in, Evaluate the size of the
parking spot. If you feel that the spot might not be a good fit.
Figure 8-31sensing perpendicular parking area dimensions.
110
Indoor Positioning
Chapter 9
111
9.1. Introduction
GPS (Global Positioning System ) is system to find location and position of the
objects ,receives the signal from the satellites and makes a triangulation process to
determine the locations of the objects.
Figure 9-1 Positioning Satellite in the orbit
As shown in figure9.1 The GPS is high accuracy in outdoor positioning However high
sensitivity GPS in positioning but the signal is attenuated and reflected by the building
materials in some indoor positioning, so GPS in indoor position system is very low accurate.
Indoor position systems used to locate the object inside the buildings and closed
environments. These systems use optical tracking's, wireless concepts or ultrasonic
techniques.
There are many methods for positioning system with different architectures to determine the
2D and 3D positions of objects. They have different accuracies, configurations, and
reliabilities.
We divided the localization system into active and passive system, the active system when
the persons or objects carry electronic device to send the signal or information to positioning
system to help it for knowing the position of object .In passive system, the persons or objects
don’t carry electronic device.
The position is estimated based on the variance of a measured signal .
112
Figure9-2 Localization systems
The most techniques used in indoor positioning are: Time of Arrival (TOA), Received Signal
Strength Indicator (RSSI), Time Difference of Arrival (TDOA) and Angle of Arrival (AOA)
. The following list represents a range of possible positioning technologies:
(1) Ultra-wideband (UWB)
(2) Wireless local area networks (WLANs)
(3) Field strength systems
(4) Next-generation indoor positioning systems
(5) Radio Frequency Identification (RFID).
There are mainly four technique are used in indoor positioning Algorithms.
113
9.2 Indoor positioning Algorithms
9.2.1 Angle of arrival (AOA Algorithm)
The angle of arrival (AoA) algorithm detect the angle of arrival of the mobile signal coming
from a known location at which it is received at multiple reference point.
Figure 9-3Triangulation
You are at A, from where you can see B and C.
To calculate the position by measuring two directions towards two reference points. Since
the positions of the reference points are known, it is hence possible to construct a triangle
where one of the sides and two of the angles are known, with the observer at the third point.
This information is enough to define the triangle completely and hence deduce the position
of the observer.
Using triangulation with transmitters requires the angle of incidence (angle of arrival, or
AoA) of a radio signal to be measured. This can be done using several antennas placed side
by side (an array of antennas, and to measure the phase difference between the signals
received by the antennas.
Figure 9-4 an antenna array
114
9.2.2 Time of arrival (TOA Algorithm)
TOA algorithm needs to measure the transmission time between the receiver and the
transmitter signal. The distance of the receiver and the transmitter can be got from the speed
and the measured time of the signal.
Figure 9-5 the length of the arrows corresponds to the arrival time at receiver P
Then the location of target estimates by using triangulation .ToA method needs precise
knowledge of the transmission start time. Due to this all receiving beacons along with mobile
devices are accurately synchronized with a precise time source.
ToA is the most accurate technique used in indoor environment which can filter out multi-
path effects one of the disadvantages of TOA approach is the requirement for precise time
synchronization of all the devices.
9.2.3 Time difference of arrival (TDOA Algorithm) Measure the relative position of the mobile transmitter by inspects the difference in time at
which the signal arrives at multiple measuring point.
Figure 9-6 positioning based on TDOA measurements.
The transmitter must lie on a hyperboloid with a constant range difference between the two
measuring points. The equation of the hyperboloid is given by
115
Where (xi, yi, zi) and (xj, yj, zj ) represent the fixed receivers i and j; and (x, y, z) represent
the coordinate of the target.
Target location estimated by the intersection of two or more TDOA measurements.
9.2.4 Received Signal Strength (RSS)
(RSSI) was employed to estimate the distances between transmitters and receivers.
Usually RF signals are used .The location of the objects are determine by calculating the
distance of the object from the transmitters using triangulation or tri-alteration technique or
collect the signal strength from three Access Pointes at positioning location and calculate
distance between positioning location to each AP by Log-distance path loss model. Then the
positioning location is estimated by triangulation algorithms .
Log-distance path loss model
Because signal strength will lost with increasing of the transmit distance. Log-distance path
loss model is described as Pr (d) =Pt - PL (d) In this format, Pr (d) [dBm] is signal strength
of receiver. Pt [dBm] is the signal strength of transmitter. d :is the distance from transmitter
to receiver which is the distance between AP and user. PL(d) [dB] is the path loss of signal
strength between transmitter and receiver PL(d)=PL(d0)+ 10nlog(d/d0)+ Xg In this
format, Xg is random variable which has Gaussian distribution with standard deviation and
zero mean. n is the rate of path loss increases with distance. d0 is the distance of a “close-in”
point, usually 1m.
The values of n depend on the building layout and construction material, they are derived
empirically.
Distances between positioning location and AP1,AP2,AP3 are written as (d1,d2,d3), then
three intersecting circles with radius of (d1,d2,d3) are constructed, the center of circles are
the locations of three APs, the intersection of these circles will be the positioning
location(X,Y). The condition illustrates in Figuer8.2.2.5
116
Positioning Equation can be written as:
(X-xi) 2+(Y-yi) 2=di 2,i=1,2,3. In this format, (xi, yi) indicates the coordinate of ith AP, (X,
Y) indicates coordinate of positioning
Location.
9.3 Available Positioning Systems
9.3.1 Infrared base system
(IR) positioning systems are one of the most common positioning systems that use wireless
technology. The spectral region of infrared has been used in various ways for detection or
tracking of objects or persons and available in various wired and wireless devices such as
mobile phone, PDAs, and TV. Most IR based Wireless devices uses line-of-sight (LOS)
communication mode between transmitter and receiver without interference. From strong
light source
Figure 9-7 position measuring
Figure 9-8 positioning systems
117
Figure 9-9 infrared base system positioning
The previous figure is to have a GPS-like system composed of several beacons that send out
infrared signals together with ultrasonic bursts. The infrared flash of a single beacon almost
arrives instantaneously at the robot that is equipped with a combined infrared/ultrasonic
receiver. But the ultrasonic signal only arrives with a certain delay, due to the "slow" sound
velocity, in comparison to the speed of light. The receiver is able to measure the time lag
between both signals and deduce the distance between the robot and the beacon
Disadvantages
Accuracy was limited to about 4cm
Multi-robot applications weren't possible
Neither the IR-sender nor the ultrasonic transmitter were optimal in terms of power
efficiency, with the result that the system was too much directionally sensitive and
thus could not be used in larger rooms
Synchronization between the beacons was too difficult
118
9.3.2 Ultrasound base system
Is a technology based on the nature of bats and operates in the low frequency band compared
to the other two signaling technologies.
The ultrasound signals are used to estimate the position of the emitter tags from the receivers.
Ultrasound is unable to penetrate walls but reflects off most of the indoor obstructions.
Ultrasound it has a lower level of accuracy (in centimeters) and suffers a lot
Of interference from reflected ultrasound signals propagated around by other sources such as
the collision of metals.
9.3.2.1 Ultrasound system application
Figure 9-10 ultrasound system application
Basically will have mic mounted on the target and will be listening for a signal from the
speakers. There will be four ultrasound speakers in each corner emitting sound. At a start the
target will send by RF signal to first speaker to send sound and then will measure time and
calculate distance. Then will do this process with second speaker and so on. When it will
come to the end it will take all distance and calculate where exactly it is on field.
119
9.3.3 Ultra-wideband (UWB)
Ubisense is based on Ultra-wideband technology, very high accurate, 15 cm for 95% of the
readings due to the use of the active tags signal triangulation, use the techniques TDOA and
AOA to know the position of specific tag. The main components of a Ubisense systems are:
the tags to be tracked, the sensors, and the software platform. Ubisense does not require Line-
of-Sight due to the UWB technology.
The signal is filtered and multipath effect reduced .This is huge advantage because the
multipath effect represents the main cause for low accuracy indoors. The environment is
organized into cells with at least four sensors/readers.
A problem of Ubisense is the timing cable required for every Ubitag which can become
challenging in some environments.
Ubisense can determine the location of the Ubitags with very high accuracy. However the
price to deploy such a system is high, about $16.875 for the research package.
9.3.4 Applying Radio Frequency base system
Radio frequency based system is popular through the ages. It is widely available across the
globe especially in most households and in cars. FM radio uses the frequency-division
multiple access (FDMA) approach which splits the band into a number of separate frequency
channels that are used by stations. FM band ranges and channel separation distances vary in
different regions .There are only a few works dedicated to FM radio based positioning.
Recently presented Research that worked on indoor positioning using FM radio signals.
120
9.3.4.1 Indoor positioning system using RFID
RFID is a means of storing and retrieving data through electromagnetic
Transmission to an RF compatible integrated circuit and is now being seen as a means of
enhancing data handling processes.
Hardware
RFID system has several basic components including a number of RFID readers and RFID
tags.
1. RFID tags
Active RFID tags are small transceivers, which can actively transmit their ID (or other
additional data) in reply to an interrogation
Figure 9-11 RFID
There are two type of tags can used
active tags
passive tags
121
Passive RFID tags operate without a battery. They are mainly used to replace the traditional
barcode technology and are much lighter, smaller in volume, and less expensive than active
tags. They reflect the RF signal transmitted to them from a reader and add information by
modulating the reflected signal.
2. RFID readers
Figure 9-12 RFID reader
The RFID reader is able to read the data emitted from RFID tags. RFID readers and tags use
a defined RF and protocol to transmit and receive data.
3. Arduino yun as a microcontroller
Figure 9-13 Arduino yun
122
RFID system explanation
Figure 9-14 Layout of the 3 by 3 Grid RFID Positioning System
As when an object is placed inside one of the cells within the selected experimental area,
the 9‐Cell RFID Positioning System will notify the RFID readers and then record the RSSI of
the object picked up by the four readers. Each cell has a fixed set of four average values of
RSSI. The system will then calculate the Euclidean distance of that object to the readers. The
cell that has the smallest Euclidean distance would mean that it is nearest to the current
position of the detected object.
Problems of RFID system implementation
To cover large area need to large number of tags
The reader needs to be at a small distance from the tag
9.3.4.2 Indoor positioning system using ZigBee
The ZigBee technology is an emerging wireless technology standard which provides solution
for short and medium range communications due to its numerous benefits. It is mainly
designed for applications which require low-power consumption but do not require large data
throughput. The signal range coverage of a ZigBee in indoor environments is typically 20m
to 30 m. Distance calculation between two ZigBee nodes is usually carried out from RSSI
values. ZigBee
is open to interference from a wide range of signal types using the same frequency which can
disrupt radio communication because it operates in the unlicensed ISM bands.
123
Hardware
Figure 9-15 Zigbee modules
As shown in figure we used four xbee pro module
Three xbee modules are used as a receiver.
One xbee module is used as a transmitter
Arduino yun
ZigBee system explanation
Network of wireless sensors, based on sensor nodes with XBee communication interfaces.
Each sensor node is placed in a well determined geographical position. The sensor of the
target is composed of an XBee pro connected to an Arduino yun platform and a battery pack.
This unit can be installed, for instance,
Within a safety helmet of a worker. Antenna orientation, the presence of walls and metal
objects are among many factors that affect the localization Accuracy when measuring RSSI.
As consequence, the obtained distance might be unreliable.
124
Connected Car
Chapter 10
125
10.1 Connected car
A connected car is a car that provide Internet access, and also with a wireless LAN.
Often, the car is also equipped with special technologies that tap into the internet or wireless
LAN and provide additional benefits to the driver This makes the car able to share internet
access with other devices both inside as well as outside the vehicle Concierge features
provided by automakers or apps alert the driver of the time to leave to arrive on time from a
calendar and send text message alerts to friends or business associates to alert them such as
BMW Connected NA that also helps find parking or gas stations. Examples include:
automatic notification of crashes and notification of speeding.
The car today has the computing power of 20 personal computers, features about 100 million lines
of programming code, and processes up to 25 gigabytes of data an hour. Yet while automotive
digital technology has traditionally focused on optimizing the vehicle’s internal functions, attention
is now turning to developing the car’s ability to connect with the outside world and enhance the in-
car experience. This is the connected car—a vehicle able to optimize its own operation and
maintenance as well as the convenience and comfort of passengers using onboard sensors and
Internet connectivity.
10.2 Function description
The aim of this function is:
Take a picture using a webcam connected to the Arduino Yun
Upload the this image through wifi to server (dropbox) using Python
126
10.3 Implementation tools
10.3.1 Arduino YUN
The Yún distinguishes itself from other Arduino boards in that it can communicate with the
Linux distribution onboard, offering a powerful networked computer with the ease of
Arduino. In addition to Linux commands like cURL, you can write your own shell and
python scripts for robust interactions.
The board has built-in Ethernet and WiFi support so no need to use external WiFi shield.
Figure 10-1 Arduino Yun WiFi connection
10.3.2 Web cam (Logitech HD Webcam C270):
HD video quality, at a resolution of 1280 x 720 pixels.
HD video recording, at resolutions of up to 720p.
Photos can be taken at a maximum resolution of 2048 x 1536 pixels, in a 4:3 format.
Pan, tilt and zoom controls.
Face tracking.
Motion detection.
127
10.4 Steps of implementation
Insert SD card into the Arduino .
Install open-wrt OS .
Plug the web cam into the Arduino usb slot.
Install fswebcam, “a simple webcam app.
Create Dropbox API app.
Install pip, a Python package manager (Dropbox has an easy to use Python
SDK).
From the command line on shell environment
Upload a file to Dropbox from the Arduino Yun in Python .
128
10.5 Result:
Figure 10-2 is showing the uploaded image on dropbox .
Figure 10-2 uploaded image on dropbox
129
Conclusion
Chapter 11
130
The car model developed throughout the duration of this project proved to be a resounding
success. The vehicle is able to hover in its own right and receive and execute commands as
required.
As mentioned in the introduction we had six specific features needed to be fulfilled at the end
of the project duration, and although we faced a lot of obstacles, problems and challenges, we
successfully achieved them and during this period we thought about more but due to lack of
time, we could not start implementing them.
Achieved features:-
1- Adaptive cruise control
Using ultrasonic sensor and PID controller helped in achieving this feature. The car model
succeeded in changing its speed according to the target vehicle.
2- Lane-keeping
Using the Infrared sensors, we were able to detect the lane markings and any sudden
deviation in the planned path. According to this, the car takes the action to return back to its
lane safely.
3- Lane departure
By using Ultrasonic and Infrared sensors, the car was able to take the decision of changing
lanes when there is an object remaining in front of it for a period of time.
4- Auto-parking
By the use of number of ultrasonic sensors, the aim of this function is achieved which was
moving a car from a traffic lane into a parking spot.
5- Indoor positioning
There were available methods and trails to achieve our goals by using X Bee and RFID
6- Security camera
Implementing this function is achieved correctly by using a webcam such that the taken
image is uploaded through WiFi to server (drop box). This feature mainly provides security
to the car, to avoid being stolen or something like that.
Last but not least, Our project can be considered just a step to reach fully autonomous cars
and in order to do so more features need to be implemented also cars need to be connected
together through wireless links and clouds so they can start communication with each other
131
Reference
Chapter 12
132
11.1 References
Chapter 1
1. The Pathway to Driverless Cars. Claire Perry
2. wordpress.com
3. theguardian.com
Chapter 2
1- store.fut-electronics.com/
2- Graduation Project Autonomous Driving System
Chapter 3
1- Store.Fut-Electronics.Com/
2- Homeudino Graduation Project
Chapter 4
1- Chassis Systems Control Adaptive Cruise Control: More comfortable driving
2- Adaptive Cruise Control and Driver Modeling/Johan Bengtsson/Department of
Automatic Control/ Lund Institute of Technology
3- Electronics|projects|focus/The Working Principle of a PID Controller
4- Playground.arduino.cc/Code/PIDLibrary
5- Adaptive Cruise Control Systems for Vehicle Modeling Using Stop and Go
Manoeuvres V. V Sivaji1, Dr. M. Sailaja
6- DRIVING WITH ADAPTIVE CRUISE CONTROL IN THE REAL WORLD ir.
H.M. Jagtman & drs E. Wiersma
7- Adaptive Cruise Control System Overview/5th Meeting of the U.S. Software System
Safety Working Group
8- Modern Control Engineering Fifth Edition/Katsuhiko Ogata
9- PID Tuning Methods An Automatic PID Tuning Study with MathCad Neil
Kuyvenhoven Calvin College ENGR. 315 December 19, 2002
10- www.studymafia.org/ A Seminar report On ADAPTIVE CRUISE CONTROL
Chapter 5
1- Design of an Automotive Lane Keeping System Based on the Structure of Electric
Power Steering. Jing-Fu Liu, Tsung-Hsien Hu, Tsung-Hua Hsu.
2- www.unece.org/fileadmin/DAM/trans/doc/2004/itc/itcrt/LKAS_presen_040218_final.
3- techinfo.subaru.com/proxy/98666/pdf/ownerManual/098666_2016_WRX/MSA5M16
15ASTISV1_6.pdf
133
4- A LANE KEEPING ASSIST SYSTEM FOR PASSENGER CARS, DESIGN
ASPECTS OF THE USER INTERFACE. Jochen Pohl, Jonas Ekmark.
5- www.arduino.cc/en/Reference/Interrupts
Chapter 6
1- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.331.2840&rep=rep1&type=
2- http://www.psych.utah.edu/AppliedCognitionLab/LC.pdf
3- http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.259.4263&rep=rep1&type=
4- https://its.mit.edu/sites/default/files/documents/DRIVIN.PDF
Chapter 8
1. Raspberry PI L298N Dual H Bridge DC Motor-Newsletter © 2016 Autodesk, Inc.
2. Adafruit's Raspberry Pi Lesson 9. Controlling a DC Motor Created by Simon Monk
3. ModMyPi | HCSR04 Ultrasonic Range Sensor on the Raspberry Pi
4. STEP BY STEP GUIDE TO REVERSE PARKING reference
5. Moore, Matthew (2009-12-20). "Women worse at parking than men, study shows".
London: telegraph.co.uk. Retrieved 2010-01-02.
6. © 1997-2016 DriversEd.com Home / Driving Information / Driving Techniques /
Perpendicular Parking
7. Parking Network Webinars reference
8. Driving Tips.ORG Reference
Chapter 9
1- Electrical engineer.com
2- Wireless indoor positioning techniques Rilind Ballazhi _Supervisor: Prof.
Dr.Károly Farkas.
3- Survey of Wireless Indoor Positioning Techniques and Systems Hui Liu, Student
Member, IEEE, Houshang Darabi, Member, IEEE, Pat Banerjee, and Jing Liu
4- Recent Advances in Wireless Indoor Localization Techniques and System. Zahid
Farid, Rosdiadee Nordin, andMahamod Ismail
5- The Study on Using Passive RFID Tags for Indoor Positioning. S.L. Ting, S.K.
Kwok, Albert H.C. Tsang and George T.S. Ho
6- An Integrated Xbee Arduino with Group Search Optimizer Approach for
Localization in Wireless Sensor NetworksR. Harikrishnan1* and V. Jawahar
Senthil Kumar2
7- Localization in a Wireless Sensor Network based on RSSI and a decision tree.
Amine CHERIET, Mohamed OUSLIM, Kamel AIZI
134
8- Condell J.A. Survey of active and passive indoor localization system
Chapter 10
1- arduino.cc/en/Main/ArduinoBoardYun
2- twilio.com