Part I: INTRODUCTION
1.1 Reason for Choosing the Topic
Currently, the trend of developing automation and artificial intelligence
technologies is growing rapidly. Among these, autonomous vehicles are becoming a
future trend, aiming to minimize risks and enhance safety in transportation. Autonomous
vehicles can be applied in various fields such as freight transport, public transportation,
and personal vehicles. Research and development of autonomous vehicles will contribute
to creating smart and sustainable transportation solutions. With automated control
systems, vehicles can maintain lanes, detect and avoid obstacles, reducing traffic
accidents caused by human errors, particularly those related to distraction or lack of
driving skills. The research and development of autonomous vehicles require knowledge
in multiple areas such as programming, image processing, device control, and system
integration. Choosing this topic enables the research team to enhance their skills in
Arduino programming, Python-based image processing techniques, and knowledge of
automated control systems. The autonomous control model not only has practical
applications but also contributes significantly to the learning and scientific research
process in the fields of information technology and automated control, while laying the
foundation for further research and development.
1.2 Scope and Limitations of the Research Topic
Limitations of the Topic
The research focuses on developing an autonomous vehicle model that processes
images using a camera. By utilizing simple programming languages such as
Python and Arduino, the vehicle is designed to follow a predefined path
accurately.
Scope of the Research Topic
The research is based on knowledge acquired from academic materials, textbooks,
and information shared by peers, mentors, and instructors. Additionally, the
project involves creating simulations using software, followed by the construction
of the model based on the collected information.
1.3 Objectives to be Achieved
The development of a "self-driving vehicle model that follows a designated lane"
is increasingly attracting the attention of researchers, students, and technology
enthusiasts. This is an exciting project that integrates mechanics, electronics, and
programming. The primary purpose of creating this autonomous vehicle model is to
simulate and study automatic control techniques, particularly in the field of self-driving
vehicles. Through the construction and testing of the model, we can gain a deeper
understanding of the operating principles of autonomous vehicles, sensors, and signal
processing. The model helps learners comprehend how sensors (such as cameras) collect
environmental data, process the received signals, and make control decisions.
Writing control code for the model enables learners to master control algorithms,
such as those implemented in Python and Arduino, and apply them practically to manage
the vehicle's speed and direction. The autonomous vehicle model also requires image
recognition, processing, and analysis. In particular, this model emphasizes the detection
of road lane markings and making appropriate control decisions to keep the vehicle
within the lane. Through the development and testing of this model, learners can gain a
clearer understanding of automatic control principles, develop programming skills, and
enhance problem-solving abilities. Arduino, MATLAB, and Python play crucial roles in
realizing the project, corresponding to hardware control, image processing, and algorithm
design, respectively.
PART 2: THEORETICAL FOUNDATION
2.1 Overview of Lane-Following Autonomous Vehicles
A lane-following autonomous vehicle is an integrated system of mechanics,
electronics, and software designed to maintain its position in the center of two lane
markings using a camera and image processing algorithms. This system simulates
autonomous driving technologies, focusing on detecting lane lines, calculating the desired
path (center of the lane), and adjusting the vehicle’s movement to follow that path. In this
project’s design, two servos control the rear wheels for movement and steering, while a
front caster wheel supports free movement, enhancing the vehicle’s flexibility in
adjusting direction.
2.2 Core Technologies
2.2.1 Image Processing with OpenCV in Python
Image processing is fundamental for lane detection. The camera captures real-time
road images, which are analyzed using OpenCV algorithms to determine lane positions.
The image processing steps include:
Image Acquisition: The camera (e.g., USB webcam or compatible camera
module) captures road images, typically in RGB or grayscale to reduce processing
load.
Image Preprocessing: Techniques applied include:
Noise Reduction: Gaussian Blur is used to minimize environmental noise.
Color Conversion: Images are converted to grayscale or HSV color space
to highlight lane markings.
Brightness Equalization: Contrast enhancement improves lane detection
under varying lighting conditions.
Edge Detection: The Canny Edge Detection algorithm identifies lane marking
edges based on pixel intensity changes.
Line Detection: The Hough Transform detects lane markings as straight lines,
identifying the two lane boundaries.
Lane Center Calculation: The midpoint between the two lane lines is computed
to determine the ideal path.
Error Calculation: The deviation (error) between the vehicle’s current position
(typically the image center from the camera) and the lane center is calculated to
generate control signals.
The OpenCV library in Python provides powerful functions like cv2.Canny(),
cv2.HoughLinesP(), and cv2.GaussianBlur() to perform these tasks efficiently.
2.2.2 Servo Control System
The vehicle’s control system uses two servos to drive the rear wheels, ensuring
movement and directional adjustments based on signals from the image processing
algorithm. Key theoretical aspects include:
Servo Operation Principle: Servo motors operate using PWM (Pulse Width
Modulation) signals, where the pulse width controls the servo’s rotation angle,
thus managing the speed and direction of the rear wheels. Each servo controls one
wheel, enabling differential drive for turning left/right or moving straight.
Speed and Direction Control:
For straight movement, both servos rotate at the same speed.
For turning, one servo rotates faster or in the opposite direction, creating a
speed differential between the wheels to adjust direction.
Free Caster Wheel: The front caster wheel is not actively controlled and freely
rotates based on the vehicle’s movement. This simplifies the control system but
requires precise image processing to ensure accurate lane following.
2.2.3 Communication via HC-06 Module
The HC-06 Bluetooth module transmits control signals from the image processing system
(running on a computer or Raspberry Pi) to the Arduino microcontroller. Theoretical
aspects include:
Bluetooth Communication Protocol: The HC-06 operates as a UART (Universal
Asynchronous Receiver-Transmitter) module, enabling serial data transmission
between Python and Arduino. Transmitted data typically includes control values
(e.g., servo angles or speed).
Signal Processing: Python sends control commands (based on image processing
results) via Bluetooth to the Arduino, which decodes them and converts them into
PWM signals for servo control.
Communication Optimization: To ensure real-time data transmission, latency is
minimized by using an appropriate baud rate (typically 9600 or 115200) and
simple data formats (e.g., numeric strings or characters).
2.2.4 Arduino Microcontroller
The Arduino Nano serves as the hardware control hub, receiving signals from the HC-06
and sending PWM signals to the servos. Theoretical aspects include:
Input Signal Processing: The Arduino reads data from the HC-06 via the Serial
port, interprets the data (e.g., lane deviation), and converts it into servo control
commands.
PWM Control: The Arduino uses the Servo library (Servo.h) to generate PWM
signals, adjusting the servo angles based on lane deviation.
Performance: The Arduino’s limited processing power requires optimized control
algorithms to ensure fast response times.
2.3 Lane-Following Algorithm
The lane-following algorithm is designed to keep the vehicle centered between two lane
markings. The main steps are:
1. Capture Road Image: The camera continuously records images of the road
ahead.
2. Process Image with OpenCV:
Apply Gaussian Blur to reduce noise.
Convert the image to grayscale and use Canny Edge Detection to detect
edges.
Use Hough Transform to identify the two lane lines.
Calculate the lane center by averaging the coordinates of the two lines.
3. Calculate Error: Compare the image center (representing the vehicle’s position)
with the lane center to determine the deviation (error).
4. Servo Control:
Use the error to calculate the required angles for the two servos.
Send the error value via HC-06 to the Arduino.
The Arduino adjusts the speed and direction of the servos to realign the
vehicle with the lane center.
5. Repeat: Continuously execute this process to ensure real-time lane following.
2.3.1 PID Control
To improve accuracy, a PID controller may be used to adjust the error:
Proportional (P): Proportional to the current error, enabling quick alignment to
the lane center.
Integral (I): Accumulates error over time to eliminate residual deviation.
Derivative (D): Predicts error trends based on the rate of change, reducing
oscillations.
The PID controller can be implemented in Python or Arduino, depending on where the
error is processed.
2.4 Challenges and Solutions
Lighting Conditions: Uneven lighting (shadows, glare) can reduce lane detection
accuracy. Solutions include advanced preprocessing techniques or adding a light
sensor to adjust camera parameters.
Bluetooth Communication Latency: The HC-06 may introduce delays if the
baud rate is not optimized. Solutions include using a high baud rate (115200) and
minimizing data size.
Image Processing Performance: OpenCV processing can be slow on low-power
hardware (e.g., Raspberry Pi). Solutions include optimizing algorithms, reducing
image resolution, or using a more powerful computer.
Servo Accuracy: Servos may not respond precisely to small errors. Solutions
include tuning the PID controller or using high-resolution servos.
2.5 Supporting Theoretical Foundations
The project is grounded in the following theories:
Computer Vision: Edge detection and line detection algorithms in OpenCV.
Control Systems: PID control and differential drive for vehicle motion.
Embedded Systems: Arduino-based hardware control and Bluetooth
communication.
Mechanics: Design with a free caster wheel and servo-driven rear wheels.
This section provides the theoretical foundation for understanding and implementing the
lane-following vehicle system, while clarifying the technologies and challenges involved.