Adaptive Cruise Control of the Autonomous Vehicle Based on Sliding Mode Controller Using Arduino and Ultrasonic Sensor

— This article will focus on adaptive cruise control in autonomous automobiles. The adaptive cruise control inputs are the safety distance which determines thanks to conditions set depending on the distance value, the measured distance, the longitudinal speed of the autonomous automobile itself, the output is the desired acceleration. The objective is to follow the vehicles in front with safety, according to the distance measured by the ultrasonic sensor, and maintain a distance between the vehicles in front greater than the safety distance which we have determined. For this, we used super twisting sliding mode controller (STSMC) and non-singular terminal sliding mode controller (NTSMC) based on neural network applied to the adaptive cruise control system. The neural network is able to approximate the exponential reaching law term parameter of the NTSMC controller to compensate for uncertainties and perturbations. An autonomous automobile adaptive cruise control system prototype was produced and tested using an ultrasonic sensor to measure the distance between the two automobiles, and an Arduino board as a microcontroller to implement our program, and four DCs motors as actuators to move or stop our host vehicle. This system is processed by code and Simulink Matlab, the efficiency and robustness of these controllers are excellent, as demonstrated by the low longitudinal velocity error value. The safety of autonomous vehicles can be enhanced by improving adaptive cruise control using STSMC and NTSMC based on neural network controllers, which are chosen for their efficiency and robustness.


INTRODUCTION
Autonomous vehicles equipped with an ACC (Adaptive Cruise Control) system represent a major advancement in automotive technology.Autonomous vehicles [1]- [6] are vehicles capable of moving without human intervention, thanks to a combination of sensors and software [7]- [9].They are now the center of interest for researchers.The study of lateral dynamics is found in [10] [11], and vertical dynamics in [12] [13].ACC is an advanced speed control system that allows vehicles to automatically maintain a safe distance from vehicles in front while adjusting their speed based on real-time traffic [14] [15].Autonomous vehicles equipped with ACC have the advantage of reducing road accidents, improving traffic flow, and reducing fuel consumption.
Our aim is to create a prototype of an autonomous vehicle that is equipped with ACC and can track lead vehicles in complete safety.The components, such as the Arduino Uno as the microcontroller [16]- [21], the DC motor as the driving force [7] [16], and the Ultrasonic HC-SR04 as the sensor [16], are essential elements to build this prototype.
The process of operating an Arduino board-based adaptive cruise control (ACC) involves several steps, beginning with vehicle host detection and ending with speed regulation.Firstly, use the ultrasonic sensor to measure the distance between lead vehicle and the host vehicle, and then transmit the distance data to the Arduino board.The Arduino board analyzes the sensor data to detect the distance between the host vehicle and the vehicle in front, based on the current distance and preset parameters, the ACC controller calculates the desired speed to maintain a safe distance from the vehicle in front.Then the Arduino board sends commands to the DC motor actuators, which allow the host vehicle to drive at the calculated desired speed.
The controller used in this study is the sliding mode controller (SMC) [22]- [26] with the following two types, super twisting sliding mode controller (STSMC) and nonsingular terminal sliding mode controller (NTSMC), these types of controllers have the advantage of avoiding uncertainties and disturbances.They are included in the nonlinear controller and applied to multi-input, multi-output (MIMO) systems, and have led to good performances, but in this work, we need to implement them in hardware to observe more.
The focus of this research will be both on theoretical design, simulation and hardware implementation.We added an ACC program as a Matlab function in a Simulink blocks in order to implement this ACC program in a microcontroller.For a simple implementation, the Arduino microcontroller would be used.Low cost, small size and wide applications [16] are all advantages of using Arduino.The integration of artificial intelligence techniques [27]- [30] is necessary for the development of the studied system.The use of neural networks [31]- [33] to approximate functions or terms has several benefits, which include modeling complex non-linear functions and adapting parameters.The effectiveness of neural networks in approximating terms depends on the quality and quantity of the training data, as well as the appropriate choice of network architecture.The neural network [23] is being exploited to improve our non-singular sliding mode controller.A study of lateral dynamics of autonomous vehicles by sliding mode control based on fuzzy logic [34].Sliding mode control based on particle swarm optimization (PSO) is used to control the lateral dynamics of autonomous vehicles [35] [36].
Our work focused on the study of adaptive cruise control of autonomous vehicles in a theoretical and practical way.The STSMC and neural network-based NTSMC controllers are used in this study.The study is divided into two parts.In the first part, we carried out a theoretical study on the adaptive cruise control of the host vehicle with the aim of keeping a safe distance from the lead vehicle.The comparison of our proposed controller with the RBF_NTSMC controller used in [37] and with HMP [38] has been carried out and the results obtained by our proposed method are better.We created a prototype of an autonomous vehicle that was equipped with adaptive cruise control (ACC) in the second part and subjected it to various tests.These tests are carried out according to three possible safety distance situations, the host automobile exists at a distance greater than the maximum safety distance, then at a distance less than the maximum safety distance, and finally at a critical safety distance.The illustrations demonstrate the robustness of the controllers developped in the theoretical part.And in the practical part, our autonomous automobile prototype passed the various tests with success.

