Está en la página 1de 73

Base

Thesis
Smart City Intelligence Safety Systems on Road

Raefi Azrani Bin Ropee Adman


(1006Q78842)

Computer Intelligence Applied Research Cluster (CIARC)


Bachelor of Engineering (Hons) Electrical and Electronic Engineering
School of Engineering, Taylors University

Supervised by
Dr. Aravind CV

November 2015

THESIS DECLARATION

DECLARATION

I declare that this B.Eng (Hons) Electrical and Electronic Engineering final year
project thesis entitled Smart City Intelligence Safety Systems on Road is my
own work except as cited in the references. This thesis has not been accepted
for any degree and is not concurrently submitted in candidature of any degree.

Signature

: _____________________________

Thesis Author

: Raefi Azrani Bin Ropee Adman

Date

: 18/11/2015

ii

ABSTRACT
Smart transportation in a futuristic safety in traffic is a key hold towards building
sustainability towards the smart city concept. The priority in such a system is the collision
avoidance and the vehicle involved within a space need to communicate to each other via
wirelessly. Collision avoidance in vehicle control and safety measure in order to prevent the
user from experiencing any type of collision, e.g. front to front, front to back or side to side
collision. For most cases it is due to the user inability to predict accurately in the areas that
involve uncertainty while the vehicle is still in use. Based on the research, statistics shows that
why accidents happen on the road is because vehicle tend to collide with another due to the
blind spot in which the driver have very limited vision of overviewing their parameter. The
second factor through collision with a random object caused due to human error. Besides that,
the collision is due to the proximity and rear impact through sudden variations in the driving
mode conditions. The purpose of this research is to identify the framework of collision in urban
transportations, simulate the environment and apply the intelligence technique from natureinspired metaheuristic algorithm and implement the proposed algorithm to the developed
framework to investigate the safety concerns, a feature that is core of next generation smart
city. The outcome of the reseach project shows that the original bats algorithm with one sensor
is sufficient enough to act as an avoidance system but because of the limited view point the
movement or next positioning move is not efficient enough, however, modification that was
made from the original mobile unit shows the performances have significantly improved. The
modification contribute the system to generate a more optimize solution for the unit to position
itself without hitting any obstacle around it. In order to fulfill the objectives, the BA optimizes
which was implemented in the modified model can function as a safety system for a 4-wheel
vehicle.

Keywords: safety, collision avoidance, vehicle control, metaheuristic algorithm, nature, smart
transportation.

iii

Table of Contents
ABSTRACT ................................................................................................................ iii
LIST OF TABLES ...................................................................................................... vi
LIST OF FIGURES ...................................................................................................vii
LIST OF ABREVIATIONS ....................................................................................... ix
CHAPTER 1 INTRODUCTION .............................................................................. 1
1.1 Introduction ..................................................................................................... 1
1.2

Problem Statement .......................................................................................... 2

1.3

Objective ......................................................................................................... 3

1.4

Project Scope ................................................................................................... 3

1.5

Contribution of Thesis..................................................................................... 4

1.6

Outline of Thesis ............................................................................................. 4

CHAPTER 2 LITERATURE REVIEW .................................................................. 5


2.1 Introduction ..................................................................................................... 5
2.2

Commercialize Vehicle Safety Features ......................................................... 5

2.2.1
2.3

Collision Avoidance Methods.................................................................. 7

Natural-Inspired Metaheuristic Algorithms .................................................... 8

2.3.1

Optimization ............................................................................................ 9

2.3.2

Search for Optimally ................................................................................ 9

2.3.3

Ant Colony Optimization....................................................................... 10

2.3.4

Particle Swarm Optimization (PSO) ...................................................... 12

2.3.5

Harmony Search (HS) ............................................................................ 13

2.3.6

Bee Algorithm ........................................................................................ 14

2.3.7

Original Bats Algorithm ....................................................................... 15

2.4

Summary ....................................................................................................... 17

CHAPTER 3 RESEARCH METHODOLOGY ...................................................... 19


3.1 Project Management ...................................................................................... 19
3.1.1

Initiation Stage ....................................................................................... 19

3.1.2

Planning Stage ....................................................................................... 21

3.1.3

Execution Stage ..................................................................................... 22

3.1.4

Monitoring and Controlling Stage ......................................................... 22

3.1.5

Closing Stage ......................................................................................... 23

3.2

Overview of the Project................................................................................. 24

3.3

Implementation of Bats Algorithm in the Collision Avoidance System of a

Vehicle ..................................................................................................................... 26
3.4

Proposed CAD Model Design to Fabricate the Prototype Model ................. 27

iv

3.5

Implementation of OBA in the Mobile Unit System .................................... 28

3.6

Modification of the OBA in the Mobile Unit System ................................... 30

3.7

Designing the Electrical System for the Modified Prototype Model ............ 31

3.8

Experiment Design ........................................................................................ 32

CHAPTER 4 RESULT AND DISCUSION ............................................................. 33


4.1 Introduction ................................................................................................... 33
4.2

Comparison of the Original Prototype Model and Optimize Prototype

Model ...................................................................................................................... 33
4.2.1

Original Prototype Model ...................................................................... 33

4.2.2

Optimize Prototype Model ..................................................................... 35

4.2.3
Comparison Evaluation between the Original Prototype Model and
Optimize Prototype Model ................................................................................... 37
4.2.4
Parameter Analysis between the Original Prototype Model and Optimize
Prototype Model................................................................................................... 38
4.3

Setting the Optimal Range Value for the Priority Constraints ...................... 39

4.3.1 Optimize Range Value for the Modified Prototype Model ........................ 40
4.4

Behavioral Evaluation Comparison between the Original Prototype Model

and Optimize Prototype Model ................................................................................ 43


4.5

Summary ....................................................................................................... 44

CHAPTER 5 CONCLUSION ................................................................................... 45


REFERENCES ........................................................................................................... 46
APPENDICES ............................................................................................................ 49
APPENDIX A .......................................................................................................... 49
APPENDIX B .......................................................................................................... 52
LIST OF PUBLICATIONS ...................................................................................... 64

LIST OF TABLES
Table

Page

2.1

Modern Safety Features

2.2

Comparison on Methods of Collision Avoidance

2.3

Ant Movement Behavior

10

2.4

Particle Swarm Optimization Variant

12

2.5

Comparison of Natural-Inspired Algorithm

18

3.1

Technical Complexity

19

3.2

Business Complexity

20

3.3

Project Timeframe

21

3.4

Estimate and Actual Cost of the Project

22

3.5

Earned Value Analysis (EVA)

22

3.6

Input/Output Pin Arrangement

31

4.1

Comparison Evaluation between the Original Prototype Model


and Optimize Prototype Model

36

4.2

Future Improvement on the Models

37

4.3

Comparison Evaluation on the Parameter Scanning between the

38

Original Prototype Model and Optimize Prototype Model

vi

LIST OF FIGURES
Figure
1.1

Page
The Total Number of Accident in Malaysia from year 2007 to

2013
1.2

Causes of Accident in Malaysia from year 2007 to 2013

2.1

Ant System Algorithms

11

2.2

First figure

13

2.3

Basic Harmony Search Algorithms

13

2.4

Basic Bee Algorithms

14

2.5

Original Bats Algorithm Flow Chart

15

2.6

Original Bat Algorithm

17

3.1

Complexity Assessment Chart

20

3.2

PDCA Diagram

23

3.3

Workflow Process

25

3.4

Adaptation of Bats Algorithm in Vehicle

26

3.5

Propose Prototype Model

27

3.6

3D Prototype Model

27

3.7

Priority Constraints

29

3.8

Adaptation of Bats Algorithm

29

3.9

Modification of the OBA in the Mobile Unit System

30

3.10

Modified Prototype Model Electrical System Design

31

3.11

Experiment Design Moving with Random Stationary Obstacle

32

4.1

Original Prototype Model

33

4.2

Top View of the Original Prototype Model

34

4.3

Top View of the Original Prototype Model Ultrasonic Sensor


(US) Positioning

34

4.4

Modified Prototype Model

35

4.5

Original Prototype Model Obstacle Scanning

37

4.6

Optimize Prototype Model Obstacle Scanning

38

4.7

Setting the range value for the Original Prototype Model

39

4.8

Range Analysis for Range Optimization

40

4.9

Range value for Point of Distance

40

4.10

Average Value of Ultrasonic Range

41

vii

Figure

Page

4.11

Optimize Prototype Model with the Range Setting

41

4.12

Original Mobile unit with 2 Obstacles

42

4.13

Modify Prototype Model with 2 Obstacles

42

4.14

Original Mobile unit with 4 Obstacles

42

4.15

Modify Prototype Model with 4 Obstacles

42

4.16

Original Mobile unit with 8 Obstacles

43

4.17

Modify Prototype Model with 8 Obstacles

43

viii

LIST OF ABREVIATIONS
CAD

Computer Aid-Design

OBA

Original Bat Algorithm

BA

Bats Algorithm

ABS

Anti-Lock Brake System

ETC

Electronic Traction Control

VCPs

Vehicle Cyber Physical System

IVCAWS

In-Wheel Collision Avoidance Warning System

DSRC

Dedicated Short-Range Communication

FCAT

Forward Collison Avoidance Technology

ACO

Ant Colony Optimization

PSO

Particle Swarm Optimization

HS

Harmony Search

PDCA

Plan, Do, Check and Act

EVA

Earned Value Analysis

PV

Planned Value

EV

Estimate Value

AC

Actual Cost

BAC

Budget at Completion

CV

Cost Variance

CPI

Cost Performance Index

SV

Schedule Variance

SPI

Schedule Performance Index

EAC

Estimation at Completion

ETC

Estimation to Completion

VAC

Variance at Completion

CQI

Continues Quality Improvement

NPD

Nearest Point of Distance

MPD

Mid Point of Distance

FPD

Furthest Point of Distance

US

Ultrasonic Sensor

ix

CHAPTER 1 INTRODUCTION
1.1 Introduction
Cities and communities around the globe are facing intractable issues such as massive
growth in population and it is predicted that an increase of 75% of growth by 2050 [1], and
increase of greenhouse-gas emissions will definitely contribute to the deprecation in our
comfort of living. In the recent years, a mixture of different industry has joined forces in
creating in a worldwide Smart City movement [2]. The increment of high demand for
intelligence and sustainable environment has struck us as a contributor to move towards a
higher positive impact living [1]. Majority of the researcher believe by adapting the Smart City
concept can lead us to achieving such goals. The conceptualization of Smart City varies from
people to people, city-to-city and country-to-country, depending on development level of the
nation and its willingness for change [4]. But in general, Smart City is defined as developed
urban area that uses digital technology and information to communicate in order to enhance the
quality and performance of its citizens and economy, to reduce the cost of operation and to
manage resource consumption effectively [3]. Smart City covers in the areas of public service,
building, mobility, energy and water system. In which, each of the area contribute to the
sustainability of the city towards making it more efficient and cheaper place to live in.

Total Number of Accident in Malaysia by Year


600000
400000
200000
0
2007

2008

2009

2010

2011

2012

2013

Figure 1.1: The Total Number of Accident in Malaysia from year 2007 to 2013

