Implementation of Line Detection Self-Driving Car
Implementation of Line Detection Self-Driving Car
Abstract — With the development of technology, especially in industries, daily human activities can be carried out with
artificial intelligence Robots. In this case, self-driving cars have several methods with GPS systems, radar, lidar, or cameras. In
this study, a self-driving car system was designed on a navigation path model using a street mark detector with a camera as a
vision sensor. This self-driving car system is used to move on a path on the detected line. This research uses the HSV method
for line detection. This robot research uses OpenCV, which functions for image processing using dilate, morphologyEx, and
Gaussian Blur processing methods. This research produces a fairly accurate level of path reading when compared to Robots
that use the Line Follower Method. After several processing stages have been passed and the path has been read, this robot
will move the motor following the path detected by the camera. Based on the hardware implementation through testing in the
Autonomous Car laboratory with Computer Vision, it can work according to the algorithm. By using image processing with
the HSV method, the resulting level of precision can reach the average value according to the direction of the self-driving
car.
Keywords – HSV, image processing, raspberry pi 4, self-driving car
321
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
a) Raspberry Pi 4 Model B
The Raspberry Pi is a minicomputer developed in
the UK by Raspberry Pi Foundation. Raspberry
Pi 3 Model B, was released in February 2016.
Broadcom BCM2837 SoC has a 64-bit quad-core Fig. 1. Hardware schematic.
ARM Cortex-A53 processor, running at higher
speed up to 1.2 GHz, 1 GB of RAM, onboard
Wi-Fi, Bluetooth up to 1.2 GHz, and USB boot B. Self-Driving Car Hardware Design
capability [10]. When using the Raspberry Pi The hardware used in this self-driving car is a
4, there are several systems, one of which is a prototype autonomous car with a drive system, namely
system for real-time programming performance a DC motor for speed control. The sensor used in
to achieve stable and not slow results. Several this self-driving car is the Raspberry Pi camera. At
companion components are needed, namely a the same time, the controller used is a Raspberry Pi
microSD and a cooling fan (heat sink). To realize 4 Model B and an Arduino nano which functions
the scope of objects to be detected effectively and as a program. As for the motor driver, L298N and
not too slowly. BTS7960 drivers are used, which function as DC motor
b) Pi Camera regulators. Fig. 2 is a prototype of an autonomous car.
The Pi camera is a module that sends data
to the Raspberry Pi 4 using an elastic cable
Self-driving is designed to detect the location of
to support sending programs. In addition, the
road marking objects through the results of the image
camera module also has a high-speed connection
processing taken by the Raspberry camera. The camera
capable of sending images and recording videos
is operated as an image receiver by the Raspberry Pi
with high resolution [11].
4 Model B minicomputer.
c) Arduino Nano
Arduino Nano [12] is a small, easy-to-use board The coordinates processing results of detecting road
based on the ATmega328P architecture with an markings from the image are sent to the Raspberry
ATmega328 microcontroller with an operating Pi 4 through communication between the camera
voltage of 5 V. It uses 32 KB of flash memory, and the Raspberry Pi 4. In addition, detecting object
of which the bootloader uses 2 KB. The Arduino result of the street mark are forwarded to run the
Nano processor clock speed is 16 MHz, which dc motor as the steering wheel and the movement
serves to send the program to the BTS7960 driver. of the self-driving car [15]. The image processing
322
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
R0 G0 B0
R0 = , G0 = , B0 = (1)
255 255 255
323
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
Eq. (5) produces hue values using the R, G, and HSV colour value used as input in measuring road
B colour values, Minimum Contrast, and Maximum marking objects in real-time video testing [17]. Fig. 6
Contrast. is a Flowchart of object detection in real-time.
The Saturation calculation is shown in (6):
(
0 ; Cmax = 0,
f (x; λ, k) = (6)
0 ; Cmax 6= 0
(6) is the value used to produce the saturation value
by using subtraction and division of the minimum and
maximum contrast values
And the Value calculation
Cmax
ContrastV alue = (7)
Cmin
(7) shows the value by determining the maximum or
minimum contrast value.
Fig. 6. Real-time detection flowchart.
If the object’s colour composition is within the
specified HSV value range, the object will be white as
assumed to match the range value. Meanwhile, items The flowchart above shows how computer vision
with a colour composition outside the range value will works. First, the program runs, then the camera for
change colour to black. Fig. 5 is the threshold process detecting road markings will be active and display a
for changing the HSV colour range. video stream for detecting roads that will be traversed
by autonomous cars.
E. Ackerman Model on a Self-Driving Car
The Autonomous Car prototype assumes the
kinematic model that there is no slip angle between
the front and rear wheels are the same therefore,
the kinematic model applies to low-speed applications
[18]. The front and rear wheels are connected by
a metal frame that allows the autonomous car to
move forward and backwards simultaneously [19],
[20]. Therefore, in this autonomous car turning motion,
it will be possible to form an angle or coordinate point.
The following is the equation of the kinematic model
of the autonomous car, where the notation is shown in
Table 2.
Table 2. Notations of the Kinematic Model
Notation Definition
Ẋ X coordinate
Ẏ Y coordinate
vb Rear wheels
vf Front wheels
la , l b Length from the center of mass AGV to axis P
lf Length from AGV axis to point Q
β Slip angle of AGV
dt Change over time
ψ̇ Change in angle at the center of the axis
γ Gamma angle Y
Fig. 5. Thresholding process based on HSV color range.
324
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
determines the initial speed of the autonomous car. measurement results obtained the average speed value
Speed, the slip β angle value and the linear speed of the in units of RPM (revolutions per minute). The results
autonomous car are written as the following equation. of the rotation speed measurement can be seen in
lf tan γ
Table 3.
−1
β = tan (11) Table 3. Rotation Speed
la + lb + lf
No. PWM duty Rotation Autonomous Car
vb cos (γ) + vb cycle (%) Speed (RPM) Speed Condition
V = (12) 1 30 125.5 Slow
2 cos (β) 2 40 210.8 Slow
The AGV position is then determined by applying the 3 50 274.8 Moderate
4 60 293.5 Moderate
integration in (8) – (10) for time t(s). 5 70 418.9 Fast
Z t
X= V cos (ψ + β)dt (13)
0 It can be seen in Table 3 that the speed test is
Z t measured at a duty cycle of 30% to 70%. At a duty
Y = V sin (ψ + β)dt (14) cycle of 30% to 40%, the motor in an autonomous car
0
Z t
will run slowly in the range of 125 rpm to 210 rpm.
Z= V cos (ψ + β)dt (15) 50% to 60% duty cycle, the autonomous car motor will
0 rotate 274 rpm to 293 rpm. While 70% duty cycle, the
Fig. 7 shows the Ackerman frame model of the autonomous car motor will move up 418 rpm. If the
self-driving car. duty cycle increases high, the motor will rotate quite
fast according to the duty cycle used. It can be seen
the wheels rotational speed when the autonomous car
is running on the track. This test influences how we
set up its PWM duty cycle.
For testing, the autonomous car will be strengthened
by the data from the output signal. These results
are obtained through the image of the oscilloscope
measurement results. The image from the oscilloscope
will later show the results of the PWM signal
measurement, as shown in Table 3.
Based on the test results, it can be analyzed that
Fig. 7. Frame Ackerman autonomous car.
the autonomous car can turn at a maximum angle. The
PWM value determines whether an autonomous car
can run slow or fast. The first measurement result with
a PWM duty cycle of 30%, shown in Fig. 8 (a), is
III. R ESULT AND D ISCUSSION the result of the signal on the oscilloscope. Fig. 8 (b)
shows the resulting speed of 125.5 RPM. The second
This test is carried out to determine the function
measurement result with a PWM duty cycle of 70%,
of the prototype autonomous car, which has an
shown in Fig. 9 (a), is the result of the signal on the
explanation of the stability and ability of the self-
oscilloscope. Fig. 9 (b) shows the resulting speed of
driving car system to detect street marks. That way, we
418.5 RPM.
can see how fast the real-time system detects street-
mark objects. With a real-time system, self-driving B. HSV Color test on Self-Driving Car
cars can calculate the detection distance based on the HSV testing is carried out to check the processing
detection area. of street mark objects on a predetermined path. In
A. Self-Driving Car Speed Test Based on Turning this test, the thresholding method is used, namely
Angle measuring the maximum and minimum limits. In
addition, this test is carried out to distinguish the white
To determine the ability of the prototype
and black colours found in the HSV method, which
autonomous car to move according to a predetermined
have a maximum or minimum value.
path. So it is necessary to test the speed and turning
angle. This test aims to determine the rate of the To find out the maximum and minimum limits of
autonomous car linearly. The linear speed itself is the HSV method, we do a test by distinguishing the
influenced by the rotation of the DC motor used filter from black objects and white objects. This test
in the prototype autonomous car. So test is carried is done by activating the program contained in the
out with a tachometer using the robot running on Raspberry Pi 4 Model B. Fig. 10, Fig. 11, Fig. 12
a predetermined path, and the rotational speed of and Table 4, Table 5, Table 6, represent the testing of
the wheels is calculated using a tachometer. The the HSV method.
325
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
Fig. 8. (a) Signal duty cycle PWM 30%, (b) Acceleration output
125.5 RPM.
Fig. 9. (a) Signal duty cycle PWM 70%, (b) Acceleration output
418.5 RPM. Fig. 12. Value threshold test.
326
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
327
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801
ISSN: 2085-3688; e-ISSN: 2460-0997
Implementation of line detection self-driving car using HSV method based on raspberry pi 4
[7] A. A. Mahersatillah, Z. Zainuddin, and Y. Yusran, Rekayasa Elektr., vol. 17, no. 1, pp. 7–14, 2021. doi:
”Unstructured road detection and steering assist based 10.17529/jre.v17i1.18087.
on HSV color space segmentation for autonomous car,” in
2020 3rd International Seminar on Research of Information [20] F. B. Setiawan, Y. Yovie, C. Wibowo, L. H. Pratomo, and S.
Technology and Intelligent Systems (ISRITI), 2020, pp. Riyadi, “Perancangan automated guided vehicle menggunakan
688–693. doi: 10.1109/ISRITI51436.2020.9315452. penggerak motor DC dan motor servo berbasis raspberry pi
4,” J. Rekayasa Elektr., vol. 18, no. 2, pp. 94–101, 2022. doi:
[8] Y. Chen, S. Chen, T. Zhang, S. Zhang, and N. Zheng, 10.17529/jre.v18i2.25863.
”Autonomous vehicle testing and validation platform:
integrated simulation system with hardware in the loop,” in
2018 IEEE Intelligent Vehicles Symposium (IV), 2018, pp.
949–956. doi: 10.1109/IVS.2018.8500461.
328
Jurnal Infotel, Vol. 14, No. 4, November 2022
https://doi.org/10.20895/infotel.v14i4.801