0% found this document useful (0 votes)
25 views35 pages

Obstacle Detection Robot Project Guide

The document outlines the development of an obstacle detection robot as part of a Cloud Robotics application using the ROS (Robot Operating System). It details the hardware and software components necessary for the project, including the Arduino board, ultrasonic sensors, DC motors, and Bluetooth modules, as well as the programming and cloud infrastructure setup. The goal is to create a robot capable of autonomously detecting and avoiding obstacles while leveraging cloud computing for enhanced capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views35 pages

Obstacle Detection Robot Project Guide

The document outlines the development of an obstacle detection robot as part of a Cloud Robotics application using the ROS (Robot Operating System). It details the hardware and software components necessary for the project, including the Arduino board, ultrasonic sensors, DC motors, and Bluetooth modules, as well as the programming and cloud infrastructure setup. The goal is to create a robot capable of autonomously detecting and avoiding obstacles while leveraging cloud computing for enhanced capabilities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Ibn Tofail University

Faculty of Sciences Kenitra


Specialized Master's

Obstacle Detection Robot

Framed by:
Mr. YOUNES ADNANI

Academic Year 2023-2024


TABLE DES MATIERES :

Part 1: Study of the Hardware section6


I. Introduction :......................................................................................................................................6
II. Material necessary.........................................................................................................................6
The Arduino board............................................................................................................................6
1.1. Choice of the card type.....................................................................................................7
1.2. Composantes from the Arduino UNO board7
2 Ultrasonic sensors.........................................................................................................................8
2-1 Operation of the sensor................................................................................................8
3 DC Motor........................................................................................................................................9
4 Module Bluetooth HC-0510
4-1Description :10
4-2 Connecting the HC-05:..........................................................................................................11
5 Using an L298N for DC motor with an Arduino.........................................................11
6 The connecting wires....................................................................................................................13
7 Batteries (car power supply) the batteries ririthe 18650ioHello you flixrbrlrtare gods
ciofigueatithe ice is meltingiI am happyllie pierhellot adaptthere is the capacitytis it thetiosrio io fioctithe ten
twiceispecific application taskstio.............................................................................................................14
III. General schemes:.....................................................................................................................14
Part 2: Study of the Software section..........................................................................................16
I. Platform Arduino programming16
II. Ubuntu 2024 and VMWare WorkStation.........................................................................................18
III. ROS Noetic..................................................................................................................................18
1 Organization of the workspace:......................................................................................18
2 Installation of ROS:...................................................................................................................19
3 Senvironment setup:............................................................................................................19
4 Creation of the Workspace:...........................................................................................................20
5 Package compilation:............................................................................................................20
6 Creating a package in ROS:.........................................................................................20
7 Creation of nodes:.....................................................................................................................21
8 The code that ensures the control of the robot:22
9 the ROS Master:22
IV. NODE RED.....................................................................................................................................23
1 Node RED launch:..............................................................................................................24
2 SNAPPY ROS :..............................................................................................................................25
2-1 Definition :.................................................................................................................................25

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:

FFIGURE1:UON THE MAPARDUINOUNO..................................................................................7


FFIGURE2:CULTRA RETURN-SONHC-SR04.............................................................................8
FFIGURE3:DDESCRIPTION OF THE ULTRA SENSOR-SONHC-SR04.....................................................8
FFIGURE4:IILLUSTRATION OF THE SIGNALTRIGGERETECHO.........................................................9
FFIGURE5:MOTEURDC.....................................................................................................10
FFIGURE6:MODULEBLUETOOTHHC-0510
FFIGURE7: SSYNOPTIC OF THE MOTOR DRIVER11
FFIGURE8:STRAPS............................................................................................................13
FFIGURE9:: BBATTERIES OF3.7V14
FFIGURE10:THE SOFTWAREARDUINO16

4
General introduction to the project:

This project is part of the development of a Cloud Robotics application using


the ROS (Robot Operating System). The goal is to leverage the potential of the cloud
computing to strengthen the capabilities of embedded systems and create robots
intelligent beings capable of interacting with their environment autonomously and efficiently.