In spite of the advancement in the road system, accident still happened among the car
driver in the world. From 2007 to 2013, the report shows reaching about 500,000 cases of
accident still happening in Malaysia alone [5] as shown in the Figure 1.1.Based on Malaysian
Automotive Association (MAA) statistic data, the growth of car sales is higher than the
countrys population growth of about 1.5% every year and the road expansion will be difficult
to keep up with the growth of cars. Malaysia has the highest number of new registered vehicles
in the world with more than 680,000 new vehicles each year. 88% of the populations are
dependent on private vehicles and 12% on public transport.

Private vehicles become an important transport mode and traffic jams have become a thorn in
urban living. The heavy traffic jams are costing the nation a huge price in terms of our safety,
mobility and productivity [6].

Recent trend shows that collision avoidance system is one of the major areas of study
in vehicle control and safety measure in order to prevent the user from experiencing any type
of injuries. For most cases, accident happens due to the user inability to predict accurately in
the areas that involve uncertainty. Research suggests that, the main reason why accidents
happen on the road is between two vehicles colliding with another. The second factor is when
the vehicle hitting a random object. Follow by side impact, rear impact and so on. All of these
cases have a common ground to it, in which the user of the vehicle has the tendency to collide
with another object while in motion [5]. The percentage of categories accident can be seen on
the graph below.

Percentage %

Causes of Accident in Malaysia from year 2007 to 2013


40
30
20
10
0
Head On
Percentage %

29

Hitting
Object
24

Hitting
Pedestrian
2

Multiple
Event
10

Rear
Impact
14

Rollover
4

Side
Impact
14

Figure 1.2: Causes of Accident in Malaysia from year 2007 to 2013

The research work focuses on optimizing the algorithm techniques. In this paper, shows
various methods which was implemented in the mobile unit system to prevent any such
collision from happening, either with one moving object to another moving object or a moving
object with a stationary object. The challenge is to tackle by adapting a nature-inspired
algorithm and place it into the collision avoidance system in the electronic design of the vehicle
for safety improvement.

1.2 Problem Statement


From old to new safety technology, various precautious step have been taken into consideration
when designing the safety mechanism for the vehicle and this is crucially important because
peoples life is at stake.

Recent advancement such as Google Car and Tesla Car Model has make driving effortless but
it is expensive to build, purchase and mostly not available to the general public. However, by
improving or modifying the conventional safety feature may be the solution to saving more life
in a wider scale with a cheaper expense.So, in order to achieve such objective, an optimize
version of a Nature-inspired Metaheuristic algorithms is purposed. It is to be implemented or
adapt into the safety system, which uses ultrasonic sensors. The aim, when the vehicle is
presented with one or more obstacle within its parameters, it could be either be stationary on in
dynamic motion, the vehicle need to avoid it at all cost when come to near impact
autonomously.

1.3 Objective
The objectives of this project are as follows:

To investigate various technique for collision avoidance.

To optimize the algorithm for collision avoidance through numerical simulation


analysis.

To design an algorithm which emphasis on finding the most efficient path which
avoiding any obstacle.

1.4 Project Scope


This research project required the fundamental knowledge of C programming, 3 dimensional
Computer Aid-Design (CAD) and basic electronic software and hardware integration.

The Scope of the project focuses on optimizing the nature-inspired algorithm techniques in
collision avoidance. The research is limited to the condition to change the variation of the
vehicle velocity and turning frequency upon determine the next best positioning state. The
fabrication of the design model and the algorithm analysis is limited to using Solidworks,
Ardunio IDE 1.6.5, Fritzing Beta 0.9.2, microcontroller from Ardurnio and Ardurnio
compabitible hardware. Solidworks acts as a CAD tool and is used to design the structure and
mechanics of the vehicle. Ardunio IDE 1.6.5 is used as the codding platform to structure and
built the algorithm and transfer it into the microcontroller. Fritzing Beta 0.9.2 is a 3D design
hardware module to design and test the electrical system. The integrated Ardurnio hardware is
to fabricate the prototype model and it is used to gather data for analyzing the performance of
the algorithm with various testing condition.

1.5 Contribution of Thesis


Adapting the nature-inspired Bats Algorithm (BA) to be used as the safety logic system in the
vehicle for collision avoidance.

1.6 Outline of Thesis


Chapter 1 mainly describing the background of the research project on the need of for safety
improvement in our vehicle system. Besides that, it also state the objective of the research and
the limitation area of the research.
Chapter 2 focuses on the understanding of the basic features of a modern vehicle safety system
and also its limitation. Furthermore, the content also described on the comparison and
application used for different type of nature-inspired logic.
Chapter 3 explain on the development of the project and the process that was taken place to
analyze the performance of the logic.
Chapter 4 shows the performance comparison between the original prototype model and the
optimize prototype model as well as evaluating different logic approach.
Chapter 5 conclude the overall summary of the project.

CHAPTER 2 LITERATURE REVIEW


2.1 Introduction
Researchers suggest that accident occurs due to the driver inability to response quickly
in a panic or critical situation. For example, the driver might be distracted by the co-driver in
the hype of the conversation and do not realize of the upcoming danger ahead. As a result, the
driver unable to response quickly in order to avoid the impact. Besides that, accidents also occur
because of the lack of awareness surround the vehicle or the misperception of the range value
between another vehicles resulting in insufficient brake response [7]. The literature review is
mainly to understand the limitation of the safety system and the necessary nature inspired-logic
that can be implemented into the vehicle electronic safety system.

2.2 Commercialize Vehicle Safety Features


With comparison of the old and new technology specifically towards the inbuilt vehicle
safety system, the common modern car consist a lot more than just a simply indicator to
notifying the driver of the upcoming danger. Recent advancement of technology has
tremendously prevented drivers from injuring themselves before, during and after accident.
Technology such as Anti-Lock Brake System (ABS), Brake Assist, Electronic Traction Control
(ETC), Pre-Crash Sensing, Rear Detection System and Vehicle Side Alert [9, 10] has
contributed to making driving safer for all. The following Table 2.1, describing the purpose
and limitations of the conventional safety feature.
Table 2.1: Modern Safety Features
Safety
Feature
Antilock
Braking
System
(ABS)

Descriptions

Limitations

ABS is mainly used on the road that has less


traction by providing the driver to break faster
or break while steering. It consists of four
main components, which are speed sensors,
valve, pump and controller. The speed sensor
is mainly to provide data to the inbuilt
computer system of the current velocity. For
the valve and pump act as the components
breaking mechanism. The controller is
control by the inbuilt computer system in the
vehicle response and monitor the data gain
from the sensors and react accordingly.

The brake system


doesnt provide a
complete stop, thus,
increases
the
probably of colliding
upon coming to a
snowy or slippery
area due to the
frequent jerk stop.

Ref.

[8,9,10]

Table 2.1: Modern Safety Features


Safety
Feature
Break
Assist

Electronic
Traction
Control

Pre-Crash
Sensing

Lane
Departure
Warning
Tracking
System

Descriptions

Limitation

The break assist system monitors the


intensity level of the pedal being press
while driving. Basically, the system
response highly if the driver comes up to a
panic situation by increasing the rate of
breaking. Research suggests that, the
combination of ABS and brake assist
system work tremendously well together.
It improved in term of its efficiency of the
system by providing a faster response rate
and a safer breaking approach system.

The break assist


solely influence by
the driver behavior
while
driving,
because of this if the
driver
shows
misleading
or
inappropriate action
may lead the break
assist may not work
properly and fail to
provide any assist to
driver.
The system cannot
function properly on
track such off-road or
muddy area due to
the likelihood that the
traction
control
system may damage
when crossing such
road.

Traction control basically reduces the


chances of the tire slipping while in contact
of wet and slippery area. The electronic
traction control works by measuring the
differences of the rotational speed of each
tire and determine at which of the tire have
lost traction to the road. From here, the
system balances the speed of the other tire
by pumping the brake until it achieves
stability.
The pre-crash sensing system is equip with
a radar system, where it can detect object
in front of the vehicle and estimate the time
period between the vehicles before any
collision happen. It works by alerting the
driver of the upcoming danger and activate
the necessary safety components according
to the danger level.

The lane tracking system assists driver that


unintentionally drift away from the
original lane. It works by equipping
camera and image processing devices on
the vehicle in order to determine the lateral
position of the vehicle within the painted
lane. From there, it will request the driver
to change it position to a safer position
using an icon located at the dashboard.

The
pre-crash
sensing systems have
the
tendency to
generate false alarm
which may lead to
unnecessary action
towards the vehicle if
the
external
electronic hardware
is spoil or uncheck.
Since the system rely
on
visual
information, if the
visual of the lane line
is distorted or fade
off, the system is
completely unable to
function.

Ref.

[9,11,12]

[9,13,14]

[9,14]

[9, 20]

Table 2.1: Modern Safety Features


Safety
Feature
Vehicle
Sides Alert
System

2.2.1

Descriptions

Limitation

Ref.

The system continuously monitors the


surrounding parameter of the vehicle on
its right, left, back and front side. It
eliminates the drivers blind side by
alerting the driver using a visible icon
on the presents of another vehicle. The
system is expected to enhance the
safety of the driver by reducing the
collision with the unseen vehicle while
moving or changing maneuverer.

Since the system


uses radar, upon
coming to a raining
or
snowing
condition,
the
system may give
out frequent false
alarm. As a result,
may
lead
to
discomfort situation
towards the driver.

[17, 18,19]

Collision Avoidance Methods

However, the research focuses on method or approach that can prevent any such
collision from happening. The following Table 2.2 described and compared the collision
avoidance approach method that is used in transportation vehicle on air, land and sea.
Table 2.2: Comparison on Methods of Collision Avoidance
Method
Vehicle Cyber
Physical System
(VCPs)

In-Wheel
Collision
Avoidance
Warning System
(IVCAWS)

Description
Predict
the
collision
by
determine
the
vehicle motion
behavior,
its
location, driver
behavior
and
road geometry.

Drawbacks
The system reflects on
the drivers behavior and
pattern, and the road
geometry that to certain
extends it is inconsistent
and would be more
difficult for the system to
predict and assess the risk
later on.

Author
Chaozhong
Wu
Liqun Peng
Zhen Huang
Ming Zhong
Daunfeng
Chu

A
warning
system
which
aids the driver in
preventing any
such collision
when the vehicle
is on the road.

As the reliability of the Masha Maltz


system increases the David Shinar
performance
of
the
system decreases. This is
because the drivers
relied on his or her own
judgment rather than the
system itself.

Ref.

[21]

[23]

Table 2.2: Comparison of Methods of Collision Avoidance


Method

Description

Drawbacks

Dedicated shortrange
Communication
(DSRC)

By analyzing the
timing of the event,
the system can
predict the situation
and communicate
with
another
vehicle in order to
prevent
the
collision.

Despite the system Antony Tang


can predict the risk Alice Yip
involve when the
driver
drive
the
vehicle, the system
does not control on
how the vehicle
should react to the
situation.

A hybrid model
that follows the
behavioral
characteristics of an
Ant and a Bat.

When
comes
to
application,
the
implementation
of
Ants algorithm in to
the vehicle or the
moving object cannot
react properly or
expectedly
when
there is a sudden
object in front of it.

Forward Collision
Avoidance
Technology
(FCAT)

In-Wheel
Collision
Avoidance
Warning System
(IVCAWS)

