# UB-LSTM: A Trajectory Prediction Method Combined with Vehicle Behavior Recognition

Authors: Haipeng Xiao; Chaoqun Wang; Zhixiong Li; Rendong Wang; Cao Bo; Miguel Angel Sotelo; Youchun Xu
Journal: Journal of Advanced Transportation
 (2020)

---

## Abstract

In order to make an accurate prediction of vehicle trajectory in a dynamic environment, a Unidirectional and Bidirectional LSTM (UB-LSTM) vehicle trajectory prediction model combined with behavior recognition is proposed, and then an acceleration trajectory optimization algorithm is proposed. Firstly, the interactive information with the surrounding vehicles is obtained by calculation, then the vehicle behavior recognition model is established by using LSTM, and the vehicle information is input into the behavior recognition model to identify vehicle behavior. Then, the trajectory prediction model is established based on Unidirectional and Bidirectional LSTM, and the identified vehicle behavior and the input information of the behavior recognition model are input into the trajectory prediction model to predict the horizontal and vertical speed and coordinates of the vehicle in the next 3 seconds. Experiments are carried out with NGSIM data sets, and the experimental results show that the mean square error (MSE) between the predicted trajectory and the actual trajectory obtained by this method is 0.124, which is 97.2% lower than that of the method that does not consider vehicle behavior and directly predicts the trajectory. The test loss is 0.000497, which is 95.68% lower than that without considering vehicle behavior. The predicted trajectory is obviously optimized, closer to the actual trajectory, and the performance is more stable.


---

## Body

## 1. Introduction

Trajectory prediction is an important research direction in the field of autopilot [1, 2]. The research on the decision-making characteristics of the driver shows that factors such as the relative speed and relative distance between the car and the surrounding moving vehicles will greatly affect the driver's decision [3] and then affect the driving safety. For static vehicles in the driving environment, intelligent vehicles can drive safely along the planned trajectory; for dynamic vehicles, human drivers can use past experience and intuition to predict the behavior of other drivers to avoid potential accidents [4]. Intelligent vehicles need to improve their driving safety by predicting the trajectories of the moving vehicles around them in real time.The existing methods are basically separate research on vehicle behavior recognition and vehicle trajectory prediction, and there are not many methods to combine the two to make a more accurate trajectory prediction [5–10]. Improving the accuracy of vehicle trajectory prediction is the most urgent problem to be solved. In fact, the accurate identification of vehicle behavior is very important to improve the accuracy of vehicle trajectory prediction, so this paper will take vehicle behavior recognition into consideration.There are many existing trajectory prediction methods, such as the Markov model [11]. Its advantage is that it can calculate the probability of maintenance capability and multiple degraded state systems, but it is not suitable for long-term prediction and is easily affected by the external environment. The advantage of Bayesian model [12] is that it is not sensitive to missing data but needs to know a priori probability, and a priori probability often depends on assumptions, and there can be many hypothetical models; therefore, at some point, the prediction effect is poor due to the hypothetical a priori model. The advantage of Kalman filter [13] is that the prediction in a short time (1 step or 2 steps) can be judged stably and accurately, but the trajectory prediction for a long time (such as more than 3 seconds or more than 5 steps) will seriously affect the prediction accuracy due to the increase of prediction error, and the model is very complex and easy to be affected by external noise.LSTM has a long-term memory function and can learn to translate languages; control robots; make image analysis, document summaries, speech recognition, image recognition, and handwriting recognition; control chatbots, predict diseases; click rates and stocks; and synthesize music [14–17]. Vehicle trajectory prediction is also a time series problem, and there is a correlation between each track point and the historical track point, so it is very suitable to use LSTM to solve the trajectory prediction problem.In order to solve the problem of vehicle trajectory prediction, a UB-LSTM vehicle trajectory prediction model combined with vehicle behavior recognition is proposed in this paper. Firstly, a many-to-one vehicle behavior recognition model is established based on LSTM, and then a trajectory prediction model is established based on one unidirectional LSTM and one bidirectional LSTM. The identified vehicle behavior information and the input information of the vehicle behavior recognition model are input into the trajectory prediction model to predict the horizontal and longitudinal speed and coordinates of the vehicle, and in the follow-up process, based on the predicted horizontal and longitudinal velocity, an acceleration trajectory optimization algorithm is proposed, and the predicted trajectory based on the optimization algorithm is more consistent with the actual trajectory and more stable. The contributions of this paper are as follows:A better trajectory prediction model is proposed, and a small test loss is obtained. In this paper, the influence of the surrounding vehicles on the predicted vehicles (that is, interactive information) is taken into account in the model, and the prediction effect of the model is improved.This paper considers a method that combines the vehicle behavior recognition model with the trajectory prediction model; that is, the behavior of the vehicle is input into the trajectory prediction model as one of the input information, which can obviously improve the accuracy of trajectory prediction.Based on the predicted horizontal and vertical velocity, an acceleration trajectory optimization algorithm is proposed, which obviously improves the accuracy and stability of the predicted trajectory.


## 2. Related Work

At present, in the aspect of vehicle trajectory prediction, the main methods are trajectory prediction based on physical motion model, trajectory prediction based on driving behavior, and trajectory prediction based on intention recognition. Gambs et al. [18] put forward the trajectory prediction method of high-order Markov model, which has high accuracy, but high computational overhead, so it is difficult to meet the real-time requirements of intelligent vehicles. Chandra et al. [10] proposed a new method based on the combination of graph analysis and deep learning to predict vehicle trajectories in urban traffic scenes, and they learned how to predict future trajectories and behaviors from the extracted vehicle trajectories. In order to reduce the error of long-term prediction (3–5 seconds) and improve the accuracy of prediction, spectral clustering regularization method was introduced and experiments were carried out on Argoverse, LYFT, and Apolloscape data sets. Deo and Trivedi [19] proposed an LSTM encoder-decoder model, which uses a convolutional social pool as an improvement to the social pool level to learn the interdependence in vehicle motion stably. In addition, based on the variability of trajectories, the model also outputs the multimodal prediction distribution of future trajectories and uses US-101 and I-80 sections of NGSIM data sets to evaluate the model. Chang et al. [20] proposed the Argoverse data set, which is designed to support self-driving vehicle perception data including 3D tracking and motion prediction. Argoverse data set includes sensor data collected by self-driving teams in Pittsburgh and Miami, as well as 3D tracking notes, extracting 300000 vehicle tracks and rich semantic maps. Using this data set can greatly reduce trajectory prediction errors. Chandra et al. [21] proposed an end-to-end vehicle trajectory prediction algorithm-RobustTP, which uses a tracking algorithm to obtain noise sensor input tracks from RGB cameras (whether stationary or moving) to predict vehicle trajectories in dense traffic and regards noise as a deviation from the real track. Firstly, the online motion model and the case segmentation algorithm based on deep learning are combined to calculate the trajectory. These noise tracks are trained by LSTM-CNN neural network structure, which simulates the interaction between different traffic objects in dense and nonuniform traffic. Chandra et al. [22] used a new LSTM-CNN hybrid network to model the interaction between different traffic objects for trajectory prediction, including buses, cars, scooters, bicycles, or pedestrians. Giuliar et al. [23] proposed a transformer network for pedestrian trajectory prediction and achieved good prediction results. Monti et al. [24] proposed a new recursive generation model to predict the trajectory of obstacles, which takes into account not only the future target of a single obstacle but also the interaction between different obstacles, and in this model, a graph neural network based on double attention is used to collect the interactive information between different obstacles, which is combined with the possible future trajectory of the obstacles, and a good prediction effect is obtained in the urban scene. Mohamed [25] proposed the social space-time graph convolution neural network (Social-STGCNN), which uses the method of modeling interaction as a graph instead of the aggregation method. The experimental results show that the final displacement error (FDE) is 20% higher than the existing methods, the average displacement error (ADE) is 8.5 times higher, and the reasoning speed is 48 times faster. Li et al. [26] proposed a universal generative neural system (Social-WaGDAT) for trajectory prediction of various obstacles and evaluated the system on three common trajectory prediction data sets, and the experimental results show that the model has a good prediction effect in terms of prediction accuracy, in which the types of obstacles include pedestrians, bicycles, and vehicles. Hao et al. [27] proposed an end-to-end generative model called attention map encoder network (AMENet), which can accurately and truly realize multipath trajectory prediction and achieve good prediction results.In order to make an accurate prediction of moving vehicle trajectory, a UB-LSTM vehicle trajectory prediction model combined with vehicle behavior recognition is proposed to obtain a smaller prediction error. Finally, based on the predicted horizontal and vertical velocity, an acceleration trajectory optimization algorithm is proposed.


