Sie sind auf Seite 1von 10

MEI 23016: INTRODUCTION TO ROBOTICS AND AUTOMATION

TASK B

LINE FOLLOWING ROBOT

Group Members
Mohammed Johirul Islam (245185)
Samuel Olaiya Afolaranmi (245179)
1

TASK B: LINE FOLLOWING ROBOT

TABLE CONTENTS
Abstract..3
Introduction.3
Methodology..4
Implementation8
Challenges9
Summary/Conclusion.10
References.10

FIGURES
Fig 1: The Line following robot model4
Fig 2: Front View of robot5
Fig 3: Top view of robot5
Fig 4: The Flow Chart.8

TASK B: LINE FOLLOWING ROBOT

Abstract
This project assignment is carried out under the course; Introduction to Robotics and Automation. The
aim of this project is to build a mobile robot, controlled by a NXT Controller to follow a line
autonomously along a dedicated track (called the Arena). The shape of the Arena is rectangular but
with several lines of intersection inside it. The robot is meant to run all the time in the trajectory lines
and also making a decision on the direction to go and the line to follow at this intersection. The robot is
to also have the capability of identifying directions that has no path and therefore not follow it. A
reflective Aluminium foil was used to mark the different points of intersection so as to enable the robot
to clearly identify these points. The robot hardware was built using the lego building blocks which
consist of 1 light sensor (positioned at the front of the mobile robot), 1 NXT Controller, 2 motors and 2
tyres. The robot follows the line with the aid of the light sensor which detects the line and calculates
the light intensity which goes to the NXT controller as an input. The Controller processes this value and
uses PID control (for smooth flow) algorithm to follow the line by controlling the movement and
direction of the motors and hence the movement and direction of the robot. The logic of the controller
was programmed in Textual Code using NXC (Not Exactly C) software.

1.0 Introduction
The application of robotics is growing widely as can be found in manufacturing, medicine, automation,
oil and gas and many other fields. Robots are reprogrammable machines designed for specific tasks. The
knowledge of mechanics, electronics and software is very essential in building and programming a
robot. Generally, the major parts that make up the robot control system are the controller, sensor and
motors. The controller is the brain; the sensor is the eyes or detecting part and the motors, the legs of
the robot. This project focuses on the building of a robot capable of following a line and also making
decisions at turning points along a dedicated track (called the Arena).

TASK B: LINE FOLLOWING ROBOT

2.0 Methodology
2.1 Robot Design
The design of the robot was made as simple as possible in order to make it navigate the track easily
without problems. The building components consist of 1 light sensor (positioned at the front of the
mobile robot), 1 NXT Controller, 2 motors and 2 tyres. The NXT controller was positioned in between the
two motors and connected to it using lego bricks and connectors. Two small tyres were connected to
the motors using two shafts. This is to ensure stability, navigation and load carrying support of the entire
system (even distribution of the weight of the robot). The light sensor was connected to the NXT
controller and positioned in front of the robot i.e in front of the wheels. This is obviously so because the
light sensor is responsible for the detection of the line along the track. A small length of RJ-11 cable was
used to transmit light signals from the light sensor port to the input port 3 of the NXT controller. Two
additional RJ-11 cables were also used to transmit signals from output ports A&B of the NXT controller
to the separate ports of the two motors in order to bring about the control of the wheels. An additional
tiny wheel was positioned at the rear of the robot to offer more support and stability. Small tyres were
selected for the wheels so that the light sensor can be at a low level and be as close as possible to the
track for easy detection of the colours and to minimize interference from ambient light and allow proper
readings.

Fig 1: The Line following Robot Model


4

TASK B: LINE FOLLOWING ROBOT

Fig 2: Front View of Robot

Fig 3: Top View of Robot

2.2 Components Used


S/N
1

Name

Type

Port

NXT Controller

Controller

N/A

Quantity Description
1

It is responsible for implementing the


program logic based on input received
from the light sensor

Light Sensor

Input

It generates digital readings based on


different light intensities of the colours.

NXT Motors

Servo

A&B

Output
4

Rubber Tyres

Provides wheel motion based on signal


received from controller

N/A

Provides smooth movement of the robot


based on motor effect

Connecting cables

RJ-11

A,B & 3

Transmits signals between controller,


sensor and motors.

TASK B: LINE FOLLOWING ROBOT

2.3 Control Principle/Mode of Operation


The mobile robot designed for this project follows clearly the trajectory lines in the arena. The arena line
is a combination of 3 colours (Black, dark grey and light grey) whereby the robot has to follow the
middle line in which is dark grey. With the aid of the light sensor, the robot continuously takes digital
readings due to light intensity of the colours along the line. These readings are transmitted as input
signals into the NXT controller. Based on the logic already into the controller, it generates corresponding
signals which goes out as an output from the controller into the motors to bring about actuation which
determines the steering and movement of the robot. In order to ensure that the robot keeps following
the line along a straight path, continuous correction of wheel movement due to deviation from the line
is made by the controller i.e depending on the direction of deviation from the track, the power of the
motors are adjusted (one motors slow down and the other moves faster) by the controller to keep the
robot back on track. This is made possible through the integration of the PID control mechanism into the
NXT controller operation. With the PID control mechanism, the controller firsts calculates its current
position (actual position) based on light sensor readings. It then calculates the error from the target
position (set point i.e the dark grey line). The controller then adjusts (turn) the powers of the left and
right motors based on the error calculated. The magnitude of the adjustments is proportional to the
error, hence the proportional component of the PID control. In the process of refocusing over the line,
the robot may overshoot the set point and move to the other side of the line. Derivative control is used
to mitigate the effect of overshoot. The Integral property is employed to improve the accuracy of the
controller. The PID algorithm is given below;
error = setpoint - actual_position

