Roy 2015

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 16

Computers and Electrical Engineering xxx (2015) xxx–xxx

Contents lists available at ScienceDirect

Computers and Electrical Engineering


journal homepage: www.elsevier.com/locate/compeleceng

Design of a high-speed line following robot that smoothly


follows tight curves q
Abhishek Roy a,⇑, Mathew Mithra Noel b
a
Robert Bosch Engineering and Business Solutions, Bangalore, India
b
VIT University, Vellore 632014, India

a r t i c l e i n f o a b s t r a c t

Article history: In this paper the design of a novel high-speed, low-cost autonomous line following robot
Received 8 June 2014 that combines human expert knowledge and experiential data extracted through neural
Received in revised form 28 May 2015 network training has been proposed and implemented. The proposed autonomous robot
Accepted 4 June 2015
overcomes the disadvantages of earlier designs like oscillations in motion, exception han-
Available online xxxx
dling, high-cost and high-energy consumption. The robot uses a novel square-topology
infrared sensor matrix that enables it to anticipate a turn by sensing the track ahead. Three
Keywords:
different strategies to control high-speed line following robots are presented: a neural net-
Artificial neural networks
Reinforcement learning
work based control strategy, a learning vector quantization based strategy and a reinforce-
Learning Vector Quantization ment learning based strategy. The final design based on a hybrid neural network based
Low-cost line following robot control strategy smoothly followed the benchmark track with just 4 neurons and used a
Non-linear control low-cost 8-bit microcontroller to implement the control system.
Ó 2015 Elsevier Ltd. All rights reserved.

1. Introduction

Autonomous line following robot are increasingly being used to perform object transport tasks in industrial environ-
ments, in surveillance applications and in construction and mining industries [1–4]. However not much published work
exists that discuss possible control strategies and implementations. Thus an investigation of possible control strategies,
detailed design, implementation and performance of a line following robot is of interest. In this paper a novel neural network
based low-cost line following robot that learns to smoothly follow a random curved path with minimal oscillations and over-
shoot is presented.
A line follower is an autonomous robot that detects and follows a line that is drawn on a flat surface. The path consists of a
black line on a white surface or a white line on a black surface. The track is designed such that the absorption coefficient of
the line being followed is significantly different from the background track. The control system must sense the line and
maneuver the robot to stay on course while constantly correcting any deviation from the line being followed. Most line fol-
lowing robots that currently exist share a common system architecture which includes a chassis, locomotion system, sensing
system and logic control unit.
Possible schemes for sensing the position of the robot with respect to the line include (i) Light Dependent Resistor (LDR)
based luminous intensity detection system where the surfaces are differentiated from one another based on the amount of
light reflected from the surface [4–6]. (ii) Infra-Red (IR) based detection system [6,7] which works on the principle of variable

q
Reviews processed and recommended for publication to the Editor-in-Chief by Associate Editor Dr. Anand Bhojan.
⇑ Corresponding author.
E-mail addresses: roy.277@osu.edu (A. Roy), mathew.m@vit.ac.in (M.M. Noel).

http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
0045-7906/Ó 2015 Elsevier Ltd. All rights reserved.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
2 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

absorption of IR rays by different surfaces. (iii) Camera feed based line imaging system [8–11] where a high-resolution track
image is captured.
The locomotion systems of most robots comprise of standard Direct current (DC) geared motors with approximately 1 Nm
torque and speed varying from 100 to 300 rpm. The control unit depends on the nature of the hardware implementation
chosen. Possible implementation choices include (i) combinational logic structures using transistor level design or logic
gates, (ii) microcontroller/microprocessor based implementations (8-bit, 16-bit, and 32-bit) and (iii) Field Programmable
Gate Array (FPGA) based implementations.
Fig. 1 shows the operation of a conventional two sensor line following robot [6,7]. In this design the robot is initially
placed such that the line lies between the two sensors. The simplest control strategy directs the robot to take control actions
that result in neither of the two sensors detecting the line. For example in Fig. 1 since the bottom sensor detects the line at
the start the control action must be to take a right turn to prevent the bottom sensor from detecting the line.
A major problem encountered with the two sensor scheme is the oscillatory nature of the robot motion even on simple
tracks. If the lateral spacing between the two sensors is not properly chosen the robot might go into an oscillatory state
where the average energy received by the motors is so low and that the robot comes to a stop.
The two sensor approach may be improved by using more sensors [4] as shown in Fig. 2. Here the control strategy is to
direct the robot to take actions that will keep the central sensor on the track at all times. The state of the other two sensors
determine wether a left or right turn is to be taken. However, it can be seen that this sensor topology is capable of taking
action only based on the instantaneous input (presence of turns in the track ahead cannot be detected) which results in over-
shoot when turns are taken [5].
In this paper a 3  3 square-topology infrared sensor matrix (Fig. 3) is proposed to overcome the disadvantages of earlier
linear sensor topologies. The strategy here is to try and maintain the central column of sensors in line with the track with the
highest priority being to keep the sensor row closest to the robot on the line. If the sensor in the central column farthest from
the robot does not detect the line then it is evident that a turn is approaching and logic control unit steers the robot such that
it does not overshoot the turn.
A 3  3 square-topology infrared sensor matrix arrangement has 9 sensors, each of which gives a binary output which
together represent the position of the robot (state) with respect to the line. The total number of possible combinations of

