Line follower robot using ros report-
Line follower robot using ros report-
Submitted by
G. ANIRUDH 21130030
K. LOKESH 21130049
Under the guidance of
Ms. N. SEENU
in partial fulfilment for the award of the degree
of
Bachelor of Technology
in
MECHATRONICS
Certified that this project report titled LINE FOLLOWING ROBOT USING
ROS is the Bonafide work of Mr.G.ANIRUDH(21130030),
Mr.K.LOKESH(21130049) who carried out the project work under my
supervision during the academic year 2023-2024.
SIGNATURE
Ms. N. SEENU
SUPERVISOR
Department of Mechatronics Engineering,
Hindustan Institute of Technology and Science,
Padur,
Chennai-603103
Name: Name:
Designation: Designation:
G. ANIRUDH (21130030)
K. LOKESH (211300349)
TABLE OF CONTENTS
CHAPTER TITLE PAGE
NO. NO.
1 INTRODUCTION 1
2 METHODOLOGY 2
APPENDIX 8-10
I
TABLE OF FIGURES
3(b) Wheels 3
5(a) Hardware 6
II
CHAPTER 1
INTRODUCTION
Integrating ROS in the development of a line follower robot allows for sophisticated control
mechanisms, easier scalability, and reusability of code across various robotic projects. The use
of ROS enhances the robot's ability to perform complex tasks, makes debugging simpler, and
leverages the vast array of tools and community support available. Whether for educational
purposes, industrial applications, or research, a ROS-based line follower robot represents a
robust platform for exploring advanced robotics concepts. Through this report, we aim to
provide an overview of the line-following robot's architecture, the integration of ROS into its
development process, and the potential applications of such robots in various domains.
1
CHAPTER 2
METHODOLOGY
The hardware setup is the first step in the ROS and Arduino method of building a line-
following robot. This includes choosing a viable robot stage, like a differential drive or wheeled
robot, and introducing line location sensors, like infrared sensors, on the robot suspension.
Furthermore, the sensors and motors are interconnected with the Arduino microcontroller
board. Moving on to the software setup, the Arduino IDE is installed on the development
computer, and ROS serial communication libraries are configured to make it easier to
communicate with ROS. Joining is then accomplished by laying out bidirectional
correspondence among ROS and Arduino utilizing ROS sequential, trailed by the improvement
of ROS hubs to connect with the Arduino board. Implementing signal processing techniques to
interpret sensor data and incorporating control algorithms like PID to adjust motor speeds and
maintain alignment with the line are the next steps in the line-following algorithm design
process. At last, ROS hub execution involves making hubs to buy into sensor information
distributed by the Arduino, handling this information to produce control orders for the robot's
engines, and guaranteeing powerful mistake taking care of to successfully address startling
situations. The essential sensors utilized in a line supporter robot are commonly infrared (IR) or
ultrasonic sensors that distinguish the line on the floor. The ground is continuously scanned by
the sensors for contrast between the line and the floor around it. ROS topics are used to publish
sensor data. There may be a separate node for publishing sensor data for each sensor. ROS hubs
for sensor information help in reflection, where the information handling rationale is decoupled
from information assortment. The sensor data topics are subscribed to by a control system
node. In light of the information got (e.g., position of the line comparative with the robot), the
control framework processes the fundamental guiding orders to follow the line. The robot's
actuators, which are typically motors, receive instructions from the control system to alter the
robot's trajectory. ROS messages provide the actuators with instructions to maintain, increase
or decrease speed, or steer left or right. This methodology comprehensively outlines the
sequential steps involved in constructing a line-following robot, emphasizing hardware setup,
software integration, algorithm development, and ROS node implementation.
2
CHAPTER 3
Components Required
Wooden Pad/Base:
• Wooden plank is used as a base of the line follower robot.
Fig -3a
Fig-3b
L298N Driver:
• Motor driver module to control the speed and direction of the motors. Wheels: Pair of
wheels suitable for the chosen robot platform. Motor Mounts: Structures to securely attach
the motors to the robot's base.
Fig-3c
Infrared Sensors:
• Sensors capable of detecting the line on the surface.
3 Fig-3d
Jumper Wires:
• Used for connecting the sensors to the Arduino and other components.
Fig-3e
Arduino Uno:
• Microcontroller board responsible for processing sensor data and controlling motor
movements. Breadboard: Provides a convenient platform for prototyping and connecting
electronic components. Jumper Wires: Used for interconnecting components on the
breadboard and Arduino. Power Supply: Battery or external power source to supply power
to the Arduino and motors.
Fig- 3f
Lithium Batteries:
• Power source for the robot, providing the necessary voltage and current for operation.
Fig-3g
4
CHAPTER 4
Fig- 4a
We can observe in the circuit diagram that the four intermission pins of the motor driver are
connected to the digital pins of the Arduino, both output sides of motor driver are connected
to the dc motors, +12V input and -Ve are connected to battery, the +5V output is connected to
IR sensors and Arduino, the GND of IR sensors is connected to the GND of Arduino and
L298N motor driver and lastly the signal of IR sensor is connected to the digital pins of the
arduino.Under the robot, sensors like infrared or reflective optical sensors are shown in the
ROS line-following robot circuit diagram. These sensors detect the line on the surface and
send data to a ROS-interfaced microcontroller, typically an Arduino or Raspberry Pi. The
microcontroller processes sensor information to decide engine orders for following the line.
Based on these commands, motor driver circuitry controls the robot's motors, ensuring precise
line navigation. This mix with ROS considers progressed functionalities and execution of the
line-following robot.
5
CHAPTER 5
Fig- 5a
The hardware of the system consists of IR Sensors, wheels, motor drivers, dc hobby motors,
Arduino, and batteries. We connected the same side motors in series and connected the series
point to the motor driver on their respective sides, and we have connected IR sensors, Arduino,
motor driver based on the circuit diagram. The motor is controlled (connected to Arduino's
digital output pins for direction control) by connecting two sensors on the sides of the robot to
the analog input pins (VCC to 5V, GND to GND). Connected to the motor driver outputs
(positive wire to motor driver's 5V, negative wire to motor driver outputs). Think about
purchasing a separate battery pack for the motors (positive to the motor driver's Vin and negative
to GND).
6
CHAPTER 6
ROS (Robot Operating System) and Arduino were used in the design of the line-following
robot, which is now fully operational. Developed with a strong wooden base, it uses side interest
engines and wheels for development, driven by a L298N engine driver for successful impetus.
The line's path can only be detected and followed by strategically mounted infrared sensors on
the robot's chassis. These sensors associate with the Arduino microcontroller through jumper
wires, working with solid information transmission. The Arduino Integrated Development
Environment (IDE) is used to program the Arduino board. It is designed to use the ROS serial
libraries to communicate with ROS better. This significant incorporation takes into consideration
a consistent and proficient trade of information between the Arduino and ROS, laying out a
sound framework activity. At the heart of its navigation capabilities, the robot employs a custom-
developed line-following algorithm that incorporates PID (Proportional, Integral, Derivative)
control. This algorithm intelligently processes the input received from the infrared sensors to
continually adjust the motor speeds. Such adjustments ensure the robot remains aligned with the
line, compensating dynamically for any deviations detected during its movement. On the ROS
side, specific nodes are dedicated to subscribing to the sensor data relayed from the Arduino.
These nodes are responsible for processing the incoming data and subsequently generating
appropriate motor control commands. The system is designed with robust error handling
mechanisms, which significantly enhance the robot’s reliability and performance across a variety
of operational scenarios. In conclusion, this line-following robot exemplifies the successful
integration of ROS and Arduino, achieving autonomous path following with high precision and
stability. This accomplishment not only marks a significant milestone in robotic design but also
sets a solid foundation for further exploration and experimentation in the field of robotics. By
leveraging the modular and scalable nature of both ROS and Arduino, future enhancements and
additional functionalities can be easily integrated, paving the way for more sophisticated robotic
applications.
7
APPENDIX
#include <ros.h>
#include <std_msgs/String.h>
ros::NodeHandle nh;
std_msgs::String str_msg;
ros::Publisher ir_pub("/ir_state", &str_msg);
if (command == "forward") {
digitalWrite(7, 0);
digitalWrite(8, 1);
digitalWrite(9, 0);
digitalWrite(10, 1);
} else if (command == "right") {
digitalWrite(7, 0);
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 1);
} else if (command == "left") {
digitalWrite(7, 0);
digitalWrite(8, 1);
digitalWrite(9, 0);
digitalWrite(10, 0);
} else if (command == "cright") {
digitalWrite(7, 0);
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 1);
} else if (command == "cleft") {
digitalWrite(7, 0);
digitalWrite(8, 1);
digitalWrite(9, 0);
digitalWrite(10, 0);
} else if (command == "sright") {
digitalWrite(7, 0);
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 1);
} else if (command == "sleft") {
digitalWrite(7, 0);
digitalWrite(8, 1);
digitalWrite(9, 0);
digitalWrite(10, 0);
8
} else if (command == "mright") {
digitalWrite(7, 0);
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 1);
} else if (command == "mleft") {
digitalWrite(7, 0);
digitalWrite(8, 1);
digitalWrite(9, 0);
digitalWrite(10, 0);
} else if (command == "stop") {
digitalWrite(7, 0);
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 0);
} else {
digitalWrite(7, 0);
digitalWrite(8, 0);
digitalWrite(9, 0);
digitalWrite(10, 0);
digitalWrite(11, 0);
}
}
void setup() {
pinMode(irPin1, INPUT);
pinMode(irPin2, INPUT);
pinMode(ledPin, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
nh.initNode();
nh.advertise(ir_pub);
nh.subscribe(sub);
}
void loop() {
int irState1 = digitalRead(irPin1);
int irState2 = digitalRead(irPin2);
ir_pub.publish(&str_msg);
nh.spinOnce();
import rospy
from std_msgs.msg import String
def ir_state_callback(msg):
if msg.data == "00":
led_pub.publish("forward")
elif msg.data == "01":
led_pub.publish("right")
elif msg.data == "10":
led_pub.publish("left")
elif msg.data == "11":
led_pub.publish("stop")
rospy.init_node('line_following_control')
rospy.spin()
10