A.Simulation Platform and Cooperative Driving Frameworks
In the field of cooperative driving research, simulation platforms and frameworks play a crucial role. Researchers utilize these tools to develop and test collaborative driving algorithms, assessing their performance and stability. In this section, we will review current popular simulation platforms in academic field, such as SUMO, MATLAB/Simulink, and CARLA, as well as cooperative driving frameworks built upon them.
SUMO is an open-source, highly portable, microscopic, and continuous traffic simulation package designed to handle large networks.
Segata et al. [8]develop Plexe based on SUMO and OMNeT++ for studying cooperative driving systems with a modular approach. This simulation toolkit is very popular in the study of platooning control, vehicle-to-vehicle (V2V) and vehicle-to-infrastructure communication (V2X).
Karl et al. [9] proposed MOSAIC, a multi-domain simulation framework integrated with software like SUMO, OMNeT++, and ns-3, for deploying and testing advanced traffic control strategies. It facilitates the coupling of leading simulators across traffic, application, and communication domains.
However, cooperative driving frameworks based on SUMO primarily focus on macroscopic traffic flow and mobility patterns rather than detailed physical interactions. This limitation restricts the ability to simulate cooperative driving scenarios that require high-fidelity vehicle dynamics.
MATLAB is a widely used numerical computing environment and its Simulink platform supports multi-domain simulation and model-based design, which is essential for the development of vehicle control systems. Leveraging its rich set of libraries, researches can simulate the dynamic behavior of vehicles with high precision.
Palmieri et al. [10] introduced a co-simulation approach using MATLAB Simulink to create high-fidelity digital twin models of distributed multi-agent cyber-physical systems (CPSs), using the platoon system as a case study. Their method employs the FMI co-simulation standard to handle CPS complexity by breaking them into interconnected components for specific domains.
Chen et al. [11] utilized a co-simulation approach combining PreScan, Matlab, and Vissim to construct a platform for evaluating the cooperative driving behavior of autonomous vehicles. Their methodology focuses on the interaction between autonomous and human-driven vehicles, offering valuable insights into the safety performance of cooperative driving systems.
Despite MATLAB/Simulink offers the most comprehensive vehicle dynamics simulation ecosystem, the proprietary nature of MATLAB/Simulink may hinder wider community collaboration as most of the code based on it is not publicly available.
Carla is an open-source autonomous driving simulation platform that offers a flexible and scalable environment for testing and developing the autonomous vehicles. It features a high-fidelity rendering game engine and supports various sensors and controllers.
Xu et al. [12] introduced OpenCDA, a widely used open-source cooperative driving framework based on Carla. This comprehensive framework provides modules for perception, localization, and vehicle control, abstracting various elements to facilitate cooperative driving in different scenarios.
Carletti et al. [13] enhanced OpenCDA by integrating advanced communication models from ns-3, thereby providing researchers with a comprehensive tool to evaluate the impact of vehicular cooperative perception under various communication technologies.
Liu et al. [14] introduced an optimization-based approach for cooperative driving in urban environments. They integrated Artificial Potential Fields (APF) into a Model Predictive Control (MPC) scheme to represent traffic rules, effectively handling cooperative driving scenarios in CARLA simulations.
CARLA strikes a balance between physical fidelity and computational efficiency. Its open-source nature has led to increasing popularity in academia, and its flexible and rich interface design makes it an excellent choice for establishing cooperative driving simulation platforms.
B. Asynchronous problems in cooperative driving
Xu et al. [15] noted that traditional synchronization updates, such as global blocking synchronization, are inefficient due to processes waiting at the barrier. Consequently, high synchronization overhead has consistently been a significant performance issue in large-scale parallel agent-based traffic simulations.
Bin et al. [16] investigated synchronous and asynchronous update methods in traffic simulation. They suggest that asynchronous updates may introduce inconsistency in the simulation results since identical vehicles tend to perceive different traffic scenarios on the same simulation step. In contrast, synchronous updates ensure all vehicles perceive the same traffic scenario.
Zhan et al. [17] highlight that in real-world scenarios, each agent updates its dynamics at distinct time intervals defined by its own clock, leading to delay and inconsistency between the ground truth and measurements. They explored the problem of asynchronous platoon cooperative control under these conditions, taking into account intermittent and delayed information transmission. The researchers proposed an asynchronous consensus-based protocol for first-order multi-agent systems with switching topologies, accommodating large but bounded update intervals and communication delays.
Hu et al. [18] further classified the asynchronous problem into the mismatched and matched disturbances and estimated it through a finite-time disturbance observer.
Vehicle Agent is a crucial component in Intelligent Transportation Systems and a vital unit in cooperative driving. In this chapter, we will explain in detail the implementation of the Vehicle Agent to facilitate future researchers in developing advanced cooperative driving algorithms using our basic Vehicle Agent model.
Due to the high computational performance requirements of the perception workflow, we chose to implement autonomous driving vehicles as control-in-the-loop rather than perception-in-the-loop. This means that information related to obstacles and maps is directly obtained from the simulator. The Autonomous Vehicle class in the ACDCarla framework comprises several components, such as the communication manager, sensor manager, global router etc. These components become sub-objects in the agent class at initialization, and the control logic is concentrated in the planner's control loop to complete route planning, perception, decision-making, and control functions.
The Vehicle Agent generates an A* global router planner that builds a topology and a graph representation of the road network using the waypoints and road segments provided by the CARLA HD map. It then employs the A* search algorithm to find the optimal path between an origin and a destination location within the graph.
The primary autonomous driving control logic resides in the Frenet local planner's control loop. During each control loop iteration, the planner first updates the ego vehicle state, processes obstacle information, and checks the local waypoint buffer.
The local planner calculates the curvature c of the waypoint buffer using three consecutive points: p1, p2, and p3:
c=1−∣p1p2∣p1p2⋅∣p2p3∣p2p3
The target speed vt is then determined based on the total curvature C of the waypoint buffer, calculated as C=∑i=1n−1ci, using the formula:
vt={max(10,vm⋅e−6C)vmif C>0.0001otherwise
where vm is the maximum speed and n is the number of points in the buffer. This allows the vehicle to slow down appropriately when approaching turns or curves, ensuring smooth and safe navigation.
The system incorporates a collision avoidance check on the future waypoints buffer, which is based on the occupancy grid and considers both the current positions of obstacles and their predicted positions 3 seconds into the future. The prediction baseline method employs a simple physical dynamics model for forecasting. If the obstacles do not occupy the grid cells corresponding to the future waypoints, the system directly applies the cruising algorithm to reach the target speed, which by default utilizes the Intelligent Driver Model (IDM) algorithm, as shown in the following equation:
Speed difference between the ego vehicle and the front vehicle (ego_v - front_v)
b
Normal deceleration
s
Current distance between the ego vehicle and the front vehicle
This approach ensures that the collision avoidance mechanism takes into account not only the real-time positions of obstacles but also their anticipated trajectories in the near future.
we utilize B-spline curves to generate smooth and feasible trajectories for the ego vehicle. The input data points, representing the waypoints of the ego vehicle's future path, are first preprocessed and then fitted using a B-spline curve approximation technique. The resulting B-spline curve is defined as a linear combination of B-spline basis functions and control points, as shown in Equation (1):
where C(u) is the point on the B-spline curve at parameter value u, Pi are the control points, Ni,p(u) are the B-spline basis functions of degree p, and n is the number of control points.
Design of the platooning scenario and platoon vehicle agent
where vi(t) is the speed of the i-th vehicle at time t, vi−1(t) is the speed of the leader vehicle at time t, ai−1(t) is the acceleration of the leader vehicle at time t, di(t) is the distance between the i-th vehicle and its preceding vehicle at time t, vi+1(t) is the speed of the front vehicle at time t, ai+1(t) is the acceleration of the front vehicle at time t, vi(t) is the speed of the ego vehicle at time t, ai(t) is the acceleration of the ego vehicle at time t, τi−1 and τi+1 are the communication delays from the leader and front vehicles, respectively, which can be used as parameters depending on the specific implementation, vi−1target(t) is the target speed of the leader vehicle at time t.
The longitudinal control of the vehicle is performed using a PID controller. The control output out(t), representing the throttle or brake command, is calculated based on the following equation:
out(t)=KPe(t)+KI∫0te(τ)dτ+KDdtde(t)
where e(t) is the error between the target speed and the current speed at time t, given by:
e(t)=vtarget(t)−vcurrent(t)
Here, vtarget(t) is the target speed in m/s at time t, and vcurrent(t) is the current speed of the vehicle in m/s at time t. The proportional gain KP is set to 1.0, the integral gain KI is set to 0.05, the derivative gain KD is set to 0, and the time step dt is set to 0.03 seconds.
The integral term ∫0te(τ)dτ is approximated using the sum of errors over a buffer of size 10:
∫0te(τ)dτ≈∑i=09e(t−i⋅dt)⋅dt
The derivative term dtde(t) is approximated using the difference between the current error and the previous error:
dtde(t)≈dte(t)−e(t−dt)
The control output u(t) is then clipped to the range [-1, 1] to ensure that the throttle and brake commands remain within valid ranges. If u(t)≥0, it represents the throttle command, and if u(t)<0, the absolute value represents the brake command.
I apologize for the oversight. Let me clarify the meaning of τ in the equations.
The longitudinal control of the vehicle is performed using a PID controller. The control output u(t), representing the throttle or brake command, is calculated based on the following equation:
u(t)=KPe(t)+KI∫0te(τ)dτ+KDdtde(t)
where e(t) is the error between the target speed and the current speed at time t, given by:
e(t)=vtarget(t)−vcurrent(t)
Here, vtarget(t) is the target speed in km/h at time t, and vcurrent(t) is the current speed of the vehicle in km/h at time t. The proportional gain KP is set to 1.0, the integral gain KI is set to 0.05, the derivative gain KD is set to 0, and the time step dt is set to 0.3 seconds.
In the integral term ∫0te(τ)dτ, τ is a variable representing time in the integration. It is used to indicate that the error is integrated over the time interval from 0 to the current time t. The integral term is approximated using the sum of errors over a buffer of size 10:
∫0te(τ)dτ≈∑i=09e(t−i⋅dt)⋅dt
The derivative term dtde(t) is approximated using the difference between the current error and the previous error:
dtde(t)≈dte(t)−e(t−dt)
The control output u(t) is then clipped to the range [-1, 1] to ensure that the throttle and brake commands remain within valid ranges. If u(t)≥0, it represents the throttle command, and if u(t)<0, the absolute value represents the brake command.
The longitudinal PID controller aims to minimize the error between the target speed and the current speed of the vehicle by adjusting the throttle and brake commands based on the proportional, integral, and derivative terms of the error. The specific gains (KP, KI, KD) and time step (dt) were chosen to achieve a satisfactory control performance.
(1) PATH CACC controller
The ACC and CACC car-following models of Milanés and Shladover were used as the basic simulation models (9). The responses of ACC followers were modeled as a second-order transfer function and are described by
ai,k=k1⋅ei,k+k2⋅(νi−1,k−1−νi,k−1)
where ei,k is the gap error of vehicle i at time step k. Equation 3
shows that vehicle acceleration depends on a gap error and a speed difference with the preceding vehicle, where their feedback gain k1 and k2 is 0.23 s−2 and 0.07 s−1, respectively.
The classic CACC [50] implementation by California Berkeley PATH Laboratory is a widely used method. The PATH CACC control law is designed using a proportional-derivative (PD) controller and is given by:
where νi,k is the control input for vehicle i at time step k, ei,k is the gap error, and e˙i,k is its derivative The parameters used in the control law are described in the following table:
Parameter
Default Value
Description
kp
0.45
Proportional gain for gap error
kd
0.25
Derivative gain for gap rate error
d0
2 m
Standstill distance
tdes
0.5 s
Desired time-gap
The control law aims to regulate the gap between vehicle i and its preceding vehicle i−1 by adjusting the control input based on the gap error and gap rate error. The proportional and derivative gains, kp and kd, determine the response of the controller to the errors. The standstill distance, d0, and the desired time-gap, tdes, are used to calculate the desired gap.
Apologies for the confusion. Let me revise the academic paper section with the suggested changes:
The lower-level control of the vehicle is handled by a PID controller, which receives the target waypoint and target speed from the planner. The PID controller consists of two sub-controllers: lateral and longitudinal.
The longitudinal PID controller calculates the acceleration output based on the following equation:
a=KPe+KI∫0te(τ)dτ+KDdtde
where a is the acceleration output, e is the error between the target speed vt and the current speed vc, i.e., e=vt−vc, KP is the proportional gain, KI is the integral gain, KD is the derivative gain, and dt is the time step. The integral term ∫0te(τ)dτ represents the accumulated error over time, which is calculated using the following approximation:
∫0te(τ)dτ≈∑i=0ne(i)⋅dt
where n is the number of time steps elapsed since the start of the control process, and e(i) is the error at time step i. This approximation is known as the trapezoidal rule for numerical integration.
The derivative term dtde represents the rate of change of the error, which is calculated using the finite difference approximation:
dtde≈dte(t)−e(t−dt)
where e(t) is the current error and e(t−dt) is the error at the previous time step.
To translate the given Python code into mathematical notation rendered in LaTeX, we first need to understand the variables and the operations being performed. The code snippet appears to manage vehicle control in a simulation, using acceleration and steering values to adjust throttle and brake levels.
Here are the necessary variables and their purpose:
(a): acceleration (computed by
self._lon_controller.run_step(target_speed)
).
(s): current steering angle (computed by
self._lat_controller.run_step(waypoint)
, though it is not directly used in the throttle/brake logic).
(throttle): the throttle value to be applied to control the vehicle's acceleration.
(brake): the brake value to be applied to control the vehicle's deceleration.
(max_{throt}): the maximum throttle limit.
(max_{brake}): the maximum brake limit.
Given the code, we can define the control logic for throttle and brake as follows:
Throttle and Brake Control:
\min(a, max_{throttle}) & \text{if } a \geq 0 \\
0 & \text{otherwise}
\end{cases}$$
$$brake = \begin{cases}
0 & \text{if } a \geq 0 \\
\min(|a|, max_{brake}) & \text{otherwise}
\end{cases}$$
In this model:
- When the acceleration $a$ is greater than or equal to 0, the throttle is applied based on the minimum of the acceleration or `max_throt`. The brake is set to 0.
- If the acceleration $a$ is less than 0, indicating a need to decelerate, the throttle is set to 0. The brake value is determined by the minimum of the absolute value of the acceleration or `max_brake`.
These equations succinctly capture the logic implemented in the Python code, translating it into a mathematical model that could be understood in a broader context such as vehicle dynamics or control systems analysis.
The lateral PID controller calculates the steering angle output using the following equation:
$$\delta = K_P \theta + K_I \int_0^t \theta(\tau) d\tau + K_D \frac{d\theta}{dt}$$
where $\delta$ is the steering angle output, $\theta$ is the error between the vehicle's heading $\psi$ and the target waypoint's direction $\psi_t$, i.e., $\theta = \psi_t - \psi$, $K_P$ is the proportional gain, $K_I$ is the integral gain, $K_D$ is the derivative gain, and $dt$ is the time step. The accumulated heading error over time $\int_0^t \theta(\tau) d\tau$ and the rate of change of the heading error $\frac{d\theta}{dt}$ are calculated using the same approximations as in the longitudinal controller.
The variables and their default values for the PID controllers are summarized in the following table:
| Variable | Longitudinal Default | Lateral Default |
| -------- | -------------------- | --------------- |
| $K_P$ | 1.0 | 1.45 |
| $K_I$ | 0.05 | 0.05 |
| $K_D$ | 0 | 0.2 |
| $dt$ | 0.03 | 0.1 |
Additional parameters used by the PID controller include:
- $offset$: lateral offset from the center line (default: 0)
- $max\_throttle$: maximum throttle value (default: 0.55)
- $max\_brake$: maximum brake value (default: 0.9)
- $max\_steering$: maximum steering angle (default: 0.5)
The PID controller takes the target waypoint and target speed as inputs, calculates the appropriate throttle, brake, and steering angle based on the current vehicle state and the PID equations, and outputs the vehicle control commands to drive the vehicle towards the target waypoint at the desired speed. The calculated acceleration is converted to throttle and brake commands, while the steering angle is directly applied to the vehicle's steering control. The PID controller ensures smooth and stable vehicle control by continuously adjusting the control commands based on the observed errors, their accumulated values, and their rates of change.
In this academic paper, we introduce an advanced cooperative adaptive cruise control (CACC) controller for platoon management. The controller aims to maintain a safe and efficient spacing between vehicles while considering various factors such as speed control, gap control, collision avoidance, and emergency situations.
The mathematical formulation of the controller is as follows:
$$a_{\text{output}} = a_{\text{feedforward}} + K_v (v_l - v_e) - K_s \hat{s} + K_{\dot{s}} \hat{\dot{s}}$$
where:
| Variable | Description |
| ------------------------ | ---------------------------------- |
| $a_{\text{output}}$ | Output acceleration command |
| $a_{\text{feedforward}}$ | Feedforward acceleration term |
| $K_v$ | Speed control gain |
| $v_l$ | Leader vehicle's target velocity |
| $v_e$ | Ego vehicle's velocity |
| $K_s$ | Gap control gain for spacing error |
| $\hat{s}$ | Estimated spacing error |
| $K_{\dot{s}}$ | Gap control gain for speed error |
| $\hat{\dot{s}}$ | Estimated speed error |
The `Advanced_CACCController` class implements an advanced cooperative adaptive cruise control system, which incorporates multiple control strategies for efficient platoon management. This includes feedforward control, Kalman filtering for state estimation, and sliding mode control for dynamic adaptation to varying conditions.
### Mathematical Model
The feedforward control term is designed to anticipate the required acceleration based on the leader's behavior and the ego vehicle's current state:
where $\kappa$ represents the feedforward gain, $v_t$ is the target velocity of the leader, $v$ is the velocity of the ego vehicle, $a_l$ is the leader's acceleration, and $\tau_l$ is the leader's delay. This term adjusts the ego vehicle's acceleration to smoothly align with the leader's speed.
For error estimation and correction, a Kalman filter is applied to both spacing and speed errors. The Kalman filter equations for the spacing error are:
\hat{s}^{(k)} = \hat{s}^{(k-1)} + K_s \cdot (s - \hat{s}^{(k-1)}),
where $K_s$ is the Kalman gain for spacing error, $s$ is the observed spacing error, and $\eta$ represents the process noise.
Similarly, the Kalman filter updates for speed error are:
with $K_v$ as the Kalman gain for speed error, and $v_e$ representing the observed speed error.
Sliding mode control is utilized to dynamically adjust control gains based on the estimated errors, enhancing the robustness:
where $g_{s0}$ and $g_{v0}$ are the static gains for spacing and speed control, respectively, and $d_{min}$ is the minimum control gap.
### Variables
The following table lists the key variables used in the controller, along with their default values and descriptions:
| Variable | Default Value | Description |
| ------------- | ------------- | ------------------------------------------------------- |
| $\tau_h$ | 0.5 | Desired headway time |
| $\kappa$ | 0.25 | Feedforward control gain |
| $g_{s0}$ | -0.45 | Static gain for spacing control |
| $g_{v0}$ | 0.125 | Static gain for derivative of spacing control |
| $g_{c_s}$ | 0.45 | Gain for collision avoidance based on spacing |
| $g_{c_v}$ | 0.05 | Gain for collision avoidance based on change in spacing |
| $\tau_{th}$ | 2.0 | Emergency threshold for collision avoidance |
| $\tau_{acc}$ | 1.0 | Headway time for adaptive cruise control |
| $d_{min}$ | 0.06 | Minimum control gap |
| $\kappa_{ff}$ | 1.0 | Feedforward gain |
| $g_{o}$ | 0.1 | Observer gain |
| $g_{m}$ | 0.1 | Sliding mode control gain |
| $N_s$ | 10 | Queue size for spacing error history |
| $N_v$ | 10 | Queue size for speed error history |
| Controller | RMS Gap Error | RMS Accel | MVE | ASE | AVE |
| --------------------------- | ------------- | --------- | -------- | -------- | -------- |
| PATH CACC Asynchronous | 0.227938 | 0.639396 | 1.033243 | 8.636486 | 0.225531 |
| PATH CACC Synchronous | 0.243944 | 0.757594 | 1.413421 | 8.562194 | 0.211045 |
| Our controller Asynchronous | 0.085340 | 0.641174 | 0.888157 | 8.396531 | 0.222399 |
| Our controller Ssynchronous | 0.128463 | 0.816342 | 1.350444 | 8.403351 | 0.255138 |
| Controller | RMS Gap Error | Max Absolute Gap Error | RMS Acceleration | Max Absolute Jerk |
| --------------------------- | ------------- | ---------------------- | ---------------- | ----------------- |
| PATH CACC Asynchronous | 0.227938 | 0.723647 | 0.639396 | 1.506721 |
| PATH CACC Synchronous | 0.243944 | 0.907988 | 0.757594 | 1.906283 |
| Our controller Asynchronous | 0.085340 | 0.383069 | 0.641174 | 1.536818 |
| Our controller Ssynchronous | 0.128463 | 0.566009 | 0.816342 | 2.046922 |
1. **RMS Gap Error**: This metric represents the Root Mean Square (RMS) error between the desired gap and the actual gap between vehicles.
2. **Max Absolute Gap Error**: This metric represents the maximum absolute difference between the desired gap and the actual gap between vehicles over the entire simulation.
3. **RMS Acceleration**: This metric represents the Root Mean Square (RMS) acceleration of the vehicle. The formula for RMS Acceleration is:
$RMS Acceleration = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (a_i)^2}$
where $n$ is the number of samples and $a_i$ is the acceleration at sample $i$.
4. **Max Absolute Acceleration**: This metric represents the maximum absolute acceleration of the vehicle over the entire simulation.
These metrics are commonly used to evaluate the performance of adaptive cruise control (ACC) and cooperative adaptive cruise control (CACC) systems. They provide insights into the system's ability to maintain desired gaps, ensure smooth acceleration and deceleration, and maintain passenger comfort by minimizing jerk.
# Advanced Cooperative Adaptive Cruise Control (CACC) with Nonlinear Feedforward, Kalman Filter, and Sliding Mode Control
## Introduction
This paper presents an advanced cooperative adaptive cruise control (CACC) algorithm that incorporates nonlinear feedforward control, Kalman filtering for error estimation, and sliding mode control for dynamic gain adjustment. The proposed controller aims to enhance the performance and robustness of vehicle platooning by considering the leader's behavior, estimating and correcting spacing and speed errors, and adapting control gains based on the estimated errors.
Thank you for your feedback. I understand that the superscript and subscript notation may be too complex for the paper. I will simplify the notation to make it more readable and suitable for an academic paper. Here's the updated description:
## Controller Design
The advanced CACC controller calculates the desired velocity of the ego vehicle based on the states of the leader and the preceding vehicle. The control law is given by:
where $v_i$ is the target velocity of the ego vehicle, $v_0$ is the current velocity, $a_{ff}$ is the feedforward acceleration term, $g_v$ is the speed control gain, $v_l$ is the velocity of the leader, $v_i$ is the velocity of the ego vehicle, $g_s$ is the spacing control gain, $\hat{s}$ is the estimated spacing error, $g_{s_d}$ is the spacing derivative control gain, and $\hat{s}_d$ is the estimated derivative of spacing error.
The feedforward control term is designed to anticipate the required acceleration based on the leader behavior and the current state of ego vehicle :
where $\kappa_{ff}$ represents the feedforward gain, $v_t$ is the target velocity of the leader, $v_i$ is the velocity of the ego vehicle, $a_l$ is the leader's acceleration, $\tau_l$ is the leader delay estimated from timestamp, and $v_l$ is the velocity of the leader. This term adjusts the acceleration of ego to smoothly align with the leader speed.
For error estimation and correction, a Kalman filter is applied to both spacing and speed errors. The Kalman filter equations for the spacing error are:
where $K_s$ is the Kalman gain for spacing error, $s_k$ is the observed spacing error at time step $k$, $\hat{s}_k$ is the estimated spacing error at time step $k$, $\sigma_{s,k}$ is the covariance of the spacing error estimate at time step $k$, and $\eta$ represents the process noise. Similarly, the Kalman filter updates for the derivative of spacing error are:
with $K_{s_d}$ as the Kalman gain for the derivative of spacing error, $s_{d,k}$ representing the observed derivative of spacing error at time step $k$, $\hat{s}_{d,k}$ as the estimated derivative of spacing error at time step $k$, and $\sigma_{s_d,k}$ as the covariance of the derivative of spacing error estimate at time step $k$.
Sliding mode control is utilized to dynamically adjust control gains based on the estimated errors
where $g_{s,0}$ and $g_{s_d,0}$ are the static gains for spacing and derivative of spacing control, respectively, $d_{min}$ is the minimum control gap, and $g_m$ is the sliding mode control gain.
## Variables and Parameters
The following table lists the key variables and parameters used in the controller, along with their default values and descriptions:
| Variable/Parameter | Default Value | Description |
| ------------------ | ------------- | ----------------------------------------------------------- |
| $\tau_h$ | 0.5 | Desired headway time |
| $g_v$ | 0.25 | Speed control gain |
| $g_{s}$ | 0.45 | Static gain for spacing control |
| $g_{s_d}$ | 0.125 | Static gain for derivative of spacing control |
| $g_{c,s}$ | 0.45 | Gain for collision avoidance based on spacing |
| $g_{c,s_d}$ | 0.05 | Gain for collision avoidance based on derivative of spacing |
| $d_{min}$ | 0.06 | Minimum control gap |
| $\kappa_{ff}$ | 0.1 | Feedforward gain |
| $g_o$ | 0.1 | Observer gain |
| $g_m$ | 0.2 | Sliding mode control gain |
| $\eta$ | 0.1 | Process noise for Kalman filter |
| $\nu$ | 0.5 | Measurement noise for Kalman filter |
Potential for chattering in sliding mode control: Sliding mode control is known for its robustness properties, but it can also introduce chattering, which is high-frequency oscillations in the control signal. Chattering can lead to increased actuator wear and reduced passenger comfort. Techniques such as boundary layer smoothing or higher-order sliding mode control can be employed to mitigate chattering.
```
import torch
torch.cuda.is_available()
```
Here are the two tables in Markdown format:
| Vehicle | Median | IQR | Min | Max |
| --------- | --------- | -------- | --------- | -------- |
| Vehicle 1 | -0.017319 | 0.003443 | -0.061437 | 0.020299 |
| Vehicle 2 | -0.017092 | 0.004237 | -0.049895 | 0.023851 |
| Vehicle 3 | -0.017310 | 0.003887 | -0.041486 | 0.024071 |
| Vehicle 4 | -0.017245 | 0.004092 | -0.049366 | 0.019779 |
| Vehicle | Median | IQR | Min | Max |
|------------|-----------|----------|-----------|----------|
| Vehicle 1 | -0.017008 | 0.050372 | -0.144781 | 0.162570 |
| Vehicle 2 | -0.016877 | 0.031408 | -0.126513 | 0.092350 |
| Vehicle 3 | -0.016856 | 0.006120 | -0.052564 | 0.475441 |
| Vehicle 4 | -0.017364 | 0.023030 | -0.681685 | 0.068530 |
| Vehicle | Synchronous Mode | | | | Asynchronous Mode | | | |
|-----------|------------------|----------|-----------|----------|-------------------|----------|-----------|----------|
| | Median | IQR | Min | Max | Median | IQR | Min | Max |
| Vehicle 1 | -0.017319 | 0.003443 | -0.061437 | 0.020299 | -0.017008 | 0.050372 | -0.144781 | 0.162570 |
| Vehicle 2 | -0.017092 | 0.004237 | -0.049895 | 0.023851 | -0.016877 | 0.031408 | -0.126513 | 0.092350 |
| Vehicle 3 | -0.017310 | 0.003887 | -0.041486 | 0.024071 | -0.016856 | 0.006120 | -0.052564 | 0.475441 |
| Vehicle 4 | -0.017245 | 0.004092 | -0.049366 | 0.019779 | -0.017364 | 0.023030 | -0.681685 | 0.068530 |
```
Given the following Python code, rewrite it as an algorithm suitable for inclusion in the "Methods" or "Algorithm" chapter of a scientific research paper. Pay close attention to the following aspects:
Mathematical Notation: Replace Python-specific syntax with mathematical expressions and notations commonly used in scientific literature. For example, use subscripts for indexing, summation symbols for loops, and mathematical operators.
Variable Naming: Rename variables to follow conventions used in mathematical equations. Use single-letter variable names (e.g., i, j, k) for indices and descriptive names for important quantities or parameters.
Equations: convert the code into algorithm involves mathematical equations, define them using proper mathematical notation. Ensure consistency between the equations and the code.
do not use list! , use table to include all paramters with its desciptiona and init value.
you should first give it a full part of equations v = (...)
then explain each part of equations
finally give a table contains all the parameters.
here is the code
class Advanced_CACCController:
def __init__(self, kp=0.45, kd=0.25, s0=2, tc=0.5, alapa=1):
"""
Initialize the PATH CACC controller.
:param kp: The proportional gain for the spacing error.
:param kd: The derivative gain for the spacing error.
:param s0: The desired minimum safety spacing.
:param tc: The desired time headway.
"""
self.kp = kp
self.kd = kd
self.s0 = s0
self.headway = tc
#slide control
self.s_lambda = 0.05
self.alapa_s = 0.27
self.x = 0
self.P = 1
self.ki = 0.1
self.int_error = 0
self.int_error_max = 0
#acceleration control
self.acc_int_error = 0
self.acc_filter_alapa = 0.01
self.pre_ego_v = 0
self.pre_front_v = 0
#leader control
self.kl = 0.01
#smooth control
def kalman_filter(self,z, x, P, m_error, p_error):
"""
z: measurement
x: estimate
"""
x_pred = x
P_pred = P + p_error
K = P_pred / (P_pred + m_error)
x = x_pred + K * (z - x_pred)
P = (1 - K) * P_pred
return x, P
def calc_speed(self, leader_v, leader_a, front_dis, front_v, front_a, ego_v, ego_a, leader_delay=0, front_delay=0, leader_tv=0, dt=0.034):
meas_dis = front_dis
self.x, self.P = self.kalman_filter(meas_dis, self.x, self.P, 0.04, 0.02)
# Calculate the desired spacing
des_spacing = self.s0 + self.headway * ego_v
# Calculate the spacing error
spacing_error = self.x - des_spacing
#Calculate the acc error
ego_acc_est = (ego_v - self.pre_ego_v)/dt
front_acc_est = (front_v - self.pre_front_v)/dt
#filter acc
filter_ego_acc_est = self.acc_filter_alapa*ego_acc_est + (1-self.acc_filter_alapa)*ego_a
filter_front_acc_est = self.acc_filter_alapa*front_acc_est + (1-self.acc_filter_alapa)*front_a
acc_error = filter_front_acc_est - filter_ego_acc_est
self.acc_int_error = max(min(self.acc_int_error + acc_error*dt, 0.5), -0.5)
self.pre_ego_v = ego_v
self.pre_front_v = front_v
#Calculate the int_error
self.int_error += spacing_error
self.int_error = max(min(self.int_error, self.int_error_max), -self.int_error_max)
speed_error = front_v - ego_v
# Calculate the control input
leader_difference = leader_v - ego_v
#leader control
leader_control_input = self.kl * leader_difference
s = spacing_error + self.alapa_s*(speed_error)
s_control_input = self.s_lambda * np.sign(s)
control_input = self.kp * spacing_error + self.kd * speed_error + self.ki*self.int_error
totle_control_input = control_input + s_control_input + leader_control_input
new_speed = ego_v + totle_control_input
return new_speed
```
The proposed CACC algorithm utilizes a Kalman filter to estimate the distance to the front vehicle based on the measured distance and the previous estimate.
The control input for the Advanced CACC is calculated using the following equation:
$$v = v_e + K_p \cdot e_s + K_d \cdot e_v + K_i \cdot \int e_s dt + \lambda_s \cdot \text{sgn}(s) + K_l \cdot (v_l - v_e)$$
where $v$ is the new speed of the ego vehicle, $v_e$ is the current speed of the ego vehicle, $K_p$ is the proportional gain for the spacing error, $e_s$ is the spacing error, $K_d$ is the derivative gain for the speed error, $e_v$ is the speed error, $K_i$ is the integral gain for the accumulated spacing error, $\int e_s dt$ is the accumulated spacing error over time (limited to a maximum value), $\lambda_s$ is the sliding control gain, $\text{sgn}(s)$ is the sign function of the sliding variable $s$, $K_l$ is the leader control gain, and $v_l$ is the speed of the leader vehicle.
The Kalman filter equations are:
$$\begin{aligned}
\hat{x}_{\text{pred}} &= \hat{x} \\
P_{\text{pred}} &= P + Q \\
K &= \frac{P_{\text{pred}}}{P_{\text{pred}} + R} \\
\hat{x} &= \hat{x}_{\text{pred}} + K \cdot (z - \hat{x}_{\text{pred}}) \\
P &= (1 - K) \cdot P_{\text{pred}}
\end{aligned}$$
where $\hat{x}$ is the estimated distance, $\hat{x}_{\text{pred}}$ is the predicted estimate, $P$ is the estimate covariance, $P_{\text{pred}}$ is the predicted estimate covariance, $Q$ is the process noise covariance, $K$ is the Kalman gain, $R$ is the measurement noise covariance, and $z$ is the measured distance.
The control input for the Advanced CACC incorporates sliding mode control to improve robustness. The sliding variable $s$ is defined as:
$$s = e_s + \alpha_s \cdot e_v$$
where $e_s$ is the spacing error, $e_v$ is the speed error, and $\alpha_s$ is the sliding control parameter.
Explanation:
The Advanced CACC algorithm employs a Kalman filter to estimate the distance to the front vehicle based on the measured distance and the previous estimate. The Kalman filter helps to reduce the impact of measurement noise and improve the accuracy of the distance estimation.
The control input for the Advanced CACC is calculated based on the spacing error, speed error, accumulated spacing error, sliding mode control, and leader control. The sliding mode control term, $\lambda_s \cdot \text{sgn}(s)$, enhances the robustness of the controller by driving the system towards the sliding surface defined by the sliding variable $s$. The leader control term, $K_l \cdot (v_l - v_e)$, adjusts the ego vehicle's speed based on the difference between the leader vehicle's speed and the ego vehicle's speed.
Parameters:
| Parameter | Description | Initial Value |
| ----------- | ----------------------------------------------- | ------------- |
| $K_p$ | Proportional gain for the spacing error | 0.45 |
| $K_d$ | Derivative gain for the speed error | 0.25 |
| $s_0$ | Desired minimum safety spacing | 2 |
| $t_c$ | Desired time headway | 0.5 |
| $K_i$ | Integral gain for the accumulated spacing error | 0.1 |
| $\lambda_s$ | Sliding control gain | 0.05 |
| $\alpha_s$ | Sliding control parameter | 0.27 |
| $K_l$ | Leader control gain | 0.01 |
| $Q$ | Process noise covariance for Kalman filter | 0.02 |
| $R$ | Measurement noise covariance for Kalman filter | 0.04 |