Obstacle Detection Robot Project Guide
Obstacle Detection Robot Project Guide
Framed by:
Mr. YOUNES ADNANI
2
Role:............................................................................................................................................25
2-3 Installation from the Snappy-ros library:.................................................................25
3-Installing Firebase in NodeRED:26
4 The connection between Firebase, Node Red, and Topics:.......................................................................26
VI. Application creation using the MIT App Inventor site:..........................................27
VII. The application is created:...............................................................................................................28
VIII. Code Arduino28
IX. Connection Bluetooth with ROS:........................................................................................32
X. The steps to control our robot:.....................................................................................34
3
List of figures:
4
General introduction to the project:
At the same time, we will set up a cloud infrastructure and a ROS system to provide
the robot additional computing and storage power, as well as connectivity
with other systems and online services. This cloud Robotics approach will enable the robot
to access real-time data, to communicate with other robots and systems, and
to significantly improve its capabilities.
This report will detail the different phases of the project, from hardware design to
the programming of the robot's behavior through the implementation of
the cloud infrastructure and the ROS system. We will also evaluate the performance of
our solution and discuss the prospects for improvement for the future
project iterations.
The idea is to use an Arduino board to read the data received from one or more,
ultrasonic sensor(s).
When the sensor detects an obstacle in front of it, the Arduino must send instructions to
motors that drive the wheels of the robot to avoid it. The robot would be partially made of
chassis and electronic components (Arduino, ultrasonic sensor, motors, ...) would be
fixed to the chassis simply using glue.
The materials needed to build this robot are:
Arduino UNO.
An ultrasonic sensor HC-SR04.
Two DC motors to drive the robot's wheels.
An 11V battery and connectors to power the DC motors.
L298N motor driver
Two wheels
Bluetooth Module HC05
Jumper cables
There are several types of Arduino boards, we focused only on the type
most frequently used is the Arduino UNO card To carry out this assembly, it is necessary to ensure the
link between each electronic component and our Arduino board.
In total, we will need an Arduino board that has at least 9 digital pins, and
also who will be able to execute the algorithm etched in its memory as quickly as possible.
On the other hand, the Arduino UNO board is the most suitable board for this situation.
It has 14 digital pins (including 6 with PWM) and 6 analog input pins.
2 ultrasonic sensors
7
2-1 Operation of the sensor
The operating principle of the sensor is fully based on the speed of sound.
Here is how a measurement is taken: We send a HIGH pulse of 10μs on
the TRIGGER pin of the sensor.
The sensor then sends a series of 8 ultrasonic pulses at 40KHz (inaudible
for the human being, it is when more pleasant than a biiiiiiiip).
Ultrasounds propagate through the air until they hit an obstacle and return to
the other direction towards the sensor.
The sensor detects the echo and ends the measurement.
The signal on the ECHO pin of the sensor remains HIGH during steps 3 and 4, which
measures the duration of the round trip of the ultrasound and thus determines the
distance.
Note: There is always a fixed duration silence after the emission of the ultrasound to avoid...
receive an echo prematurely coming directly from the sensor.
8
3 DC Motor
Figure 5: DC Motor.
9
Figure 6: Bluetooth module HC-05
4-1Description :
This Bluetooth module allows for adding a wireless Bluetooth serial connection to your
ARDUINO. It communicates with the microcontroller via a serial port.
Specifications
100% compatible with
ARDUINO
Nominal voltage: 3.3 V- 5
V MAX
2.4 GHz antenna
integrated
Control your
Wireless ARDUINO
10
Operating principle
Description
The L298N motor driver is a monolithic circuit integrated in Milliwatt packages.
PowerSO20 with 15 pins. This is a high voltage full-bridge driver and
high current designed to accept inductive loads of level sand drive
standard TTL logic such as relays, solenoids, direct current motors and stepper motors
in steps. Two validation inputs are provided to activate or deactivate the device
independently of the input signals. The emitters of the lower transistors of each
where they are connected together and the corresponding external terminal can be used for the
connection of an external detection resistor. An additional power input
is provided so that the logic operates at a lower voltage.
11
Characteristics:
The L298N module allows for the independent control of two DC (direct current) motors.
3 to 30V, or a stepper motor, the latter produced in 1930, their true development
is related to the event of micro-computing (microprocessor). The stepper motor can
fill two functions:
conversion of electrical energy into mechanical energy (this is the classic motor).
conversion of digital information into an angular or linear positioning.
L298N motor driver works with a 5V TTL control interface (therefore compatible
with ARDUINO or with many other low voltage microcontrollers). It includes
two H bridges to switch the currents (2A per bridge at peak, 20W). This module allows
to vary the rotation speed (in PWM modulation) and to reverse the direction of rotation
of motors. It can drive inductive loads (windings, relays), the outputs of
powers are protected by back EMF diodes.
Programming of the L298N motor driver:
The following program allows to activate the motor connected to bridge B by
passing through the serial port. Through the serial monitor, we send an integer between -255
and 255 to activate the motor, the value 0 meaning 'stop the motor' [annex 1]
L298N motor driver application:
The L298N motor driver integrated circuit has many applications in the field.
embedded, particularly on the robotics side. Most microcontrollers
operate on very low voltage and current (5v) while motors require
higher voltages and currents. Thus, microcontrollers cannot provide them
12
a higher current as well. For this, we use driver integrated circuits
motor. The motor driver is a small current or voltage amplifier. It takes a
weak current signal and emits a high current signal that can drive a motor. It
can also control the direction of the motor. Motor drives are
various types depending on the maximum supply voltage, the output current
maximal, from the nominal power dissipation, the charging voltage and the number of
outputs, etc. We will discuss the L298N motor driver here. It is used in the project of
control of the speed of the direct current motor and you can easily interface the
DC motor with the microcontroller using this motor driver. And also
in a Bluetooth-controlled robot using a PIC microcontroller. You can consult
the line-following robot to learn more about its applications.
The connector wires
Cables, wires, or connectors are necessary elements to establish connections
between different electrical components.
Figure 8: Straps
The Li-ion 18650 battery offers flexibility in its configuration in series or parallel.
allowing the capacity and voltage to be adapted according to specific needs of
the application.
They can be connected in series. In this case, the voltage increases and the capacitance remains.
equal to a battery. This can be done using a special case. By connecting 3 batteries
from 3.7 v each, we get a battery of 11.1 volts 3600 mA.
13
Figure 9:: 3.7V batteries
1 2 3
14
4 5
15
Part 2: Study of the Software Part
This section is dedicated to the representation of the computing platforms used in the
development of the robotic system.
I. Arduino programming platform
The Arduino IDE interface is quite simple, it offers a minimal and streamlined interface for
develop a program on Arduino boards. It is equipped with a code editor with
syntactic coloring and a quick toolbar. These are the two most
important aspects of the interface are those that we use most often. We also find a
menu bar, more classic which is used to access the advanced functions of the IDE.
Finally, a console displaying the results of the compilation of the source code, operations on
the map, etc.
16
a. Writing an Arduino program
An Arduino program (Sketch) = 1 setup() function + 1 loop() function The language used
C/C++
17
II. Ubuntu 2024 and VMWare WorkStation
Ubuntu is a popular Linux operating system, known for its user-friendliness and its
security. VMware Workstation is a virtualization application that allows you to create and
manage virtual machines on a computer. By combining Ubuntu with VMware
Workstation, users can create flexible development environments and
secured, ideal for testing applications, developing software or configuring
servers without affecting their main operating system.
Source packages do not have a hierarchical structure (or only a single level when the
deposits contain several ROS packages).
18
2 Installation of ROS:
Update the list of available packages and install ROS with the following command:
19
4 Creation of the Workspace:
To create a workspace in ROS, we use the commands
following:
Package compilation:
The catkin_make command is a fundamental step in using ROS.
(Robot Operating System). Its main role is to compile the packages included in
a ROS workspace
20
7 Creation of nodes:
21
The code that ensures the control of the robot:
22
The rosrun command in ROS allows you to start a specific node by specifying its name.
the package where the node is located as well as the name of the node itself. This command is
used to execute particular nodes. To interact with the topics:
Node-RED est une plateforme de programmation visuelle basée sur un navigateur, conçue
to facilitate the creation of IoT applications. It uses a data flow model where the
users connect predefined nodes to create applications by drag-and-drop.
Node-RED offers a library of ready-to-use nodes, extensibility for integration
diverse services and flexibility to quickly develop applications based on
data flow.
23
1 Launch Node RED:
24
2 SNAPPY ROS :
2-1 Definition:
Snappy ROS is a module or library that allows Node-RED to
communicate with robotic systems using the Robot Operating System (ROS). It
uses the 'Snappy' protocol to exchange messages and data with the nodes
ROS, thus enabling seamless integration between Node-RED and the ROS ecosystem.
2-2 Role:
Snappy ROS in Node-RED facilitates integration and communication between Node-RED
and the ROS ecosystem, allowing developers to create robotic applications
richer and more interactive by combining the features of these two platforms
forms.
25
3-Installation of Firebase in NodeRED:
V. FireBase
26
Firebase is a mobile and web application development platform offered by
Google. It offers a range of ready-to-use backend services, SDKs for
several platforms, and development and testing tools to help developers to
create, improve and evolve their applications. Firebase is known for its ease
integration, its high availability and high performance, making it a choice
popular among developers looking to build modern applications and
evolving.
27
VII. The application is created:
#include <ros.h>
#include <std_msgs/Int32.h>
int m1a = 9;
int m1b = 10;
int m2a = 11;
int m2b = 12;
int speedPinRight = 2;
int speedPinLeft = 3;
int demar = 0;
#define trigPin 6
#define echoPin 7
ros::NodeHandle nh;
28
{
Backward();
demar = 1;
}
else if(statue == 4)
{
turnLeft();
demar = 1;
}
else if(statue == 1)
{
Forward();
demar = 1;
}
else if(statue == 3)
{
turnRight();
demar = 1;
}
else if(statue == 0)
{
stop();
demar = 1;
}
}
std_msgs::Int32 SensorROS;
ros::Publisher CapteurROSPublisher("Capteur", &CapteurROS);
ros::Subscriber<std_msgs::Int32> EtatROSsubscriber("Etat", &callBackFunctionEtat);
29
void setup() {
[Link]()->setBaud(9600);
[Link]();
[Link](EtatROSsubscriber);
[Link](CapteurROSPublisher);
//______________________________OUTPUT INPUT
pinMode(speedPinRight, OUTPUT);
pinMode(speedPinLeft, OUTPUT);
Set pin mode of m1a to OUTPUT;
pinMode(m1b, OUTPUT);
pinMode(m2a, OUTPUT);
pinMode(m2b, OUTPUT);
Set the trigPin to OUTPUT mode;
pinMode(echoPin, INPUT);
}
void loop() {
[Link]();
delay(5);
if (demar == 1 ) {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 15) {
[Link] = 1 ;
}
30
else {
[Link] = 0 ;
}
[Link](&CapteurROS);
}
}
void Backward() {
digitalWrite(m1a, HIGH);
digitalWrite(m2a, LOW);
digitalWrite(m1b, LOW);
digitalWrite(m2b, HIGH);
analogWrite(speedPinRight, 150);
analogWrite(speedPinLeft, 150);
}
void Forward() {
digitalWrite(m1a, LOW);
digitalWrite(m2a, HIGH);
digitalWrite(m1b, HIGH);
digitalWrite(m2b, LOW);
analogWrite(speedPinRight, 150);
analogWrite(speedPinLeft, 150);
}
void turnLeft(){
digitalWrite(m1a, LOW);
digitalWrite(m2a, LOW);
digitalWrite(m1b, HIGH);
digitalWrite(m2b, LOW);
analogWrite(speedPinLeft, 150);
}
void turnRight(){
31
digitalWrite(m1a, LOW);
digitalWrite(m2a, HIGH);
digitalWrite(m1b, LOW);
digitalWrite(m2b, LOW);
analogWrite(speedPinRight, 150);
}
void stop() {
digitalWrite(m1a, LOW);
digitalWrite(m2a, LOW);
digitalWrite(m1b, LOW);
digitalWrite(m2b, LOW);
}
32
Sensor topic
Data'0' absence of obstacle.
Data'1' presence of obstacle
State topic:
33
X. The steps to control our robot:
General conclusion:
34
During these mini-projects, we explored two distinct approaches for the
development of embedded systems and intelligent robots. The first mini-project has
focused on the creation of a presence detection robot equipped with ultrasonic sensors,
while the second mini-project implemented a cloud Robotics application using the
ROS (Robot Operating System).
In the first mini-project, we designed and created a robot capable of detecting the
obstacles using ultrasonic sensors and avoid collisions by adjusting its trajectory.
We used common hardware components such as an Arduino Uno, motors
DC, ultrasonic sensors HC-SR04, and other components. This project allowed us to
understand the basic principles of embedded robotics and develop
practical skills in hardware design and programming.
In the second mini-project, we explored the cloud robotics approach by putting ...
implementing an application using ROS for communication between different
components, including cloud, smartphones, and embedded systems. This approach
has allowed us to harness the power of cloud computing to enhance the capabilities of
our robots, allowing them to access computing and storage resources
supplements, as well as online services such as databases and services
of communication. This project also allowed us to understand the advantages and the
challenges associated with the use of cloud in the field of robotics.
In conclusion, this project has been enriching and instructive, allowing us to acquire some
new skills and better understand the challenges and opportunities offered by the
modern robotics. They also gave us the opportunity to develop our creativity and
our ability to solve complex problems. Finally, they raised our awareness of
the growing importance of cloud integration in the field of robotics to create
more intelligent, more flexible, and more efficient systems.
35