Fig. 1. Line follower with 2 sensors arranged linearly. In this approach curves cannot be anticipated and motion is oscillatory.

Fig. 2. Line follower with 3 sensors demonstrates less oscillation but curves cannot still be anticipated.

Fig. 3. A 3 by 3 square arrangement of sensors can detect the curvature of the track so line follower has reduced oscillations and overshoot.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 3

the sensor matrix outputs or states is therefore 29 (512). The classical approach to control a robot with such a sensor arrange-
ment would be an algorithm that assigns a control action to all of the 512 possible cases using a set of IF–THEN rules. The
major drawback of using IF–THEN rules is the difficulty encountered in logically determining the correct outcomes for each
of the 512 states manually. In general if a n by n sensor matrix is used the possible the number of possible states is 2n2. This
exponential increase in the number of states with increase in sensor resolution precludes the use of rule based systems when
the number of sensors is large. The computational power of the controller used is also a limitation for rule based control
strategies [10,11]. Thus alternate control strategies that avoid the need to specify a control action for every state manually
are of interest. A central idea in this paper is to use a learning algorithm to learn a control strategy from training data thereby
avoiding problems associated with determining an optimal control action for an exponentially large state space.
In the following three different learning algorithm based strategies are discussed. Two different Artificial Neural Network
(ANN) control strategies, a Learning Vector Quantization (LVQ) based control strategy and a Reinforcement Learning (RL)
based control strategy are considered. In the first approach the mapping between the state of the sensors and the control
action (left, straight and right) is learnt from a human trainer using a feedforward ANN. This approach resulted in poor train-
ing performance and large-ANN, so a second approach was considered. In the second approach in addition to the feedforward
ANN a set of IF–THEN rules was used to handle certain exceptional states (4 states) for which the ANN has difficulty learning
the correct control action. This approach resulted in smooth control performance without overshoot with just 3 tansig hid-
den layer neurons. ANN based control strategies for some benchmark robot control tasks that use the function approxima-
tion abilities of ANNs are explored in [12–17].
Three robots were built during the process of progressively refining and optimizing the performance and cost of the robot.
The cost considered in the paper is the total cost of manufacturing the robot. The first prototype cost INR 5000 and was the
costliest since it employed an ARM processor, a PIC microcontroller and a flash memory system to store the training data for
the ANN. Once the training data was acquired an ANN was trained externally using the Back propagation algorithm and only
the trained ANN was implemented in the second robot. Performance analysis and experimentation on the second robot
showed the number of neurons in the ANN could be reduced from 15 to 4 if a hybrid strategy is adopted. The hybrid strategy
employed IF–THEN rules to handle exceptional states avoiding the need for the ANN to learn the outputs for the exceptional
states. This hybrid strategy with reduced number of neurons was used in the final robot. Since the final design employed only
4 neurons and simple IF-THEN rules a single PIC microcontroller was found to be sufficient. The second robot also cost INR
5000, however the final optimized design with the hybrid strategy cost only INR 2000 due to reduction in computational and
storage requirements.
As described in the introduction a rectangular array of IR LEDs and photodiode pairs was used to sense the position of
robot relative to the track. IR LED and photodiodes are inexpensive devices (costing only INR 10 each) and do not signifi-
cantly increase the total cost if additional pairs are added. The cost of the robot was determined primarily by cost of the
microcontroller, DC motors and battery.
A detailed discussion of possible strategies for controlling line following robots and possible design with experimental
validation is presently not available in published literature. Also the problem of designing a line following robot that learns
to smoothly follow a curved track has not been addressed in existing literature. There is also an increasing need for line fol-
lowing robots in the manufacturing sector and new application areas such as autonomous transportation of passenger bag-
gage and transportation of raw materials in the construction industry. Thus, a discussion on different strategies for
controlling line following robots with possible hardware design and experimental results is of interest.
The paper is organized as follows: firstly the physical construction of the line following robot is presented, next three pos-
sible control strategies which overcome the disadvantages of the classical approach are proposed and finally implementation
details and results for the ANN based control strategy are presented.

2. Construction of the robot

Three robots were developed to address different requirements (Fig. 4). The first robot was dedicated for collecting the
training data. It required a number of subsystems for acquiring and storing the training data. The subsystems of the training
robot include (i) LCD display: which gives feedback of training samples to the human trainer. (ii) SD card module: used for
storing large volumes of training data. (iii) Buzzer: to indicate whether the system was ready for the next sample. (iv) Matrix
Keypad: to allow a human trainer to control the robot. However, these subsystems were not essential in the final design and
hence the final mapping generated by the neural net was implemented on smaller robots which had only the necessary sub-
systems. The second robot explored a pure ANN based control strategy and the third robot explored the better performing,
hybrid ANN control strategy.
The section below describes the mechanical and electronic sub-systems of the developed robots.