## 3. Methods

Long short-term memory (LSTM) network [28] is a recurrent neural network (RNN) structure proposed by Hochreitrer and Schmidhuber in 1997. LSTM mainly solves the problems of gradient explosion and gradient vanishing of RNN [29]. LSTM mainly adds forgetting gate, input gate, and output gate on the basis of RNN to realize selective forgetting and memory of information, thus realizing the function of long-term memory. LSTM realizes the function of long-term memory through long-term memory. Because there is only simple multiplication and addition on the track of long-term memory, and there is no nonlinear operation, information flows more smoothly at different times, which can effectively restrain the problem of gradient dissipation of long-term memory.The process of this method is to first establish a vehicle behavior recognition model to realize vehicle behavior recognition and finally input the behavior identified by the vehicle behavior recognition model and vehicle information into the established trajectory prediction model to predict the horizontal and vertical speed and coordinates in the next 3 seconds. The overall flow chart is shown in Figure1. The concrete realization is to establish a separate vehicle behavior recognition model and a vehicle trajectory prediction model and train them separately, in which the training data of the vehicle trajectory model contains the marked vehicle behavior information. Then, the vehicle behavior recognition model and the trajectory prediction model are tested together, and finally, the acceleration trajectory optimization algorithm is used to generate a more accurate prediction trajectory.Figure 1
The basic flow of trajectory prediction.The following will introduce in detail the vehicle behavior recognition model, trajectory prediction model, and acceleration trajectory optimization algorithm in turn.


### 3.1. Vehicle Behavior Recognition Model

The behavior recognition model proposed in this section is mainly used to identify the five behaviors of each vehicle trajectory, including going straight, turning left and right, and changing lanes. Not only the state of the vehicle can affect vehicle behavior but also the surrounding vehicles, pedestrians, bicycles and so on. For example, avoiding pedestrians and bicycles will obviously affect the vehicle behavior. Therefore, the input features of each trajectory point include the vehicle state (i.e., coordinates, velocity, and acceleration, etc.) and interactive information features. Before predicting the trajectory, the input characteristics of each trajectory point are input into the vehicle behavior recognition model to get the behavior characteristics of the vehicle. Then, the behavior characteristics, vehicle state characteristics, and interactive information characteristics are input into the trajectory prediction model together.In this paper, a vehicle behavior recognition model is established based on a many-to-one LSTM classifier, as shown in Figure2, where the seq_length is the number of features of the input data (i.e., the number of LSTM units); batch training is used to load data, and the batch_size is the load size; the embedding is the corresponding vector length of the input LSTM unit, where embedding = 1; the hidden_size is the number of LSTM hidden layer nodes; the output_size is the output category size; the n_layers is the number of hidden layers of LSTM. Finally, a full connection layer FC is used to make the classification, and only the last node yseq_length is taken as the classification result. The output layer does not use activation functions. The Adam is used to update weights. The loss function is CrossEntropyLoss Function L, as defined in(1)L=−∑iNyilogy^i+1−yilog1−y^i,where yi is the actual value and y^i is the predicted value.Figure 2
Vehicle behavior recognition model.


### 3.2. Vehicle Trajectory Prediction Model