A. Related Works
In [39], the authors proposed a composite longitudinal controller for speed regulation of unmanned vehicles.A composite longitudinal control strategy integrating a steadystate controller and an active disturbance rejection state feedback controller is designed for speed regulation control during acceleration and deceleration.
In [40], the authors have studied a T-S fuzzy model predictive control framework is applied to the problem of adaptive cruise control (ACC).Variations in the preceding vehicle velocity and road surface conditions are considered to formulate adaptive cruise control as a tracking control problem of a T-S fuzzy system subject to parameter uncertainties and external persistent perturbations.
In [41], the authors realized a parking distance controller based on Arduino Uno using ultrasonic sensors.Three main components, namely Arduino UNO, Arduino MP3 Shield and ultrasonic HC-SR04.The prototype method steps are the design, writing of the system, implementation of the parking prototype and testing of its validity.
An ultrasonic sensor was utilized by the authors to create a fully automated cruise control system [42].A microcontroller and ultrasonic obstacle detector have been used to develop an automatic vehicle speed control system.In ref. [43], the authors developed an adaptive cruise control based on fuzzy logic using a remote control car, controlled by an Arduino Uno R3 board and used an ultrasonic sensor mounted on the front of the car.

B. Motivation
The research is motivated by the desire to contribute to the development of robust and adaptive control systems.STSMC and NTSMC_NN (neural networks) are used to improve stability and control performance, particularly in terms of efficiency and robustness.
The creation of an autonomous automobile prototype based on the study of an adaptive cruise control (ACC) is motivated by several factors which aim to improve the safety and efficiency of autonomous driving, and also to provide a solid basis for further development of this technology.ACC is a fundamental part of the autonomous driving system.By creating a prototype based on this technology, the project contributes to the development and deeper understanding of the technologies needed to make vehicles fully autonomous.The validation of this prototype and the identification of the challenges to develop it through the integration of new technologies is our essential motivation.

C. Novelties and Contributions of this Paper are as
Follows: • We propose a neural network-based NTSMC controller with a choice of reaching law expression and a neural network structure able of controlling the longitudinal dynamics of autonomous vehicles by improving the performance of ACC.Neural networks allow for the estimation of the reaching law term parameter.This is an innovative approach that can enhance control performance, particularly in terms of its effectiveness and robustness.
• Our proposal was to create a prototype of an autonomous automobile that focused on the study of ACC.This study has several advantages, including the validation of a prototype, and this prototype could serve as a practical demonstration of the ACC system, which is a key part of the autonomous driving system.This contributes to the advancement of technology in this area.
The document will be organized as follows.The introduction takes up the first section of the document.The Rachid Alika, Adaptive Cruise Control of the Autonomous Vehicle Based on Sliding Mode Controller Using Arduino and Ultrasonic Sensor second section is the design of autonomous vehicles and controllers.Then, the next section is the hardware configuration in which we have defined the essential components and we have given the functional diagram of this prototype.The following section includes the results and discussion related to numerical simulation and hardware implementation.The final section is devoted to conclusions and future work.