2.1. Mechanical sub-system: chassis

Figs. 5–8 show the computer aided design (CAD) models of the robot. In the figures below the green plane at the top is the
Printed Circuit Board (PCB) containing the processor. The bottom green plane is the PCB that supports the 3 by 3
square-topology infrared sensor matrix and signal conditioning circuitry. The bottom blue plane is an aluminum structure

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
4 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

Fig. 4. (Left to Right) The hybrid ANN robot, the pure ANN robot and the training robot.

Fig. 5. An angular view of the robot.

Fig. 6. The bottom view of the robot.

that supports the entire assembly. Low-cost aluminum strips were used to contrast the mechanical framework to support
the different subsystems of the robot. The main design consideration for the chassis is the need for a light weight structure
that does not compromise structural stability.

2.2. Electronic subsystems

Fig. 9 below shows the schematic of the training robot used to collect data from a human trainer for training the
feed-forward ANN. In the following section the important electronic subsystems are discussed.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 5

Fig. 7. Shows an angular view of the bottom.

Fig. 8. The side view of the robot.

Fig. 9. The schematic of the training robot.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
6 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

2.2.1. Track sensing system


An image of the track is acquired using a 3 by 3 IR LED/Photodiode matrix (Fig. 10). The output of the photodiode is an
analog voltage that varies with the amount of IR radiations reflected from the surface below the sensor. The IR sensing sys-
tem provides a voltage between 0.22 V and 0.56 V corresponding to varying reflectance of the track surface. The output of the
photodiode is quantized to 1 or 0 corresponding to white and black surfaces and is fed to the ARM/PIC18f processor.
Thus the sensor above a black portion of the track will report a value of zero and a sensor above the white line will report
a value of 1 to the data acquisition system. The collection of all outputs of the sensors can be organized as a bit vector with 9
components representing the positions of the robot with respect to the track. This 9 dimensional vector of zeros and ones is
referred to as the state of the robot. In Fig. 9 pins SNS1–SNS9 output the state vector and is interfaced to the digital input
lines of the ARM controller.

2.2.2. Data storage system: SD card module


The state vectors and the user inputs from the keyboard are stored in the SD card periodically. The SD card is interfaced
via the SPI protocol. Data is written to the SD card in batches of 512 Bytes (1 sector = 512 Bytes). Training data can be col-
lected in 2048 sectors i.e. 1,048,576 readings. The SD card acts as the slave device and the controller acts as the master. The
MISO, MOSI, SSEL and SCK pins of the SD card module are interfaced to the SPI1 port of the ARM controller. The ARM con-
troller, being the master is responsible for generating the clock for the data transfer.

2.2.3. Motor direction control: motor driver module


L298 motor driver chip was selected for this application as it can easily handle power fluctuations from the power supply
which in this case is a lead acid battery. The large heat sink integrated in the L298 chip ensures good heat dissipation which
is important as a lot of heat is generated by the motor driver. The chip is designed to work with TTL level input signals and
hence can be easily interfaced to any microcontroller. It supports a current rating of 2 A and has an integrated
over-temperature protection. The direction control of motion is achieved by sending the appropriate digital levels to M1a,
M1b, M2a, M2b (Fig. 9) which is the low-side and high-side power stage control inputs to the L298. Speed control is achieved
by sending a 10 kHz PWM signal at EN1 and EN2 (Fig. 9) of the L298.

3. Control strategies

In the following three possible control strategies for controlling a high-speed line following robot that use a
square-topology infrared sensor matrix arrangement to sense the environment are presented.

3.1. Hybrid ANN based control strategy

The track consists of a white line on a black surface and is sensed by a 3 by 3 square-topology infrared sensor matrix. The
signal conditioning circuit quantizes the output of each sensor as either 1 or 0 corresponding to white and black (Sec-
tion 2.2.1). Thus the state of the sensor matrix s can be represented as a column vector with 9 elements each of which

Fig. 10. The 3 by 3 IR LED/Photodiode matrix used to obtain an image of the track.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 7

Table 1
Rule base.

State (s) Action (p (s))


100100100 Right (1)
010010010 Straight (0)
000010010 Straight (0) half power
001001001 Left (1)

Table 2
Learning Vector Quantization (LVQ) based line following control strategy.

(1) Initialize training data D ¼ fðsðnÞ ; aðnÞ Þ : n ¼ 1 to Ng, learning rate l(0) and prototype vectors
w1 (Left), w2 (Right), w3 (Straight Ahead).
(2) FOR k = 1 to number of epochs
(3) FOR n = 1 to N do the following:
(4) Let qðsðnÞ Þ ¼ argmaxksðnÞ  wi k2 be the prototype vector closest to sðnÞ in terms of Euclidean distance.
IF C sðnÞ ¼ C qðsðnÞ Þ THEN wq wq þ lðkÞðsðnÞ  wq Þ
ELSE wq wq  jlðkÞðsðnÞ  wq Þ
END (3)
(5) Reduce learning rate lðkÞ lð0Þ=k
END (2)
(6) Do the following for continuous control.
(i) Acquire the current state s from sensors
(ii) Compute the class to which s belongs using qðsÞ ¼ argmaxks  wi k2
(iii) Take action Left, Right or Straight Ahead corresponding to the class computed in (ii)