The vehicle behavior recognition model is shown in Figure3, which is mainly used to predict the vehicle trajectory. It can be seen that not only the state of the vehicle but also the surrounding vehicles, pedestrians, and bicycles can affect the trajectory of the vehicle and that the current behavior of the vehicle can also determine the future trajectory. For example, the trajectories of straight lines and turns are obviously different. The behavior characteristics can be marked in advance in the dataset, or they can be identified by the trained vehicle behavior recognition model. In this paper, the trajectory point of the output trajectory includes the characteristics of horizontal and longitudinal velocity and horizontal and longitudinal coordinates, that is, to predict the future horizontal and longitudinal speed and coordinates of the vehicle.Figure 3
Trajectory prediction model.Compared with the traditional Unidirectional or Bidirectional LSTM trajectory prediction model, this paper uses UB-LSTM to establish the trajectory prediction model. Bidirectional LSTM can make use of not only the previous information but also some of the latter information to make the prediction results more accurate. Then, combining the prediction results of the two LSTM can further improve the overall prediction accuracy of the model. The results of the addition of the two LSTM output layers are input into the two full connection layers in turn. Because the value range of the Tanh function is from −1 to 1, the range of the output value is limited, so the input data is directly input into a full connection layer to get an output data and then process the output value by the Tanh activation function. Finally, a full connection layer is used to get the output result. The pseudo-code of the trajectory prediction model is as follows: (Algorithm1).Algorithm 1: Trajectory prediction model.
(1)
Input:x(2)
Output: out(3)
(batch_size, seq_length,n_feature-1) ⟵ x.shape;(4)
behavior ⟵ bemodel(x);(5)
x_tra ⟵ torch.cat(x, behavior);(6)
(batch_size, seq_length,n_feature) ⟵ x_tra.shape;(7)
Linear(n_feature, input_size) ⟵ FC1;(8)
LSTM(input_size, hidden_size,n_layers, bidirectional = False, dropout) ⟵ LSTM;(9)
Linear(n_feature, input_size) ⟵ FC2;(10)
LSTM(input_size, hidden_size//2,n_layers, bidirectional = True, dropout) ⟵ BILSTM;(11)
LSTM_OUT, hidden ⟵ LSTM(FC1(x_tra));(12)
BILSTM_OUT, hidden ⟵ BILSTM(FC2(x_tra));(13)
Linear(hidden_size, hidden_size ∗ 2) ⟵ FC3;(14)
Linear(hidden_size ∗ 2, hidden_size//2) ⟵ FC4;(15)
LSTM_FC_OUT ⟵Tanh(FC3(LSTM_OUT + BILSTM_OUT));(16)
fc_out1 ⟵ Tanh(FC4(LSTM_FC_OUT));(17)
Linear(n_feature, hidden_size//2) ⟵ FC5;(18)
fc_out2 ⟵ FC5(x_tra);(19)
Linear(hidden_size//2, output_size) ⟵FC6;(20)
out ⟵FC6(fc_out1 + fc_out2);(21)
end;(22)
Return out;The bemodel is the vehicle behavior recognition model mentioned in Part A of Section3. The seq_length is the number of input trajectory points. The n_feature is the number of features contained in the input trajectory points. The input_size is the length of the vector input into LSTM cells, the hidden_size is the number of hidden layer nodes of LSTM, and the n_layers is the number of hidden layers. Using dropout method to prevent overfitting, the dropout is in the discarding rate. The behavior is the vehicle behavior identified by the vehicle behavior recognition model, and bidirectional indicates whether the LSTM is a bidirectional LSTM. The Tanh is a hyperbolic tangent activation function. The loss function uses the mean square error loss function (MSELoss), as shown in(2)MSELoss=12n∑i=1nyi−y^i2,where n represents the total number of variables,yi represents the actual value, and y^i represents the predicted value.


### 3.3. Acceleration Optimization Trajectory Algorithm

Based on the trajectory prediction model, an acceleration trajectory optimization algorithm is proposed in this paper. This algorithm refers to the acceleration and displacement formula in physics, as shown in(3)s=v2−v022a,where s is the displacement, v is the final velocity, v0 is the initial velocity, and a is the acceleration at v0. The transverse and longitudinal acceleration is calculated according to(4)axt−1=vxt−vxt−1Δt,ayt−1=vyt−vyt−1Δt,where Δt represents the interval time between two points, vx and vy represent the horizontal and longitudinal speeds of the vehicle predicted by the trajectory prediction model, and t represents the time of the trajectory point. The horizontal and longitudinal displacements are calculated according to(5)sxt−1=vxt2−vxt−122axt−1,syt−1=vyt2−vyt−122ayt−1.The coordinate values are calculated according to(6)xt=xt−1+sxt−1,yt=yt−1+syt−1,where xt−1 and yt−1 represent the coordinates of the previous trajectory point, and xt and yt represent the coordinates of the trajectory point. In this paper, the last point of the historical trajectory point is taken as the starting trajectory point and then calculated in turn until the coordinates of all the predicted trajectory points are calculated. In this paper, the time interval of trajectory points is 0.1 s.


## 3.1. Vehicle Behavior Recognition Model

The behavior recognition model proposed in this section is mainly used to identify the five behaviors of each vehicle trajectory, including going straight, turning left and right, and changing lanes. Not only the state of the vehicle can affect vehicle behavior but also the surrounding vehicles, pedestrians, bicycles and so on. For example, avoiding pedestrians and bicycles will obviously affect the vehicle behavior. Therefore, the input features of each trajectory point include the vehicle state (i.e., coordinates, velocity, and acceleration, etc.) and interactive information features. Before predicting the trajectory, the input characteristics of each trajectory point are input into the vehicle behavior recognition model to get the behavior characteristics of the vehicle. Then, the behavior characteristics, vehicle state characteristics, and interactive information characteristics are input into the trajectory prediction model together.In this paper, a vehicle behavior recognition model is established based on a many-to-one LSTM classifier, as shown in Figure2, where the seq_length is the number of features of the input data (i.e., the number of LSTM units); batch training is used to load data, and the batch_size is the load size; the embedding is the corresponding vector length of the input LSTM unit, where embedding = 1; the hidden_size is the number of LSTM hidden layer nodes; the output_size is the output category size; the n_layers is the number of hidden layers of LSTM. Finally, a full connection layer FC is used to make the classification, and only the last node yseq_length is taken as the classification result. The output layer does not use activation functions. The Adam is used to update weights. The loss function is CrossEntropyLoss Function L, as defined in(1)L=−∑iNyilogy^i+1−yilog1−y^i,where yi is the actual value and y^i is the predicted value.Figure 2
Vehicle behavior recognition model.


## 3.2. Vehicle Trajectory Prediction Model

The vehicle behavior recognition model is shown in Figure3, which is mainly used to predict the vehicle trajectory. It can be seen that not only the state of the vehicle but also the surrounding vehicles, pedestrians, and bicycles can affect the trajectory of the vehicle and that the current behavior of the vehicle can also determine the future trajectory. For example, the trajectories of straight lines and turns are obviously different. The behavior characteristics can be marked in advance in the dataset, or they can be identified by the trained vehicle behavior recognition model. In this paper, the trajectory point of the output trajectory includes the characteristics of horizontal and longitudinal velocity and horizontal and longitudinal coordinates, that is, to predict the future horizontal and longitudinal speed and coordinates of the vehicle.Figure 3
Trajectory prediction model.Compared with the traditional Unidirectional or Bidirectional LSTM trajectory prediction model, this paper uses UB-LSTM to establish the trajectory prediction model. Bidirectional LSTM can make use of not only the previous information but also some of the latter information to make the prediction results more accurate. Then, combining the prediction results of the two LSTM can further improve the overall prediction accuracy of the model. The results of the addition of the two LSTM output layers are input into the two full connection layers in turn. Because the value range of the Tanh function is from −1 to 1, the range of the output value is limited, so the input data is directly input into a full connection layer to get an output data and then process the output value by the Tanh activation function. Finally, a full connection layer is used to get the output result. The pseudo-code of the trajectory prediction model is as follows: (Algorithm1).Algorithm 1: Trajectory prediction model.
(1)
Input:x(2)
Output: out(3)
(batch_size, seq_length,n_feature-1) ⟵ x.shape;(4)
behavior ⟵ bemodel(x);(5)
x_tra ⟵ torch.cat(x, behavior);(6)
(batch_size, seq_length,n_feature) ⟵ x_tra.shape;(7)
Linear(n_feature, input_size) ⟵ FC1;(8)
LSTM(input_size, hidden_size,n_layers, bidirectional = False, dropout) ⟵ LSTM;(9)
Linear(n_feature, input_size) ⟵ FC2;(10)
LSTM(input_size, hidden_size//2,n_layers, bidirectional = True, dropout) ⟵ BILSTM;(11)
LSTM_OUT, hidden ⟵ LSTM(FC1(x_tra));(12)
BILSTM_OUT, hidden ⟵ BILSTM(FC2(x_tra));(13)
Linear(hidden_size, hidden_size ∗ 2) ⟵ FC3;(14)
Linear(hidden_size ∗ 2, hidden_size//2) ⟵ FC4;(15)
LSTM_FC_OUT ⟵Tanh(FC3(LSTM_OUT + BILSTM_OUT));(16)
fc_out1 ⟵ Tanh(FC4(LSTM_FC_OUT));(17)
Linear(n_feature, hidden_size//2) ⟵ FC5;(18)
fc_out2 ⟵ FC5(x_tra);(19)
Linear(hidden_size//2, output_size) ⟵FC6;(20)
out ⟵FC6(fc_out1 + fc_out2);(21)
end;(22)
Return out;The bemodel is the vehicle behavior recognition model mentioned in Part A of Section3. The seq_length is the number of input trajectory points. The n_feature is the number of features contained in the input trajectory points. The input_size is the length of the vector input into LSTM cells, the hidden_size is the number of hidden layer nodes of LSTM, and the n_layers is the number of hidden layers. Using dropout method to prevent overfitting, the dropout is in the discarding rate. The behavior is the vehicle behavior identified by the vehicle behavior recognition model, and bidirectional indicates whether the LSTM is a bidirectional LSTM. The Tanh is a hyperbolic tangent activation function. The loss function uses the mean square error loss function (MSELoss), as shown in(2)MSELoss=12n∑i=1nyi−y^i2,where n represents the total number of variables,yi represents the actual value, and y^i represents the predicted value.


## 3.3. Acceleration Optimization Trajectory Algorithm

Based on the trajectory prediction model, an acceleration trajectory optimization algorithm is proposed in this paper. This algorithm refers to the acceleration and displacement formula in physics, as shown in(3)s=v2−v022a,where s is the displacement, v is the final velocity, v0 is the initial velocity, and a is the acceleration at v0. The transverse and longitudinal acceleration is calculated according to(4)axt−1=vxt−vxt−1Δt,ayt−1=vyt−vyt−1Δt,where Δt represents the interval time between two points, vx and vy represent the horizontal and longitudinal speeds of the vehicle predicted by the trajectory prediction model, and t represents the time of the trajectory point. The horizontal and longitudinal displacements are calculated according to(5)sxt−1=vxt2−vxt−122axt−1,syt−1=vyt2−vyt−122ayt−1.The coordinate values are calculated according to(6)xt=xt−1+sxt−1,yt=yt−1+syt−1,where xt−1 and yt−1 represent the coordinates of the previous trajectory point, and xt and yt represent the coordinates of the trajectory point. In this paper, the last point of the historical trajectory point is taken as the starting trajectory point and then calculated in turn until the coordinates of all the predicted trajectory points are calculated. In this paper, the time interval of trajectory points is 0.1 s.


## 4. Experimental Validation

### 4.1. Experiment Platform

In this paper, the experiment is carried out on the ubuntu16.04 system, the GPU is Tesla V100-PCIE-32GB, and the model is built on Jupyter Notebook based on PyTorch.


### 4.2. Data Sources and Preprocessing

This paper uses the NGSIM data set for experiments. The NGSIM data set is derived from the Next Generation Simulation (NGSIM) program initiated by the Federal Highway Administration of the United States. The sampling frequency is 10 Hz and records information including vehicle coordinates, speed, acceleration, vehicle type, and lane number [30].


#### 4.2.1. Calculate Angle, VEL_X, VEL_Y, and Behavior

The vehicle heading angleθ is calculated using(7)θ=arctanxi−xi−1yi−yi−1,where (xi, yi) represents the coordinates of the vehicle at i time, and (xi−1, yi−1) indicates the coordinates of the vehicle at i−1 time.According to the change rate of heading angleθ between the two trajectory points of the vehicle,ω marks the vehicle behavior Label, as in formula (8). A total of five behaviors are marked, including going straight, turning left and right, and changing left and right lanes, which are represented by 0, 1, 2, 3, and 4, respectively:(8)ω=θi−θi−1Δt,where Δt represents the interval time between two points.The transverse and longitudinal velocities Vel_x and Vel_y of the vehicle are calculated according to(9)vxt=xt−xt−1Δt,vavgxt=vxt+vxt+12,vbegin=2vx0−vavgx0,vend=2vxend−vavgxend,vx0=vbegin,vx1=vavgx0,vx2=vavgx1,⋮vxend=vend,(10)vyt=yt−yt−1Δt,vavgyt=vyt+vyt+12,vbegin=2vy0−vavgy0,vend=2vyend−vavgyend,vy0=vbegin,vy1=vavgy0,vy2=vavgy1,⋮vyend=vend,where Δt denotes the interval time between two points, (x, y) represents the coordinate of the trajectory point, t represents the time of the occurrence of the trajectory point, and end represents the last trajectory point of the vehicle.


#### 4.2.2. Acquisition of Interactive Information

The main purpose is to obtain the vehicles that may exist in the left-top, left-bottom, middle-top, middle-bottom, right-top, and right-bottom positions around the vehicle, which are represented as L_Top, L_Bot, C_Top, C_Bot, R_Top, and R_Bot, respectively. Firstly, the lateral coordinate difference dis_x and the longitudinal coordinate difference dis_y between the surrounding vehicle and the predicted trajectory vehicle at a certain time are calculated, and then the position of the surrounding vehicle relative to the predicted trajectory vehicle is judged according to(11)relative_position=L_Top−5<dis_x<−1,0<dis_y<5,L_Bot−5<dis_x<−1,−5<dis_y<0,C_Top−1<dis_x<1,0<dis_y<5,C_Bot−1<dis_x<1,−5<dis_y<0,R_Top1<dis_x<5,0<dis_y<5,R_Bot1<dis_x<5,−5<dis_y<0.Then, we record the id, relative distance, speed, acceleration, heading angle, and behavior of the vehicle that meets the conditions. If there is no vehicle in a certain position, the above information is all set to 0, so the interactive information of the vehicle is obtained.


#### 4.2.3. Generate Trajectory and Behavior Dataset

In the experiment, the Savizkg-Golag smoothing algorithm is firstly used to smooth the coordinates of vehicle trajectory points to eliminate the noise, then remove the vehicles with less than 130 trajectory points or two trajectory points with a distance of more than 5 meters, and at the same time, limit the maximum number of trajectories of each vehicle to 61. By doing so, the number of trajectories of each vehicle will keep consistent. Finally, a total of 17,320 trajectory data are generated, and each trajectory contains 100 trajectory points, including a total of 321 vehicles. The trajectory is standardized using(12)x=x⌢−meanstd,where x⌢ represents a single value in each column, x represents the changed value, mean represents the average of each column, and std represents the standard deviation.In the experiment, a total of 26 features are selected as the input trajectory points. At the same time, a total of four features including the vehicle horizontal and longitudinal velocity and coordinates of the trajectory point 3 seconds behind the input trajectory point are selected as the output trajectory point.The vehicle behavior data is first restored according to equation (13), then the vehicle behavior feature of each input trajectory point is separated as a tag, and the rest of 25 features are used as input features:(13)x=x⌢∗std+mean.In order to better observe the training process, the vehicle trajectory data is divided into a training set, verification set, and test set according to the proportion of 8 : 1 : 1. The training set is used to train the model, the verification set is used to monitor the training process in real time, and the test set is used to evaluate the effect of the model after the training.


### 4.3. Vehicle Behavior Recognition Model Experiment

Set batch_size = 100, seq_length = 25, embedding = 1, hidden_size = 256,n_layers = 2, output_size = 5, and learning rate = 0.0001. Only the model with minimum validation loss is saved with a total of 100 iterations. The training process is shown in Figure 4.Figure 4
Training process of behavior recognition model. (a) Loss change of behavior recognition model. (b) Accuracy change of behavior recognition model.
(a)(b)The training time is 3.943 hours, and the minimum verification loss is 0.0066. The accuracy of vehicle behavior recognition is the ratio of the correct recognition number of each vehicle behavior to the total number of each vehicle behavior. The test results are shown in Table1. As can be seen from the test results, the recognition accuracy of each behavior of the vehicle is higher than 98%.Table 1
Test results of the behavior recognition model.
Left_turnLeft_changeRight_turnRight_changeKeepAllTest_lossCorrect_n/ALL9017/90428635/86911708/17201524/1552152166/152195173050/173200.0026Accuracy (%)99.7299.3699.3098.2099.9899.91


### 4.4. Trajectory Prediction Model Experiment

In order to verify the influence of vehicle behavior, the trajectory prediction accuracy is compared with and without considering the vehicle behavior in this study. In the experiments, the trajectory data is restored using equation (13). In order to reflect the superiority of the acceleration trajectory optimization algorithm proposed in this paper, the trajectory generated by the coordinate of the predicted trajectory point is compared with that generated by the trajectory optimization algorithm.


#### 4.4.1. Trajectory Prediction Model Experiment without Vehicle Behavior

Set batch_size = 128, seq_length = 100,n_feature = 25, input_size = 256, hidden_size = 256, n_layers = 2, output_size = 4, dropout = 0.5, and we used the ReduceLROnPlateau method to adjust the learning rate. The initial learning_rate is 0.001. When the verification loss does not decrease for 20 iterations, the learning rate is adjusted to 10% of the existing rate. Only the model with minimum validation loss is saved, within a total of 1,000 iterations. The training process is shown in Figure 5, where vehicle behavior is not considered here.Figure 5
Training process of trajectory prediction model without vehicle behavior.The training time is 3.944 hours, and the minimum verification loss is 0.0114. It can be seen from Figure5 that the loss decreases slowly during the training. In the testing process, the test loss is 0.0115, the MSE between the predicted trajectory and the actual trajectory is 4.3, and the MSE produced by the optimization algorithm is 2.4. Figure 6 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point. As can be seen from Figure 6, the trajectory generated by the optimization algorithm is very close to the actual trajectory; but the prediction performance without the optimization algorithm is far away from satisfactory.Figure 6
Trajectory prediction results without vehicle behavior. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)


#### 4.4.2. Trajectory Prediction Model Experiment Combined with Vehicle Behavior

Set batch_size = 128, seq_length = 100,n_feature = 26, input_size = 256, hidden_size = 256, n_layers = 2, output_size = 4, dropout = 0.5, and initial Learning_rate = 0.001. Figure 7 depicts the training result.Figure 7
Training process of the trajectory prediction model considering behavior.The training time is 7.12 hours, and the minimum verification loss is 0.00041732. In order to test the fusion effect of the vehicle behavior model and the trajectory prediction model, first of all, the trajectory prediction model is used alone after the behavior recognition model, and then two models are used in parallel.The vehicle trajectory prediction model predicts the horizontal and longitudinal speed and coordinates of the vehicle and uses the transverse and longitudinal velocity and the last trajectory point of the historical trajectory to realize the acceleration trajectory optimization. First of all, the experiment is carried out without using the vehicle behavior recognition model. The test loss is 0.000486. The MSE between the predicted trajectory and the actual trajectory is 1.361. The MSE generated by the optimization algorithm is 0.122. Figure8 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point.Figure 8
Trajectory prediction results using the two models in the series. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)Comparing Figures6 and 8, one can find that the prediction effect is obviously improved; thus, it is very necessary to consider vehicle behavior in the prediction model. The prediction trajectory obtained by the optimization algorithm is more consistent with the actual trajectory, which indicates that the usage of the optimization algorithm makes the prediction performance stable.When the behavior recognition model and the trajectory prediction model are integrated, the test loss is 0.000497, the recognition accuracy of the behavior recognition model is 99.9%, the MSE without the optimization algorithm is 1.36, and the MSE with the optimization algorithm is 0.124. It can be found that the MSE and test losses after fusion are slightly higher than those of the individual use of the prediction model in Figure8. Figure 9 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point. It can be seen from Figure 9 that the trajectory prediction effect of the proposed method is good, which is basically consistent with the actual trajectory, and is stable, without large fluctuations, and basically achieves the expected effect. It shows that the trajectory prediction method proposed in this paper has high prediction accuracy and good stability.Figure 9
Trajectory prediction results using the two models in parallel. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)


### 4.5. Discussion

As can be seen from Figures5, 7, and 8, the trajectory generated by the optimization algorithm is much better, more reasonable, and more consistent with the actual trajectory than the trajectory directly predicted in this paper. It shows that the trajectory optimization algorithm proposed in this paper contributes a very good improvement effect.In order to examine the behavior recognition effect, the following comparisons are further conducted. Herein, the test without considering behavior recognition is abbreviated as NCB; the test with considering behavior recognition is abbreviated as CB; the alone test model considering vehicle behavior is abbreviated as CB_A; the fusion test model considering vehicle behavior is abbreviated as CB_F; the test based on the coordinate method without considering behavior recognition is abbreviated as NCB_CB; the test based on optimization algorithm without considering behavior recognition is abbreviated as NCB_OB; the alone test based on coordinate method considering vehicle behavior recognition is abbreviated as CB_A_CB; the alone test based on optimization algorithm considering vehicle behavior recognition is abbreviated as CB_A_OB; the fusion test based on coordinate method considering vehicle behavior recognition is abbreviated as CB_F_CB; the fusion test based on optimization algorithm considering vehicle behavior recognition is abbreviated as CB_F_OB. The comparison results are demonstrated as follows.


#### 4.5.1. Minimum Verification Loss

The minimum verification loss is shown in Figure10 and Table 2. As can be seen, the minimum verification loss with consideration of behavior recognition is much smaller than that without considering it, which indicates that it is necessary to consider vehicle behavior.Figure 10
Comparison of minimum verification loss.Table 2
Comparison of minimum verification loss.
NCBCBMin_valid_loss0.01140.000417


#### 4.5.2. Test Loss

The test losses are shown in Figure11 and Table 3. It can be seen that the test loss of the model without considering the behavior recognition is the largest and the test loss of the individual test model is the smallest when considering the behavior, which shows the importance of vehicle behavior recognition. Hence, it suggests that in the real world application, it is very important to use a vehicle behavior recognition model to identify vehicle behavior before predicting the trajectory.Figure 11
Comparison of test losses.Table 3
Comparison of test losses.
NCBCB_ACB_FTest_loss0.01150.0004860.000497


#### 4.5.3. MSE Comparison

The MSE size under each method is shown in Figure12 and Table 4. It can be seen from the results that the MSE generated by the optimization algorithm is much lower than that of the coordinate method, which means that the optimization algorithm can greatly improve the accuracy of trajectory prediction. It can be also seen that the MSE of the model considering behavior recognition is always lower than that not considering vehicle behavior. In addition, by considering vehicle behavior, the MSE produced by the series configuration of the recognition model and prediction model is very close to that of the parallel configuration of the two models, which shows that combining the two models is feasible.Figure 12
MSE comparison.Table 4
MSE comparison.
NCB_CBCB_A_CBCB_F_CBNCB_OBCB_A_OBCB_F_OBMSE4.31.3611.362.40.1220.124To sum up, the UB-LSTM based trajectory prediction model, which combines the vehicle behavior recognition and acceleration trajectory optimization algorithm, is able to predict the trajectory accurately and stably.


## 4.1. Experiment Platform

In this paper, the experiment is carried out on the ubuntu16.04 system, the GPU is Tesla V100-PCIE-32GB, and the model is built on Jupyter Notebook based on PyTorch.


## 4.2. Data Sources and Preprocessing

This paper uses the NGSIM data set for experiments. The NGSIM data set is derived from the Next Generation Simulation (NGSIM) program initiated by the Federal Highway Administration of the United States. The sampling frequency is 10 Hz and records information including vehicle coordinates, speed, acceleration, vehicle type, and lane number [30].


### 4.2.1. Calculate Angle, VEL_X, VEL_Y, and Behavior

The vehicle heading angleθ is calculated using(7)θ=arctanxi−xi−1yi−yi−1,where (xi, yi) represents the coordinates of the vehicle at i time, and (xi−1, yi−1) indicates the coordinates of the vehicle at i−1 time.According to the change rate of heading angleθ between the two trajectory points of the vehicle,ω marks the vehicle behavior Label, as in formula (8). A total of five behaviors are marked, including going straight, turning left and right, and changing left and right lanes, which are represented by 0, 1, 2, 3, and 4, respectively:(8)ω=θi−θi−1Δt,where Δt represents the interval time between two points.The transverse and longitudinal velocities Vel_x and Vel_y of the vehicle are calculated according to(9)vxt=xt−xt−1Δt,vavgxt=vxt+vxt+12,vbegin=2vx0−vavgx0,vend=2vxend−vavgxend,vx0=vbegin,vx1=vavgx0,vx2=vavgx1,⋮vxend=vend,(10)vyt=yt−yt−1Δt,vavgyt=vyt+vyt+12,vbegin=2vy0−vavgy0,vend=2vyend−vavgyend,vy0=vbegin,vy1=vavgy0,vy2=vavgy1,⋮vyend=vend,where Δt denotes the interval time between two points, (x, y) represents the coordinate of the trajectory point, t represents the time of the occurrence of the trajectory point, and end represents the last trajectory point of the vehicle.


### 4.2.2. Acquisition of Interactive Information

The main purpose is to obtain the vehicles that may exist in the left-top, left-bottom, middle-top, middle-bottom, right-top, and right-bottom positions around the vehicle, which are represented as L_Top, L_Bot, C_Top, C_Bot, R_Top, and R_Bot, respectively. Firstly, the lateral coordinate difference dis_x and the longitudinal coordinate difference dis_y between the surrounding vehicle and the predicted trajectory vehicle at a certain time are calculated, and then the position of the surrounding vehicle relative to the predicted trajectory vehicle is judged according to(11)relative_position=L_Top−5<dis_x<−1,0<dis_y<5,L_Bot−5<dis_x<−1,−5<dis_y<0,C_Top−1<dis_x<1,0<dis_y<5,C_Bot−1<dis_x<1,−5<dis_y<0,R_Top1<dis_x<5,0<dis_y<5,R_Bot1<dis_x<5,−5<dis_y<0.Then, we record the id, relative distance, speed, acceleration, heading angle, and behavior of the vehicle that meets the conditions. If there is no vehicle in a certain position, the above information is all set to 0, so the interactive information of the vehicle is obtained.


### 4.2.3. Generate Trajectory and Behavior Dataset

In the experiment, the Savizkg-Golag smoothing algorithm is firstly used to smooth the coordinates of vehicle trajectory points to eliminate the noise, then remove the vehicles with less than 130 trajectory points or two trajectory points with a distance of more than 5 meters, and at the same time, limit the maximum number of trajectories of each vehicle to 61. By doing so, the number of trajectories of each vehicle will keep consistent. Finally, a total of 17,320 trajectory data are generated, and each trajectory contains 100 trajectory points, including a total of 321 vehicles. The trajectory is standardized using(12)x=x⌢−meanstd,where x⌢ represents a single value in each column, x represents the changed value, mean represents the average of each column, and std represents the standard deviation.In the experiment, a total of 26 features are selected as the input trajectory points. At the same time, a total of four features including the vehicle horizontal and longitudinal velocity and coordinates of the trajectory point 3 seconds behind the input trajectory point are selected as the output trajectory point.The vehicle behavior data is first restored according to equation (13), then the vehicle behavior feature of each input trajectory point is separated as a tag, and the rest of 25 features are used as input features:(13)x=x⌢∗std+mean.In order to better observe the training process, the vehicle trajectory data is divided into a training set, verification set, and test set according to the proportion of 8 : 1 : 1. The training set is used to train the model, the verification set is used to monitor the training process in real time, and the test set is used to evaluate the effect of the model after the training.


## 4.2.1. Calculate Angle, VEL_X, VEL_Y, and Behavior

The vehicle heading angleθ is calculated using(7)θ=arctanxi−xi−1yi−yi−1,where (xi, yi) represents the coordinates of the vehicle at i time, and (xi−1, yi−1) indicates the coordinates of the vehicle at i−1 time.According to the change rate of heading angleθ between the two trajectory points of the vehicle,ω marks the vehicle behavior Label, as in formula (8). A total of five behaviors are marked, including going straight, turning left and right, and changing left and right lanes, which are represented by 0, 1, 2, 3, and 4, respectively:(8)ω=θi−θi−1Δt,where Δt represents the interval time between two points.The transverse and longitudinal velocities Vel_x and Vel_y of the vehicle are calculated according to(9)vxt=xt−xt−1Δt,vavgxt=vxt+vxt+12,vbegin=2vx0−vavgx0,vend=2vxend−vavgxend,vx0=vbegin,vx1=vavgx0,vx2=vavgx1,⋮vxend=vend,(10)vyt=yt−yt−1Δt,vavgyt=vyt+vyt+12,vbegin=2vy0−vavgy0,vend=2vyend−vavgyend,vy0=vbegin,vy1=vavgy0,vy2=vavgy1,⋮vyend=vend,where Δt denotes the interval time between two points, (x, y) represents the coordinate of the trajectory point, t represents the time of the occurrence of the trajectory point, and end represents the last trajectory point of the vehicle.


## 4.2.2. Acquisition of Interactive Information

The main purpose is to obtain the vehicles that may exist in the left-top, left-bottom, middle-top, middle-bottom, right-top, and right-bottom positions around the vehicle, which are represented as L_Top, L_Bot, C_Top, C_Bot, R_Top, and R_Bot, respectively. Firstly, the lateral coordinate difference dis_x and the longitudinal coordinate difference dis_y between the surrounding vehicle and the predicted trajectory vehicle at a certain time are calculated, and then the position of the surrounding vehicle relative to the predicted trajectory vehicle is judged according to(11)relative_position=L_Top−5<dis_x<−1,0<dis_y<5,L_Bot−5<dis_x<−1,−5<dis_y<0,C_Top−1<dis_x<1,0<dis_y<5,C_Bot−1<dis_x<1,−5<dis_y<0,R_Top1<dis_x<5,0<dis_y<5,R_Bot1<dis_x<5,−5<dis_y<0.Then, we record the id, relative distance, speed, acceleration, heading angle, and behavior of the vehicle that meets the conditions. If there is no vehicle in a certain position, the above information is all set to 0, so the interactive information of the vehicle is obtained.


## 4.2.3. Generate Trajectory and Behavior Dataset

In the experiment, the Savizkg-Golag smoothing algorithm is firstly used to smooth the coordinates of vehicle trajectory points to eliminate the noise, then remove the vehicles with less than 130 trajectory points or two trajectory points with a distance of more than 5 meters, and at the same time, limit the maximum number of trajectories of each vehicle to 61. By doing so, the number of trajectories of each vehicle will keep consistent. Finally, a total of 17,320 trajectory data are generated, and each trajectory contains 100 trajectory points, including a total of 321 vehicles. The trajectory is standardized using(12)x=x⌢−meanstd,where x⌢ represents a single value in each column, x represents the changed value, mean represents the average of each column, and std represents the standard deviation.In the experiment, a total of 26 features are selected as the input trajectory points. At the same time, a total of four features including the vehicle horizontal and longitudinal velocity and coordinates of the trajectory point 3 seconds behind the input trajectory point are selected as the output trajectory point.The vehicle behavior data is first restored according to equation (13), then the vehicle behavior feature of each input trajectory point is separated as a tag, and the rest of 25 features are used as input features:(13)x=x⌢∗std+mean.In order to better observe the training process, the vehicle trajectory data is divided into a training set, verification set, and test set according to the proportion of 8 : 1 : 1. The training set is used to train the model, the verification set is used to monitor the training process in real time, and the test set is used to evaluate the effect of the model after the training.


## 4.3. Vehicle Behavior Recognition Model Experiment

Set batch_size = 100, seq_length = 25, embedding = 1, hidden_size = 256,n_layers = 2, output_size = 5, and learning rate = 0.0001. Only the model with minimum validation loss is saved with a total of 100 iterations. The training process is shown in Figure 4.Figure 4
Training process of behavior recognition model. (a) Loss change of behavior recognition model. (b) Accuracy change of behavior recognition model.
(a)(b)The training time is 3.943 hours, and the minimum verification loss is 0.0066. The accuracy of vehicle behavior recognition is the ratio of the correct recognition number of each vehicle behavior to the total number of each vehicle behavior. The test results are shown in Table1. As can be seen from the test results, the recognition accuracy of each behavior of the vehicle is higher than 98%.Table 1
Test results of the behavior recognition model.
Left_turnLeft_changeRight_turnRight_changeKeepAllTest_lossCorrect_n/ALL9017/90428635/86911708/17201524/1552152166/152195173050/173200.0026Accuracy (%)99.7299.3699.3098.2099.9899.91


## 4.4. Trajectory Prediction Model Experiment

In order to verify the influence of vehicle behavior, the trajectory prediction accuracy is compared with and without considering the vehicle behavior in this study. In the experiments, the trajectory data is restored using equation (13). In order to reflect the superiority of the acceleration trajectory optimization algorithm proposed in this paper, the trajectory generated by the coordinate of the predicted trajectory point is compared with that generated by the trajectory optimization algorithm.


### 4.4.1. Trajectory Prediction Model Experiment without Vehicle Behavior

Set batch_size = 128, seq_length = 100,n_feature = 25, input_size = 256, hidden_size = 256, n_layers = 2, output_size = 4, dropout = 0.5, and we used the ReduceLROnPlateau method to adjust the learning rate. The initial learning_rate is 0.001. When the verification loss does not decrease for 20 iterations, the learning rate is adjusted to 10% of the existing rate. Only the model with minimum validation loss is saved, within a total of 1,000 iterations. The training process is shown in Figure 5, where vehicle behavior is not considered here.Figure 5
Training process of trajectory prediction model without vehicle behavior.The training time is 3.944 hours, and the minimum verification loss is 0.0114. It can be seen from Figure5 that the loss decreases slowly during the training. In the testing process, the test loss is 0.0115, the MSE between the predicted trajectory and the actual trajectory is 4.3, and the MSE produced by the optimization algorithm is 2.4. Figure 6 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point. As can be seen from Figure 6, the trajectory generated by the optimization algorithm is very close to the actual trajectory; but the prediction performance without the optimization algorithm is far away from satisfactory.Figure 6
Trajectory prediction results without vehicle behavior. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)


### 4.4.2. Trajectory Prediction Model Experiment Combined with Vehicle Behavior

Set batch_size = 128, seq_length = 100,n_feature = 26, input_size = 256, hidden_size = 256, n_layers = 2, output_size = 4, dropout = 0.5, and initial Learning_rate = 0.001. Figure 7 depicts the training result.Figure 7
Training process of the trajectory prediction model considering behavior.The training time is 7.12 hours, and the minimum verification loss is 0.00041732. In order to test the fusion effect of the vehicle behavior model and the trajectory prediction model, first of all, the trajectory prediction model is used alone after the behavior recognition model, and then two models are used in parallel.The vehicle trajectory prediction model predicts the horizontal and longitudinal speed and coordinates of the vehicle and uses the transverse and longitudinal velocity and the last trajectory point of the historical trajectory to realize the acceleration trajectory optimization. First of all, the experiment is carried out without using the vehicle behavior recognition model. The test loss is 0.000486. The MSE between the predicted trajectory and the actual trajectory is 1.361. The MSE generated by the optimization algorithm is 0.122. Figure8 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point.Figure 8
Trajectory prediction results using the two models in the series. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)Comparing Figures6 and 8, one can find that the prediction effect is obviously improved; thus, it is very necessary to consider vehicle behavior in the prediction model. The prediction trajectory obtained by the optimization algorithm is more consistent with the actual trajectory, which indicates that the usage of the optimization algorithm makes the prediction performance stable.When the behavior recognition model and the trajectory prediction model are integrated, the test loss is 0.000497, the recognition accuracy of the behavior recognition model is 99.9%, the MSE without the optimization algorithm is 1.36, and the MSE with the optimization algorithm is 0.124. It can be found that the MSE and test losses after fusion are slightly higher than those of the individual use of the prediction model in Figure8. Figure 9 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point. It can be seen from Figure 9 that the trajectory prediction effect of the proposed method is good, which is basically consistent with the actual trajectory, and is stable, without large fluctuations, and basically achieves the expected effect. It shows that the trajectory prediction method proposed in this paper has high prediction accuracy and good stability.Figure 9
Trajectory prediction results using the two models in parallel. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)


## 4.4.1. Trajectory Prediction Model Experiment without Vehicle Behavior

Set batch_size = 128, seq_length = 100,n_feature = 25, input_size = 256, hidden_size = 256, n_layers = 2, output_size = 4, dropout = 0.5, and we used the ReduceLROnPlateau method to adjust the learning rate. The initial learning_rate is 0.001. When the verification loss does not decrease for 20 iterations, the learning rate is adjusted to 10% of the existing rate. Only the model with minimum validation loss is saved, within a total of 1,000 iterations. The training process is shown in Figure 5, where vehicle behavior is not considered here.Figure 5
Training process of trajectory prediction model without vehicle behavior.The training time is 3.944 hours, and the minimum verification loss is 0.0114. It can be seen from Figure5 that the loss decreases slowly during the training. In the testing process, the test loss is 0.0115, the MSE between the predicted trajectory and the actual trajectory is 4.3, and the MSE produced by the optimization algorithm is 2.4. Figure 6 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point. As can be seen from Figure 6, the trajectory generated by the optimization algorithm is very close to the actual trajectory; but the prediction performance without the optimization algorithm is far away from satisfactory.Figure 6
Trajectory prediction results without vehicle behavior. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)


## 4.4.2. Trajectory Prediction Model Experiment Combined with Vehicle Behavior

Set batch_size = 128, seq_length = 100,n_feature = 26, input_size = 256, hidden_size = 256, n_layers = 2, output_size = 4, dropout = 0.5, and initial Learning_rate = 0.001. Figure 7 depicts the training result.Figure 7
Training process of the trajectory prediction model considering behavior.The training time is 7.12 hours, and the minimum verification loss is 0.00041732. In order to test the fusion effect of the vehicle behavior model and the trajectory prediction model, first of all, the trajectory prediction model is used alone after the behavior recognition model, and then two models are used in parallel.The vehicle trajectory prediction model predicts the horizontal and longitudinal speed and coordinates of the vehicle and uses the transverse and longitudinal velocity and the last trajectory point of the historical trajectory to realize the acceleration trajectory optimization. First of all, the experiment is carried out without using the vehicle behavior recognition model. The test loss is 0.000486. The MSE between the predicted trajectory and the actual trajectory is 1.361. The MSE generated by the optimization algorithm is 0.122. Figure8 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point.Figure 8
Trajectory prediction results using the two models in the series. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)Comparing Figures6 and 8, one can find that the prediction effect is obviously improved; thus, it is very necessary to consider vehicle behavior in the prediction model. The prediction trajectory obtained by the optimization algorithm is more consistent with the actual trajectory, which indicates that the usage of the optimization algorithm makes the prediction performance stable.When the behavior recognition model and the trajectory prediction model are integrated, the test loss is 0.000497, the recognition accuracy of the behavior recognition model is 99.9%, the MSE without the optimization algorithm is 1.36, and the MSE with the optimization algorithm is 0.124. It can be found that the MSE and test losses after fusion are slightly higher than those of the individual use of the prediction model in Figure8. Figure 9 shows the predicted results, where the axis x represents the lateral coordinates of the predicted trajectory point, and the axis Y represents the longitudinal coordinates of the predicted trajectory point. It can be seen from Figure 9 that the trajectory prediction effect of the proposed method is good, which is basically consistent with the actual trajectory, and is stable, without large fluctuations, and basically achieves the expected effect. It shows that the trajectory prediction method proposed in this paper has high prediction accuracy and good stability.Figure 9
Trajectory prediction results using the two models in parallel. (a) Prediction trajectory 1. (b) Prediction trajectory 2.
(a)(b)