A warning system
which aids the
driver in preventing
any such collision
when the vehicle is
on the road or near
to impact to any
object.

Author

Quazi
Delwar
Hossain
Mohammad
Naim Uddin
Md.
Mahmudul
Hasan

As the reliability of Masha Maltz


the system increases David Shinar
the performance of
the system decreases.
This is because the
drivers relied on his
or her own judgment
rather than the system
itself.

Ref.

[24]

[22]

[23]

2.3 Natural-Inspired Metaheuristic Algorithms


For an optimization safety system, it needs to satisfy the requirement of avoiding any
harmful situation such as collision among objects or vehicle while in motion autonomously.
The following literature content focuses on searching for optimization, understanding and
comparing various algorithms to be implement and act as the core personality of how does the
electrical safety system should operate by adapting from the natural-inspired metaheuristic
algorithms.

2.3.1

Optimization
Optimization can be done in various areas of life such as businesses, design and systems

flow. For most cases, it can be done through a theoretical mathematics equation [30], which are
as follows;
Minimize ( ):

(), ( = 1, 2, 3, , )

(2.1)

Subject to:

(), ( = 1, 2, 3, , )

(2.2)

() 0, ( = 1, 2, 3, , )

(2.3)

Where,

= (1 , 2 , 3 , , )T

(2.4)

Where, (), () and ()are defines as the design vector. While, function as a decision
component. It can be either be real continuous, discrete or combine. For further elaboration, the
objective function and value of () is called the solution space. Where, Rn is the search space
within the search variables. The constraints are defined by the equalities, and inequalities,
. For maximization of the inequalities it can be written as gk>0.For cases that do not required
any objective is a feasibility problem because any solution is to be consider as an optimal
solution.

Optimization problems can be seen in two areas, single objective (M=1) or multiobjective M>1.
For most cases, optimization only occurs for multi objective purposed. The reason for
optimization is to achieve or gain certain level of efficiency to make output or solution more
ideally depending on the scenario or system objective [36].

2.3.2

Search for Optimally


The next step to solve optimization problem is to search for an optimal solutions. It can

be done by testing it a randomize situation or a fixed case condition. It is done by repeating the
experiment and adjusts accordingly until a desirable solution is obtained. In order for a set of
algorithm to be tested it can be put in either a determistic algorithm or stochastic algorithm
category.
9

For a determistic algorithm, it is put in a condition that is fix and will be tested repeatedly.
Whereas, for a stochastic algorithm it is done by putting randomize variable. The reason for
both categories is to create a constant condition so that an optimal solution can be reach for the
algorithm purpose [36].

2.3.3

Ant Colony Optimization


Ants are social incents which live in large colonies. The ants colony consist of two

different social status, the queen (reproductive females), male and female workers
(nonproductive females) [25]. Whereby each type have their own role in building up their
colony. The queen sustains the continuation of the species while the worker ants hunt or search
for food.

The ants communicate by leaving pheromone on the tracks that it takes in order for it
to check it direction and also as indicator for other ants. When searching for food, ants move in
random direction and when another ant detects its pheromone and the probability for it to follow
that trail is higher. As more ants choose the same path that the first ant took in search for food,
the more ants are attracted to the same path. As a result, the ants follow the tracks that lead
them to the shortest distance from the base to the food and back. This will continue until the
pheromone that is on the track dies off. The following figures describe on how the ants behaves
when choosing the best route out of pure randomness motion [25].
Table 2.3: Ant Movement Behavior [25]
Movement
Ants move in
a straight line

Movement Behavior
Direction
c

Ants

Ants move in
random

Ant choose
the best route
of cause

10

Ant Colony Optimization (ACO) Logic


For an Ant System the ants construct their own path whereby these paths can be
improved by a local search algorithm [26]. In other words, it simply determines the best path
to be taken which provide a better and faster route from one point to the next [27]. For this
algorithm, it is mostly highlight on the finding the best and most efficient route in detecting
various ways between two different points.
The following code shows the most basic form when comes to the implementation of the logic
[23].
Set parameters, initialize pheromone trails while termination
conditions not met do
ConstructAntSolutions
ApplyLocalSearch {optional}
UpdatePheromones

end while
Figure 2.1: Ant System Algorithms [23]
The ant system follows the following rule [22]:

={

h allowed k(t,I)

(2.5)

Where, is the probability of ant k choosing the path from ( , ) to Vi. The parameters of and
are the pheromone and heuristic information that is assigned to the edge of ( , ) and are
constants to determine the relative influence of pheromone and heuristic information. Lastly,
the allowed (, ) is the set of vertices which to be permit accordingly to the problem
constraints.
And then, the ant k moves and deposited the pheromone on the track, which is defined as
follow:

= {
0,

If ant k uses connection ( , ) in its solution


Otherwise

(2.6)

Where, Q is the positive constant and Lk is the cost of path used by ant k.

11

Finally, when all the ant m has completed their path finding, the pheromone is updated based
on the following formula:

(1 ) +
=1 =>

(2.7)

Where, the evaporation factor (0 < < 1) caused the early pheromone to vanish over number of
iterations. Therefore, the new corresponding pheromone becomes better thus eliminating the
initial undesired solution.

2.3.4

Particle Swarm Optimization (PSO)

PSO was inspired by the group behavior of birds, fish and insects. The capability of
PSO based logic is to search for the most optimal solutions when comes to multivariable
problem. For PSO, each particle keep track of its track of its coordinate in order to come out
with the best solution [28]. Each particles position is a potential solution to the problem. Each
particles velocity is modified based on its distance from its personal best position and the
global best position. In other words the particles move according to their experience and that
of their neighbors that yields the best fitness value [29].
Table 2.4: Particle Swarm Optimization Variant [29]
Variant
Velocity Clamping

Function
Reducing the size
step so that the
particle will remain
within the area.

Advantages
Reducing the step
size velocity so it
can control the
movement of the
particle.

Disadvantages
If all the velocity
becomes equal the
particle will continue
to conduct it search
and
will
not
convergence
the
whole area.

Construction
Coefficient

The
weight
is
control
by
the
momentum of the
previous velocity.

A larger inertia Cause unnecessary


weight will foster fluctuation.
the
convergence
ability.

Synchronous and
Asynchronous
Updates

To
secure
the Comparable with the More sophisticated
stability of the inertia weight.
finite
element
convergence for the
formulations.
PSO algorithm

Synchronous and
Asynchronous
Updates

Optimize
parallel Enhance the rate of Sophisticate
finite
processing.
convergence.
formula and higher
densities.

12

2.3.5

Harmony Search (HS)

Harmony search was adapted from the improvisation process of creating harmonic
sounds. The process works by recognizing the best harmonic song and adapt it to the new
sound harmony memory. This is because in Genetic Algorithm memory is important. As a
result, these ensure the best harmonic sound is constantly updated. The algorithm work by
comparing the selected solution and compare it to the worst solution and determine to either
put in the memory as the new best harmonic memory or to eliminate it. Figure 2.2 and Figure
2.3, shows the basic HS algorithm.

Solution
Improvisation

Random
Solution

Selection

Evaluation

Harmony
Memory

Worst
Solution

Comparison

Better
Fitness

No
Elimination

Yes
Replacement

Figure 2.2: Basic Harmony Search Algorithms [23]

Objective function f(x), x=(x1,x2, ...,xd)T


Generate initial harmonics (real number arrays)
Define pitch adjusting rate (rpa), pitch limits and bandwidth
Define harmony memory accepting rate (raccept)
while ( t<Max number of iterations )
Generate new harmonics by accepting best harmonics
Adjust pitch to get new harmonics (solutions)
if (rand>raccept), choose an existing harmonic randomly
else if (rand>rpa), adjust the pitch randomly within limits
else generate new harmonics via randomization
end if Accept the new harmonics (solutions) if better
end while
Find the current best solutions
end
Figure 2.3: Harmony Search Code [26]

When comes to using the algorithm effectively, three major components is needed to be
consider, which are harmony memory accepting, pitch adjustment and randomization.
13

The harmony memory accepting ranging from the value of 0 to 1, where, the value moving
towards 0 has lesser-selected harmonies and producing slower coverage. Whereas, the value
that is moving towards 1 uses more and more selected harmonic memory, which may lead to
certain memory not being explore resulting in producing the wrong solution. Therefore, the
accepted range should be from 0.7 to 0.95. For the pitch adjustment, it is determine by the pitch
bandwidth and pitch adjustment rate. These influence the existing solution in the harmonic
memory. Finally, the randomization act to increases the possibilities of the solution. This can
be further explore the possibilities of a new improve solution by comparing it to the updated
solution [30 -32].

2.3.6

Bee Algorithm

Bee portray a complex characteristic behavior when comes to mating, breeding and
foraging. In which all of the behavior is crucial to sustain the bee colony from dying [33].
Figure 2.4 shows the practical bee algorithm.

Start

Initial Scout Bees(n)

Evaluate Fitness

Select Elite
bees from
scout bees(e)

Random
assign scout
bees(r)

PSO procedure (Petir) by


neighborhood wondows
Selfparameter
update
No

Select Best
bees from
scout bees(b)

PSO procedure (Pbtir)


by neighborhood
windows

Convergence?
Yes
End

Figure 2.4: Basic Bee Algorithms [34]


Initially, the bee will be put in a search space in random respectively for the speed and
location. After that, the evaluation process occurs to select which is the best to be put in the
selection category either for the elite or best bees.

14

In the PSO procedure the elite and best bees is selected. Finally, the best is put at the updated
parameter and check if the best fit to function accordingly [35].

2.3.7

Original Bats Algorithm


The bat-inspired algorithm is an adaptation from the characteristics of the echolocation

of microbats. The bats echolocation is mostly used to determine its pin point location to the
point of its surrounding such as rocks, wall or other bats. Furthermore, it is also used to
differentiate between foods or objects and also to direct its movement accordingly without
colliding with the other bats. The microbats move in such randomness with velocity, at position,
with a fixed frequency, and by varying its wavelength, and loudness [37], it can determine the
potential danger that is about to happen or how it located its preys. The following Figure 2.5
shows the original bats algorithm.

Start

Scan Parameters: Positions


X,Velocity,V Frequency,f
Loudness,A etc.

Generates the best solution based on


the current stituations

Generates Global Solution

Generates local Solution


No

Generates new best solution based


on previous best solution

End

Convergence?

Yes

Figure 2.5: Original Bats Algorithm Flow Chart [31]

Bats Movement
The movement of the bats is define by certain type of rules where the positions and
velocity, in the d-dimensional search space is consider as the influencer on how does the bats
move. In order for the bats to create a path for them to move efficiently, the next action steps
needed to be constantly updated so that the next move will be better that the previous one.

15

From the equation that was developed by X.Yang [30, 31], showcase how to determine the
new location point based on the previous decision where the position, and velocity, is obtain
at any given time;
= + ( min)

(2.8)

= 1 + ( )

(2.9)

= 1 +

(2.10)

Where [0.1] is categories as the random vector that is drawn from a uniform distribution.
Furthermore, is defined as the current best location after comparing the solution with all the
other bats.
For the local search part, it is generated based on the current best solution and the new solution
is generated locally using random walk.
= +

(2.11)

Where [-1, 1] is taken randomly and = < > is determine by the average loudness of all
the bats at that time.

Loudness and Pulse Emission


The loudness and rate, ri of pulse emission are determined by the number of iterations. This
can be calculated by the following equation:
+1
=

(2.12)

+1 = 10 exp()

(2.13)

Where and are constants.


From here, the loudness and emission rates can be updated if and only if the new solution is
somewhat improve. Because of such characteristics the bats are moving accordingly to the most
optimal movement at that time and place while avoiding any obstacle that surrounds it.

16

Input: Bat population xi = (xi1, . . . , xiD)T for i = 1. . . Np, MAX FE.


Output: The best solution xbest and its corresponding value fmin = min(f(x))
1: init bat();
2: eval = evaluate the new population;
3: fmin = find the best solution(xbest ); {initialization}
4: while termination condition not meet do
5: for i = 1 to Np do
6: y = generate new solution(xi);
7: if rand(0, 1) > ri then
8: y = improve the best solution(xbest )
9: end if{ local search step }
10: fnew = evaluate the new solution(y);
11: eval = eval + 1;
12: if fnew fi and N(0, 1) < Ai then
13: xi = y; fi = fnew;
14: end if{ save the best solution conditionally }
15: fmin=find the best solution(xbest );
16: end for 17:
end while
Figure 2.6: Original Bat Algorithm [38]
Based on the Figure 2.6, from line 1 to 3 indicates the initialization phase where all the
parameter of the algorithm is consider and to evaluate the initial population in order to obtain
the best solution. At line 6, is the part where it generates the best possible outcome depending
on the initial parameters. From line 7 to 9, it evaluates the solution and tries to improve from
there. At line 10, the updated solution is carried out. Line 12 to 14, it adapting to the situation
and provide the best solution for it. Finally at line 15, the new and updated solution is carried
out.

2.4 Summary
These algorithms are capable of creating a sufficient system that can prevent any
collision among objects based on its algorithmic behavior. However, for a moving object
(dynamic obstacle) is far more tedious comparing to avoiding a static object. This is because
for a dynamic object the speed and position varies within time, thus, the ideal logic required to
compensate with these condition. Therefore, the literature review is mainly to compare other
natural-inspired algorithm and evaluate which is the most suited logic when comes to
application in the vehicle system for collision avoidance. Table 2.5 shows a summarization of
the application and the limitation of each of the nature-inspired algorithm.

17

Table 2.5: Comparison of Natural-Inspired Algorithm


Natural-Inspired
Algorithm

Main Application

Limitations

Ant Colony Optimization


(ACO)

Optimize the best route The solution is based on the


between two points of number of iterations, therefore,
distance.
the best route may or may not be
the most inefficient route to cross
since it is depends on the
popularity of the route.

Particle Swarm
Optimization (PSO)

Solution for multivariable The algorithm can only function


condition.
if and only if the next agent is
equipping with the same logic.

Harmony Search (HS)

Adapting to the condition The algorithm depends crucially


or requirement.
on memory capacity.

Bee Algorithm (BA)

Evaluation and
comparing process.

Required a master and slave


condition.

Original Bats Algorithm


(OBA)

Next positioning state.

The variable of a different


condition may be the same
resulting in same solution.

Each of the algorithms function differently, however, OBA shows the most applicable
when comes obstacle avoidance for a vehicle system. The OBA is mainly influence by the
velocity of the bat and frequency differences. The relations between the factors that influence
the variables of the bats positioning behavior can be used in the vehicle operation. The velocity
state the motion speed of the vehicle while at move, where frequency state the intensity rate of
the sensors of the vehicle. With comparison with other logic such ACO is inapplicable since it
is applied to find the best route of cause and not for avoiding purposes. For HS and BA aims to
find the best new solution from the previous solution or condition which can only be useful if
the variable is gradually change but for a vehicle collision avoidance application that would not
be possible since the tendency for the vehicle to change the surrounding is high. PSO
application is to control multivariable condition and operate accordingly with the changes of
the environment. This algorithm would be the most ideal if and only if the other units or vehicle
carried the same logic. Therefore, OBA is most suited since it emphasis on the best positioning
approach for at move or in standby condition.

18

CHAPTER 3 RESEARCH METHODOLOGY


3.1 Project Management
Project management is a tool used to monitor the growth of the project within a period of time.
It involves in the areas of initiation, planning, execution, monitoring and controlling, and
closing. For the project to be successful, it required to satisfied the conditions which are the
quality of the project, cost control and the time period that the project need to be completed.
However, the success of the project is depending on the level at which the objective is meet
and the satisfaction of the customers or clients.

3.1.1

Initiation Stage

The initiation stage focuses on the necessity and the limitation of the project by applying the
complexity assessment. From here, it determine if the project is leaning more towards the
technicality or business side. The rating is ranging from 0 to 4, where 0 being the lowest and 4
being the highest complexity. In Table 3.1 and Table 3.2 shows the assessment for technical
and business complexity.
Table 3.1: Technical Complexity
Attributes

Rating

Justification
The programming code can be easily excess from
other related project.

Availability Recourse

Knowledge

The nature-inspired logic need to be understood


and apply in order to evaluate the performance.

Skills

Skills involving C programming, modelling and


hard integration.

New Technology

The algorithms is easily obtain in the internet.

Scope

The project was mainly focusing on developing the


algorithms and optimizing application.

Average score Technical Complexity =

1+4+3+2+3
5

= 2.6

19

Table 3.2: Business Complexity


Attributes
Budget

Rating
Justification
1
The cost of developing the model was inexpensive
since Taylors University have provided with
mostly with all the components needed.

Market

The project have high market potential in sense of


it application.

Time Scale

Constructing the programming code and


optimizing the electrical hardware design are time
consuming.

Geography

The application of the OBA is mainly for land


vehicle.

Policies and Procedures

No policies constraint was involved during the


development of this project aside from the rules and
regulations set by the University.

Average score Technical Complexity =

1+3+4+2+1
5

= 2.2

Based on Table 3.1 and 3.2 complexity assessment for technical and business complexity, it
shows that the project complexity is more leaning technical side. . This is further shown in
Figure 3.1 below. This will state that the success of the project will be determine by overcoming
the complexity level of the fabricating and designing the final product.

High

Technical Environment

4
I

II

I.
II.
III.
IV.

Low

Very high complexity


High Technical Complexity
High Business Complexity
Routine/Low

III

IV

High

Business Environment

Figure 3.1: Complexity Assessment Chart


20

3.1.2

Planning Stage

The planning stage focuses on listing out all the activities which needed to be execute and estimation time for each of the activities and overall project duration.
This can be done by creating a timeframe as be seen in Table 3.3.
Task Description

Semester 1
Week
1 2 3 4

10

12

13

14

Semester 2
Week
1 2 3 4

10

12

13

14

Project Selection
Find an Objective
Literature Review
Initial Proposal
Creating a simulation environment
Analyzing the results
Project Interim Report
Engineering Fair 1 (Tier 1)
eureca Conference
Adjusting the CAD design to fit the
requirement
Fabricate the CAD model
Implement and Test the logic
control
Analyzing the results
Modification adjustment
Dissemination of research findings
Final Year Thesis
Engineering Fair 2 (Tier 2)
eureca Conference
Table 3.3: Project Timeframe

21

3.1.3

Execution Stage

The continuation process of the project will based at this stage. In order for the project to grow
continuously until the end point, the author of the project keep track of the project performance
by recording it in the weekly logbook. This is to promote a constant progression of the project
at which to minimize the delay time between executing one task to the next until to the point of
completion.

3.1.4

Monitoring and Controlling Stage

The next stage of the project is to monitor and control the project performance. The reason for
doing so, the progress of the project may be effected by the external factor such as shortage in
monetary resource or hardware malfunction. This external influence can greatly affect the
health level of the project. However, this can be counter by measuring the Earned Value
Analysis (EVA). This tool is used to measure the aforementioned degree affected for the
project. Table 3.4 shows the application EVA.

Table 3.4: Estimate and Actual Cost of the Project


Cost
Materials
Ultrasonic Sensor

Estimation (RM)
200

Actual (RM)
217

L293D motor Driver

14

DK electronic motor shield

50

55

Ardurnio Uno

90

110

Ardurnio Mega

160

157

Chassis

200

150

Others

50

60

Total

764

677

Table 3.5: Earned Value Analysis (EVA)


Attributes
Planned Value (PV)

Formula
N/A

Amount (RM)
764

Estimate Value (EV)

N/A

700

Actual Cost (AC)

N/A

667

Budget at Completion (BAC)

N/A

764

EV AC

33

EV/AC

1.049

Cost Variance (CV)


Cost Performance Index (CPI)

22

Table 3.5: Earned Value Analysis (EVA)


Attributes
Schedule Variance (SV)

Formula
EV-PV

Amount (RM)
-64

EV/PV

0.92

Estimation at Completion (EAC)

BAC/CPI

728.30

Estimation to Completion (ETC)

EAC-AC

61.31

BAC-EAC

35.7

Schedule Performance Index (SPI)

Variance at Completion (VAC)

3.1.5

Closing Stage

The last stage of the project focus on the Continues Quality Improvement (CQI). At this stage,
the project is to be ensure that it will not here and continue improve over time. There are 4
phase that are in involve in the CQI process, plan, do, check, and act. Each of the phase
represent a process for future development as can be seen in Figure 3.2.

Plan

Do

Designing the
logic related
application

Constructing the
Algorithm

Act

Check

Optimizing
the Algorithm

Simulation
Analysis

Figure 3.2: PDCA Diagram

The application of CQI is perform by checking the condition and requirement of the application.
Follow by constructing the logic for the system. Then, the algorithm is test out and the necessary
data is collected. Finally, improvement should be made in order to gain the optimize
performance for the application.

23

3.2 Overview of the Project


The nature of this research will be focusing on fabricating a prototype model that can
be used and experiment for the uses of evaluating the collision avoidance algorithm. In order
to gain certain understanding on how the control system function when comes to controlling
the movement of the motor a conventional controller kit (Ardurnio Uno and Ardunio Mega)
was used. The research is then focus on the fabrication of the prototype model. The prototype
model was adapted from the 3D CAD model that was extracted from an open source. The
comparison of the algorithm was tested with fix specifications of the mobile unit with different
set of logic in a different set of environment. Based on that, the results will then be evaluate
and compare with each set of logic that is used to which is the most reliable and have the highest
performance rate. The comparison is mostly focuses on the effectiveness of avoiding any
collision with the intended use of it application.
To further elaborate on the project, the first phase of the project will be focusing on
experimenting with the conventional microcontroller kit, Ardurnio and understand how it
function when comes to controlling the wheel movement using motor and any external devices
that can be integrate with the microcontroller. The research then will be focusing on comparison
the algorithm, this will be done after the prototype model is fabricated. The prototype design
was adapted from a 3D CAD model that was extracted from an open source. After that, the
algorithm is the tested, evaluate and compare. After obtaining the data, the algorithm is then
compared to the original bats algorithm (OBA). Further optimization approach will be consider
in order to maximize the outcome based on the intended application.

24

The process of the work flow is show in Figure 3.3.


Phase 1
Preliminary
Design Analysis

Testing of circuit using conventional controller for wheel movement control

Phase 2
Modelling and
Analysis

Model the vehicle dynamic system


using CAD tool

Using simulink
express
Phase 4
Implementation
and Evaluations

Model of the system using


SIMULINK

Analyse the various parameters that need to control the wheel


movement (Rudder/Wheel alignment )

Phase 3
Algorithm
Development and
Deployment

Phase 2
Modelling and
Analysis

Conventional algorithm to test on


the modelled systems

Comparison of the various analysis


using SIMULINK model

Nature inspired algorithm using


Bats Intelligence []

Controller decoding and testing for


algorithm evaluation in real time

Model of the system using


SIMULINK

Comparison of the BA and


improved BA using the modelling
tool

Improved bat algorithm for dynamic


system (back to back and side sensing)

Figure 3.3: Workflow Process


25

3.3 Implementation of Bats Algorithm in the Collision Avoidance System of a


Vehicle
In theory, the variation on how bats differentiate object is influence by the frequency
difference. Where, object that is in stationary, reflect a constant or fix bandwidth or frequency.
This is determining by their echolocation capability, whereas, for a prey or predator that is in
dynamic movement, give out difference vive of frequency. For example, if the object is
approaching towards the bat, the reflected wave produces a more intense frequency and if the
object is going away from the bat, it reflects a lighter wave.
For application purpose, the behavior of the bat is look at 3 main condition that are stationary,
approaching and receding obstacle. The figure below shows a more illustrate concept of the BA
adaption.

Stationary
Obstacle

Stationary Object

Approaching
Obstacle

Receding
Obstacle

Figure 3.4: Adaptation of Bats Algorithm in Vehicle


From Figure 3.4, shows 3 different cases when detecting an object around it. By applying
modern technology devices, an ultrasonic sensor has the most similarity to producing radar of
wave like a bat. So, the first case show when a vehicle detects a stationary object when using
an ultrasonic sensor, whereas for case 2 and 3 shows how the vehicle sees and react upon
detection of a moving vehicle. To further explain, for a stationary obstacle, the car system only
detect if and only if there is an obstacle nearby it. For an approaching and receding obstacle,
the vehicle detects earlier on and warns the system of the upcoming obstacle before proceeding
to the action steps.

26

3.4 Proposed CAD Model Design to Fabricate the Prototype Model


The following Figure 3.2 shows a 3D CAD model that was used as a references guide to build
the prototype model. As can be seen in Figure 3.5, the model consists of two tires, chassis and
six unique ultrasonic sensors (front and back side) that give it a wider range to scan for its
parameters.

Ultrasonic Sensors

Figure 3.5: Propose Prototype Model

To further illustrate the 3D CAD model, Figure 3.6 shows the design from different angel of
view point.

(a) Front View

(b) Back View

Figure 3.6: 3D Prototype Model

27

(c) Left Side View

(e) Top View

(d) Right Side View

(f) Bottom View

Figure 3.6: 3D Prototype Model

3.5 Implementation of OBA in the Mobile Unit System


The implementation of the BA using Ardunio is set in deferent priority points. The point is set
as the Nearest Point of Distance (NPD), Mid. Point of Distance (MPD) and Furthest Point of
Distance (FPD). The NPD area functions as the highest alert level, whereas the MPD and FPD
act as an early system warning. Further elaboration can be seen in Figure 3.7.

28

Alert Level

Back Front

NPD

FPD

MPD

NPD
MPD
FPD
0

Distance, cm
(b) Priority Level Chart

(a) Priority Level Model

Figure 3.7: Priority Area


The condition of the algorithm is set based on three different areas, FPD, MPD and NPD. The
areas are categories with set of conditions where each condition is based on the priority level.
Each of the command in the logic increases or decreases based on the alert level. As the alert
level increases so goes the intensity of action of the mobile unit. This can be done by
differentiate the speed of the unit and turning percentage of the motor to go left, right or
backward. Furthermore, constraint works as the distance of the mobile unit to the obstacle
increases, the alert level decrease. This concept is to promote an optimize solution for
positioning the mobile unit while in the moving stage.
Start

Load Scan Parameters

No
Yes
Furthest
Point of
Distance

Command

No

Yes
Mid
Point of
Distance

Command

End

No
Nearest
Point of
Distance

Yes

Command

Figure 3.8: Adaptation of Bats Algorithm


To further elaborate on the conceptual algorithm, NPD state that the mobile unit is at highest
alert point since the tendency to collide with any sort of obstacle is high.

29

Thus, the settings of the condition need to tolerate such condition. At here, the speed of the
mobile unit need to be reduce by 40% of the original speed and the turning angle needed to be
increase by 50% from the mid angle turning. At MPD, the speed is only reduce at 20% and
there is no change for the turning angle. Lastly, at FPD, the speed is at 100% and there is no
turning required.

3.6 Modification of the OBA in the Mobile Unit System


In Figure 3.9 (a) illustrate on the improvement of the original prototype model. The
modification that is intended to make, is to increases the parameter scanning capability. From
the improvement, the mobile would be able to generate a more optimize positioning solution
because of the increase in the influence variable.
Start

Scanning the
Parameters

Range < NPD

Ultrasonic
Sensor

Range < MPD

No

Back Front

No
True

Range < FPD


No

True

Yes

Yes

Nearest Point
of Distance

Mid Point of
Distance

Command

Command

True
Yes

Furthest Point
of Distance
Command

End

(a) Modified Prototype Model

(b) Adaptation of Bats Algorithm on the Modified


Model

Figure 3.9: Modification of the OBA in the Mobile Unit System

Figure 3.9 (b) shows on the construction of the algorithm for the modified prototype model. It
behave similar to the original algorithm, however, based on the modified model the logic need
to integrate with 6 different ultrasonic sensors at different position. This is done by setting case
condition for each action command depending at which area does the obstacle are put at. The
aim for the modification is for the mobile unit to gain wider range of view throughout its
parameters before generating the next best solution for the next position. As a results, it can
provide a more optimize positioning movement.

30

3.7 Designing the Electrical System for the Modified Prototype Model
The following Figure 3.10 shows an electrical system that aims to integrate between six
different ultrasonic sensors. Based on the position of the ultrasonic sensor and the range value
that it can provides, the electrical system need to function as such it can control the movement
of the motor from the data obtain from scanning the parameters.

Ultrasonic
Sensor 1

Ultrasonic
Sensor 4

Ultrasonic
Sensor 2

Ultrasonic
Sensor 5

Ultrasonic
Sensor 3

Ultrasonic
Sensor 6

Ardunio Mega
and Motor Shield

DC
Motor 1

Switch

DC
Motor 2

Power Supply

Figure 3.10: Modified Prototype Model Electrical System Design

In the electrical system design the echo and trig pin for the ultrasonic is combined due to the
lack of specific pin to operate the sensors. However, this modification will not affect the
performance of the sensors. The following Table 3.6 shows the Input/Ouput for the electrical
component with the Ardurnio Mega pin.
Table 3.6: Input/Output Pin Arrangement
Component
Ultrasonic Sensor 1

Ardurnio Mega Pin


46

Ultrasonic Sensor 2

45

Ultrasonic Sensor 3

44

Ultrasonic Sensor 4

42

Ultrasonic Sensor 5

32

Ultrasonic Sensor 6

22

31

Table 3.6: Input/Output Pin Arrangement


Component
DK electronic
motor shield

Ardurnio Mega Pin


1 -13

Batttery

Vin, Gnd

Motor 1

M3

Motor 2

M4

3.8 Experiment Design


The evaluation was conducted in purpose of evaluating the mobile unit behavior while
moving with random stationary obstacle. The settings of each of the experiment are
shown as follow in Figure 3.11.

(a) 2 Obstacles

(a) 4 Obstacles

(c) 8 Obstacles

Figure 3.10: Experiment Design Moving with Random Stationary Obstacle

The objective of the experiment is to determine which is the most effective design when comes
to avoiding any collision. For each of the environment setting the number of obstacle increase
in order to evaluate the performance when the difficulty level of the environment increase. The
experiment was conducted using two case model, the first model was done using the original
prototype model which only have one ultrasonic sensor and for the second case model was done
using the modified prototype model. The result of the experiment is shown in Chapter 4, where
the evaluation of the behavior is presented and analyze.

32

CHAPTER 4 RESULT AND DISCUSION


4.1 Introduction
The purpose for developing the mobile units is to evaluate the performance of the adaption
OBA by putting the model in a setup environment. In the analysis show two type of prototype
model where the second was done for overcoming the limitation of the original model.
Furthermore, the results focuses more on optimizing the adaptation of the OBA for safety
purposes.

4.2 Comparison of the Original Prototype Model and Optimize Prototype Model
4.2.1

Original Prototype Model

Figure 4.1 shows the overview of the original prototype model before any modification was
made on it. The mobile unit consists of one ultrasonic sensor, 7.6V battery, L293D motor driver,
two motor and an Ardunio Uno.

Ultrasonic
Sensor

(a) Front Side View

(b) Backside View

Figure 4.1: Original Prototype Model

33

L293D motor
driver

DC
Motor 1

Ardurnio
Uno

DC
Motor 2

(c) Top View

(d) Bottom View

(e) Right Side View

(f) Left Side View

Switch

Figure 4.1: Original Prototype Model


To further explain on the system flow of the prototype model, when the ultrasonic sensor
detected an object within its range, it will then convert the detection alert into a form of data.
The data is then transfer to the microcontroller, Ardurnio Uno as the range value between the
object and the prototype model. In the microcontroller , the data obtain will determine the
movement of the motor 1 and motor 2 and this can be done by sending output signal to the
L293D motor driver. The rate of movement or direction of the motor is depending on the
command function that is determine by the range value.

34

4.2.2

Optimize Prototype Model

Figure 4.2 and Figure 4.3 shows the top view of the modification prototype model. The model
consist of six ultrasonic sensors, an Ardunio Mega, DK electronic motor shield, 7.4 battery and
a switch
Ardurnio
Mega
Switch

US 4
Motor Shield

US 3

US 2

US 1

Figure 4.2: Top View of the Original


Prototype Model

US 5

US 6

Figure 4.3: Top View of the Original


Prototype Model Ultrasonic Sensor (US)
Positioning

The modification of the original prototype model was done by microcontroller from Ardurnio
Uno to Ardurnio Mega in order to increase the number of pin available for the sensors. Besides
that, the number of ultrasonic used was increase from one to six sensors so that the mobile unit
can gain a wider range of parameter scanning. Finally, the L293D was changed to DK
electronics shield in order to gain a certain level of stability in the current flow within the
electrical system. This is because, by increasing the number of ultrasonic sensor the power
consumption may fluctuated since the sensors operate in a manner of sequence.
In Figure 4.4 shows the view point angle point from the top, bottom, right and left side of the
modified prototype mobile unit model.

35

Ultrasonic Sensors
(a) Front Side View

(b) Backside View

Ardurnio Mega and


Motor Shield
(d) Left Side View

(c) Right Side View

DC Motor 2

DC Motor 1

(e) Bottom Side View


Figure 4.4: Modified Prototype Model

36

4.2.3

Comparison Evaluation between the Original Prototype Model and


Optimize Prototype Model

Table 4.1: Comparison Evaluation between the Original Prototype Model and Optimize
Prototype Model

Model
Original
Prototype
Model

Optimize
Prototype
Model

Number
of Sensor
1

Advantages
The model shows it required
very little power to operate
and the battery can last longer
compared to the optimize
model. Besides that, it can
generate a fast response rate
because it only equip with 1
ultrasonic sensor, which
doesnt required a delay
function in the program.

Drawback
The limitation of the original
prototype model shows at when
it is scanning the parameter in
order to move to avoidance the
obstacle. This is because the
model consist only 1 sensor,
which limit it scanning
capability to the other blind
sides of the model. Thus, the
tendency to collide with an
obstacle is higher.

The model scanning point


shows that it covers every
side of the model. Thus, the
model can provide a better
solution
for
its
next
positioning while avoiding
any collision. As a result, the
rate of collision is lower
compare to the original
model.

The model generates a slow


response rate because of the
multiple ultrasonic sensors.
This is because in order for the
sensors to synchronous well
together it required a delay
function it the program. The
reason being to avoid any
crossover between sensors.
Besides that, the model required
higher power consumption so
that all the 6 sensors can be
integrate properly.

Table 4.2: Future Improvement on the Models


Model
Original
Prototype
Model

Improvement
The model can be improve by reducing the side of its body and to provide at least
one sensor for each of the sides in order to extract more data from it parameters
before proceeding with the movement command.

Optimize
Prototype
Model

In order for the model to function properly it required a higher voltage power
battery so that the microcontroller would be interrupt by power shortage while in
motion.

37

4.2.4

Parameter Analysis between the Original Prototype Model and Optimize


Prototype Model

Front
Side

Ultrasonic
Sensor

Back Front

Middle

Back
Side

(a) Original Model Scanning for


Obstacle

(b) Original Model Scanning for


Obstacle Diagram

Figure 4.5: Original Prototype Model Obstacle Scanning


In Figure 4.5, the original prototype model showcase that it is only capable of detecting one
object in front of it. The object that is on the right, left and backside, the model is not able to
detect it because of the limitation in the number of sensor. Thus, this shows that the model can
only response in detecting objects that is only in front of it.

In Figure 4.6, the model shows that it is able to detect more than one object before proceeding
with the command function.

Front
Side

Ultrasonic
Sensor

Back Front

Middle

Back
Side

(a) Optimize Model Scanning


for Obstacle Diagram

(b) Optimize Model Scanning


for Obstacle Diagram

Figure 4.6: Optimize Prototype Model Obstacle Scanning

38

This creates a lower tendency rate for the model to collide with any of the object because of the
model capability to detect more than one object at a time. As a result, a better positioning
solution can be generated from the data gain from the ultrasonic sensors

Table 4.3: Comparison Evaluation on the Parameter Scanning between the Original
Prototype Model and Optimize Prototype Model
Analyzing
Original Prototype Model
Scanning the The model shows that it can only detect
one object in front of it at a time and
Parameter
complete oblivious to the other obstacle
that surrounds it on the right, left and back
sides of the model.

Optimize Prototype Model


The model shows that it can detect
more than one object before
proceeding with the command
function. However, the object that
are not within the range of the
sensors, the model is not able to
detect it.

Performance The optimize prototype model shows higher performance rate compare to the
original prototype model when comes detecting objects that surrounds the
models. However, both of the models show limitation when the objects is not
within the range of the sensor, Thus, creating blind spots for the models.

4.3 Setting the Optimal Range Value for the Priority Constraints
Figure 4.8 shows the range setting for the original prototype model.

Ultrasonic
Sensor

10 cm

30cm

60cm

Back Front

Back Front

90 cm
NPD

MPD

FPD

NPD
MPD
FPD

(b) Actual Maximum Range Value for each


of the Areas

(a) Point of Measurements

Figure 4.7: Setting the range value for the Original Prototype Model

39

The condition of the algorithm is set based on three different areas, FPD, MPD and NPD. The
areas are categories with set of conditions where each condition is based on the priority level.
Each of the command in the logic increases or decreases based on the alert level. As the alert
level increases so goes the intensity of action of the mobile unit. This can be done by
differentiate the speed of the unit and turning percentage of the motor to go left, right or
backward. Furthermore, constraint works as the distance of the mobile unit to the obstacle
increases, the alert level decrease. This concept is to promote an optimize solution for
positioning the mobile unit while in the moving stage. Figure 6 shows the different alert level
depending on the distance between the mobile unit and the object.
For the original prototype model, the maximum range value at the NPD is 10 cm, for MPD is
40 cm and for the FPD is as more than 40 cm. The constraints is to help develop the algorithm
behavior on the intensity level of the motion. If an obstacle suddenly appeared at NPD, the
mobile unit need to response quickly in order to avoid the obstacle. However, for the FPD, the
obstacle is still at far so alert level should be low since the danger is low because of delay time
between the unit and the obstacle is high.

4.3.1 Optimize Range Value for the Modified Prototype Model


In order to obtain the optimal value for each of the areas, the range analysis was done in order
to gain the ideal range when comes to priority setting. The reason for such analysis is because
for each of the sensor is located at different position on the mobile unit as can be seen in
Figure 4.8. The shapes in the Figure 4.8 represents the maximum point of measurement for
each of the sensor.

Ultrasonic
Sensor

Back Front

NPD
MPD
FPD

Figure 4.8: Range Analysis for Range Optimization

40

Range Value, cm

From the data gain in Figure 4.9, the range value is tabulated.
Range Value for Point of Distance
35
30
25
20
15
10
5
0

Nearest Point of Distance


Middle Point of Distance
Furtherst Point of
Distance

9
21

10
22

31

30

3
4
Ultrasonic Sensor
9
11
21
22
31

32

10
23

11
22

29

32

Figure 4.9: Range value for Point of Distance

As can be seen in Figure 4.10, the optimum value to be set for each of the set within its area
are, NPD is 10 cm, MPD is 23 cm and FPD is 24 cm onwards. These numbers are crucial
because based on the set of range it will determine on how does the algorithm response to the

UltraSonic Range, cm

external environment.
Average Value of Ultrasonic Range
35
30
25
20
15
10
5
0

Nearest Point of
Distance
Middle Point of
Distance
Furtherst Point of
Distance

Ultrasonic Range
10
22
31

Figure 4.10: Average Value of Ultrasonic Range

41

Figure 4.11 shows the implantation of the optimize range setting for the modified prototype
model.

Start

78 cm
Scanning the
Parameters

78 cm
12 cm

12 cm
0 cm < Range < 10cm

Ultrasonic
Sensor

10 cm

10 cm < Range < 22 cm

Range > 23 cm

10 cm
No

10 cm 12 cm

No
True

78 cm

Back Front

No
True

Yes

Yes

Nearest Point
of Distance

Mid Point of
Distance

Command

Command

True
Yes

100 cm

NPD

Furthest Point
of Distance
Command

MPD
FPD
End

(a) Diagram on the Modified Model with the (b) Adaptation of Bats Algorithm on the
Modified Model with the Optimize Range
Optimize Range Setting
Setting
Figure 4.11: Optimize Prototype Model with the Range Setting

To further elaborate on the logic conditions, it is set within 3 different range value. For NPD
value from the range of 0 to 10 centimeters for all the sensors, at this point the mobile unit have
the highest alert level meaning the speed is slower than normal and the turning rate is much
high. Opposite NPD, the FDP have the lowest to none alert level. At this point the mobile is to
only move forward without changing any direction.
The area between NPD and FPD is MPD, at the point the alert level is still low, however, the
velocity of the model will reduce by 20% and turning intensity is also low since the time to
reach from the current position of the mobile unit is high.

42

4.4 Behavioral Evaluation Comparison between the Original Prototype Model


and Optimize Prototype Model
Case 1: Moving with 2 Stationary Obstacles

Figure 4.12: Original Mobile unit with


2 Obstacles

Figure 4.13: Modify Prototype Model


with 2 Obstacles

For Figure 4.12 the mobile unit detects an object in front it and turn left until the obstacle is no
longer detected. For Figure 4.13, the modified prototype model detected 2 objects within its
parameter, it will turn left or right depending on which area shows more clearance for it to pass
through.

Case 2: Moving with 4 Stationary Obstacles

Figure 4.14: Original Mobile unit with


4 Obstacles

Figure 4.15: Modify Prototype Model


with 4 Obstacles

For Figure 4.14, it shows that mobile unit has difficulty in moving due to the limitation of
scanning its parameter. As a result, the unit bumps into two of the obstacle. Whereas, the mobile
unit in Figure 4.15 shows no difficulty in deciding the next movement.

43

Case 3: Moving with 8 Stationary Obstacles

Figure 4.16: Original Mobile unit with


8 Obstacles

Figure 4.17: Modify Prototype Model


with 8 Obstacles

For Figure 4.16, it shows that mobile unit move with detecting any obstacle around it. As a
result, the unit bumps into most of the obstacle that surrounds it. For Figure 4.17, the mobile
unit shows a better result in passing through mostly all the obstacle around it.

4.5 Summary
The research focused on the concept of designing an algorithm and adapting to the
application that can be used as safety precaution for the user upon driving on the road
specifically towards four-wheel vehicles. The OBA with one sensor is sufficient enough to act
as an avoidance system but because of the limited view point for its external detection the
movement is not efficient enough to avoid the obstacle fully. The modification that was made
from the original mobile unit shows the performances have significantly improved. The
modification contribute the system to generate a more optimize solution for the unit to position
itself without hitting any obstacle around it. Thus, increase the performance of avoiding the
obstacle. In order to fulfill the objectives, the BA optimizes which was implemented in the
modified model can function as a safety system for 4 wheel vehicle.

44

CHAPTER 5 CONCLUSION
The research focuses on the optimization of the BA in the application of collision
avoidance. This is done by studying the characteristic and the behaviour on how the bat behave
in order to avoid any collision with the external environment such as rocks, wall or other bats.
Furthermore, it is also used to differentiate between prey and predators but mainly it is used to
direct its movement without colliding with the other bats or objects. The movement of the bats
depends on its velocity and position of the bats, and because of its ability to emit wave it can
determine the best next position. With comparison with other logic, OBA is the most suited
since it emphasis on the best positioning approach during movement or in standby condition.
For example, ACO is inapplicable to be apply as such since it is applied to find the best route
of cause and not for avoiding purposes. For HS and BA aims to find the best new solution from
the previous solution which the application would not be possible since the tendency for the
vehicle to change the surrounding is high. PSO application is to control multivariable condition
and can only operate accordingly to the changes of the environment providing the units is equip
with the same logic. Furthermore, the OBA with one sensor is sufficient enough to act as an
avoidance system but because of the limited view point the tendency for the mobile units body
to collide with an obstacle is higher. The modification that was made on the original model
contribute the system to generate a more optimize solution for the unit to position itself without
hitting any obstacle around it. Thus, increase the performance of avoiding the obstacle

For future work, it is recommend to future researcher to focus on the communication between
vehicle to vehicle upon coming to a collision state so that a more optimize solution can be
develop. However, the system need to operate in manner it can function independently or
operate with other vehicle. This is because if the vehicle is able to communicate with another
vehicle, both of the vehicle can compensate each other condition and at the same time producing
a synchronous solution. However, the vehicle also need to be able to operate independently
since the obstacle is not only with other vehicle but with other objects that may not be seen by
the driver.

45

REFERENCES
[1] Ieee.org, 'Smart Cities Community, IEEE', 2015. [Online]. Available:
https://www.ieee.org/membershipcatalog/productdetail/showProductDetailPage.html?product
=CMYSC764. [Accessed: 29- Oct- 2015].
[2]S. Huston, 'Smart City - Contemporary Frameworks and Antiquity', SSRN
Electronic Journal.
[3]V. Albino, U. Berardi and R. Dangelico, 'Smart Cities: Definitions, Dimensions,
Performance, and Initiatives', Journal of Urban Technology, vol. 22, no. 1, pp. 3-21, 2015.
[4]Smart City Guidelines, 1st ed. India: Ministry of Urban Development Government of India,
2015.
[5]T. Toroyan, M. Peden and K. Iaych, 'WHO launches second global status report on road
safety', Injury Prevention, vol. 19, no. 2, pp. 150-150, 2013.
[6] Statistics.gov.my, 'Department of Statistics Malaysia Official Portal', 2015. [Online].
Available: https://www.statistics.gov.my/index.php. [Accessed: 29- Oct- 2015].
[7]'Vehicle Safety Features Vehicle Safety Features Current and the Future Current and the
Future',
2015.
[Online].
Available:
http://ritzel.siu.edu/courses/302s/vehicle/VehicleSafetyFeatures.pdf. [Accessed: 01- Nov2015].
[8]'Mercedes-Benz | Forschung und Entwicklung in Indien', MTZ - Motortechnische
Zeitschrift, vol. 74, no. 5, pp. 357-357, 2013.
[9]Car Safety- Physics, 'Anti-lock Brakes vs Normal Brakes- Benefits and Limitations', 2015.
[Online]. Available: http://carsafetyphysics.weebly.com/anti-lock-brakes-vs-normal-brakes-benefits-and-limitations.html. [Accessed: 10- Oct- 2015].
[10]'Vehicle Safety Features Vehicle Safety Features Current and the Future Current and
the
Future',
2015.
[Online].
Available:http://ritzel.siu.edu/courses/302s/vehicle/VehicleSafetyFeatures.pdf. [Accessed: 01
Nov- 2015].
11]A. Aly, E. Zeidan, A. Hamed and F. Salem, 'An Antilock-Braking Systems (ABS) Control:
A Technical Review', ICA, vol. 02, no. 03, pp. 186-195, 2011.
[12] Brainonboard.ca, 'Brake assist - Active safety features', 2015. [Online]. Available:
http://www.brainonboard.ca/safety_features/active_safety_features_brake_assist.php#q5.
[Accessed: 10- Oct- 2015].