Table 3
Algorithm for RL based control of line following robot.
2 3
0 1 0
(1) Define the desired state sd ¼ 4 0 1 0 5, current state
0 1 0
s ¼ ½sij  sij ¼ 1 if sensor abov e track; else 0 and reward rðsÞ ¼ ksd  sk2
(2) For each of the possible 512 states, initialize VðsÞ :¼ 0
(3) Repeat for N iterations
Repeat for every state

VðsÞ ¼ RðsÞ þ maxcV  ðs0 Þ ð5Þ


a2A

End
End
(4) Repeat for each state

pðsÞ ¼ arg maxVðs0 Þ ð6Þ


a2A

Store pðsÞ
End
(5) Do the following for continuous control:
(i) Acquire the current state s from the sensor matrix
(ii) Command the robot to take action a ¼ pðsÞ
(iii) Go to (i)

can be either 1 or 0. Thus, s ¼ ½x1 x2 x3    x9 T ; xi 2 f0; 1g. The control action that can be taken in each state is the direction
of motion of the robot namely right, straight and left coded as -1, 0 and 1 respectively. A control policy for this robot is a
mapping between the set of states and the set of actions: p : S ! A where S ¼ fs : s ¼ ½x1 x2 x3    x9 T xi is 0 or 1g and
A ¼ f1; 0; 1g. Thus the set of states is finite with 512 elements. The goal of selecting a control strategy to make the robot
follow the track can be reformulated as a function approximation problem that attempts to learn a policy p that makes the
robot smoothly follow the track without oscillations. One approach is to use a feed-forward ANN to learn an approximation p ^
to p where p is the policy followed by a human trainer [18]. The training data to the feed-forward ANN is set of state action

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
8 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

pairs where the action is the action taken by a human trainer to make the robot follow the track smoothly (Section 4.1).
When a feed-forward ANN was employed to learn the control policy of a human trainer it was observed that an ANN with
more than 14 hidden layer neurons was needed. In order to reduce the complexity of the controller and reduce ANN training
time a hybrid approach was explored. In this approach the response to certain obvious exceptional states was handled using
IF–THEN rules and the ANN produces the responses to the remaining states. With this hybrid approach only 3 tan-sigmoidal
(tansig) hidden neurons were needed to learn the control policy and make the robot smoothly follow the track. Thus, the
exceptional states were excluded from the training data to reduce the complexity of the ANN. Table 1 shows the rule base
used in the hybrid approach for 4 exceptional states. The control action for the remaining states is computed by the
feed-forward ANN.
The Back Propagation (BP) algorithm use to train the ANN can be computationally costly, suffer from poor-generalization
and convergence to local minima so alternative strategies are considered in the following [18].

3.2. Learning Vector Quantization (LVQ) based control strategy

The state of the robot can be defined as the position of the robot with respect to the track. The 3 by 3 sensor matrix out-
puts ones and zeros corresponding to the presence or absence of the line below each sensor. The output of the sensors can
thus be represented as a 9 by 1 column vector s of ones and zeros. Thus the state space of the robot has 512 states
ðfsðnÞ : n ¼ 1 to 512gÞ. At each time step the robot moves forward and a decision to turn left, right or go straight ahead
has to be made based on the state of the robot. The problem of learning the mapping between states and actions can be con-
sidered as a classification problem where each state is classified as Left, Right or Straight Ahead depending on the decision. In
the following we consider the application of the LVQ algorithm [19] which is a supervised classification algorithm for solving
the line following problem. The LVQ algorithm can be used to find the prototype vectors that represent the centroids of the
three classes Left (CL), Right (CR) and Straight Ahead (CS) from the training data. The training data obtained by controlling the
robot by a human trainer can be represented as D ¼ fðsðnÞ ; aðnÞ Þ : n ¼ 1 to Ng. Where s(n) is the state and a(n) is the correspond-
ing action taken by the human n trainer at time n. After the prototype vectors for each class are obtained from the LVQ algo-
rithm, the robot can be controlled in real-time by classifying each state obtained from the sensors using a nearest neighbor
decoding scheme [18]. A detailed working of the LVQ based control strategy is presented in Table 2 below:

3.3. Learning without training data: Reinforcement Learning (RL) based control

Reinforcement Learning (RL) solves the general problem of learning a control policy by interacting with the environment
[20–22]. The learner also referred to as an ‘agent’ receives a scalar reward signal r(s, a) from the environment that indirectly
specifies the desirability of taking an action ‘a’ in state ‘s’ (a and s are vectors in general). The most important attribute of the

Fig. 11. The training robot with its subsystems.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 9

Fig. 12. Flowchart depicting the algorithm used for acquiring training data from a human trainer.

RL framework is the use of a scalar value function V p ðsÞ to capture the desirability of following a policy p. The policy p is a
mapping, p : S ! A from the set of states to the set of all possible actions. The value of a state is defines to be