## 4.5. Discussion

As can be seen from Figures5, 7, and 8, the trajectory generated by the optimization algorithm is much better, more reasonable, and more consistent with the actual trajectory than the trajectory directly predicted in this paper. It shows that the trajectory optimization algorithm proposed in this paper contributes a very good improvement effect.In order to examine the behavior recognition effect, the following comparisons are further conducted. Herein, the test without considering behavior recognition is abbreviated as NCB; the test with considering behavior recognition is abbreviated as CB; the alone test model considering vehicle behavior is abbreviated as CB_A; the fusion test model considering vehicle behavior is abbreviated as CB_F; the test based on the coordinate method without considering behavior recognition is abbreviated as NCB_CB; the test based on optimization algorithm without considering behavior recognition is abbreviated as NCB_OB; the alone test based on coordinate method considering vehicle behavior recognition is abbreviated as CB_A_CB; the alone test based on optimization algorithm considering vehicle behavior recognition is abbreviated as CB_A_OB; the fusion test based on coordinate method considering vehicle behavior recognition is abbreviated as CB_F_CB; the fusion test based on optimization algorithm considering vehicle behavior recognition is abbreviated as CB_F_OB. The comparison results are demonstrated as follows.


### 4.5.1. Minimum Verification Loss

The minimum verification loss is shown in Figure10 and Table 2. As can be seen, the minimum verification loss with consideration of behavior recognition is much smaller than that without considering it, which indicates that it is necessary to consider vehicle behavior.Figure 10
Comparison of minimum verification loss.Table 2
Comparison of minimum verification loss.
NCBCBMin_valid_loss0.01140.000417