A. Vehicle Dynamics Longitudinal Model
The study of the longitudinal dynamics of autonomous vehicles uses Newton's second law motion as follows, In Equation ( 1), the symbol ∑  signifies the summation of all forces exerted upon the vehicle.Within this equation, m represents the combined mass of the vehicle, while  denotes the vehicle's acceleration.The summation of all forces ∑ , can be detailed as follows.
the force denoted as   represents the driving force generated by the vehicle's engine.  accounts for the aerodynamic drag.  represents the rolling resistance.Lastly,   represents the vehicle's gravitational force.
The model wheel dynamics is given by this equation, where   =   /  [44].
From equation (3), the force   is given as follows, The aerodynamic drag is written as follows, The rolling resistance is given as follow, The gravity resistance of the vehicle is given by, where   is the propulsion (drive) torque,   is the engine torque,   is gear ratio,   is Brake torque,   the inertia of wheel car,  is the angular velocity,   is the rolling radius,   is coefficient of the aerodynamic drag, A is the area of the front surface of the vehicle, ρ is the air density,   is the longitudinal velocity, m is the vehicle mass, g is the acceleration caused by gravity,  is the coefficient of rolling resistance and θ represents the road's angle of inclination.
From equations ( 1) and ( 2) we can write, We replace the existing forces in equation ( 2

B. Profile Speed
The velocity tracking which we considered as reference velocity is illustrated in Fig. 1,

C. Control Strategy
The controller is made up of two parts, the upper controller and the lower controller.In this part of our study, we conduct a theoretical study on adaptive cruise control, also known as an upper controller, which uses an algorithm to determine the minimum and maximum distance safety conditions, see Fig. 4.And a theoretical analysis of a lower controller that attains adequate longitudinal speed to ensure the host vehicle follows the lead vehicle, see Fig. 2.
The study on the lower controller was carried out using the super twisting sliding mode controller (STSMC) and non-singular terminal sliding mode controller (NTSMC) based on neural networks.The controllers work in such a way that the controlled vehicle must maintain a safe distance and follow the lead vehicle safely.The NN-NTSMC method with the adaptation of the parameters of the neural network to the controller by the Lyapunov method was carried out.

1) Design of Adaptive Cruise Controller
The upper controller, called adaptive cruise control, is a longitudinal speed regulator which allows the longitudinal speed to be adjusted according to the distance between the two automobiles.This safety distance determined by certain conditions of maximum and minimum distance value, according to the following ACC Algorithm which we have implemented.If the measured distance is greater than the maximum safety distance, the vehicle is accelerated according to a desired speed (Zone 1), If the measured distance is between the minimum and maximum safety distance, the vehicle is decelerated according to a desired speed (Zone 2) see Fig. 1, and if the measured distance is less than or equal to a minimum safety distance, the vehicle is stopped.The output of this controller is the desired longitudinal acceleration and the inputs are the measured distance, the longitudinal speed of the host vehicle see Fig. 3.
The output of the upper controller is the desired longitudinal acceleration [14] [45], which is the input to the lower controller from which either a traction command or a braking command is generated to control the host vehicle, see Fig. 2.  The radial basis function has a weight value: The output of RBF is as follows: () =    =  1  1 +  2  2 + ⋯ +

3) Design of Neural Network Based Adaptive Non-Singular Terminal Sliding Mode Controller
The non-singular terminal sliding mode controller is composed of two parts, the equivalent control part u EQ and another complementary part called the exponential reaching law u ER ,  =   +   with   = −() − ,  > 0,  > 0.
To apply the non-singular terminal sliding mode controller to the vehicle's longitudinal dynamics, two essential steps are included.The initial step involves defining the nonsingular sliding surface, which is done as, where  > 0, ,  ( > ) are positive odd numbers and   denotes the difference between the actual speed   and the targeted longitudinal speed   , which can be expressed as, We have the time derivative of ( 7) that is, We replace equation ( 6) in equation ( 9), we obtain,

𝑢 = 𝑢 𝐸𝑄 + 𝑢 𝐸𝑅
For the system dynamics to be optimal, the control law is, where  is weight value of neural network.
Our approach involves the development of a neural network system with the objective of approximating a key parameter within the exponential reaching law.We obtain the equivalent control when ṡ= 0, with 1<   ⁄ < 2.
We present the adaptive neural network controller,