VðsÞ ¼ Rðs0 Þ þ cRðs1 Þ þ c2 Rðs2 Þ þ    ð1Þ


In (1) c 2 ½0; 1Þ is a discount factor that favors immediate rewards over rewards obtained in the future. The value function
satisfies Bellman’s equation:

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
10 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

V p ðsÞ ¼ RðsÞ þ cV p ðs0 Þ ð2Þ


Bellman’s equation simply states that the total cumulative, discounted reward obtained from state s by following a policy
p is the sum of the reward for being in the current state s and the cumulative rewards obtained from the next state s0 . The
optimal value function V  is the value function that results when the optimal or best policy is followed. In other words V  ðsÞ
is the maximum possible cumulative discounted reward obtainable from state s. Since the maximum possible reward
obtainable from state s is equal to the sum of the immediate reward for being in state s and the maximum possible dis-
counted reward from the next state s0 , V  also satisfies Bellman’s equations. It is clear from (3) that the best possible action
(optimal action) is the action that leads to the state with the highest value, hence (4).

V  ðsÞ ¼ maxV p ðsÞ ¼ RðsÞ þ maxcV  ðs0 Þ ð3Þ


p a2A

p ðsÞ ¼ arg maxV  ðs0 Þ ð4Þ


a2A

Eqs. (3) and (4) are used as the basis of an iterative algorithm called the Value Iteration algorithm [18] to learn a control
policy p. In the following a Value Iteration based algorithm to learn a control policy for a high-speed line following robot is
proposed.
The current state of the robot can be represented by a matrix s ¼ ½sij , whose elements are 1 or 0 based on presence or
absence of the track below sensor in row i and column j. The set of possible actions is given by
A ¼ fLeft; Straight Ahead; Rightg.
Since the ultimate goal is to align the robot with the track with the center of the sensor arrangement while moving for-
ward, the ideal state is taken to be s ¼ ½sij  sij ¼ 1 if j ¼ 2. The reward function must penalize for any deviation from the
desired state so the reward function is taken to be rðsÞ ¼ ksd  sk2 . This choice of the reward function provides a negative
reward when the sensor matrix is not aligned with the track and zero if it is perfectly aligned. It is clear from the form of the
reward function that any strategy that maximizes cumulative rewards must align the robot with the track while moving for-

Fig. 13. The Algorithm used for the hybrid line follower.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 11

ward. Table 3, shows the application of the RL based control policy for controlling a line following robot that senses its envi-
ronment using a 3 by 3 sensor matrix.

4. Experimental setup and implementation details

The following Section describes the implementation of the training robot (Fig. 11) and the final robot with the hybrid ANN
control strategy.

4.1. Design of the data acquisition algorithm of the training robot

The training robot featured a LCD display for feedback of training samples to the human trainer, a SD card module for
storing large volumes of training data and a buzzer for communicating whether the system was ready for the next sample
or not. The system was developed on an ARM processor for easy integration of different modules.
During the process of training, the user presses one of the 3 buttons on the keyboard corresponding to forward, right or
left depending on the desired output expected from the robot at that point of the track. The switches on the keyboard act as
inputs to the ARM processor. Upon detecting activation on any of the three switches the reading from the 3 by 3
square-topology infrared sensor matrix is captured and stored in a temporary array (software implementation) along with
the correct response chosen by the human trainer for that state. After the array index size reaches 512 the data is ready to be
written to a sector of the SD card. During SD card write the system halts and issues a warning to the user directing him not
press any switch while the sector of SD card is being written with the training data. When a particular control key is pressed
(corresponding to ‘left’, ‘right’ or ‘straight’ control actions) the data from the sensing system is acquired and the robot moves
a small distance in the direction indicated by the human trainer.
Steps taken for collection of training data from a human trainer:

1. The operator presses a control key on the keypad indicating the correct control action for the current state of the robot.
2. The state of the robot is read from the sensor array.
3. The training data sample involving the correct control action and state vector from sensor array is stored in the SD card.

Fig. 14. The response of the ANN for different training inputs. Two tansig hidden layer neurons and one linear output neuron were used.

Fig. 15. The response of the neural net having 13 tansig hidden layer neurons and one linear output neuron with different training inputs.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
12 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

The training robot was used to acquire close to 100,000 training data samples from a human trainer. Fig. 12 below
describes the complete algorithm used in the software implementation of the training robot.

4.2. Design of the control algorithm for the robots with pure and hybrid ANN strategy

The Robot using the Pure ANN control strategy uses the output ‘y’ of the final feed-forward ANN to determine the control
action. The 9-bit state vector ‘s’ captured by the matrix sensor (represented as X1–X9) is fed as input to the ANN function
approximation, The computed value of the function lies between [1.5, +1.5]. The computed value of this function is trans-
lated to motor direction control using a simple classification as shown below. The ANN is trained using Back-propagation
from training data obtained with a human trainer. The ANN function approximation is given below:

Y ¼ 0:5ftanhð5:2047X 1 þ 0:3180X 2  5:1899X 3  5:0482X 4 þ 0:3243X 5  5:1247X 6  5:0238X 7 þ 0:3275X 8


 5:1788X 9  14:7892Þg þ 0:0001ftanhð4:2505X 1  4:7910X 2 þ 1:7235X 3  1:1613X 4  4:8663X 5 þ 1:9845X 6
 1:5827X 7  4:8587X 8  4:9005X 9  4:8322Þg  ftanhð5:5850X 1 þ 2:4121X 2  8:9355X 3 þ 5:6893X 4
þ 2:4215X 5  8:8812X 6 þ 5:4962X 7 þ 2:4138X 8  8:8382X 9 þ 15:8126Þg þ 0:5

The action taken by the controller (command issued to the drive system) ‘a’ is related to the ANN output ‘y’ as follows:

IF neural net output y e [1.5, 0.5] then a = 1 (Right).


ELSE IF neural net output y e (0.5, 0.5) then a = 0 (Straight).
ELSE IF neural net output y e [0.5, 1.5] then a = 1 (Left).

This is so because the neural net training data followed the same convention. i.e. 1 corresponds to right, 0 corresponds
to straight and 1 corresponds to left.

Fig. 16. The response of the ANN for different training inputs. Three tansig neuron hidden layer neurons and one linear output neuron were used.

Fig. 17. The response of the neural net having 3 tansig neurons with modified training data. Exceptional states were removed to simplify the function
approximation task solved using the ANN. The exceptional states were separately handled using a rule base.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 13

Fig. 13 summarizes the overall operation of the line following robot with the hybrid control strategy. The function
approximation by the ANN and the set of IF–THEN rules (Table 1) taken together completely specify the control action (left,
straight or right) for each possible state of the sensor array. Depending on the output of the sensor matrix, either the ANN or
set of IF–THEN rules are used to compute the action.

5. Results

As discussed above, two different ANN based control strategies were explored. In the first approach, a feedforward ANN
was used to learn the mapping between the sensor system states and the control action by using the training data acquired
by the training robot by observing a human trainer. It is known from existing literature on function approximations using
ANNs that an arbitrary function with finite number of finite discontinuities can be approximated to any accuracy with
two tansig and one linear layer. So tansig and linear neurons were chosen for the ANN. However, current theory does not
address the number of neurons needed to achieve a given accuracy in a particular application. It is also known that too many
neurons lead to over training and poor generalization. Thus, an empirical approach to determine the number of neurons was
adopted. In particular, starting with a large number of neurons the number of neurons was progressively reduced till the
ANN failed to train successfully.
The minimal number of neurons that resulted in acceptable error performance was found to be 4 as training failed with 3
neurons and no appreciable improvement in error was achieved with more than 4 neurons. Fig. 14 shows the response of the
ANN having two tansig neurons in the hidden layer, it can clearly be seen that the neural net fails to learn the mapping
between the sensor states and the corresponding control action. In Fig. 15 it can be seen that with 13 tansig neurons in
the hidden layer the ANN learns the mapping almost perfectly. Fig. 16 shows the outputs of the ANN having three tansig
hidden layer neurons. It is seen that there is no appreciable performance advantage by using 13 hidden layer neurons instead
of three. The ANN with fewer neurons is preferable to avoid generalization problems associated with overfitting. ANNs with
large number of neurons are also more likely to simply memorize the training data due to overfitting effects and fail to pro-
duce an appropriate output for inputs not present in the training data. Thus computational costs as well as generalization
considerations favor the use of the ANN with 3 hidden layer neurons.

Best Validation Performance is 9.9708e-10 at epoch 51


Mean Squared Error (mse)

0
10 Train
Validation
Test
-5 Best
10

-10
10

0 10 20 30 40 50
51 Epochs

Fig. 18. A plot of the Mean square error versus training epochs.

Fig. 19. The pure ANN control strategy based robot vs. the hybrid ANN control strategy based robot on the benchmark track.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
14 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

Table 4
Comparison of the performance of the pure ANN robot and the hybrid ANN robot.

Pure ANN robot Hybrid ANN robot


Average track completion time 25 s 13 s
Endurance with fully charged battery 1 h 43 mins 1 h 56 mins

In the second approach a hybrid feed-forward ANN based approach was explored. In this approach some exceptional
states (as listed in Table 1) are handled using IF–THEN rules and the remaining states are handled by the ANN. This approach
resulted in good training performance with only 3 hidden layer neurons (Figs. 17 and 18).
Both the robots had the same payload of 5 kg and energy storage unit (12 V, 1.2 Ah lead acid battery) and were tested
against on a 4 m track with different concave and convex curves (Fig. 19). The performance metrics used for comparison
of different line following strategies include battery endurance and track completion times and the result of the relative
comparison of both the robots are listed in Table 4.
In order to analyze the relative extent to which the rule-base and the neural network algorithm are used in the hybrid
ANN Robot, an algorithm was implemented to keep track of the frequency of each. It was observed that the rule-base
was used approximately 23% of the time and the remaining cases were computed using the neural network function
approximation.
It was experimentally demonstrated that using the hybrid ANN control strategy reduced the oscillations in the system
and resulted in increased speed (50%) and lesser power consumption (13%).

6. Conclusion