46

[13]Toyota-global.com, 'Toyota Global Site | Technology File', 2015. [Online]. Available:


http://www.toyotaglobal.com/innovation/safety_technology/safety_technology/technology_fil
e/active/brake.html. [Accessed: 01- Nov- 2015].
[14]CarsDirect, 'Advantages of Traction Control', 2015. [Online]. Available:
http://www.carsdirect.com/car-safety/advantages-of-traction-control. [Accessed: 10- Nov2015].
[15]]L.the Editors of Publications International, 'Traction Control Explained', HowStuffWorks,
2005.
[Online].
Available:
http://auto.howstuffworks.com/28000-traction-controlexplained.htm. [Accessed: 01- Nov- 2015].
[16]'PRE-CRASH SENSOR FOR PRE-CRASH SAFETY', Toyota Motor Corporation, p. 554,
2015.
[17]Wheelspeedsensor.net, 'Wheel Speed Sensor', 2015.
http://www.wheelspeedsensor.net. [Accessed: 10- Oct- 2015].

[Online].

Available:

[18] Z. HAN, 'FFT / IFFT Method for Wheel Speed Sensor Signal Processing When Car Runs
at High Speed', Journal of Mechanical Engineering, vol. 50, no. 16, p. 155, 2014.
[19] Consumerreports.org, 'Avoiding Crashes with Self-Driving Cars - Consumer
Reports',2015.[Online].Available:
http://www.consumerreports.org/cro/magazine/2014/04/the-road-to-self-drivingcars/index.htm. [Accessed: 10- Oct- 2015].
[20]] 'Hardware Evaluation of Heavy Truck Side and Rear Object Detection Systems', pp. 125.
[21] 'Internet of Car: Accident Sensing, Indication and Safety with Alert system', American
Journal of Engineering Research, vol. 02, no. 10, pp. 92-99, 2013.
[22] J. Laukkonen, 'How Does a Lane Departure Warning System Work?', About.com Autos,
2015. [Online]. Available: http://cartech.about.com/od/Safety/a/What-Are-Lane-DepartureWarning-Systems.htm. [Accessed: 10- Oct- 2015].
[23] M. Staubach, 'Factors correlated with traffic accidents as a basis for evaluating
AdvancedDriverAssistanceSystems', Accident Analysis & Prevention,vol.41,no. 5, pp. 10251033, 2009.
[24] M. Maltz and D. Shinar, 'Imperfect in-vehicle collision avoidance warning systems can
aid distracted drivers', Transportation Research Part F: Traffic Psychology and Behaviour, vol.
10, no. 4, pp. 345-357, 2007.
[25] A. Tang and A. Yip, 'Collision avoidance timing analysis of DSRC-based vehicles',
Accident Analysis & Prevention, vol. 42, no. 1, pp. 182-195, 2010.

