BY
of Bachelor of Science
in Electronic Engineering
JANUARY 2017
DECLARATION
I hereby declare that this project report entitled SLAM BASED CARGO DETECTING
FORKLIFT is an original work carried out by AnumImtiaz, Aruba Shahid, Syed AsharAlam,
Fatima Shoaib, Saqib Akhter in partial fulfillment for the award of degree of Bachelor of Science
Engineering and Technology, Karachi, Pakistan during the year 2013 to 2014. The Project report
has been approved as it satisfies the academic requirements in respect of project work prescribed
I also declare that it has not been previously and concurrently submitted for any other degree or
other institutions.
Signature: ____________________________
Date: _____________________________
ii
ACKNOWLEDGEMENT
First of all we would like to thank ALMIGHTY ALLAH without which nothing would have
been possible to accomplish. His willing makes everything possible and we are able to complete
this Final Year Project entitled SLAM BASED CARGO DETECTING FORKLIFT.
On this occasion, deepest thanks and appreciation to our family members for their prayers,
cooperation, encouragement, care and constructive suggestion from the beginning till the end.
Without their support we would have not been able to complete this project on time. We dedicate
We would like to express our heartfelt gratitude to our internal advisor Sir Noman Mehmood for
giving us strength, knowledge and sincere advice throughout the project. Due to his invaluable
guidance and generous support this project turns out to be a successful one.
We would like to thanks all our teachers for sharing their knowledge and skills with us
throughout these four years. Furthermore, thanks to the lab staff, our batch mates, friends and
Finally, we would like to thank Sir Syed University of Engg. And Technology for giving us
platform to show our skills and polish them, converting our knowledge into a valuable product.
January 2017
iii
TABLE OF CONTENTS
Page
DECLARATION...................................ii
ACKNOWLEDGEMENT....iii
TABLE OF CONTENTS..................................iv
LIST OF FIGURES.vii
ABSTRACT..ix
1.0 Introduction.....1
1.1 Robot...1
1.2 Cartesian coordinate robot...1
1.3 Course of action...2
1.4 Background and overview...2
1.5 Application of Project......3
1.6 Conclusion...3
2.0 Introduction.....4
2.1 SLAM..4
2.1.1 History of SLAM..5
2.1.2 Implementation of SLAM.....5
2.2 Forklift.....5
2.2.1 History of Forklift.....6
3.0 Introduction.....7
3.1 Circuit Diagram...8
3.2 Mechanical Structure.......8
3.2.1 Main Assembly.10
3.2.2 Dimensions...11
iv
CHAPTER FOUR: SYSTEM HARDWARE..12
5.0 Introduction..27
5.1 Python..27
5.1.1 Whats New in Python .30
5.1.2 Features.30
5.2 Why python31
5.2.1 Readability..........31
5.2.2 Libraries..32
5.2.3 Community.......32
5.3 Forward Motion Planning and mapgeneration...33
5.3.1 Monocular Slam....33
5.3.2 Grid Slam..33
5.4 PygameWindow.....40
5.5 Opencv.....41
v
5.5.2 Why Open Cv? ......43
5.5.3 Image processing.......43
5.6 K-Nearest Neighbors Algorithm..45
5.6.1 Classification with K-Nearest Neighbors..............45
5.6.1 K-Nearest Neighbors Algorithm overview........50
5.7 Optical Character Recognition...54
5.7.1 Introduction...54
5.7.2 Steps with images..54
5.8 Flowchart Representation of OCR..59
5.9 Object Detection.60
5.10 Reverse MotionPlanning.61
5.11 Wi-Fi Communication62
5.11.1 Introduction....62
5.11.2 How Wi-Fi works? ....62
5.11.3 IEEE 802.11 standard63
5.11.4 Interference....63
5.11.5 Ad hoc communication..64
6.1 Result.66
7.0 Conclusion67
REFERENCES...68
GLOSSARY....69
APPENDIX A72
Coding.....72
APPENDIX B...116
Cost Analysis. ...........116
Gantt Chart.117
DATASHEETS.118
TURNITIN REPORT..121
vi
LIST OF FIGURES
Page
vii
5.9 Complete Algorithm For Map Generation...............................................................................40
viii
ABSTRACT
Our motivation is to create an autonomous path planning forklift robot for industrial use by using
different navigation techniques and technologies. It has a wide range of applications, such as
algorithm. Path planning in robotics is defined as navigation that shall be collision free and most
optimum for the autonomous vehicle to maneuver from a source to its destination.
The project is synergism and implementation of four techniques SLAM, image processing, OCR
and WIFI communication system. The project is implemented by using ultrasonic sensors,
Simultaneous Localization and Mapping (SLAM) is a process by which a robot can build a map
of an unknown environment and at the same time determine its location within this map. This is
Thus, the first goal of the project is to investigate how well SLAM, using ultrasonic sensors and
secondly picking up the object from one place and placing it to its desired location autonomously
through image processing and OCR (optical character recognition). The use of only these types
of measurements results in a solution where the estimation of the position and heading of the
robot is obtained. A substantial deployment would represent a major step forward in the
scale SLAM system, capable of vehicle localization and map building over large areas, and
moving an object from one location to another not only help as means of a solution to the map
management problem but also perform the task of locating the object to the desired position
ix
Chapter 1 Introduction
CHAPTER ONE
INTRODUCTION
1.0 INTRODUCTION
For the past century there has been a lot of buzz about artificially smart machines i.e. machine
that could learn that is navigate through unknown paths , create vocal responses of different
questions , respond to cognitive and repetitive tasks hence eliminating the human imputes. The
last century gave us the industrial revolution it is safe to say today is the dawn of smart
revolution.
1.1 ROBOT
A robot is an autonomous system which exists in a physical world, can sense its environment,
and can act on it to achieve some goals. Industrial robot serves as a general purpose unskilled or
semiskilled laborer. There are 5 types of industrial robot our robot is Cartesian coordinate robot.
A Cartesian coordinate robot has three linear axes of control (x, y, z). Cartesian coordinate robots
with the horizontal members supported at both ends are sometimes called Gantry robots and can
1
Chapter 1 Introduction
We have to create an autonomous land vehicle which can generate map of its path by using
ultrasonic sensors. Camera is used to detect the desired object by using image processing
technique i.e. image similarity algorithm and an optical character recognition algorithm to read
alpha numeric characters. Then hydraulic lift is used to lift the object and placed back it to its
initial position by using reverse motion technique. The path of movement and 2d coordinates
will be wirelessly transmitted using Wi-Fi communication. 2D map is shown on the pygame
window.
Therefore as Pakistan in the coming years will experience a surge in dry port facilities due to
It is an overriding concern, if these facilities are not modernized may have financial
repercussions.
The course of implementation involves the visual access to data that is a map showing path
of movement.
The question arises that how to create an autonomous ground vehicle that maps area as well
We make our task more challenging the return path will be implemented using our own
algorithm.
2
Chapter 1 Introduction
SLAM is central to a range of indoor, outdoor, in-air and underwater applications for both
manned and autonomous vehicles. This project is not only beneficial for the large industries
moving heavy accoutrements, rigging, baggage, equipment etc, but also its applications can vary
1.6 CONCLUSION
environment and, using relative observations only, incrementally build a perfect map of
the environment.
To lift that object through Hydraulic lifter and then placed that object to desire place.
3
Chapter 2 Theoretical Background & Review Of Literature
CHAPTER TWO
2.0 INTRODUCTION
For every project, there are always some inspirations and requirements which motivate to make
the project so that it must fulfill what one had thought. Similarly, for us it is the industrial
revolution. For the past century there has been a lot of buzz about artificially smart machines I.e.
machine that could learn that is navigate through unknown paths , create vocal responses of
different questions , respond to cognitive and repetitive tasks hence eliminating the human
imputes.
Our project is SLAM based cargo detecting forklift which means we have to perform three major
environment.
Cargo detection: Detecting the desired object by performing image processing and OCR
Forklift: Hydraulic lifter is used to lift the object and placed back it to its position.
SLAM is used for robot mapping. It is a problem to keep track of robot location within it while
creating or updating a map of an unknown environment. There are several algorithms to solve
this problem include the particle filter and extended Kalman filter.
4
Chapter 2 Theoretical Background & Review Of Literature
In 1986 research on the approximation of 3-D uncertainty by R.C. Smith and P. Cheeseman
cause an inspirational work in SLAM.Other revolutionary work was conducted by the research
group of Hugh F. Durrant-Whyte in the early 1990s. This showed that there are infinite solutions
In 1999 by Austrian inventor named Erich Bieramperl described autonomous robot systems. See
Organisms" (US-Patent Nr. 6172941). Every map generation of the environment is based on the
comparison of previously acquired and stored elapse-time data with actual elapse-time data.
SLAM got worldwide attention when DAPRA Grand challenge won by self-driving STANLEY
Various algorithms of SLAM are implemented in the libraries of ROS (Robot operating
system)
2.2 FORKLIFT
A forklift is an industrial truck used to lift an object and placed it at short distances. In the early
5
Chapter 2 Theoretical Background & Review Of Literature
Forklift has been serving the industry for 90 years. Forklift was introduced by Clark in 1917 and
these machines offered for sale in 1918. Initially these forklift looked like tractors having
platform attached to it. Over the early 1920s, the design of the forklift evolved with a vertical
lifting mast such as we know today. In the 1930s Hyster Company moved from a manufacturer
In World War II the need of fork lift increases. This brought number of manufacturers into this
business. The US Armed forces required mobile method to move materials to the front lines for
After world war, the need of more efficient fork lift increases this led to introduce the Narrow
Aisle Reach truck by Raymond Corporation in the early 1950s. Other manufacturers, such as
Lewis-Sheppard and Crown Equipment, introduce industries with lines of battery powered pallet
trucks.
Fork lift have been developed which increases its use to move the cargo of the world. Now fork
lifts are not only bulky industrial equipment. Todays forklift equipped with electronic
equipment operator to interface with cargo management systems and new RFID technology to
6
Chapter 3 Method Of Investigation Or Detailed Of The Design
CHAPTER THREE
3.0 INTRODUCTION
The System model, autonomous SLAM based forklift is divided into 5 main parts. The first part is
the forward motion planning and map generation to move the forklift to the destination. The
second part is the image acquisition from fixed camera and image processing by using MATLAB
in which performed object detection by comparing with the reference image to identify the
desired object. The third part is the optical character recognition to read and the data of the desired
object. The fourth part is the reverse motion planning to return the forklift to its original position
after lifting object. Finally the fifth part is to create the communication between user interface and
the controlling device on the forklift to see the map and other information on the user interface.
7
Chapter 3 Method Of Investigation Or Detailed Of The Design
8
Chapter 3 Method Of Investigation Or Detailed Of The Design
9
Chapter 3 Method Of Investigation Or Detailed Of The Design
10
Chapter 3 Method Of Investigation Or Detailed Of The Design
3.2.2 DIMENSIONS
11
Chapter 4 System Hardware
CHAPTER FOUR
SYSTEM HARDWARE
We have designed the cargo lifting robot in such a way that the back of the body has greater
weight so the machine can lift the weight from the front through the fork so that it may not fall
down.
4.1 MOTORS
When we talk about the motors, in normal many or almost all motors operate by interacting
between current of the windings and the magnetic field of the electrical motor which produce a
For specific specification it can be used in industry which is used for the transporter system by
automate the working of all operations in which all the working motors which can be made
automatic.
An electric motor is a motor which generates or produce electrical energy by using the
mechanical energy.
General motors GP with characterized and with a standard dimensions produce mechanical
energy for firm use. A micro motor can be used in wrist watch or wall clock.
Construction
Power source
Applications
Outputs
12
Chapter 4 System Hardware
Applications of the motors which we can use in daily life are power appliances, hair dryer, fan,
The DC source produces by motors such as rectification, vehicles of motors and battery.
Direct Current voltage or direct current is used to supply a dc drive to drive a dc motor. A DC
Permanent magnet motors are used as replacement for the field windings. It has brushes,
armature and the commutator. It has the low power. The starting torque of the permanent magnet
13
Chapter 4 System Hardware
The armature reaction of the DC motor is not compensate because of the magnetic
strength of the field gets weaker due to demagnetizing effect of the armature winding.
We cannot control externally the speed of the field because the field in the air gap is
fixed.
Applications of PMDC motors are: automobiles starter, toys, wipers, washers, hot blowers, air
Forward braking, forward motoring, reverse motoring and reverse braking. These are four
In motoring mode the electrical energy is converted into mechanical energy thus machine acts as
a motor. In braking mode the mechanical energy is converted into electrical energy thus the
machine act as a generator and it oppose the motion. The motor can run in both the directions
14
Chapter 4 System Hardware
In the I quadrant power developed is positive and the machine is working as a motor supplying
mechanical energy. The I (first) quadrant operation is called Forward Motoring. II (second)
quadrant operation is known as Braking. In this quadrant the direction of rotation is positive,
and the torque is negative, and thus, the machine operates as a generator developing a negative
The kinetic energy of the rotating parts is available as electrical energy which may be supplied
back to the mains. In dynamic braking dissipated the energy is dissipated in the resistance.
The III (third) quadrant operation is known as the reverse motoring. The motor works, in the
reverse direction. Both the speed and the torque have negative values while the power is positive.
In the IV (fourth) quadrant, the torque is positive, and the speed is negative. This quadrant
K is constant and the torque is varies by varying the flux and the armature current Ia.
In separately excited dc motor field winding is independent that of armature winding. in this
motor the armature current does not flow through the field windings and the field is energized by
15
Chapter 4 System Hardware
Hydraulic motor is used to convert the hydraulic energy into mechanical energy.It consist of a
rotating shaft which it uses hydraulic pressure and flow to generate torque and rotation.
(T=Displacement xpsi/24pi).
Slow motion.
Hydraulic fluids may catch fire in the event of leakage, especially in hot regions glycol-
16
Chapter 4 System Hardware
Hydraulic motors have many applications like we can use it in crane drives, winches, mixer, roll
mills, etc.
A gear motor is an extension of a dc motor. It has a gear box that increases torque and decreases
in speed. Hydraulic gear motors and piston motors are high speed motors. The output speed of
the shaft can be reduced by using gears. The operating pressure of the gear motor is usually 100
17
Chapter 4 System Hardware
4.2.1 WORKING:
Hydraulic gear motor has greater torque and less speed. They reduce the speed in series of gears
which create more torque. To increase the torque output of the hydraulic motor we need gears.
The gear box contains the integrated series of gears which is attached by a main motor and shaft
is connected with a second reduction shaft. The ratio between diameters of two spiked gears
The greater the diameter on output side results in greater torque but less rpm.
The longer the reduction gears connected in a series (chain of gears) the slower the output at the
end.
The example of the gear is the electric time clock which has the hour, minute and second hands.
The gears of the motor rotate at certain speed of 1500 revolutions per minute to spin the rotor.
4.3.1 H-BRIDGES
H-bridge is an electronic device that enables a voltage which can be applied across a motor are
any load or it can be applied in both directions. H-bridge can be used to run the motors. These
18
Chapter 4 System Hardware
circuits are often used in robotics and other applications to allow DC motors and stepper motors
to run backwards and forward. H bridges not only used for forward and backward motion but
also for stopping the motor. When it comes to motor control and H-bridges, there are two types
of power transistors that take the main stage. The power BJT and power MOSFET. The main
difference between the two is as far as we concerned is the power loss, thats why we use the
power MOSFET in our project and also relay based H-bridge L298.
4.4 RASPBERRY PI 3
The Raspberry Pi 3 is the third generation Raspberry Pi. It replaced the Raspberry Pi 2 Model B
19
Chapter 4 System Hardware
Bluetooth 4.1
1GB RAM
4 USB ports
40 GPIO pins
Ethernet port
The Raspberry Pi 3 has an identical form factor to the previous Pi 2 (and Pi 1 Model B+) and has
20
Chapter 4 System Hardware
4.5 BATTERY
Battery is a device that consists of one more electrochemical cells. It transforms chemical energy
into electricity which is used to power electrical devices. In our project we used dry battery
LIDO whose power rating is 12ah/12v. We used battery to operate hydraulic lift, 4 motors and
Raspberry pi 3.
Always keep battery in a dry, cool ventilated area. Do not store near heat or open flames.
Conductive material should not touch the battery terminals. Battery failure and fire may occurred
21
Chapter 4 System Hardware
4.6 SENSORS
A sensor is a device which is used to detect physical data from an environment (analog data) and
convert it into digital data which is readable by our controller and make decisions on the basis of
the data provided by the sensors. There are two types of sensors:
In our project we used both the sensors local and global. While selecting the local sensor which
is used to measure the distance from surrounding environment we have three different choices
i.e. IR sensor, LIDAR (light detection and ranging) and ultrasonic sensor.
IR (infrared sensor) is an electronic device. It has high noise immunity. But we cant use this in
our project because it works on a very short range i.e. 1mm to 2mm. It can easily be affected by
physical environment like fog, dust, rain and pollution which affect data transmission and it cant
LIDAR (light detection and ranging) is a sensor in which light is used in the form of a pulsed
laser to measure distances. It has very high range and resolution but we cant use it in our project
Ultrasonic sensor is used to determine the distance by utilizing the properties of sound that is the
time difference between sending and receiving the sound pulse. It is excellent for very-near
range max 4m but accurate up to 2m. It work regardless of light levels. It is cheap and small. We
The hardware model consists of sensors to sense the distances from the surrounding environment
simply by using ultrasonic distance sensors. We used three ultrasonic sensors in our project.
22
Chapter 4 System Hardware
Ultrasonic module HC-SR04 includes ultrasonic transmitter, receiver and control circuit.
For calculation of distances the trigger acts as an output and emits a 40kHz signal
The timer is initiated till the echo sensor receives an input reflected signal of 3.3v due to
1kohm resistor.
The start and stop time are calculated and subtracted to get pulse duration usually in
milliseconds.
Centimeters.
23
Chapter 4 System Hardware
24
Chapter 4 System Hardware
5V VCC supply
0V ground
4.7 CAMERA
In our project camera is used for image processing that is image similarity and optical character
recognition of desired cargo. While selecting camera we have different choices i.e. Pi cam, pixy
Pi camera is a module of Raspberry pi which can be used to take still picture and record videos.
It is tiny and 5 megapixels camera module to take high definition videos and still picture which
means it required larger bandwidth. That is why we dont use pi camera in our project because it
Pixy cam is a device capable of detecting color of the objects and to track their position. It made
robot vision very easy and it also simplified our programming. But we cant use this in our
25
Chapter 4 System Hardware
project because we have to perform OCR (optical character recognition) whose algorithm is very
difficult to perform with pixy cam. It also performs poorly when lighting condition changes.
Web cam is a USB cable connecting camera. It is low cost and convenient to use in our project.
We select a 2.1 mega pixel USB camera for image processing that is image similarity and optical
character recognition of desired cargo. It required low bandwidth which means it uses les
26
Chapter 5 System Software
CHAPTER 5
SYSTEM SOFTWARE
5.0 INTRODUCTION
Our software utilizes a series of surrounding data acquisition using local distance sensors
furthermore various image processing codes are used to detect desired Cargo. The map generated
(the path of motion) on a pygame window is wirelessly communicated to our main computer via
Wi-Fi communication. The SLAM algorithm has been broadly segmented into four parts:
Image similarity
Application of OCR
5.1 PYTHON
Python is a programming language that lets you work more quickly and integrate your systems
more effectively. It is a user friendly platform which let you integrate more than one language
together or in simple words it is very supportive for the user and easy to implement as compare
27
Chapter 5 System Software
E-mail processing.
IPython is a powerful interactive shell that features easy editing and recording of a work
The Software Carpentry Course teaches basic skills for scientific computing, running
28
Chapter 5 System Software
Education
Python is a superb language for teaching programming, both at the introductory level and in
The Education Special Interest Group is a good place to discuss teaching issues.
Desktop GUIs
Some toolkits that are usable on several platforms are available separately:
wxWidgets
GTK+
Software Development
Python is often used as a support language for software developers, for build control and
Buildbot and Apache Gump for automated continuous compilation and testing.
29
Chapter 5 System Software
Numeric handling has been improved in many ways, for both floating-point numbers and for
the Decimalclass. There are some useful additions to the standard library, such as a greatly
convenient OrderedDict and Counterclasses in the collections module, and many other
improvements.
Much as Python 2.6 incorporated features from Python 3.0, version 2.7 incorporates some of the
new features in Python 3.1. The 2.x series continues to provide tools for migrating to the 3.x
series.
5.1.2 FEATURES:
collections.
The new "," format specifier described in PEP 378: Format Specifier for Thousands
Separator.
30
Chapter 5 System Software
The repr() of a float x is shorter in many cases: its now based on the shortest decimal string
thatfloat(repr(x)) recovers x.
Float-to-string and string-to-float conversions are correctly rounded. The round() function is
So what are the major reasons why we choose Python and recommend it to as many people as
5.2.1 Readability
Python very closely resembles the English language, using words like not and in to make it to
where you can very often read a program, or script, aloud to someone else and not feel like
youre speaking some arcane language. This is also helped by Pythons very strict punctuation
rules which means you dont have curly braces ({ }) all over your code.
Also, Python has a set of rules, known as PEP 8, that tell every Python developer how to format
their code. This means you always know where to put new lines and, more importantly, that
pretty much every other Python script you pick up, whether it was written by a novice or a
seasoned professional, will look very similar and be just as easy to read. The fact that my Python
code, with five or so years of experience, looks very similar to the code that Guido van Rossum
31
Chapter 5 System Software
5.2.2 Libraries
Python has been around for over 20 years, so a lot of code written in Python has built up over
the decades and, being an open source language, a lot of this has been released for others to use.
commonly called the Cheese Shop. You can install this software on your system to be used by
your own projects. For example, if you want to use Python to build scripts with command line
arguments, youd install the click library and then import it into your scripts and use it. There
are libraries for pretty much any use case you can come up with, from image manipulation, to
5.2.3 Community
Python has user groups everywhere, usually called PUGs, and does major conferences on every
continent other than Antarctica. PyCon NA, the largest Python conference in North America,
sold out its 2,500 tickets this year. And, reflecting Pythons commitment to diversity, it had over
30% women speakers. PyCon NA 2013 also started a trend of offering Young Coder
workshops, where attendees taught Python to kids between 9 and 16 years of age for a day,
getting them familiar with the language and, ultimately, helping them hack and mod some games
on the Raspberry Pis they were given. Being part of a positive community does a lot to keep you
motivated.
32
Chapter 5 System Software
As our project is SLAM based cargo detecting forklift, so for creating an autonomous land
vehicle that creates its own path, Forward motion planning is the ability to empower our
unknown environment by an autonomous robot and then follows the map generated. SLAM is
applicable for both 2D and 3D mapping but we are only considering 2D mapping. There are two
In monocular SLAM single visual camera is used. However, software used in monocular SLAM
is much more complicated because algorithms needed for molecular SLAM are complex.
Disadvantage of monocular SLAM is that from single image of a camera the depth cannot be
directly concluded. Instead, it has to be calculated through analyzing the video using an EKF
In grid SLAM grids are used for showing an environment by using an important algorithm. With
this form of representation, the continuous spaces of the environment are discretized in such a
way that the environment is from such moment represented under the configuration of a multi-
33
Chapter 5 System Software
In our project we implement both types of SLAM camera is used to recognize the desired object
by performing OCR (optical character recognition) and three ultrasonic sensors are used to
Most of the approaches being implemented for slam based robots require feedback mechanism in
the form of PID (proportional, integrator and differentiator) to neutralize any deviation in
actuator motion (permanent magnet DC motor) or encoder systems to record motor movements
to attain motion information contrary to this conventional approach common in SLAM based
machines we record all forward motion in the form of array based coordinates as shown by the
Cyan and pink based turning blocks in Fig.5.1 eliminating encoder use. Motors are synchronized
using the PWM techniques hence dilute the need for a PID controller.
The environmental data is acquired in the form of distances from three ultrasonic sensors (HC-
SR04) mounted on a Raspberry pi 3 B with one sensor 0 (right) one at 90 (front) and one at
180(left) .Under static condition distance is acquired and after determining that the front
distance is greater than 0.5m the forklift commences forward .There is a 500ms (millisecond)
hiatus in forward motion as distance can only be acquired under static conditions.
Once the front distance mitigates to lower than 0.5m our sensors quantitatively analyze the left
and right values if the right distance is greater than the left distance it will turn right and vice
The problem that comes forth is that how to portray this motion in the form of a map. This
purpose is attained by showing our map in a two dimensional Euclidean domain. For example if
our robot moves forward in a positive y axis trajectory the first right will cause motion on to the
positive x axis direction on the pygame window a second right will cause a motion towards the
negative y axis. This shows that the visual trajectory of motion is a difficult feat to achieve .The
34
Chapter 5 System Software
below logical approach that we have designed allows us to develop a robust algorithm allowing
path generation.
For path generation on pygame window we installed pygame 9.1.2b on our Raspberry pi 3. We
consider three variables a, b and code for map generation. Variables a, b are used to represent the
path while c is used to represent that whether forklift picked up the desired object or not. Initially
all the variables are equal to zero. When forklift picked up the desired object then code=0
changes into code=1 and now robot follow the reverse motion path to place the object back.
We made algorithms for all the possible conditions that robot can follow:
When the robot is at its initial position a=0 and b=0 but when it moves first forward in a
positive y-axis trajectory then the variable changes a=1 and b=1.Shown in Fig.5.2
Fig 5.2
35
Chapter 5 System Software
When the robot moves towards left it cause an increment in variable a and when it moves
towards right it cause an increment in variable b. Now consider that the robot moves first left
will cause motion on to the negative x-axis. Now variable changes to a=2 and b=1.
When robot moves first right will cause motion on to the positive x-axis. Now variable
Fig.5.3
When robot moves second left after first left will cause motion on to the negative y-axis.
When robot moves second right after first left will cause motion on to the positive y-axis.
Fig.5.4
36
Chapter 5 System Software
When robot moves second left after first right will cause motion on to the positive y-axis.
Now variable changes a=2 and b=2. As this condition is similar to second right after first left
When robot moves second right after first right will cause motion to the negative y-axis. Now
Fig 5.5
When robot moves third left after second and first left will cause motion on to the positive x-
axis. As this is similar to first right movement of robot so the values of variables are also
When robot moves third right after second and first left will cause motion on to the negative
x-axis. As this is similar to first left movement of robot so the values of variables are also
similar to first left i.e. a=2 and b=1. Shown in Fig 5.6.
37
Chapter 5 System Software
Fig 5.6
When robot moves third left after first left and second right or after first right and second left
will cause motion in negative x-axis. As this is similar to first left movement of robot so the
variables are also similar to first left i.e. a=2 and b=1.
When robot moves third right after first left and second right or after first right and second
left will cause motion in positive x-axis. As this is similar to first right movement of robot so
the values of variables are also similar to first right i.e. a=1 and b=2. As shown in Fig 5.7.
Fig 5.7
38
Chapter 5 System Software
When robot moves third left after first and second right will cause motion in positive x-
axis. As this is similar to first right movement of robot so the values of variables are also
When robot moves third right after first and second right will cause motion in negative x-
axis. As this is similar to first left movement of robot so the values of variable are also
similar to first left i.e. a=2 and b=1. As shown in Fig 5.8.
Fig 5.8
As you note that after third left and third right conditions are similar to that of first left and first
right it means that coding for all these conditions will remain same. At all the turning points of
robot coordinates save into variables r and s [r, s] which is going to be used for reverse motion of
39
Chapter 5 System Software
For initializing a window or screen for displaying our map we used command
pygame.display.set_mode (). This function will create a display surface. The arguments inside it
pygame.color() this function is used to fill the color of the display screen. Its value range is 0-
Pygame.display.update () it only update a portion of the screen instead of entire area for
software display. After checking each condition of forward motion of robot we use this
40
Chapter 5 System Software
5.5 OPEN CV
5.5.1 INTRODUCTION
Open CV (Open Source Computer Vision Library) is an open source computer vision and
machine learning software library. Open CV was built to provide a common infrastructure for
computer vision applications and to accelerate the use of machine perception in the commercial
products. Being a BSD-licensed product, Open CV makes it easy for businesses to utilize and
The library has more than 2500 optimized algorithms, which includes a comprehensive set of
both classic and state-of-the-art computer vision and machine learning algorithms. These
algorithms can be used to detect and recognize faces, identify objects, classify human actions in
videos, track camera movements, track moving objects, extract 3D models of objects, produce
3D point clouds from stereo cameras, stitch images together to produce a high resolution image
of an entire scene, find similar images from an image database, remove red eyes from images
taken using flash, follow eye movements, recognize scenery and establish markers to overlay it
with augmented reality, etc. OpenCV has more than 47 thousand people of user community and
Along with well-established companies like Google, Yahoo, Microsoft, Intel, IBM, Sony,
Honda, Toyota that employ the library, there are many startups such as Applied Minds,
VideoSurf, and Zeitera, that make extensive use of OpenCV. OpenCVs deployed uses span the
range from stitching streetview images together, detecting intrusions in surveillance video in
Israel, monitoring mine equipment in China, helping robots navigate and pick up objects at
41
Chapter 5 System Software
Willow Garage, detection of swimming pool drowning accidents in Europe, running interactive
art in Spain and New York, checking runways for debris in Turkey, inspecting labels on products
It has C++, C, Python, Java and MATLAB interfaces and supports Windows,
Linux, Android and Mac OS. OpenCV leans mostly towards real-time vision applications and
takes advantage of MMX and SSE instructions when available. A full-featured CUDA and
OpenCL interfaces are being actively developed right now. There are over 500 algorithms and
about 10 times as many functions that compose or support those algorithms. OpenCV is written
natively in C++ and has a templated interface that works seamlessly with STL containers.
In simple words, OpenCV is an open source C++ library for image processing and computer
vision, originally developed by Intel and now supported by Willow Garage. It is free for both
commercial and non-commercial use. Therefore it is not mandatory for your OpenCV
It is a library of many inbuilt functions mainly aimed at real time image processing. Now it has
several hundreds of image processing and computer vision algorithms which make developing
Optimized for real time image processing & computer vision applications.
42
Chapter 5 System Software
If you are fresh to computer vision applications, you might be doubting where to start from.
Primarily you have to know the basic values of image processing and computer vision. Then you
have to select an appropriate language to advance your computer vision application. Some of the
MATLAB is one of the easiest but the inefficient way to route images and Open CV, on the
other hand is the most efficient but also the hardest way to process pictures. Nonetheless Open
CV has lots of elementary inbuilt image processing functions so that those who want to acquire
computer vision can improve their applications through apposite understanding about what they
do.
So, we consider that it is good to learn computer vision with Open CV as we did in our project.
Image processing in very simple words is any type of process that we do on an image. It is
basically a collection of algorithms and tools for extracting out objects or features from an
image. Nowadays, image processing is among rapidly growing technologies. It forms core
Image is a collection of points in a matrix format. It is a bunch of values arranged with each
other and 2x2 in our case given in x and y coordinates and so every point has some relation with
points nearby it and they all have different values. In a more technical words, image is a two-
43
Chapter 5 System Software
dimensional function f(x,y), where x and y are the spatial (plane) coordinates, and the amplitude
of f at any pair of coordinates (x,y) is called the intensity of the image at that level.[12]
If x,y and the amplitude values of f are finite and discrete quantities, we call the image a
digital image. A digital image is composed of a finite number of elements called pixels, each of
The whole goal of image processing tools is to find features to find particular aspects of objects
that we are interested in. for example the object that we are interested in has larger values and
find ways for extracting out these features so that we can extract out the objects of interest so it is
all about unique features. So in simpler case the object has larger distinct values from the
background; we could really just threshold and say any value lets say greater than one is our
object. But usually it is not that easy. So the whole point of image processing is to extract out
unique features have tools for doing that and develop algorithms for extracting out those features
Output in which result can be altered image or report that is based on image analysis.
There are two types of methods used for image processing namely, analogue and digital image
processing. Analogue image processing can be used for the hard copies like printouts and
photographs. Image analysts use various fundamentals of interpretation while using these visual
techniques. Digital image processing techniques help in manipulation of the digital images by
using computers. The three general phases that all types of data have to undergo while using
44
Chapter 5 System Software
Classification
Feature extraction
Pattern recognition
Projection
As we have to implement optical character recognition, among these our main focus is on
understanding the classification, feature extraction and pattern recognition to some extent.
The classification algorithm that is used in our project is k-nearest neighbors popularly known as
knn algorithm. Generally classification in simple words is to create a model that best divides or
separates our data. For example you have a graph and on that you have some data points as
shown below.
45
Chapter 5 System Software
The objective is to how to separate these into obvious groups and looking at this intuitively you
could see that there are two groups here. And by doing that, we are actually did clustering.
Classification is like we have a data set that could be easily understood by the example as shown
in fig.5.11.
There are groups having pluses and minuses and the objective is to create some type of model
that fits both of these groups that means that that properly divides them so a some sort of model
that defines the pluses and some sort of model that defines minuses so what if that you have a
data point x so which group it would be assigned to. The most likely condition is that it would
be assigned to the pluses group. Similarly a point y is somewhere close to the minuses so it
would be possibly assigned to that group. So, basically all the four points (pluses) are closer to x
than the closest minus which is pretty far. So this example actually turns out that what is done
here is nearest neighbors. So with nearest neighbors, it is a checking of who are the nearest or
closest points to the NEW point on the data. Most of the time this is used as k-nearest neighbors
where k is the no. of closest points to that new point. For instance, k=2 so it would find the two
46
Chapter 5 System Software
closest neighbors. So you have got two points that are the closest to x and y which shows that
Fig 5.12 Two closest points to 'x' and 'y' when k=2
But what if it had a point somewhere in the middle of the two groups and so the two nearest
Now here, basically nearest neighbors place vote on what the identity of this new point z is so
47
Chapter 5 System Software
So as shown fig5.14, in this case the vote would be minus, minus and plus so 2/3, we would say
the class is actually a negative class. Another thing that should be kept in mind that for instance
if there are three groups, k should atleast be 5 to avoid any sort of split vote. From k-nearest
neighbors not only the actual classification for the data point that has been picked can be
obtained but also the accuracy in the model so that you can train and test the model for the
models overall accuracy but each point can also have a degree of confidence. Like the example
discussed before where there is a minus, minus and a plus. So that is a 66% confidence in the
classification of that data but not only it is the confidence 66% but it can also have the entire k-
nearest neighbors model that has been trained, it can have that accuracy which is more like a
confidence.
In order to find out the closest neighbors, we have to measure that distance we used the
EUCLIDEAN distance. To find the Euclidean distance, the simplest method is to measure the
distance between any given point and all of the other points and then the closest neighbors will
be found.
48
Chapter 5 System Software
EUCLIDEAN distance:
Named after euclid, famous mathematician popularly known as the father of geometry.
(, ) = ( )2
=1
x=(1,3)
y=(2,5)
=2.23606
In the project, character recognition is performed via the k-nearest neighbors algorithm in open
cv. The objective is to detect alphanumeric code written on the cargo. For this purpose, it has to
Lets suppose, to recognize the digits 0-9,there could be five training images of each digit as
shown below.
49
Chapter 5 System Software
For any machine learning process, like in this case there is a training data set of five each of the
characters 0 through 9. For example, there are five 0s, five 1s and so on. So 10 digits each having
5 training images, there is a total of 50 training images. The second thing is to resize each of the
training images to be 10 pixels x 10 pixels so in other words each image would have a total area
of 100 pixels. The image in the test set is also resized when attempting to identify in the test set
later on.
2) The set of numbers indicating which group or classification each corresponding images
in. For example, the first five images out of the 50, the classification data structure would
Once the training process is done then testing begins that is to identify characters under test. For
example, an unknown digit X is to be identified. So now the KNN algorithm starts its process
of identifing that unknown digit by identifying its nearest neighbors which ultimately means the
50
Chapter 5 System Software
This shows that when we compared X to the training set the best possible match found is the 99
of the 100 pixels in X matched one of the training images that happen to be a zero so that would
be the nearest neighbor. The second best match 97 of the pixels matched and that happened to be
an 8. The third best match 96 of the pixel match that happened to be an 8 and so on all the way
down to the worst matches of 4 and 2 of the pixels matched. The next consideration is the k
value where k referring to the number of nearest neighbors. In our example data set, when k=1,
X=0 because there is only one nearest neighbor that should be looked and that is 0. Similarly,
when k=3 there are two 8s and one 0 so two out of these three is 8 so X=8. In the same
One specific point for choosing k value is not to choose an even number as discussed in detail in
section xx. Another thing is that k value cannot be larger than the smallest number of samples for
any of the classes. For example, there are only three training images of the character 0 but 50
images for character 1-9. So the k value cannot be larger than 3 because there are only three
51
Chapter 5 System Software
In the project, we worked on relatively simplified data but in the production environment, testing
with different fonts, different sizes, if going to read peoples handwriting tests thousands of
different handwriting samples are needed. But in our case, there are digits 0-9 and alphabets
A-Z having one instance of each to keep the program training time down.
To sum up all the major steps involved in what algorithm is all about which has been explained
52
Chapter 5 System Software
53
Chapter 5 System Software
5.7.1 INTRODUCTION
Optical character recognition colloquially known as OCR, its the ability of the ability of the
computer to convert images into strings this approach utilizes the implementation of a series of
In photography and computing, a grayscale digital image is an image in which the value
of each pixel is a single sample, that is, it carries only intensity information. Such images
are also known as black-and-white, that are composed solely of shades of gray, varying
relatively easier to deal with (in terms of calculation) a single color channel (shades of
white/ black) than multiple color channels. In addition to it, the objective of the project
can be accomplished in gray scale images. Thus decreases the complexity and increases
54
Chapter 5 System Software
The main purpose of applying the Gaussian blur is to reduce the noise. We have applied
a Gaussian blur by selecting a 3x3 kernel which is two dimensional matrix. The process
involved in Gaussian blur is that we process every pixel by averaging the pixel value of
every pixel corresponding to its location in the convolution kernel and apply it back to
the image. This process is carried out from the first pixel of an image and then goes
through every corresponding pixel applying kernel until we get to the end. At this point
After noise smoothening, the next term in the image processing is thresholding. What it
does is that it replaces each pixel in an image with a black pixel if the intensity level is
below a certain constant T or with a white pixel if the pixel intensity value is above this
applied on the image instead of fixed thresholding. As in such cases where there is
different lighting in different areas and thus affecting the performance. So in this case,
adaptive thresolding gives better results for images with varying illumination.[15]
Adaptive threshold Gaussian is applied on our image that takes sum of weighted values
of neighboring values that are in the window. In simple words, it selects an individual
threshold for each pixel based on the range of intensity values in its local neighborhood.
55
Chapter 5 System Software
The next technique applied to the image is contour tracking in order to extract its
boundary. It is also one of the preprocessing techniques to extract information about their
general shape. Once the contour of a given pattern is extracted, its different
characteristics is examined and used as features. For that reason, correct extraction of the
contour will generate more precise features which will amplify the chances of
The question arises that why to waste computational time on it and not directly collecting
the features from an image? Here comes the advantage of contouring. Basically, the
contour pixels are usually a small subset of the total number of pixels representing a
feature extracting algorithms on the contour instead of on the entire pattern. Since the
contour shares a lot of features with the original pattern, the feature extraction process
becomes much more efficient when performed on the contour rather on the original
pattern.[16]
56
Chapter 5 System Software
After the detection of boundary or edges as a result of which shape can be detected. The main
task is started to detect the characters in the image. For this the following steps is carried out:
Fig5.19a Possible characters in scene Fig 5.19b list of matching characters in scene
58
Chapter 5 System Software
59
Chapter 5 System Software
Our aim was to detect the cargo. For this purpose, image similarity algorithm is developed that is
primarily used for enabling the robot to distinguish between desired object and an obstacle
converting the images to gray scale despite increases the similarity between the images normally
this difference is about 3-4% between the desired object and the stored image whereas this
In the second stage ,Once the forklift comes in front of within less than 0.5m from the obstacle it
will capture an image using a 2.1 mega pixel USB camera and compares that image with the pre
stored image. If it matches with the pre-stored image it means that the cargo has been detected
This approach of image comparison was not only become complex but most importantly it was a
time consuming approach as it first image processing is done followed by extracting out the
60
Chapter 5 System Software
characters in the image and then the whole process is repeated for the image that had been
captured by the webcam every time the forklift was at a distance less than 0.5m. Another major
flaw in this approach was that it was not detecting the cargo and ocr implemented on it was not
successful.
So the next approach was a very simple yet efficient which was the user input approach through
which initially it will ask the user to feed the cargo that needs to be detected or in other words
that needs to be lifted. the same thing will happen in this approach also that is, the webcam will
capture the image when the forklift is at a distance less than 0.5m from the obstacle and then the
whole long series of image processing techniques will be implied leading to the character
recognition as a result of which only the characters from the whole image will be extracted and
then that characters will be directly compared to the user inputs one and if that matches then it
means the cargo has been detected and forklift should lift it up. In other case, it that does not
match the robot will consider it as an obstacle and will continue its path avoiding it.
The fourth step requires reverse motion planning (return to initial position after lifting cargo)
this is achieved by generating a two dimensional array the array consists of the starting point, all
turning points and the point of cargo detection( as denoted in the form of pink and cyan blocks
The length of this array will be variable depending on the number of turns we will firstly get the
length of this array then subtract the last point of turning n-1 and the pint of detection n we get
the magnitude of the difference vector using np.linalg.norm(x) using the law of proportion the
distance between the two points will determine the amount of time the motor will run in forward
61
Chapter 5 System Software
direction. Once the point n-1 is reached the two left and right sensors will allow whether to turn
left or right again we will take the difference between n-1 and n-2 points the same principle is
implemented as done previously when the subtraction from n -x results below zero the program
is halted.
Np.linalg.norm(x): This function is able to return one of eight different matrix norms, or one of
an infinite number of vector norms depending on the value of the ord parameter. X is an
Input array. If there is no axis define it means X must be 1-D or 2-D. [13]
5.11.1 INRODUCTION
Wi-Fi is a big buzz word in todays world. Wi-Fi is a technology that enables different electronic
devices to connect to a wireless LAN (WLAN) network which may be password protected or
open allowing the devices to access the resources of the WLAN network that lies within its
range. In simple words it provides internet access to those devices that lies within the range of
wireless network.
Wi-Fi is a type of electromagnetic radiations that uses radio waves like cell phones, televisions
and radios do. In fact, communication across a wireless network is quite like a two-way radio
communication that gives us the power to send huge amount of data wirelessly. Different types
of electromagnetic radiations are pretty similar, what make them different are their wavelengths.
Wi-Fi mainly uses ultra high frequency of 2.4 GHz (wavelength of about 12 cm) and super high
frequency of 5 GHz (wavelength of 6cm) which is certainly too petite for us to see.
62
Chapter 5 System Software
Wi-Fi is basically carrying a set of instructions or data that it sends wirelessly through radio
signals to a receiver of some sort generally a wifi card or adapter. These instructions or data are
converted to a code which only needs two different modes on and off. So for instance to
transmit a picture you need a huge amount of on off signals and for video, even more.
Fortunately electromagnetic radiations travels very fast so even something complex like video
or something that has so many signals to transmit, it is transmitted super quickly. For a wifi each
send signal has a 6 digit code and the change in height and the starting place of the wave
determines that whether the digit is on or off between gaps of no signal. The gaps between the
pulses separates the wave symbols just like the spaces between words, meaning really
The IEEE 802.11 standard is a set of media access control (MAC) and physical layer (PHY)
specifications for the implementation of wireless local area network (WLAN) computer
The Wi-Fi Alliance enforces the use of the Wi-Fi brand to technologies based on the IEEE
As with wireless adapters, many routers can use more than one 802.11 standard. Normally,
802.11b routers are to some extent less expensive than others, but because the standard is older,
they're also slower than 802.11a, 802.11g, 802.11n and 802.11ac routers. 802.11n routers are the
most common.
63
Chapter 5 System Software
5.11.4 INTERFERENCE
There are several devices that use the 2.4 GHz band. For instance, many cordless telephones,
baby monitors, microwave ovens, Bluetooth devices, security cameras, ZigBee devices and other
ISM band devices operating at the same frequency at which Wi-Fi standards 802.11b, 802.11g
Moreover, as wi-fi travels outside from its source it is affected by the objects it encounters. Wi-
Fi connections can also be distorted or the Internet speed may be lowered by having other
devices in the same area. Such as, if there are lots of wifi signals near you, parts of your signal
Interference can be prevented through many ways like by changing the channels or to move from
the 2.4GHz frequency to another frequency which lacks the susceptibility to interference innate
Wi-Fi technology also allows peer to peer communication without passing through an access
point (AP). Ad hoc networks forms wireless LAN that dont require any infrastructure to work.
Ad-hoc mode can be useful and easier where you want only two devices to be connected with
each other without requiring a centralized access point. For example, there are two people sitting
in a hotel room with their laptops without Wi-Fi. So the two laptops can be directly connected
with ad hoc mode to form a temporary Wi-Fi network without needing a router.
64
Chapter 6 Result And Discussions
CHAPTER 6
The main technical problem during the project apart from the software side is the over current in
motors causing the damage of h-bridges and overheating the motors. It is not unusual for a motor
rated at 2A continuous to have a higher short term current rating - maybe 4A intermittent, for
max. 10 minutes in any half hour. After troubleshooting the problem of burning h-bridges and
not running the motors properly we decided to use the relay based h bridges instead as they are
more insensitive than mosfets which was a plus in our case. In addition to it, some more reasons
or pros as to why relay based h-bridges are selected to drive the motor includes:
Relays have zero closed resistance; Semiconductors have a forward voltage drop that
Relays can operate at temperature extremes; semiconductors are limited to 95C and a
over current, dv/dt and di/dt, Relays are primarily damaged by over-current.
Relays have a very high isolation from the control coil, Semiconductors as a rule are not
But there are also some of the disadvantages which are as follows:
65
Chapter 6 Result And Discussions
Semiconductors can operate at (Megahertz) speeds; Relays are much slower at 200 hertz.
Semiconductor switches almost never wear-out; Relays have a much shorter mechanical
Semiconductors can amplify analog signals, Relays can only open and close.
But in our case, the cons are not of great impact on the project. In fact, it works absolutely fine
Furthermore, the relay h-bridge has optocoupler for protection. Optocouplers are commonly used
to isolate components from potentially dangerous outside sources. They can potentially offer
6.1 RESULT
It can be concluded that most of the goals were achieved with satisfactory results. The
mechanical design introduces some challenges because of the time limitation the electrical
design has been implemented but it is achieved after facing many challenges. The biggest
challenge of the electrical design was to know the hardware and the software used in the project
and to implement the slam operations map generation, object detection and image similarity.
66
Chapter 7 Conclusion And Future Works
CHAPTER 7
SLAM based robots can be said to be the pinnacle of robotic advancement in this day and age
these robots can be in future optimized to a level where self navigation and machine learning
can be made possible though our implementation saw a much rudimentary approach in robotics
that is obtaining sensory data from multiple sensors this implementation can be further
streamlined to a point where a single camera can simply manipulate data to allow it to make
decisions on its own that means Future approaches for implementation of similar projects may be
computer vision centric. One thing that comes to wildest corners of human imagination is
making this robot perform similar tasks with a mechanical alteration of machining it closer to a
humanoid henceforth moving away from the hackneyed wheel based concept of robotics.
Numerous journals have theoretically envisioned the concept of robots based automations in
warehouses creating a lager robot with more long range sensors such as the infamous
HuyokoLidar may come to be a solution to major bottleneck in the supply chain and retail side of
the industry. Mobile eye a Tel Aviv based startup headquartered in the Netherlands is a refined
example of our project that allows some basic modifications in a human controlled car to be
converted into fully autonomous vehicles similarly German giant Bosh and American inventor
Elon Musk are leaders in innovation self driving vehicles. With some design alterations the map
generating and object picking approach utilizing image processing could be utilized in sulfur
mine notorious for causing life threatening diseases. To sum it up the sky is the limit our project
has barely scratched the surface of this exciting field of Localization and mapping.
67
REFRENCES
REFERENCES:
[1] https://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping#History
[2] http://www.liftsrus.com/InfoDocs/Forklift_History.html
[3] https://en.wikipedia.org/wiki/H_bridge
[4] http://www.electrical4u.com/permanent-magnet-dc-motor-or-pmdc-motor/
[5] http://www.doityourself.com/stry/how-a-gear-motor-works
[6] https://www.raspberrypi.org/products/raspberry-pi-2-model-b/
[7]https://www.doc.ic.ac.uk/project/2015/163/g1516307/computing_topics_website/introductiont
omonocular.html
[8] http://www.sciencedirect.com/science/article/pii/S1571066111001824
[9] http://www.pygame.org/docs/ref/display.html
[10] https://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.norm.html
[11] http://www.micropik.com/PDF/HCSR04.pdf
[12] http://www.ijteee.org/final-print/july2015/Design-Features-Recognition-Using-Image-
Processing-Techniques.pdf
[13] http://www.ijteee.org/final-print/july2015/Design-Features-Recognition-Using-Image-
Processing-Techniques.pdf
[14] http://ijarcet.org/wp-content/uploads/IJARCET-VOL-4-ISSUE-12-4310-4313.pdf
[15] http://en.wikipedia.org/wiki/Grayscale
68
GLOSSARY
Robot: A robot is an autonomous system which exists in a physical world, can sense its
Cartesian coordinate robot: A Cartesian coordinate robot has three linear axes of control (x, y,
z).
Grid Slam: In grid SLAM grids are used for showing an environment by using an important
algorithm.
Forklift: A forklift is an industrial truck used to lift an object and placed it at short distances.
Motor: An electric motor is a motor which generates or produce electrical energy by using the
mechanical energy.
PMDC: Permanent Magnet Dc Motors are used as replacement for the field windings.
Separately Excited Dc Motor: In separately excited dc motor field winding is independent that
of armature winding. In this motor the armature current does not flow through the field windings.
Hydraulic Motor: Hydraulic motor is used to convert the hydraulic energy into mechanical
energy. It consist of a rotating shaft which it uses hydraulic pressure and flow to generate torque
and rotation.
Hydraulic Gear Motor: A gear motor is an extension of a dc motor. It has a gear box that
increases torque and decreases in speed. Hydraulic gear motors and piston motors are high speed
motors.
69
GLOSSARY
H-Bridge: H-bridge is an electronic device that enables a voltage which can be applied across a
motor are any load or it can be applied in both directions. H-bridge can be used to run the
motors.
Sensor: A sensor is a device which is used to detect physical data from an environment (analog
LIDAR: Light detection and ranging is a sensor in which light is used in the form of a pulsed
Ultrasonic sensor: It is used to determine the distance by utilizing the properties of sound that is
the time difference between sending and receiving the sound pulse.
Open CV: Open Source Computer Vision Library is an open source computer vision and
machine learning software library. The library has more than 2500 optimized algorithms.
basically a collection of algorithms and tools for extracting out objects or features from an
image.
Euclidean Distance: To find the Euclidean distance, the simplest method is to measure the
distance between any given point and all of the other points and then the closest neighbors will
be found.
OCR: Optical character recognition its the ability of the ability of the computer to convert
images into strings this approach utilizes the implementation of a series of filters to end up with a
clean image.
70
GLOSSARY
Thresholding: It replaces each pixel in an image with a black pixel if the intensity level is below
a certain constant T or with a white pixel if the pixel intensity value is above this threshold value.
IEEE 802.11 STANDARD: The IEEE 802.11 standard is a set of media access control (MAC)
and physical layer (PHY) specifications for the implementation of wireless local area network
(WLAN) computer communication in the 2.4, 3.6, 5, and 60 GHz frequency bands.
Ad Hoc Communication: Ad hoc networks forms wireless LAN that dont require any
infrastructure to work.
71
APPENDIX A
CODING
importpygame,sys
frompygame.locals import *
importpygame.camera
import Image
importnumpy as np
importpygame
importos
importRPi.GPIO as GPIO
import time
import cv2
import commands
os.putenv('SDL_FBDEV', '/dev/fb1')
pygame.init()
GPIO.setmode(GPIO.BOARD)
TRIG=12
ECHO=10
ECHO1=40
72
APPENDIX A
TRIG1=38
ECHO2=35
TRIG2=36
motor1fa=11
motor1ba=15
motor2fa=19
motor2ba=21
motor1fb=37
motor1bb=33
motor2fb=31
motor2bb=29
hydr1=23
hydr2=24
GPIO.setup(motor1fa,GPIO.OUT)
GPIO.output(motor1fa,0)
GPIO.setup(motor1ba,GPIO.OUT)
GPIO.output(motor1ba,0)
GPIO.setup(motor2fa,GPIO.OUT)
GPIO.output(motor2fa,0)
GPIO.setup(motor1ba,GPIO.OUT)
GPIO.output(motor1ba,0)
GPIO.setup(motor2ba,GPIO.OUT)
GPIO.output(motor2ba,0)
73
APPENDIX A
GPIO.setup(hydr1,GPIO.OUT)
GPIO.output(hydr1,0)
GPIO.setup(hydr2,GPIO.OUT)
GPIO.output(hydr2,0)
GPIO.setup(motor1fb,GPIO.OUT)
GPIO.output(motor1fb,0)
GPIO.setup(motor1bb,GPIO.OUT)
GPIO.output(motor1bb,0)
GPIO.setup(motor2fb,GPIO.OUT)
GPIO.output(motor2fb,0)
GPIO.setup(motor1bb,GPIO.OUT)
GPIO.output(motor1bb,0)
GPIO.setup(motor2bb,GPIO.OUT)
GPIO.output(motor2bb,0)
GPIO.setup(TRIG,GPIO.OUT)
GPIO.output(TRIG,0)
GPIO.setup(ECHO,GPIO.IN)
GPIO.setup(TRIG1,GPIO.OUT)
GPIO.output(TRIG1,0)
GPIO.setup(ECHO1,GPIO.IN)
GPIO.setup(TRIG2,GPIO.OUT)
GPIO.output(TRIG2,0)
GPIO.setup(ECHO2,GPIO.IN)
74
APPENDIX A
GPIO.setwarnings(False)
lcd = pygame.display.set_mode((1000,1000))
lcd.fill(pygame.Color(0,0,0))
defvideocap():
cap = cv2.VideoCapture(0)
while(True):
#Capture frame-by-frame
ret=cap.set(3,320)
ret=cap.set(4,240)
cv2.imshow('frame',gray)
break
cap.release()
cv2.destroyAllWindows()
return
defcamerasimilaritys():
pygame.camera.init()
c = pygame.camera.Camera("/dev/video0",(352,288))
c.start()
image2 = c.get_image()
pygame.image.save(image2,'/home/pi/102.jpg')
75
APPENDIX A
c.stop()
image1 = cv2.imread('/home/pi/102.jpg')
gray1 = cv2.cvtColor(image1,cv2.COLOR_BGR2GRAY)
equ1=cv2.equalizeHist(gray1)
cv2.imwrite('/home/pi/102.jpg',gray1)
x = Image.open('/home/pi/102.jpg')
x = x.filter(ImageFilter.SHARPEN)
y = Image.open('/home/pi/101.jpg')
y = y.filter(ImageFilter.SHARPEN)
iflen(x.getbands()) == 1:
else:
print o
return o
defcamerasimilarity():
pygame.camera.init()
c = pygame.camera.Camera("/dev/video0",(100,100))
76
APPENDIX A
c.start()
image1 = c.get_image()
pygame.image.save(image1,'extract.jpg')
c.stop()
#boundaries
=[([17,15,100],[50,56,200]),([86,31,4],[220,88,50]),([25,146,190],[62,174,250]),([103,86,65],[14
5,133,128])]
image=cv2.imread('extract.jpg')
img_hsv=cv2.cvtColor(image,cv2.COLOR_BGR2HSV)
lower_red =np.array([0,100,100])
upper_red=np.array([10,255,255])
lower_red =np.array([170,50,50])
upper_red=np.array([180,255,255])
mask=mask0+mask1
#mask=cv2.medianBlur(mask, 3)
output_image=image.copy()
output_image[np.where(mask==0)] =0
imgray=cv2.cvtColor(output_image,cv2.COLOR_BGR2GRAY)
#ret,thresh = cv2.threshold(imgray,127,255,cv2.THRESH_TRUNC)
77
APPENDIX A
thresh=cv2.adaptiveThreshold(imgray, 255,
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV, 11, 1)
mask=cv2.medianBlur(thresh, 9)
mask=cv2.medianBlur(thresh, 9)
cv2.imwrite('extract.jpg',mask)
contours,
hierarchy=cv2.findContours(mask,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
a=len(contours)
print a
if a > 1:
o=98
else:
o=20
return o
defaftersimilarity():
pygame.camera.init()
c = pygame.camera.Camera("/dev/video0",(400,400))
c.start()
image1 = c.get_image()
pygame.image.save(image1,'extract.jpg')
78
APPENDIX A
c.stop()
image=cv2.imread('extract.jpg')
imgray=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY)
kernel_sharpen = np.array([[-1,-1,-1],[-1,9,-1],[-1,-1,-1]])
out=cv2.filter2D(imgray,-1,kernel_sharpen)
gray_blur=cv2.GaussianBlur(out, (15,15),0)
thresh=cv2.adaptiveThreshold(gray_blur, 255,
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,cv2.THRESH_BINARY_INV, 11, 1)
thresh=cv2.medianBlur(thresh, 9)
cv2.imwrite("thresh.jpg",thresh)
text = image_to_string(Image.open('thresh.jpg')).strip()
print text
return
def distance():
GPIO.output(TRIG,1)
time.sleep(0.00001)
GPIO.output(TRIG,0)
whileGPIO.input(ECHO)==0:
#time.sleep(0.01)
pass
start=time.time()
whileGPIO.input(ECHO)==1:
#time.sleep(0.01)
79
APPENDIX A
pass
stop=time.time()
x=(stop-start)*17150
time.sleep(0.01)
x=round(x,2)
else:
x=500
return x
def distances():
GPIO.output(TRIG1,1)
time.sleep(0.00001)
GPIO.output(TRIG1,0)
whileGPIO.input(ECHO1)==0:
pass
start1=time.time()
whileGPIO.input(ECHO1)==1:
pass
stop1=time.time()
time.sleep(0.01)
y=(stop1-start1)*17150
time.sleep(0.01)
80
APPENDIX A
y=round(y,2)
else:
y=500
return y
def distance2():
GPIO.output(TRIG2,1)
time.sleep(0.00001)
GPIO.output(TRIG2,0)
whileGPIO.input(ECHO2)==0:
pass
start2=time.time()
whileGPIO.input(ECHO2)==1:
pass
stop2=time.time()
time.sleep(0.01)
z=(stop2-start2)*17150
time.sleep(0.01)
z=round(z, 2)
else:
z=500
81
APPENDIX A
return z
def backward():
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,1)
GPIO.output(motor1ba,1)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,1)
GPIO.output(motor1bb,1)
GPIO.output(motor2bb,0)
time.sleep(0.5)
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
time.sleep(0.1)
return
82
APPENDIX A
def forward():
GPIO.output(motor1fa,1)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,1)
GPIO.output(motor1fb,1)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,1)
time.sleep(0.75)
GPIO.output(motor1fa,1)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,1)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,1)
GPIO.output(motor1bb,1)
GPIO.output(motor2bb,0)
time.sleep(0.1)
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
83
APPENDIX A
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
time.sleep(0.1)
return
def stop():
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
time.sleep(0.3)
return
def right():
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,1)
GPIO.output(motor1ba,1)
GPIO.output(motor2ba,0)
84
APPENDIX A
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,1)
GPIO.output(motor1bb,1)
GPIO.output(motor2bb,0)
time.sleep(0.5)
GPIO.output(motor1fa,1)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,1)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,1)
GPIO.output(motor1bb,1)
GPIO.output(motor2bb,0)
time.sleep(2.49)
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
85
APPENDIX A
time.sleep(1)
return
def left():
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,1)
GPIO.output(motor1ba,1)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,1)
GPIO.output(motor1bb,1)
GPIO.output(motor2bb,0)
time.sleep(0.5)
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,1)
GPIO.output(motor1ba,1)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,1)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,1)
time.sleep(2.49)
GPIO.output(motor1fa,0)
86
APPENDIX A
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
time.sleep(1)
return
def up():
GPIO.output(hydr1,1)
GPIO.output(hydr2,0)
time.sleep(30)
GPIO.output(hydr1,0)
GPIO.output(hydr2,0)
time.sleep(0.1)
return
def down():
GPIO.output(hydr1,0)
GPIO.output(hydr2,1)
time.sleep(30)
GPIO.output(hydr1,0)
GPIO.output(hydr2,0)
87
APPENDIX A
time.sleep(0.1)
return
def turnaround():
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,1)
GPIO.output(motor1ba,1)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,1)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,1)
time.sleep(5)
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
time.sleep(0.1)
return
r=100
88
APPENDIX A
s=500
a=0
b=0
back=[]
code=0
for t in range(0,100):
if distance()>3 and distances()>3 and distance2()>40 and a==0 and b==0 and code==0:
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
s-=10
stop()
a=1
b=1
break
89
APPENDIX A
print r
print s
pygame.display.update()
aftersimilarity()
up()
turnaround()
a=0
b=0
code=1
back.append((r,s))
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
90
APPENDIX A
break
stop()
right()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r+=10
stop()
a=1
b=2
break
print r
print s
91
APPENDIX A
pygame.display.update()
aftersimilarity()
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
92
APPENDIX A
left()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r-=10
stop()
a=2
b=1
break
print r
print s
pygame.display.update()
aftersimilarity()
93
APPENDIX A
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
left()
94
APPENDIX A
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
s+=10
stop()
a=3
b=1
break
print r
print s
pygame.display.update()
aftersimilarity()
up()
95
APPENDIX A
turnaroound()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
right()
stop()
96
APPENDIX A
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
s-=10
stop()
a=2
b=2
break
print r
print s
pygame.display.update()
aftersimilarity()
up()
turnaround()
97
APPENDIX A
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
left()
stop()
pygame.display.update()
98
APPENDIX A
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
s-=10
stop()
a=2
b=2
break
print r
print s
pygame.display.update()
up()
turnaround()
a=0
b=0
code=1
99
APPENDIX A
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
right()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
100
APPENDIX A
stop()
pygame.display.update()
time.sleep(0.1)
s+=10
stop()
a=1
b=3
break
print r
print s
pygame.display.update()
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
101
APPENDIX A
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
left()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
102
APPENDIX A
pygame.display.update()
time.sleep(0.1)
r+=10
stop()
a=1
b=2
break
print r
print s
pygame.display.update()
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
103
APPENDIX A
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
right()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r-=10
104
APPENDIX A
stop()
a=2
b=1
break
print r
print s
pygame.display.update()
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
105
APPENDIX A
a=0
b=0
code=1
back.append(r,s)
break
stop()
right()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r+=10
stop()
a=1
b=2
106
APPENDIX A
break
print r
print s
pygame.display.update()
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
107
APPENDIX A
back.append(r,s)
break
stop()
left()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r-=10
stop()
a=2
b=1
break
108
APPENDIX A
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
109
APPENDIX A
stop()
left()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r+=10
stop()
a=1
b=2
break
print r
print s
110
APPENDIX A
pygame.display.update()
up()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
stop()
111
APPENDIX A
right()
stop()
pygame.display.update()
back.append((r, s))
for x in range(0,100):
forward()
stop()
pygame.display.update()
time.sleep(0.1)
r-=10
stop()
a=2
b=1
break
print r
print s
pygame.display.update()
up()
112
APPENDIX A
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
print r
print s
pygame.display.update()
turnaround()
a=0
b=0
code=1
back.append(r,s)
break
turnaround()
t=len(back)
print t
for u in range(1,100):
if (t-u-1)>=0:
113
APPENDIX A
y=np.subtract(back(t-u),back(t-u-1))
i=round(np.linalg.norm(y))
GPIO.output(motor1fa,1)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,1)
GPIO.output(motor1fb,1)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,1)
time.sleep(i)
GPIO.output(motor1fa,0)
GPIO.output(motor2fa,0)
GPIO.output(motor1ba,0)
GPIO.output(motor2ba,0)
GPIO.output(motor1fb,0)
GPIO.output(motor2fb,0)
GPIO.output(motor1bb,0)
GPIO.output(motor2bb,0)
time.sleep(2)
elif (t-u-1)<0:
sys.exit()
114
APPENDIX A
elif distance()>distances():
right()
elif distances()>distance():
left()
GPIO.cleanup()
115
APPENDIX B
COST ANALYSIS
116
APPENDIX B
117
DATASHEETS
118
DATASHEETS
119
DATASHEETS
120
TURNITIN REPORT
121