We are particularly focused on the design and realization of a robot capable


to detect obstacles and avoid them autonomously. To do this, we will use
hardware components such as an Arduino Uno, HC-SR04 ultrasonic sensors,
DC motors, and others. This robot will be able to detect the presence of obstacles thanks to its
ultrasonic sensors, and adjust its trajectory to avoid them by controlling its DC motors.

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.

Part 1: Study of the Hardware part


5
I. Introduction :
The objective of this electronics project is to create a presence detection robot that ...
moves around a room and avoids obstacles when it encounters them. The robot's 'eyes' are
a ultrasonic sensor (for example HC-SR04). This sensor is connected to an Arduino board.
When the sensor sends the information to the Arduino that there is an obstacle in front of it, the Arduino
must send an instruction to the motors that control the wheels to avoid the obstacle.

II. Necessary Materials:

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

The Arduino board

An Arduino board is a small electronic board equipped with a microcontroller.


The microcontroller allows, based on events detected by sensors, to program and
order actuators; the Arduino board is therefore a programmable interface.
It can be programmed to analyze and produce electrical signals, in order to
perform very diverse tasks such as controlling household appliances, lighting,
heating, the control of a robot, embedded computing, etc.

Figure 1: An Arduino UNO board


6
1.1. Choice of the type of card

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.

1.2. Components of the Arduino UNO board

An Arduino UNO board essentially consists of:


• Power jack: Allows you to connect a power supply (battery, battery, mains adapter,
+ at the center Vin 7 to 12 V).
• Microcontroller: stores the program and executes it.
Analog inputs: Allows connection of analog sensors and detectors.
16
• USB (Universal Serial Bus) connection: Allows power supply to the board.
(5V). Allows uploading the program to the board.
• Digital inputs and outputs: Allows you to connect actuators. Allows for
connect detectors.

2 ultrasonic sensors

Figure 2: HC-SR04 ultrasonic sensor