47

[26] Q. Hossain, M. Uddin and M. Hasan, 'Collision avoidance technique using bio- mimic
feedback control', 2014 International Conference on Informatics, Electronics & Vision
(ICIEV), 2014.
[27]Intechopen.com, 'Swarm Optimization | Swarm Intelligence | InTechOpen', 2015.
[Online].Available:http://www.intechopen.com/books/swarm_intelligence_focus_on_
ant_and_particle_swarm_optimization. [Accessed: 17- March- 2015].
[28]H. Salehinejad and S. Talebi, 'Dynamic Fuzzy Logic-Ant Colony System-Based Route
Selection System', Applied Computational Intelligence and Soft Computing, vol. 2010, pp. 113, 2010.
[29]I. Fister, I. Fister, X. Yang and J. Brest, 'A comprehensive review of firefly algorithms',
Swarm and Evolutionary Computation, vol. 13, pp. 34-46, 2013.
[30]D. Palupi Rini, S. Mariyam Shamsuddin and S. Sophiyati Yuhaniz, 'Particle Swarm
Optimization: Technique, System and Challenges', International Journal of Computer
Applications, vol. 14, no. 1, pp. 19-27, 2011.
[31]J. Fourie, S. Mills and R. Green, 'Harmony filter: A robust visual tracking system using the
improved harmony search algorithm', Image and Vision Computing, vol. 28, no. 12, pp. 17021716, 2010.
[32] X. Wang, X. Gao and S. Ovaska, 'Fusion of clonal selection algorithm and harmony
search method in optimisation of fuzzy classification systems', IJBIC, vol. 1, no. 12, p. 80,
2009.
[33] Xin-She Yang 'Harmony Search as a Metaheuristic Algorithm', pp. 1-18.
[34] [1]'Artificial Bee Colony Algorithm and Its Application to Generalized Assignment
Problem', pp. 113-143.
[35]L. Lien and M. Cheng, 'A hybrid swarm intelligence based particle-bee algorithm for
construction site layout optimization', Expert Systems with Applications, vol. 39, no. 10, pp.
9642-9650, 2012.
[36]B. Yuce, M. Packianather, E. Mastrocinque, D. Pham and A. Lambiase, 'Honey Bees
Inspired Optimization Method: The Bees Algorithm', Insects, vol. 4, no. 4, pp. 646-662, 2013.
[37] X. Yang, 'Nature-Inspired Metaheuristic Algorithms: Second Edition', Luniver Press,
2010.
[38] Xin-She Yang,Nature-Inspired Metaheuristic Algorithms Second Edition, 2nd ed.
University of Cambridge: Luniver Press, 2010.
[39] I. Fister, I. Fister, X. Yang, S. Fong and Y. Zhuang, 'Bat algorithm: Recent advances',
Computational Intelligence and Informatics (CINTI), 2014 IEEE 15th International
Symposium on, pp. 163-167, 2014.