### 4.5.2. Test Loss

The test losses are shown in Figure11 and Table 3. It can be seen that the test loss of the model without considering the behavior recognition is the largest and the test loss of the individual test model is the smallest when considering the behavior, which shows the importance of vehicle behavior recognition. Hence, it suggests that in the real world application, it is very important to use a vehicle behavior recognition model to identify vehicle behavior before predicting the trajectory.Figure 11
Comparison of test losses.Table 3
Comparison of test losses.
NCBCB_ACB_FTest_loss0.01150.0004860.000497


### 4.5.3. MSE Comparison

The MSE size under each method is shown in Figure12 and Table 4. It can be seen from the results that the MSE generated by the optimization algorithm is much lower than that of the coordinate method, which means that the optimization algorithm can greatly improve the accuracy of trajectory prediction. It can be also seen that the MSE of the model considering behavior recognition is always lower than that not considering vehicle behavior. In addition, by considering vehicle behavior, the MSE produced by the series configuration of the recognition model and prediction model is very close to that of the parallel configuration of the two models, which shows that combining the two models is feasible.Figure 12
MSE comparison.Table 4
MSE comparison.
NCB_CBCB_A_CBCB_F_CBNCB_OBCB_A_OBCB_F_OBMSE4.31.3611.362.40.1220.124To sum up, the UB-LSTM based trajectory prediction model, which combines the vehicle behavior recognition and acceleration trajectory optimization algorithm, is able to predict the trajectory accurately and stably.