The HC-SR04 sensor is a low-cost ultrasonic sensor. This sensor works with a
5 volts power supply voltage, has a measurement angle of about 15° and allows for
make distance measurements between 2 centimeters and 4 meters with a precision of 3mm (in
theory, in practice it is not quite accurate.

7
2-1 Operation of the sensor

Figure 3: Description of the ultrasonic sensor HC-SR04.

Figure 4: Illustration of the signal RIGGGR etGCHO.

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

A DC motor is an electromechanical converter that allows for conversion.


bidirectional energy between an electrical installation carried by a direct current
and a mechanical device. DC motors have the particularity of being able to operate
in both directions, depending on how the current is applied to it. DC motors are
controlled by a motor controller. Electric motor controllers allow for control
a
motor in speed, position or torque by supplying electrical power and the signal
adequate.

Figure 5: DC Motor.

4 Module Bluetooth HC-05

Bluetooth is a communication protocol that facilitates bidirectional exchange of


data on short distances using UHF radio waves in the frequency band
2.4 GHz. Its goal is to simplify connections between electronic devices.
proximity by eliminating the need for cables. For example, it allows for the replacement of cables
between computers, tablets, speakers, and mobile phones.

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

4-2 Connection of the HC-05:

RXD -> TXD of the Arduino (data reception).


- TXD -> RXD of the Arduino (data transmission).
- GND -> connected to the GND pin of the ARDUINO board GND
VCC -> 5V power supply

5 Using an L298N for DC motor with an Arduino


The L298N motor driver is an electronic component used to control speed and the
simultaneous control of two direct current motors. It works with motors
having a voltage of 5 to 35V and a peak current of up to 2A.

10
Operating principle

Figure 7: Synopsis of the driver


motor

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.

Principle diagram of the L289N motor driver module

11
Characteristics:

High operating voltage, reaching up to 40 volts;


Standard output current, the instantaneous peak current can reach up to 3A;
With a nominal power of 25 W;
Two integrated H bridges, high voltage, high current, full bridge driver, which
can be used to train direct current motors, stepper motors
no, relay coils and other inductive loads.
Use of standard logic level signal for control.
Able to drive a two-phase stepper motor or a four-phase stepper motor.
phases and two-phase direct current motors.
Adopt a high-capacity filter capacitor and a freewheeling diode that protects
the devices of the circuit against damage caused by reverse current of a
inductive charging, thereby improving reliability
The module can use the integrated 78M05 voltage regulator to obtain 5 V from
the power supply. But to protect the 78M05 chip from damage, when the
the variator voltage is greater than 12v, an external 5v logic power supply must be
used.
tension d’entraînement : 5-35 V; tension logique: 5 V
PCB size: 4.2 x 4.2 cm

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

7 Batteries (car power supply)

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

III. General schemes:

IV. the steps for carrying out the assembly:

1 2 3

14
4 5

1. Installation of the wheels + DC motors.


2. Installation of Arduino, Ultrasonic sensor, and batteries.
3. Installation of the L298N motor driver and HC-05 Bluetooth module.
4. Connection of the straps.
5. Final results

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.

Figure 10: the Arduino software

16
a. Writing an Arduino program
An Arduino program (Sketch) = 1 setup() function + 1 loop() function The language used
C/C++

The setup() function: must contain the initialization


The loop() function: a function repeated indefinitely
These two functions are called by a main() program required,
cached and non-modifiable

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.

III. ROS Noetic :

ROS, or Robot Operating System, is an open-source software development framework.


widely used source in robotics. It provides tools and libraries for
simplify the creation, control, and communication between the components of a robot. Thanks
to an asynchronous communication system and to efficient packet management, ROS
facilitates the development of modular and reusable robotic applications.
In ROS, a number of concepts common to many middleware can be found:

Nodes: A node is an executable that uses ROS to communicate with others.


nodes.
Messages: ROS data types used to subscribe or publish to a topic.
Topics: Nodes can publish messages on a topic as well as subscribe.
to a topic to receive messages.
Master: Name of the service for ROS (i.e. helps the nodes to find each other).
Parameters: Very little dynamic information that needs to be shared in
the application.
rosout: Equivalent of stdout/stderr.
roscore: Master + rosout + parameter server.

1 Organization of the workspace:

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:

3Setting up the environment:

Configure your ROS environment by running 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

6 Creating a package in ROS:


To create a new package, we use the following commands:

20
7 Creation of nodes:

Once you have used the command 'touch subscriber_node.py' to create a


new file named "subscriber_node.py", which could serve as a basis for the creation
From a ROS node, this file is created as non-executable by default. To make it
executable and thus allow its execution as a program or script, you can
use the command "chmod +x subscriber_node.py". This will add execution rights to
file, which will allow you to run the script directly without having to specify
the command interpreter. This step simplifies the development and testing process of
ROS nodes.
By similarly creating the Publisher node.

21
The code that ensures the control of the robot:

9 the ROS Master:


Facilitates the dynamic discovery of nodes in a ROS network, allowing for
different components of the system to communicate with each other flexibly. It
simplifies the management of the ROS environment by providing a central point of
coordination and information for the system nodes.

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:

IV. NODE RED

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:

First window after launching IP address in Node RED browser:

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.

2-3 Installation of the Snappy-ros library:

25
3-Installation of Firebase in NodeRED:

4 The connection between Firebase, Node Red, and Topics:

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.

VI. Application creation using the MIT App Inventor site:

27
VII. The application is created:

VIII. Arduino Code

#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;

void callBackFunctionStatus(const std_msgs::Int32 &StatusROS) {


int statue = [Link];
//__________________________commands
if(statue == 2)

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);
}

IX. Bluetooth connection with the ROS:

32
Sensor topic
Data'0' absence of obstacle.
Data'1' presence of obstacle

State topic:

Data '0' Stop


Data '1' Advanced
Data '2' Turn left
Data '3' Turn right
Data '4' retreat

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

You might also like