(error calculation)

proportional = Kproportional * error (Proportional = error times proportional constant)


integral = integral + error (Integrate, sum of errors)
derivative = (error - previous_error) / dt (stores change in error to derivate)
output = proportional + Kintegral * dt * integral + Kderivative * derivative (Calculation of the Output,
which is the correction factor applied to the left and right motors)
previous_error = error (save error value for period)

TASK B: LINE FOLLOWING ROBOT

The constants (Kproportional, Kintegral and Kderivative) in the PID control algorithm were adjusted to
minimize overshoot and oscillations and eliminate errors more quickly at the highest speed possible by
first adjusting the proportional constant, the integral constant and then the derivative constant. The
final values were determined by trial and error through repeated testing.
At the points of intersection where we have the reflective aluminium foil, the robot stops temporarily to
make a decision on the direction of movement. The light sensor takes readings and sends to the
controller for decision making. The robot could go straight, turn right or turn left. The decision making is
a function of the logic programmed into the controller. For the decision making, the Random function
was used. Once the controller receives light readings for aluminium, the Random function is
implemented and as a result, any of the numbers 0, 1 and 2 is generated randomly. Each of these
numbers represents a decision. Based on the generated number; a decision is taken i.e (0 for forward
movement, 1 for left turn and 2 for right turn). The robot then takes the direction corresponding to the
number generated and stops again and scans to check whether there is a path (i.e whether the path
taken is along the track based on sensor readings corresponding to the set point). If set point readings
are measured, it continues along that path. However, if measured readings differ from the set point, the
robot returns back to its previous position and then the random function is implemented again. It
continues this until it finds a valid path along the track.
Therefore, the robots navigation along the track is based on repeated and continuous implementation
of the PID algorithm and the decision making algorithm which is based on the use of the Random
function.

TASK B: LINE FOLLOWING ROBOT


3.0 Implementation
3.1 Flow Chart

Fig 4: The Flow Chart

TASK B: LINE FOLLOWING ROBOT

3.2 Programming
The coding for this was done using NXC (Not eXactly C) textual programming software. All important
constants and parameters such as Kproportional, Kintegral, Kderivative and all other variable
assignments were made at the beginning of the program, outside the main program (task main()).The
line following mechanism was implemented using PID control algorithm and the robot decision making,
using the Decision making algorithm which is based on random number generation using the Random
function. The PID Control algorithm (PID_move())and Decision making algorithm (Decision()) were
written and implemented as sub routine functions which would later be called in the main program. The
main program is made up of the declaration and assignment of the set point value and also a never
ending while loop. The main program consists of the while loop and the function calls, PID_move() and
Decision(). PID_move function is used for steering control of the motors based on light sensor readings
using the PID control algorithm. The Decision function is triggered at the points of intersection due to
the light sensor readings on getting to the aluminium foil. The two sub routine functions PID_move() and
Decision() defined earlier are recursively called based on different values of light intensity specified in
the program which is determined by the light sensor. For different values of measured light intensity,
the main program continues to execute the PID_move() and Decision() functions which results in the
movement and navigation of the robot.
4.0 Challenges
For the initial design of the rear wheel, we had used fixed wheel, small but similar to the other two front
wheels. However, during the navigation of the robot particularly at turning points, we observed that the
rear wheel was causing some kind of friction and thereby causing a delay in motion and preventing the
robot from making a perfect turn, which also lead to the robot missing the track atimes. To solve this,
we implemented a castor like design for the rear wheel such that it could rotate free about 360
degrees as it moves along the track, particularly at turning points.
Also, the intensity of the light grey colour of line was very close to the intensity of the white colour
background of the arena. This sometimes makes the robot to confuse light grey colour for white and
therefore retracts and implements the decision making algorithm instead of the PID control algorithm
and by so doing, it misses the track completely. To correct this, we defined a fixed set point value of 38
(for dark grey) in the program as against the robot using the light sensor to take the set point value at
9

TASK B: LINE FOLLOWING ROBOT

the beginning of the program. This really helped the robot in avoiding this confusion and clearly
distinguishing between the different colours of the line and the arena.

5.0 Summary/Conclusion
The line following robot project brought about interesting and great challenge to us. It helped us to
discover better ways of relating and understanding ourselves. It helped us to understand the
relationship between mechanical and electrical systems and their integration with programming. It also
helped to expand our knowledge of robotics and also develop huge interest in programming generally as
we are willing to learn programming to a greater depth. Most importantly, the project helped us to
understand some of the theories taught in class in the robotics course an also the course on control
theory. We should continue to have projects like this so that it can help understand better, improve and
also develop new skills. The success of this project was as a result of the meaningful contribution and
participation of the both team members also the enormous advice, support and guidance of the project
coordinator, Mr Luis Gonzalez who really helped us in fine tuning our thoughts and designs for the
project. In all, the project was a huge success as we were able to achieve the aim of building a line
following robot using the lego kits.
6.0 References
http://www.engineersgarage.com/contribution/line-follower-robot
http://jerryfarke.com/wp-content/uploads/2013/04/Robot-Report_FINAL.pdf
http://en.wikipedia.org/wiki/Mobile_robot

10

Das könnte Ihnen auch gefallen