## 4.5.1. Minimum Verification Loss

The minimum verification loss is shown in Figure10 and Table 2. As can be seen, the minimum verification loss with consideration of behavior recognition is much smaller than that without considering it, which indicates that it is necessary to consider vehicle behavior.Figure 10
Comparison of minimum verification loss.Table 2
Comparison of minimum verification loss.
NCBCBMin_valid_loss0.01140.000417


## 4.5.2. Test Loss

The test losses are shown in Figure11 and Table 3. It can be seen that the test loss of the model without considering the behavior recognition is the largest and the test loss of the individual test model is the smallest when considering the behavior, which shows the importance of vehicle behavior recognition. Hence, it suggests that in the real world application, it is very important to use a vehicle behavior recognition model to identify vehicle behavior before predicting the trajectory.Figure 11
Comparison of test losses.Table 3
Comparison of test losses.
NCBCB_ACB_FTest_loss0.01150.0004860.000497


## 4.5.3. MSE Comparison

The MSE size under each method is shown in Figure12 and Table 4. It can be seen from the results that the MSE generated by the optimization algorithm is much lower than that of the coordinate method, which means that the optimization algorithm can greatly improve the accuracy of trajectory prediction. It can be also seen that the MSE of the model considering behavior recognition is always lower than that not considering vehicle behavior. In addition, by considering vehicle behavior, the MSE produced by the series configuration of the recognition model and prediction model is very close to that of the parallel configuration of the two models, which shows that combining the two models is feasible.Figure 12
MSE comparison.Table 4
MSE comparison.
NCB_CBCB_A_CBCB_F_CBNCB_OBCB_A_OBCB_F_OBMSE4.31.3611.362.40.1220.124To sum up, the UB-LSTM based trajectory prediction model, which combines the vehicle behavior recognition and acceleration trajectory optimization algorithm, is able to predict the trajectory accurately and stably.