48

APPENDICES
APPENDIX A:
// Codding for the original prototype model
#include <NewPing.h> //include the ultrasonic sensor libary
//setting the pin
#define T_P 11
#define E_P 12
#define M_D 100
const int M1P1 = 7; // Motor 1 at pin 7
const int M1P2 = 6; // Motor 1 enabler at 6
const int M2P2 = 4; // Motor 2 at 4
const int M2P1 = 5; // Motor 3 enabler at 5
NewPing sonar(T_P, E_P, M_D);
unsigned int time;
int distance;
int triggerDistance = 30; //trigger distance at 30 cm
int fDistance;
int lDistance;
int rDistance;
void setup()
{
//turning on the motor
pinMode(M1P1, OUTPUT);
pinMode(M1P2, OUTPUT);
pinMode(M2P2, OUTPUT);
pinMode(M2P2, OUTPUT);
}
void loop()
{
scan(); //start scanning
fDistance = distance;
if(fDistance < triggerDistance){
Backward();
delay(1000);
Right();
delay(500);
Stop();
scan();
rDistance = distance;
moveLeft();
delay(1000);

49

Stop();
scan();
lDistance = distance;
if(lDistance < rDistance){
Right();
delay(200);
Forward();
}
else{
Forward();
}
}
else{
Forward();
}
}
void scan(){
time = sonar.ping();
distance = time / US_ROUNDTRIP_CM;
if(distance == 0){
distance = 100;
}
delay(10);
}
// move backward
void Backward(){
digitalWrite(M1P1, LOW);
digitalWrite(M1P2, HIGH);
digitalWrite(M2P1, LOW);
digitalWrite(M2P2, HIGH);
}
//move forward
void Forward(){
digitalWrite(M1P1, LOW);
digitalWrite(M1P2, HIGH);
digitalWrite(M2P1, LOW);
digitalWrite(M2P2, HIGH);
}
//move right
void Right(){
digitalWrite(M1P1, LOW);
digitalWrite(M1P2, HIGH);
digitalWrite(M2P1, LOW);
digitalWrite(M2P2, HIGH);
}

50

//move left
void Left(){
digitalWrite(M1P1, LOW);
digitalWrite(M1P2, HIGH);
digitalWrite(M2P1, LOW);
digitalWrite(M2P2, HIGH);
}
//stop
void Stop(){
digitalWrite(M1P1, LOW);
digitalWrite(M1P2, LOW);
digitalWrite(M2P1, LOW); digitalWrite(M2P2, LOW); }

51

APPENDIX B:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Final Year Project 2
//Project :Smart Intellingence Safety System on Road
//Prototype
//Model Desc.:The prototype model uses 6 PING ultrasonic sensor surrounding the
//chasis, 2 DC motor,1 pack of 7.4V of lipo rechargeable battery, Ardurnio Mega
// and motor shield from DK electronics.
//
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Created by Raefi Azrani,1006Q78842,Bachelor(Hons) Electrical & Eletronic Engineering,
//Taylor's University,Malaysia - 2015
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Initial Setting
#include <AFMotor.h>

//Include motor library

