Project Obstactle Avoid
Project Obstactle Avoid
Mahendra Mistri(01619129)
Umakanta Khatua(01619137)
Animesh Maity(01619127)
requirements for the award of degree of B.Tech. submitted in the Department of Department of
authentic record of our own work carried out under the supervision of Mr. AYANDEEP
GANGULY, Associate Professor. The matter presented has not been submitted by me in any
This is to certify that the above statement made by the candidate is correct to the best of my
knowledge.
car using ultrasonic wave sensor in this thesis. By sending pulses, the obstacle
avoidance distance can be measured. At the same time, we can control steering gear
to realize the obstacle avoidancefunction. The robot car uses front axle steering, rear
wheel drive arrangement. Two drive tires are driven by two DC motors with gear
reduction mechanisms. Using Arduino MCU chip as the control core of the Robot
car. Through the design of the hardware and software system, webuild the robot car
ArtificialIntelligence
1 Chapter One: Introduction and Background
1.1 Introduction
Robotics is part of Todays communication. In today’s world ROBOTICS
is fast growingand interesting field. It is simplest way for latest technology
modification. Now a day’s communication is part of advancement of
technology, so I decided to work on ROBOTICSfield, and design
something which will make human life simpler in today aspect.
1
available free space.
An obstacle may be a living things or any object.
Autonomous Intelligent Robots are robots that can perform desired tasks in
unstructured environments without continuous human guidance. Thus, by
using this technology in vehicleswe make the drive safe.
1.3 Methodology
simulations of Obstacle-avoiding Robot will be performed
before and afteroptimization in Proteus Simulink, and
others tools if needed.
The methodology may include research, surveys and other research
techniques, andcould include both present and historical
information.
Prepare the required components to do a practical
2
simulation by Arduinomicrocontrollers to make the
Robot
Start to design the final project
3
2 Chapter Two: History and Literature Review
4
remotely-controlled bomb- disposal robots and robotic arms; or. However,
the majority of robots fall in between theseextremes, being controlled by pre-
programmed computers [2].
Robots use actuators to spin wheels and jointed pivot. Some robots use
solenoids and electricmotors as actuators; others some use a pneumatic
system (a system driven by compressed gases); yet others use a hydraulic
system. A robot may even use all of these actuator types together.
Robots need a power source to be able to drive the actuators. Most robots
have a battery or they plug into an electricity source. Pneumatic robots need
air compressors or compressed airtanks and hydraulic robots need a pump
that pressurizes the hydraulic fluid. The actuators arewired to an electrical
5
circuit. The circuit powers these electrical motors and solenoids directly. It
also activates the hydraulic system by manipulating electrical valves. The
valves determine the pressurized fluid's path through the machine.
A more elaborate version of the same idea is used by more advanced robots.
Roboticists create new sensor systems and algorithms to make robots more
perceptive and smarter. Today, robots are able to effectively navigate a
variety of environments. Obstacle avoidancecan be implemented as a reactive
control law whereas path planning involves the pre- computation of an
obstacle-free path which a controller will then guide a robot along.
Some mobile robots also use various ultrasound sensors to see obstacles or
infrared. These sensors work in a similar fashion to animal echolocation. The
robot sends out a beam of infrared light or a sound signal. It then detects the
reflection of the signal. The robot locatesthis distance to the obstacles
depending on how long it takes the signal to bounce back.
6
Some advanced robots also use stereo vision. Two cameras provide robots
with depth perception. Image recognition software then gives them the
ability to locate, classify variousobjects. Robots also use smell and sound
sensors to gain knowledge about its surroundings.
More advanced robots are able to analyze unfamiliar environments and adapt
to them. Theyeven work on areas with rough terrain. This kind of robots can
associate particular terrain patterns with particular actions.
For example, a rover robot constructs a land map with the help of its visual
sensors. If the map depicts a bumpy terrain pattern, the robot decides to
travel some other way. Such kinds of system are very useful for exploratory
robots and can be used to operate on other planets. Figure 2.1 shows the bot
developed by NASA called Urbie. It is designed for various militarypurposes
and is able to move through stairs and other such paths .
Figure 2.1 Autonomous Urbie developed by NASA, is designed for various urban
operations,including military reconnaissance and rescue operations.
An ant tries to get over an obstacle, it does not decide when it needs to get
over an obstacle. Itsimply keeps trying different things until it gets over the
obstacle. An alternative robot designtakes a similar less structured approach,
which can also be termed as a randomness approach.When the robot gets
stuck, it moves its appendages in every way until something works out. Force
sensors work very closely with the actuators, instead of the computer
directing everything based on a program.
7
3 Chapter Three: Introduction to Arduino
8
sensors (registering user inputs) and driving the behaviors and responses of
the external components such as speakers, motors, and LED (responding to
the user inputs). The most important feature of Arduino is the ease of
programmability hence users with little expertise are able to use it. This
aspect has made Arduino one of the most popular tools of choice for
designers and artists in creating interactive spaces and objects (Arduino
Team).
9
The microprocessor, due to the small form factor, was incorporated into a
surfeit of electronic devices ranging from personal computers to calculators
and are still used up to date. More programming languages were also
developed in the 1970s and 80s including C, C++ and Java for applications in
science and business. (Massimo, 2005)
10
Arduino also incorporated the ability to program its board using a standard
USB connection with a low price point (Wheat, 2001).
11
Figure 3.1 Types of Arduino Boards
12
3.8 Features of Arduino Boards.
Arduino System
Processor Memory Digital I/O Analogue I/O
Board Voltage
Arduino Uno
Arduino Due
84MHz
96KB SRAM, 12 inputs, 2
3.3V AT91SAM3X 54
512KB flash outputs
8E
Arduino
Mega 16MHz 8KB SRAM, 16 inputs, 0
5V 54
ATmega2560 256KB flash output
Arduino
Leonardo 2.5KB
16MHz 12 inputs, 0
5V SRAM, 32KB 20
ATmega32u4 output
flash
Arduino
LilyPad
ATmega 168v 1KB SRAM, 6 inputs, 0
2.7-5.5 V 14
or 328v 16KB Flash output
Arduino
Nano
Atmel
2KB SRAM, 8 inputs, 0
5V ATmega328 14
32KB Flash output
13
Arduino FIO
3.3KB
ATmega328P 8 inputs, 0
3.3V SRAM, 32KB 14
output
Flash
Arduino
Mini
2KB SRAM, 8 inputs, 0
5v ATmega328 14
32KB Flash outputs
Arduino Pro
Mini
2KB SRAM, 6 inputs, 0
3.3V or 5V ATmega328 14
16KB Flash output
14
4 Chapter Four: The Final Project Construction, Testing,
Results
Each component has been explained below along with their circuital
representation as used inthe building of the robot. The software
implementation is included in the microcontroller phase
Figure 4.1 Block diagram depicting the Hardware Implementation for the project
15
4.1.1 HC-SR04 Ultrasonic Sensor
16
Since it is known that sound travels through air at about 344 m/s (1129 ft/s),
you can take the time for the sound wave to return and multiply it by 344
meters (or 1129 feet) to find the total round-trip distance of the sound wave.
Round-trip means that the sound wave traveled 2 times the distance to the
object before it was detected by the sensor; it includes the 'trip' from the
sonar sensor to the object AND the 'trip' from the object to the Ultrasonic
sensor (after thesound wave bounced off the object). To find the distance to
the object, simply divide the round-trip distance in half.
17
Figure 4.4 Ultrasonic Sensor Pins
1 VCC The VCC pin powers the sensor, typically with +5V
18
For example, if the object is 10 cm away from the sensor, and the speed of
the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about
294 u seconds. But what we willget from the Echo pin will be double that
number because the sound wave needs to travel forward and bounce
backward. So, in order to get the distance in cm we need to multiply the
received travel time value from the echo pin by 0.034 and divide it by 2 as
shown above.
19
L298N module is a high voltage, high current dual full-bridge motor driver
module for controlling DC motor and stepper motor. It can control both the speed
and rotation direction of two DC motors. This module consists of an L298 dual-
channel H-Bridge motor driver IC. This module uses two techniques for the
control speed and rotation direction of the DC motors. These are PWM For
controlling the speed and H-Bridge For controlling rotation direction.
20
servo motor, and if it is AC powered motor then it is called AC servo motor.
We can get a very high torque servo motor in a small and light weight
packages.Doe to these features they are being used in many applications like
toy car, RC helicopters andplanes, Robotics, Machine etc. The position of a
servo motor is decided by electrical pulse andits circuitry is placed beside the
motor.
Now day’s servo system has huge industrial applications. Servo motor
applications are also commonly seen in remote controlled toy cars for
controlling direction of motion and it is alsovery commonly used as the
motor which moves the tray of a CD or DVD player. Beside these there are
other hundreds of servo motor applications we see in our daily life. The main
reason behind using a servo is that it provides angular precision, i.e. it will
only rotate as much we want and then stop and wait for next signal to take
further action. This is unlike a normal electrical motor which starts rotating
as and when power is applied to it and the rotation continues until we switch
off the power. We cannot control the rotational progress ofelectrical motor;
but we can only control the speed of rotation and can turn it ON and OFF.
21
Figure 4.8 diagram of Servo Closed Loop System
Here reference input signal is compared to reference output signal and the
third signal is produces by feedback system. And this third signal acts as
input signal to control device. Thissignal is present as long as feedback signal
is generated or there is difference between reference input signal and
reference output signal. So, the main task of servomechanism is to maintain
output of a system at desired value at presence of noises.
22
appliedsignal and the signal generated at potentiometer, and in this situation
motor stops rotating.
23
commanded output position of the servo shaft. Second, the servo hasits own
power electronics, so very little power flows over the control signal. All
power is draw from its power lead, which must be simply hooked up to a
high-current source of 5 volts.
4.1.4 DC motor
24
4.1.4.2 DC Motor – Types
These types of motors are powered by direct current (DC).
Brushed Motors
Brushless Motors
Planetary Gear Motors
Spur Gear Motors
Stepper Motors
Coreless & Coreless Brushless Motors
Servo Motors
Gear heads Motors
4.1.4.3 DC Motor – Gear Motor
In order to select the most suitable gear motor for our application we must first compute:
Load
Speed
Torque requirements for our application
25
4.2 robot working principle
The robot uses the Ultrasonic distance sensor to measure the distance in front
of it. When thisdistance reduces to a particular level, the robot interprets it to
mean the presence of an obstacle in its path. When the robot detects an
obstacle in its path, it stops, goes backward fora few cm, looks around (right
and left) then turn towards the direction that shows more free space in front
of it.
26
Clip
11.Jumper
Wires as
required12.1x
ON/OFF
Switch
27
Step 1. Connect the motor and wheels to the chassis.
To complete this step, we start by soldering the thick red
and black wires tothe positive and negative terminals of the
motors as shown in the image below.
28
attach the rear wheels to the chassis
we add a switch to the battery holder so that we will be able to turn the robot
on or off. The switch is connected according to the schematics shown below
and attached to the case using ahot glue. The Battery case is attached to the
chassis using a double-sided tape to ensure everything sticks together.
Figure 4.19 schematic circuit diagram of the switch and the power source
29
Figure 4.20 Soldering the ON/OFF Switch
This step is to mount other parts of the robot before we start connecting their
wires. The motor shield is stacked on the Arduino and it is mounted on the
chassis using a double-sided tape. The current requirements of the motors are
often higher than what the Arduino can provide, that is why it’s important to
use the motor shield as it is equipped with additional circuitry to provide up
to 600mA current to each of the motors. This shield provides power tothe
motors and the servo motor and ultrasonic sensor and makes it much easier.
The Ultrasonic sensor is also mounted on the top of the servo motor which is
then mounted on thechassis using some screws.
30
Step 4. Wire up the components
31
Figure 4.24 Block Diagram of connect ultrasonic sensor Pins to the Motor
Shield
Servo ▶ Motor Shield (Servo_2 port)
Signal (yellow wire) ▶ S
Vcc(Red wire) ▶ +
Gnd(Blow wire) ▶ -
Figure 4.25 Wire up the Servo Motor to Motor Shield (Servo _ port 2)
32
Figure 4.26 Wire up the DC motors to Motor Shield
33
Figure 4.27 Arduino integrated development environment (IDE)
34
4.7.1 Processes and flow of program
35
4.7.2 Arduino Coding
The code uses three libraries. Two of them must be downloaded in order
for the program tocompile. The first one is the motor shield driver from
Adafruit. The second library is the NewPing library for the supersonic
distance sensor.
The first thing we do in the code is to include the libraries that have been
downloaded intothe code.
#include <AFMotor.h>
#include <NewPing.h>
#include <Servo.h>
Next, we declare the pins to which or ultrasonic sensor is connected to, and some
variables
which will be used to store info as the code runs then we set the speed of the
motors. We canset the motors speed in any value up to 255.
#define TRIG_PIN A4 // Arduino pin tied to trigger pin on the ultrasonic
sensor.
#define ECHO_PIN A5 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_SPEED_OFFSET 20
Next, we Initialize the servo motor by creating an object of the servo library. We Also
initialize the Motors to which the wheels are connected using the AF library.
AF_DCMotor motor1(1, MOTOR12_1KHZ);
AF_DCMotor motor2(3, MOTOR12_1KHZ);
Servo myservo;
We then move into the void setup () function where we initialize the servo motor and we
set it to “look” straight. In my case, this was at 115 degrees angle. Next, we read the
distance a few times in order to get a valid distance measurement as shown below
36
void setup() {
myservo.write(115);
delay(2000); // Wait for 2s.
distance = readPing();
delay(100);
distance = readPing();
delay(100);
distance = readPing();
delay(100);
}
Now we go to the loop function which executes every 40 Ms. If the distance
we measured isless than or equal to 15 cm, we stop the motors, reverse for
300ms, stop, look right and left and measure the distance in each direction. If
the distance in one direction is greater than theother we turn the robot to the
direction with the farthest/greatest distance and instruct it to move forward as
shown below.
void loop() {
int distanceR =
0;int distanceL
= 0;delay(40);
if(distance<=15)
{
moveStop();
delay(100);
moveBackward();
delay(300);
moveStop();
delay(200);
distanceR =
lookRight();
delay(200); 37
distanceL = lookLeft();
delay(200);
if(distanceR>=distanceL)
{
turnRight();
moveStop();
}else
{
turnLeft();
moveStop();
}
}else
{
moveForward();
}
distance = readPing();
}
this autonomous robot (auto mode) has 5 statuses: move forward, stop, move
backward, scanright and left, and turn right or left. Since only 1 distance
sensor used in this project, the sensor must have the capability to turn around
to scan for alternative way to move so it must attach together with servo.
The servo shaft can be turn in 180 degrees to help the sensor scanthe
obstacle around and choose the clear path to move along. A homemade
bracket used to attach the sensor to the servo.
38
Figure 4.29 Turning function by servo motor to detect obstacles
myservo.write(50);
myservo.write(170);
return distance;
39
4.7.4 Sensor System
The obstacle sensor is used avoiding the robot from the clash to any
external devices or thatis like walls, any obstacle which comes in its way.
Here I used the Ultrasonic Sensor as shown below.
we will be using the following rotation of wheel for steering and straight motion:
40
Figure 4.31 Robot Driving System
motor1.run(RELEASE);
motor2.run(RELEASE);
motor1.run(FORWARD);
motor2.run(FORWARD);
41
{
motor1.setSpeed(speedSet);
motor2.setSpeed(speedSet+MAX_SPEE
D_OFFSET); delay(5);
}
}
}
{
goesForwar
d=false;
motor1.run(
BACKWARD);
motor2.run(
BACKWARD);
for (speedSet = 0; speedSet < MAX_SPEED; speedSet
+=2) // slowlybring the speed up to avoid loading down the batteries
too quickly
{
motor1.setSpeed(speedSet);
motor2.setSpeed(speedSet+MAX_SPEE
D_OFFSET); delay(5);
}
}
{
motor1.run(F
ORWARD);
motor2.run(BA
CKWARD);
delay(300);
motor1.run(F
ORWARD);
42
motor2.run(F
ORWARD);
}
{
motor1.run(BA
CKWARD);
motor2.run(F
ORWARD);
delay(300);
motor1.run(FORWARD);
motor2.run(FORWARD);
}
43
5 Chapter five: Conclusion and Recommendation.
5.1 Conclusion
Today we are in the world of robotics. Knowingly or unknowingly, we
have been usingdifferent types of robots in our daily life.
The project is “obstacle detection and the avoidance robot” is practically
proved by using the Ultrasonic sensor for sensing the robot, Motor Shield
Driver for the driving the dc motors, dcmotor is used for the movement of the
robot with the help of the Arduino Microcontroller.
A lot of factors determined the accuracy of the robot we designed. These
factors were the environmental phenomenon in which the robot was tested,
the number of obstacles present making the test space crowded or
relatively less crowded the type and shape of the obstacle(the robot is
designed for a uniform shaped obstacle).
These factors majorly affected the sensors. The accuracy of the robot is
dependent on thesensors used. Thus, the nature of the sensor and its
accuracy defined the accuracy of my robot.
44
land, underground, in the air or in space.
A fully autonomous robot has the ability to
Work for an extended period of time without intervention from
human or a need forpower supply.
Avoid situations that are harmful.
5.4 Advantages
Collision control.
It provides Safe Navigation.
This is the basic of all robot and has a wide scope of extensions
5.5 Limitations
The performance of this robot mainly depends on the sensors and
number of sensors. The ultrasonic sensor used here is of commercial
application so it may easily undergointerference.
45
Figure 5.1 Ultrasonic Sensor Problems Faced
46
BIBLIOGRAPHY
47
APPENDIX:
48
void loop() {
int distanceR = 0;int distanceL = 0; delay(40);
if(distance<=15)
{
moveStop(); delay(100); moveBackward();delay(300);
moveStop(); delay(200);
distanceR = lookRight();delay(200);
distanceL = lookLeft();delay(200);
if(distanceR>=distanceL)
{
turnRight();moveStop();
}else
{
turnLeft(); moveStop();
}
}else
{
moveForward();
}
distance = readPing();
}
49
int lookRight()
{
myservo.write(50);delay(500);
int distance = readPing();delay(100); myservo.write(115); return
distance;
}
int lookLeft()
{
myservo.write(170);delay(500);
int distance = readPing();delay(100); myservo.write(115); return
distance; delay(100);
}
50
}
51
delay(300); motor1.run(FORWARD);motor2.run(FORWARD);
}
void turnLeft() { motor1.run(BACKWARD);
motor2.run(FORWARD); delay(300); motor1.run(FORWARD);
motor2.run(FORWARD);
}
52