## 5. Conclusions and Future Plan

This paper proposes a UB-LSTM trajectory prediction model, which inputs vehicle state information, vehicle behavior information, and interactive information into the trajectory prediction model to predict the vehicle transverse and longitudinal speed and coordinates. A vehicle behavior recognition model is trained to make a prediction combined with the vehicle trajectory prediction model. An acceleration trajectory optimization algorithm is proposed to improve the trajectory prediction accuracy. Experimental results show that the model test loss obtained by the proposed UB-LSTM is 0.000497, and the prediction MSE is 0.124, which is 97.2% lower than that without considering the vehicle behavior information. As a result, the proposed UB-LSTM method is suitable for practical usage.In the next step, we will consider predicting the trajectory for a longer time and collect more experimental data to improve the model training effect. Although a real car is not available at this moment, the real vehicle experiment will be considered in the near future. The NGSIM dataset used in this experiment records the time stamp, id, coordinates, speed, and acceleration of the vehicles. However, a LIDAR can also provide the time stamp, id, coordinates, velocity, and acceleration of the surrounding obstacles, and the types of obstacles include vehicles, pedestrians, and bicycles. Thus, the interactive information provided by a LIDAR is more comprehensive. Moreover, environmental information can be obtained through high-precision maps, so more input information can be used in the process of real cars. Based on the above characteristics, the real vehicle dataset, similar to NGSIM dataset, can be collected by a LIDAR to carry out real car experiments. The intelligent car uses the C++ language to realize automatic driving, while the training model in this paper is realized by Python language based on PyTorch, so we will consider using LibTorch to migrate the model to the intelligent vehicle. The basic process is as follows: the LIDAR is firstly used to collect the vehicle trajectory dataset, then train the UB-LSTM model, and lastly, transfer the trained model to the intelligent vehicle for real vehicle experiments. However, the difference between the real vehicle experiment and the simulation is that the data processing should be carried out in real time. This will be carried out in the future.Compared with the physical model method, the disadvantage of the proposed method is that the calculation speed is slower due to a large number of calculations, and it is basically necessary to use GPU to meet the real-time requirements. In the next work, we will try our best to improve the real-time performance of the model.



---

*Source: 8859689-2020-08-01.xml*