A. Hardware Design
The system shown in Fig. 6 includes an ultrasonic sensor, four DC motors, an L298N motor driver [49], a battery, an LCD 1602 display [50], and a switch.The connections between these components play a crucial role in the proper functioning of the whole [16][51] [52].
The Arduino is responsible for coordinating the operations of all the components, acting as the brain.The ultrasonic sensor is connected to the Arduino to measure the distance.The Arduino program utilizes the sensor output signal to determine decisions based on the measured distance.The four DC motors are connected to the L298N driver, which acts as an H-bridge to control the direction and speed of the motors.The battery powers the L298N driver, ensuring sufficient power to the motors.The LCD 1602 is connected to the Arduino to display crucial information in real time, providing a user interface.The switch is integrated to facilitate easy management of system power.

1) Arduino Uno Microcontroller
The Arduino Uno [53][54][55] is a popular and widely used microcontroller board for building electronic projects, especially in the field of embedded systems and robotics.There are 20 I/O pins on the Arduino Uno, 6 of them analog and 14 of them digital, of which 6 can be used for PWM (Pulse width Modulation) outputs.

2) Ultrasonic Sensor
The ultrasonic sensor [56][57][58] works by sending sound waves from the transmitter on which it is fixed, these waves bounce off an object (lead vehicle) and then return to the receiver (host vehicle).The distance of the object can be calculated by measuring the time it takes for sound waves to travel to the object and return to the sensor. = ( *   )/2 3) Motor DC Actuator DC motors [59]- [61] are continuous actuators that generate mechanical energy from electrical energy.Continuous angular rotation is generated by the DC motor, which can be utilized to rotate wheels, pumps, and fans.The DC motor, or Direct Current motor, is the most commonly used actuator to produce continuous motion and whose rotational speed can be easily controlled, making it ideal for use in applications such as control speed, and position control.To control the speed of the DC motor, it's simply a matter of controlling its input voltage.In this section, we have combined the functions of Matlab and Simulink Matlab presented in Fig. 9, in order to implement our ACC program in the autonomous vehicle prototype mentioned in Fig. 7.  I.
Table I presents the functioning principle of the host vehicle control and the obtained practical results.Our prototype passes all the tests that we submitted to it, see Table I.To test our prototype and validate our theoretical design control law, we have applied the profile distance shown in Fig. 10 and described in the following: • In the first case where the distance is greater than 100 cm.
• In the second the distance is less than 100 cm and greater than 50 cm.
• In the third case, the distance is greater than 100 cm and the speed of our controlled automobile was greater than 0, which means that the automobile is not stopped.
• In the fourth case, the distance is less than 50 cm.
• In the fifth case, the distance is greater than 100 cm our automobile was stopped due to a distance limitation (distance less than 50 cm).Our autonomous automobile prototype has successfully passed all tests, see video in https://shorturl.at/jkP08.The video content introduces two vehicles, the lead vehicle is controlled by Bluetooth to move forward and stop this automobile in order to test the ACC operations, and the host vehicle is our prototype which is equipped with an ultrasonic sensor, an Arduino Uno board and Wheels powered by a DC motor actuator.In this video, the lead vehicle is placed at a distance greater than 100 cm, and the host vehicle starts first and it is seen that it moves forward with an increase in speed, and when the distance becomes less than 100 cm, the speed of the host vehicle decreases, and when the distance becomes less than 50 cm, the host vehicle stops.Then at the end, we move the lead vehicle which is controlled by Bluetooth and we see that the host vehicle moves forward again without starting when the distance exceeds 50 cm.
In the theoretical part, we assume that the initial distance is   =110 cm and that the initial longitudinal speed of the lead vehicle is   ℎ =22.22 m/s.
The comparison is made with the results obtained in the reference document [37], knowing that we used the same parameters as those used by this document.The parameters of RBFNN are given in Table II.Fig. 11 shows that the longitudinal speed obtained by STSMC or NTSMC based on NN corresponded to the desired longitudinal speed in all cases, even in the transitory cases, with a low error.The maximum error during the use of the STSMC controller is equal to 0.00633, while the maximum error during the use of the NTSMC-based on NN controller is equal to 0.00632.Thus, both commands are effective.However, from Fig. 12, we see that our proposed controller NTSMC based on NN is slightly better than STSMC controller.
Our proposed controller NTSMC_NN allows us to obtain better results such that the maximum error is equal to 0.00632 m/s comparable to the results obtained by RBF_NTSMC [37] such that the maximum error is equal to 0.665 m/s, and also we note that the results obtained by HMPC [38] (when the road slope angle   = 0.3) are not satisfactory, so the maximum error is equal to 1.5 m/s.The longitudinal speed of the host vehicle used is not above 15 m/s.It's important to note that the parameters used in this system [38] are not the parameters we used in our system.
The errors obtained when using the STSMC control method or the second method when using the NTSMCbased on NN control are very low, as shown in Fig. 12. Do not exceed 2.4 10 −3 in normal cases, and 6.4 10 −3 in critical cases.And we see that the error curve of NTSMC based on NN control proposed is always lower than that of STSMC control.
Our results are considerable and the controller is very efficient and robust.We can see this performance in the illustrations, particularly Fig. 11 and Fig. 12.The traction controller curve in Fig. 13 allows the autonomous automobile to accelerate to follow the one in front, which follows the reference speed by its role.In normal cases the amplitude of this controller does not exceed 450 N but in critical cases, that is, when the automobile needs maximum speed to accelerate in order to follow the automobile that is moving located in front, the controller reaches an amplitude of 973.3 N. When the distance between automobiles is reduced, we see from Fig. 14 that the brake controller enables the automobile to brake.In the normal case, that is, the distance is greater than 50 cm and less than 100 cm, the amplitude of the controller brake does not exceed 53 N, and to stop the