An ANN based control strategy, a LVQ based strategy and a RL based strategy for controlling high-speed line following
robots were proposed and implementation results for a hybrid ANN based strategy was presented. The design presented here
incorporates a novel square-topology sensor array that detects the curvature of the track being followed in advance and
overcomes the disadvantages of linear topology sensor arrays used earlier. A general formula for calculating the turn decision
(left, right or straight) for any line following robot that uses the 3 by 3 square-topology sensor matrix to sense its state is
presented. The hybrid ANN based strategy required only the final successfully trained ANN to be implemented in the micro-
controller avoiding the need for computationally costly online training.
The use of a hybrid strategy avoids the need for large neural networks to learn the nuances of the state-to-action map-
ping. This hybrid control strategy resulted in a system that smoothly followed the track with just three tansig neurons in the
hidden layer. Based on the results presented it can be inferred that a hybrid control strategy that uses ANNs in combination
with IF–THEN rules obtained from human experts can effectively avoid the need for large neural networks for robot control
tasks. This work demonstrated that the difficult task of smoothly following tight curves can be learnt with just 4 artificial
neurons if a hybrid approach is taken. Future work will consider the implementation and comparison of the ANN based con-
trol strategy with LVQ and RL based strategies.

Appendix A

Sl. Item Qty. Description/application


no.
Mechanical subsystems
1 Aluminium sheet (Size: 1 The aluminum sheet can be cut in the shape as illustrated in
12  12 in.) (Thickness: 0.75 mm) Section 2.1. For weight reduction the plate can be perforated. This
forms the chassis of the bot
2 Motor: DC geared 2 Speed: 200 RPM, Torque: 1 Nm, Shaft Dia: 5 mm, Current consumption:
800 mA (Peak), 400 mA (nominal)
3 Wheels with rubber gripper 2 1mm Rubber gripper used for better traction. Wheels with alloy rims
(100 mm) are used for better rigidity
4 Castor Wheel (diameter: 10 mm) 1 Located at the rear of the bot and ensures complete translational in the
horizontal plane
5 Brass spacers M3 (1 in.) 8 For connecting various subsystems of the robot to the chassis
6 Brass spacers M3 (2 in.) 4 For connecting various subsystems of the robot to the chassis
7 L-angles (30  30 mm) 2 Connects the motors to the chassis
8 M3 Screws 26 For connecting the spacers and L-Angles

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx 15

Appendix A (continued)

Sl. Item Qty. Description/application


no.

Electrical subsystems
1 LPC2148 Development boards 1 The training bot is built around the ARM controller. The ARM controller
(ARM7TDMI architecture) has 2 serial ports, 2 SPI controllers and is clocked at 60MHz (x5 PLL).
The SD-Card module is interfaced to one of the SPI-lines. The keyboard
module and the track image sensor serve as inputs to the ARM
controller. The 9-bit processed data along with the control action from
the keyboard is temporarily stored in the flash memory of the
controller from which it is later transferred to the SD-Card. Refer to
Sections 2.2 and 4.1 for more details
2 PIC18f458 Development board 1 The final ANN trained function is implemented on this 8-bit controller.
The PIC 18 series of controllers have an enhanced Harvard architecture
and are able to clock up to 40 MHz
3 Motor driver (Pins: M1a, M1b, 1 L298 Motor driver having two channels is used. It receives TTL level
M2a, M2b, EN1, EN2) control inputs from the ARM controller (Training bot) and PIC
controller (Final bot). Refer to Section 2.2.3 for more details
4 Track image sensing unit (Pins: 1 A Vishay IR LED TSAL6100 is used as the transmitter and a Visual IR
SNS1–SNS9) Photodiode BVP10NF is used as the receiver. The photodiode’s output
signal is fed to an op-amp LM358 configured as a comparator. A 3  3
arrangement of this setup is fabricated on a PCB. Refer to Section 2.2.1
for more details
5 Keyboard (Pins: KYB1–KYB3) 1 3 momentary-switches are configured in the active high configuration.
The output of the keyboard is routed to the ARM processor of the
trainer bot
6 LCD display 1 Provides visual data feedback to the trainer and is present in the trainer
bot
7 Lead acid battery 1 12 V, 1.2 Ah valve regulated lead acid battery is the power source of the
system
8 SD card module 1 Standard class-4 SD Card adapter with SPI pin-outs for interface (MOSI,
MISO, SSEL, SCK)

References