AF_DCMotor M1(3);
AF_DCMotor M2(4);

//Connecting to Motor 2 for Right Side


//Connecting to Motor 1 for Left Side

const int pingPin_R = 44;


const int pingPin_C = 45;
const int pingPin_L = 46;
const int pingPin_SR = 42;
const int pingPin_B = 32;
const int pingPin_SL = 22;

//sets the pin for the PING sensor on the right side
//sets the pin for the PING sensor in the center side
//sets the pin for the PING sensor on the left side
//sets the pin for the PING sensor on the side right
//sets the pin for the PING sensor on the back side
//sets the pin for the PING sensor on the left side

long duration_C, i_C,duration_R, i_R,duration_L, i_L,duration_SR, i_SR,duration_B,


i_B,duration_SL, i_SL;

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup(){
//Turining on the motor
M1.setSpeed(200);
M2.setSpeed(200);
delay(2000);
Serial.begin(115200);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
{
int i;
int j = 1;
delay(5000);
for(i=0; i<1; i*1){
j++;
getping_all();

52

//all clear, no obstacles within 20" in any direction


if(i_C >= 15 && i_R >= 15 && i_L >= 15 && i_SR >=15 && i_SL>= 15)
{
forward();
}
//obstacle(s) within 0-6" range
else if (i_L < 3 || i_C < 3 || i_R < 3 i_SR ||15 || i_SL|| 15)
{
stop();
backward();
delay(1500);
stop();
if(j%3 == 0){ // randomness function
back_right(); //for movements,
back_right();
//in a loop,
left();
j=1;
}
else{
back_left();
back_left();
right();
}
}
//obstacle(s) within 6"-12" range
//obstacle on left and center and right
else if (i_R < 6 && i_C < 6 && i_L < 6)
{
stop();
backward();
delay(1500);
back_left();
stop();
right();
forward();
}
//obstacle on center OR left and right
else if (i_L >= 6 && i_R >= 6 && i_C < 6 ||
i_C >= 6 && i_R < 6 && i_L < 6)
{
stop();
backward();
delay(1500);
back_left();
stop();
right();
forward();
}
//obstacle on left and center

53

else if (i_R >= 6 && i_C < 6 && i_L < 6)


{
stop();
backward();
delay(1500);
back_left();
}
//obstacle on right and center
else if (i_L >= 6 && i_C < 6 && i_R < 6)
{
stop();
backward();
delay(1500);
back_right();
}
//obstacle on right
else if (i_L >= 6 && i_C >= 6 && i_R < 6)
{
left();
left();
}
//obstacle on left
else if (i_R >= 6 && i_C >= 6 && i_L < 6)
{
right();
right();
}
//obstacle(s) within 12"-30" range
//obstacle on left and center
else if (i_R >= 15 && i_C < 15 && i_L < 15)
{
right();
right();
}
//obstacle on right and center
else if (i_L >= 15 && i_C < 15 && i_R < 15)
{
left();
left();
}
//obstacle on right and left
else if (i_C >= 15 && i_L < 15 && i_R < 15)
{
forward();
}
//obstacle on right
else if (i_L >= 15 && i_C >= 15 && i_R < 15)
{
left();
}
//obstacle on left
else if (i_R >= 15 && i_C >= 15 && i_L < 15)

54

{
right();
}
//obstacle on center
else if (i_L >= 15 && i_R >= 15 && i_C < 15)
{
if(j % 2 == 0){
left();
j=1;
}
else{
right();
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//motion setting
//max speed at 250 PWM
//min speef at 150 PWM
//Turning Degree :23,45,68,90 and 113
//
// Command:
//
run(FORWARD) (motor run in clockwise direction)
//
run(BACKWARD) (motor run in anticlowise direction)
//
setSpeed(n) (motor speed is set at n)
//
delay(n) (delay function at (n)ms as duration period)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//playing
void play(){
M1.setSpeed(250);
M2.setSpeed(250);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(1000);
}
void forward(){
//moving forward at 250PWM FPA
if(i_C>=27 && i_R>=27 && i_L >=27 && i_SR >=27 && i_B >=27 && i_SL>=27){
//moving forward at 250PWM FPA
M1.setSpeed(250);
M2.setSpeed(250);
M1.run(FORWARD);
M2.run(FORWARD);
}
else if(i_C <=26 || i_R <=26 || i_L <=26 || i_SR <=26 || i_B <=26 || i_SL <=26 ){
//moving forward at 200PWM MPA
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(FORWARD);
}

55

else if(i_C <=10 || i_R <=10 || i_L <=10 || i_SR <=10 || i_B <=10 || i_SL <=10){
//moving forward at 150PWM NPA
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(FORWARD);
}
}
//moving forward at 150PWM NPA
void forwardN(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(FORWARD);
}
//moving forward at 200PWM MPA
void forwardM(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(FORWARD);
}
//moving forward at 250PWM FPA
void forwardF(){
M1.setSpeed(250);
M2.setSpeed(250);
M1.run(FORWARD);
M2.run(FORWARD);
}
//temporary moving forward at 180 PWM
void forwardD(){
M1.setSpeed(180);
M2.setSpeed(180);
M1.run(FORWARD);
M2.run(FORWARD);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//moving backward at 150PWM
void backward(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(BACKWARD);
}
//temporary moving backward at 150 PWM
void backwardD(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(BACKWARD);
delay(500);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

56

//stop
void stop(){
M1.run(RELEASE);
M2.run(RELEASE);
delay(300);
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Nearest Point of Distance
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//moving right at 23 degrees
void right23(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(50);
stop();
}
//moving right at 45 degrees
void right45(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(140);
stop();
}
//moving right at 68 degrees
void right68(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(160);
stop();
}
//moving right at 90 degrees
void right90(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(200);
stop();
}
//moving right at 113 degrees
void right113(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(260);
stop();
}

57

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//moving left at 23 degrees
void left23(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(50);
stop();
}
//moving left at 45 degrees
void left45(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(140);
stop();
}
//moving left at 68 degrees
void left68(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(160);
stop();
}
//moving left at 90 degrees
void left90(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(200);
stop();
}
//moving left at 113 degrees
void left113(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(260);
stop();
}

58

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Mid Point of Distance
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//moving right at 23 degrees
void right23M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(50);
stop();
}
//moving right at 45 degrees
void right45M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(120);
stop();
}
//moving right at 68 degrees
void right68M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(140);
stop();
}
//moving right at 90 degrees
void right90M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(180);
stop();
}
//moving right at 113 degrees
void right113M() {
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(220);
stop();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//moving left at 23 degrees
void left23M(){
M1.setSpeed(200);

59

M2.setSpeed(200);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(50);
stop();
}
//moving left at 45 degrees
void left45M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(140);stop();
}
//moving left at 68 degrees
void left68M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(180);stop();
}
//moving left at 90 degrees
void left90M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(180);stop();
}
//moving left at 113 degrees
void left113M(){
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(220);stop();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//move left
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(BACKWARD);
M2.run(FORWARD);
//move right
M1.setSpeed(200);
M2.setSpeed(200);
M1.run(FORWARD);
M2.run(BACKWARD);

60

//backward right
void back_right(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(FORWARD);
M2.run(BACKWARD);
delay(300);
backward();
delay(500);
stop();
delay(350);
}
//backward left
void back_left(){
M1.setSpeed(150);
M2.setSpeed(150);
M1.run(BACKWARD);
M2.run(FORWARD);
delay(300);
backward();
delay(500);
stop();
delay(350);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//Ultrasonic Scanning Setting
//
// PING Sensor:
//
L = Left side sensor
//
C = Centre side sensor
//
R = Right side sensor
//
SL = side left sensor
//
SR = sode right sensor
//
B = Back side sensor
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void getping_C()//get distance from center PING
{
pinMode(pingPin_C, OUTPUT);
digitalWrite(pingPin_C, LOW);
delayMicroseconds(2);
digitalWrite(pingPin_C, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin_C, LOW);
pinMode(pingPin_C, INPUT);
duration_C = pulseIn(pingPin_C, HIGH);
i_C = microsecondsToI(duration_C);
}
void getping_R()//get distance from right PING
{
pinMode(pingPin_R, OUTPUT);
digitalWrite(pingPin_R, LOW);
delayMicroseconds(2);

61

digitalWrite(pingPin_R, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin_R, LOW);
pinMode(pingPin_R, INPUT);
duration_R = pulseIn(pingPin_R, HIGH);
i_R = microsecondsToI(duration_R);
}
void getping_L()//get distance from left PING
{
pinMode(pingPin_L, OUTPUT);
digitalWrite(pingPin_L, LOW);
delayMicroseconds(2);
digitalWrite(pingPin_L, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin_L, LOW);
pinMode(pingPin_L, INPUT);
duration_L = pulseIn(pingPin_L, HIGH);
i_L = microsecondsToI(duration_L);
}
void getping_SR()//get distance from side right PING
{
pinMode(pingPin_SR, OUTPUT);
digitalWrite(pingPin_SR, LOW);
delayMicroseconds(2);
digitalWrite(pingPin_SR, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin_SR, LOW);
pinMode(pingPin_SR, INPUT);
duration_SR = pulseIn(pingPin_SR, HIGH);
i_SR = microsecondsToI(duration_SR);
}
void getping_B()//get distance from back PING
{
pinMode(pingPin_B, OUTPUT);
digitalWrite(pingPin_B, LOW);
delayMicroseconds(2);
digitalWrite(pingPin_B, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin_B, LOW);
pinMode(pingPin_B, INPUT);
duration_B = pulseIn(pingPin_B, HIGH);
i_B = microsecondsToI(duration_B);
}
void getping_SL()//get distance from side left PING
{
pinMode(pingPin_SL, OUTPUT);
digitalWrite(pingPin_SL, LOW);
delayMicroseconds(2);
digitalWrite(pingPin_SL, HIGH);
delayMicroseconds(5);
digitalWrite(pingPin_SL, LOW);
pinMode(pingPin_SL, INPUT);
duration_SL = pulseIn(pingPin_SL, HIGH);
i_SL = microsecondsToI(duration_SL);
}

62

//Scan all in sequence with 2ms delay


void getping_all()
{
getping_C();
delay(2);
getping_R();
delay(2);
getping_L();
delay(2);
getping_SR();
delay(2);
getping_B();
delay(2);
getping_SL();
delay(2);
}
long microsecondsToI(long microseconds){
return microseconds / 74 / 2;}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//CODE END
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

63

LIST OF PUBLICATIONS

Journal
1. Raefi Azrani, Aravind CV, Collision Avoidance using Nature-Inspired Bat
Algorithm, "International Journal of Applied Engineering Research ISSN 09734562, Online : ISSN 1087-1090 [Under Reviewed]
Conferences
1. Raefi Azrani, Aravind CV, Collision Avoidance using Nature-Inspired Bat
Algorithm,

Green

technologies

in

power

generation,

Communication

Instrumentation-2016,26-27 Feb 2016, Chennai, India [Accepted for Publishing]


2. Raefi Azrani, Aravind CV, Bat Algorithm, Smart City Intelligence Safety Systems
on Road,Engineering Undergraduate Research Catalyst Conference (EURECA2015)
Kuala Lumpur, Malaysia. [Accepted]

64

También podría gustarte