Fig. 2 .
Fig. 2. Block diagram of the control strategy

Fig. 3 .Fig. 4 .
Fig. 3. Upper controller of the ACC The ACC controller functions are accomplished according to the next algorithm: Algorithm: ACC Input:   ,  ℎ Output:  ℎ,  if   >  ,  Vehicle accelerates according to a reference speed of zone 1 profile.elseif   <=  ,  and   >  ,  Vehicle decelerates according to a reference speed of zone 2 profile.elseif   < =  ,  Vehicle stopping.end

Fig. 6 .
Fig. 6.The overall series of hardware configurations: arduino microcontroller circuit with ultrasonicThe autonomous vehicle shown in Fig.7is composed of three essential elements, an Ultrasonic sensor to detect the distance of the vehicle in front, the Arduino Uno board is used to implement our ACC program which controls the distance between automobiles, and the four DC Motor actuators are responsible for moving the automobile autonomously.

Fig. 7 .
Fig. 7. Autonomous vehicle prototype Our experience in Fig. 8 consists of two autonomous automobiles, the automobile which exists in front controlled by Bluetooth remote, and the host automobile on which we mounted the ACC controller.

Fig. 8 .
Fig. 8. Lead and host vehicles IV.RESULTS AND DISCUSSION

Fig. 9 .
Fig. 9. Adaptive cruise control simulink model A scenario has been provided to test the operation of our autonomous vehicle prototype, different distance values between the two automobiles are chosen to test different possible situations.These distance values are presented in TableI.

Fig. 13 .
Fig. 13.Traction controller from theory to practice by creating realworld projects such as sensors, robots, and other interactive devices, strengthening their understanding of fundamental concepts.Students receive immediate feedback while experimenting with Arduino.They can see the results of their code in real time, making it easier to understand errors and fix problems.This helps to develop the skills needed to tackle technical challenges in the real world.Therefore, it will be advantageous for the educational purpose and the implementation of the material.
The use of Arduino encourages practical learning.Students ISSN: 2715-5072 302 Rachid Alika, Adaptive Cruise Control of the Autonomous Vehicle Based on Sliding Mode Controller Using Arduino and Ultrasonic Sensor can quickly move

TABLE I .
ULTRASONIC SENSOR TESTING

TABLE II .
RBFNN PARAMETERS FOR THE APPROXIMATION OF K(, )