[1] Mae Johannes, Hazor Andy, Wiryanto Nina Karina, EndraOey, Hedwig Rinda. Modified-maze algorithm for mobile robot navigation. Proc Eng
2012;50:740–7. http://dx.doi.org/10.1016/j.proeng.2012.10.081 [ISSN 1877-7058].
[2] Ibrahim Mohd Tarmizi, Hanafi Dirman, Ghoni Ruzlaini. Autonomous navigation for a dynamical hexapod robot using fuzzy logic controller. Proc Eng
2012;38:330–41. http://dx.doi.org/10.1016/j.proeng.2012.06.042 [ISSN 1877-7058].
[3] Yusoff Mohd Ashiq Kamaril, Samin Reza Ezuan, Ibrahim Babul Salam Kader. Wireless mobile robotic arm. Proc Eng 2012;41:1072–8. http://dx.doi.org/
10.1016/j.proeng.2012.07.285 [ISSN 1877-7058].
[4] Khoon Teh Nam, Sebastian Patrick, Saman Abu Bakar Sayuti. Autonomous fire fighting mobile platform. Proc Eng 2012;41:1145–53. http://dx.doi.org/
10.1016/j.proeng.2012.07.294 [ISSN 1877-7058].
[5] Bhatti Anjum Khalique, Bhatti Muhammad Iqbal, Khowaja Kamran, Shah Asadullah. Command based line following robot using RF technology. J Adv
Comput Sci Technol Res 2011;1:25–35.
[6] Nagrecha H, Roy A. Design, fabrication and implementation of a transistor level autonomous navigational robot using mobile-DTMF interface. Int J Appl
Eng Res 2013;8(15):1863–74.
[7] Gosim Nwokomah Wilson, Faisal Tarig, Al-Assadi HMAA, Iwan Mahmud. Pick and place ABB working with a liner follower robot. Proc Eng
2012;41:1336–42. http://dx.doi.org/10.1016/j.proeng.2012.07.319 [ISSN 1877–7058].
[8] Schmidt, Rodney Albert, Jr. A study of the real-time control of a computer-driven vehicle, PhD in Electrical Engineering, 1971.
[9] Zhang Lijun, Zhuan Xiangtao, Gao Xukai. Design and implementation of a vision based four-wheeled line track robot. In: 2010 WASE international
conference on information engineering (ICIE), vol. 3; 14–15 August 2010. p. 3–6.
[10] Elhady WE, Elnemr HA, Selim G. Implementation and evaluation of image processing techniques on a vision navigation line follower robot. J Comput
Sci 2014;10(6):1036–44.
[11] Wen YJ, Liu Z. Development of embedded intelligent line-following robot based on image processing. Adv Mater Res 2014;849:346–50.
[12] Yang Simon X, Meng M. Real-time collision-free path planning of robot manipulators using neural network approaches. In: Proceedings of 1999 IEEE
international symposium on computational intelligence in robotics and automation, 1999. CIRA ’99, 1999. p. 47–52.
[13] Hunmo Kim, Parker Joey K. Artificial neural network for identification and tracking control of a flexible joint single-link robot. In: Proceedings SSST ‘93.,
twenty-fifth southeastern symposium on system theory, 1993, 7–9 March 1993. p. 233–7.
[14] Bing Hao, Xuefeng Dai, The collision-free motion of robot with Fuzzy neural network. In: 2010 2nd international conference on industrial and
information systems (IIS), vol. 2; 10–11 July 2010. p. 219–22.
[15] Kim YH, Lewis FL. Neural network output feedback control of robot manipulators. IEEE Trans Robot Autom 1999;15(2):301–9.
[16] Pomerleau DA. Knowledge-based training of artificial neural networks for autonomous robot driving. In: Connell J, Mahadevan S, editors. Robot
learning. Boston Kluwer Academic Publishers; 1993. p. 19–43.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014
16 A. Roy, M.M. Noel / Computers and Electrical Engineering xxx (2015) xxx–xxx

[17] Mitchell TM, Thrun SB. Explanation-based neural network learning for robot control. In: Hanson, Cowan, Giles, editors. Advances in neural information
processing systems, vol. 5. San Francisco: Morgan Kaufmann; 1993. p. 287–94.
[18] Learning Machine. Tom mitchell. McGraw Hill; 1997.
[19] Ding S, Chang XH, Wu Q-H. A study on the application of learning vector quantization neural network in pattern classification. Appl Mech Mater
2014;525:657–60.
[20] Sutton RS, Barto AG. Introduction to reinforcement learning. vol. 10; 1998.
[21] Mahadevan S, Connell J. Automatic programming of behavior-based robots using reinforcement learning. In: Proceedings of the ninth national
conference on artificial intelligence. San Francisco: Morgan Kaufmann; 1991.
[22] Lin LJ. Hierarchical learning of robot skills by reinforcement. In: Proceedings of the international conference on neural networks, 1993.

Abhishek Roy is currently a future graduate student at the Ohio State University. He completed his B.Tech. in Electronics and Instrumentation from VIT
University, India. He worked at Robert Bosch Engineering and Business Solutions, in the battery management systems team for hybrid and electric vehicles.
His research interests include smart control systems, real time embedded systems and artificial intelligence.

Mathew Mithra Noel is currently a professor in the School of Electrical Engineering at VIT University. He received his Ph.D. in Electrical and Computer
Engineering from the University of Alabama at Birmingham and M.E. in Electronics and Control from The Birla Institute of Technology and Science, India. His
current research interests include Machine Learning, Control Systems and Optimization.

Please cite this article in press as: Roy A, Noel MM. Design of a high-speed line following robot that smoothly follows tight curves. Comput
Electr Eng (2015), http://dx.doi.org/10.1016/j.compeleceng.2015.06.014

You might also like