Chapter 1 Overview of Line Detection and Obstacle Avoidance Robots
Chapter 1 Overview of Line Detection and Obstacle Avoidance Robots
3. Research objectives
Research and build a robot model to detect lines and avoid obstacles
Research and develop robots in applications of technology
4. Object and scope of research
Regarding object
- Arduino has become very popular among beginners getting acquainted with
electronics. Unlike most previous programming boards, Arduino does not require a
separate hardware programmer to upload new code—you simply use a USB cable.
Furthermore, the Arduino IDE utilizes a simplified version of the C++ programming
language, making it easier to learn programming.
Figure 4: Arduino R3 Microcontroller
- The Arduino hardware and software are designed for teachers, students,
designers, enthusiasts, hackers, beginners, and anyone interested in creating interactive
objects or environments. Arduino can connect to buttons, LEDs, motors, speakers, GPS
devices, cameras, the internet, and even your smartphone or TV.
- This flexibility, along with the fact that the Arduino software is free, its
hardware is relatively inexpensive, and both hardware and software are easy to learn,
has created a large and active community. This community has contributed and
published numerous tutorials and code for a wide variety of projects based on the
Arduino platform.
- There are many types of Arduino boards that can be used for different
purposes. Some boards may look slightly different from the one below, but most
Arduinos share a majority of the following common components:
PWM (8): You may notice a tilde (~) next to some of the digital pins (specifically
pins 3, 5, 6, 9, 10, and 11 on the Arduino UNO). These pins function as regular
digital pins but can also be used for a feature called Pulse Width Modulation
(PWM). We have a detailed guide on PWM, but for now, you can understand that
these pins can simulate analog output (such as dimming and fading an LED).
AREF (9) : The abbreviation for Analog Reference. Typically, you can leave this
pin unconnected. However, it is sometimes used to set an external reference
voltage (from 0 to 5 volts) as the upper limit for the analog input pins
b, Line Detection:
- When the left sensor detects a line (high signal), the robot turns left.
- When the right sensor detects a line, the robot turns right.
- If neither sensor detects a line, the robot turns back.
c, Obstacle Avoidance:
- If the ultrasonic sensor detects an obstacle at a certain distance (e.g. less than 20
cm), the robot stops and determines the direction of rotation.
- The robot can turn left or right depending on the location of the obstacle, or turn
back and find a new direction.
- To sum up, the line-following obstacle-avoidance robot utilizes a combination of
sensors to detect the path and obstacles, a controller to process signals, and adjust
its movement. This operation allows the robot to autonomously navigate along a
predefined path while avoiding collisions with obstacles.
CHAPTER 3: SYSTEM MODELING
Kinematics of Line Detection and Static Obstacle Avoidance Robot
In robotics, line detection and static obstacle avoidance are two critical functionalities for
autonomous navigation. These behaviors often rely on sensors, algorithms, and control
strategies to allow the robot to follow a line while avoiding obstacles in its path. Below is
an explanation of the kinematics and key components of a robot designed for both tasks.
1. Kinematic Model of the Robot
The kinematic model describes the motion of the robot with respect to time, without
considering forces or mass. In a robot designed for line detection and static obstacle
avoidance, the typical kinematic model is based on differential drive, where two wheels
(or motors) control the robot's velocity.
a. Differential Drive Kinematics
A robot with a differential drive system typically has two wheels located on either side of
the robot. The kinematic equations for a differential drive robot can be expressed as:
x(t)x(t)x(t): the robot's position along the x-axis (forward/backward).
y(t)y(t)y(t): the robot's position along the y-axis (left/right).
θ(t)\theta(t)θ(t): the orientation of the robot (heading angle with respect to the x-
axis).
Let the two wheels have the following linear velocities:
vLv_LvL: linear velocity of the left wheel.
vRv_RvR: linear velocity of the right wheel.
The robot's linear velocity vvv and angular velocity ω\omegaω are given by:
v=vL+vR2v = \frac{v_L + v_R}{2}v=2vL+vR ω=vR−vLL\omega = \frac{v_R - v_L}
{L}ω=LvR−vL
Where LLL is the distance between the two wheels (the axle length).
The robot's motion can be described by the following differential equations:
dxdt=vcos(θ)\frac{dx}{dt} = v \cos(\theta)dtdx=vcos(θ) dydt=vsin(θ)\frac{dy}{dt} = v \
sin(\theta)dtdy=vsin(θ) dθdt=ω\frac{d\theta}{dt} = \omegadtdθ=ω
These equations describe how the robot's position and orientation change with respect to
time based on the velocities of the left and right wheels.
2. Line Detection
Line detection is often achieved using sensors like infrared (IR) sensors, color sensors, or
cameras that can detect a visible line (e.g., a black line on a white surface). The robot
needs to follow this line while maintaining its orientation relative to the path.
a. Line Following Control Algorithm
The primary challenge in line detection is to keep the robot on the path while adjusting its
trajectory. A common approach to line following is to use a feedback control algorithm
like Proportional-Integral-Derivative (PID) control.
Proportional (P): The robot adjusts its direction based on how far it deviates from
the center of the line.
Integral (I): The robot accounts for accumulated errors over time, helping to
eliminate drift.
Derivative (D): The robot anticipates the direction of the error and makes
corrections faster.
Given a sensor reading, the control algorithm adjusts the robot's steering (turning the
wheels) to correct for deviations from the line.
The general line-following logic includes:
1. Sensor Feedback: The robot uses its sensors (e.g., a set of IR sensors) to detect
whether it is off-center from the line.
2. Error Calculation: The sensor readings provide a measure of the robot’s error in
terms of lateral displacement from the line.
3. Adjustments: The robot adjusts its speed or steering angle to bring it back onto the
line.
A simple proportional controller can be expressed as:
Steering Correction=Kp⋅Error\text{Steering Correction} = K_p \cdot \
text{Error}Steering Correction=Kp⋅Error
Where:
KpK_pKp is a proportional gain constant.
Error\text{Error}Error is the lateral displacement from the center of the line.
The robot continuously adjusts its steering to minimize this error, keeping it on the line.
3. Static Obstacle Avoidance
Static obstacle avoidance ensures the robot can detect and avoid objects in its path, which
may include walls, barriers, or other obstacles. This is typically achieved using sensors
like ultrasonic sensors, LiDAR, or cameras that provide distance measurements to
obstacles.
a. Sensor-based Obstacle Detection
The robot’s sensors detect the distance to obstacles. If the distance is below a predefined
threshold, the robot needs to make an adjustment to avoid the obstacle.
b. Obstacle Avoidance Algorithms
There are various algorithms for obstacle avoidance, but a commonly used one is the
Potential Field Method or Bug Algorithm.
1. Potential Field Method:
o In this method, obstacles are treated as "repulsive" forces and the target (or
line) as an "attractive" force. The robot moves in the direction of the overall
force (the sum of the attractive and repulsive forces).
o The robot will avoid obstacles by moving away from them while still being
drawn towards the target line.
The control law for motion based on this potential field can be written as:
Ftotal=Fattractive+FrepulsiveF_{\text{total}} = F_{\text{attractive}} + F_{\
text{repulsive}}Ftotal=Fattractive+Frepulsive
Where:
o FattractiveF_{\text{attractive}}Fattractive is the force drawing the robot
toward the line.
o FrepulsiveF_{\text{repulsive}}Frepulsive is the force that repels the robot
from obstacles.
2. Bug Algorithm:
o The robot follows the line until it detects an obstacle. If an obstacle is
detected, the robot follows the perimeter of the obstacle until it finds a way
to continue along the line.
o The "bug" algorithm can be implemented using a simple rule: if an obstacle
is detected, turn and move around it until the robot can safely proceed along
the line.
c. Obstacle Avoidance Behavior
The behavior of the robot in the presence of obstacles is as follows:
1. Detection: The robot scans the environment for obstacles using sensors (e.g.,
ultrasonic or LiDAR).
2. Avoidance Decision: If an obstacle is detected in front of the robot, it computes a
new direction to avoid the obstacle. This may involve turning or moving backward.
3. Movement: The robot executes the movement necessary to avoid the obstacle,
while maintaining its goal of line-following (if possible).
4. Resume Line Following: After avoiding the obstacle, the robot reorients itself and
resumes following the line.
4. Integrated Line Following and Obstacle Avoidance
In an integrated system, the robot must continuously balance line following and obstacle
avoidance. The robot follows the line while monitoring for obstacles. If an obstacle is
detected, it switches to an avoidance mode, navigating around the obstacle, then resumes
line following once the path is clear.
The integration of these behaviors can be achieved with a state machine or a priority
system:
If an obstacle is detected, the obstacle avoidance behavior takes priority,
temporarily interrupting the line following.
Once the obstacle is avoided, the robot returns to line following mode.
A typical behavior loop for such a robot might look like:
1. Sense Line: Continuously check for deviations from the line.
2. Sense Obstacle: Continuously check for obstacles in front of the robot.
3. Decision:
o If no obstacle is detected, follow the line using the line following control
algorithm.
o If an obstacle is detected, switch to obstacle avoidance mode and navigate
around the obstacle.
4. Repeat: Once the obstacle is avoided, switch back to line-following mode.
Conclusion
In summary, the kinematics of a robot designed for line detection and static obstacle
avoidance relies on the differential drive model, which allows for control of the robot's
forward movement and turning. Line detection is handled by sensor feedback and control
algorithms like PID, while obstacle avoidance is typically achieved using potential fields
or other path planning algorithms. By integrating these two behaviors, the robot can
autonomously follow a line while avoiding obstacles in its environment.
3.1 System block diagram design
3.1.1. Definition
System block diagram design is the process of building a visual model to describe the
major components of a system and the relationships between them. Block diagrams help
analyze, communicate, and design the processes, information flows, and functions of a
system in a clear and understandable way.
Flowcharts are commonly used in engineering, project management, software
development, and many other fields to describe processes, information systems, or
complex operating mechanisms.
3.1.2 Using fritzing to design electronic circuit
Fritzing is an open source software designed specifically for people who need to create
electronics projects, especially hardware libre, and those who do not have access to the
necessary documentation. It can also be used to implement your designs, record examples
for tutorials, etc. In addition, this tool has a large community behind it that is always
updated or ready to help if you run into problems. It can even be a great tool for
classrooms, for both electronics students and teachers, for users who want to share and
record their prototypes, and even for professionals.
The electronic circuit consists of an arduino sensor controller, an H-bridge circuit, 4 servo
motors, 3 infrared sensors, 1 battery and 1 ultrasonic sensor.
3.2. Sensor analysis and selection
3.2.1. Infrared sensor
Infrared sensor has the English name Infrared Sensor,
abbreviated IR Sensor. Infrared sensor is an electronic device
that can emit or receive infrared radiation from the
environment around them. The structure includes a light-
emitting diode (LED) and a receiver. When an object
approaches the sensor, the LED device will actively emit
infrared radiation and reflect it back to the object so that the
receiver can detect it.