Human-Machine Cooperative Trajectory Planning for Semi-Autonomous Driving Based on the Understanding of Behavioral Semantics

: This paper presents a novel cooperative trajectory planning approach for semi-autonomous driving. The machine interacts with the driver at the decision level and the trajectory generation level. To minimize conﬂicts between the machine and the human, the trajectory planning problem is decomposed into a high-level behavior decision-making problem and a low-level trajectory planning problem. The approach infers the driver’s behavioral semantics according to the driving context and the driver’s input. The trajectories are generated based on the behavioral semantics and driver’s input. The feasibility of the proposed approach is validated by real vehicle experiments. The results prove that the proposed human–machine cooperative trajectory planning approach can successfully help the driver to avoid collisions while respecting the driver’s behavior.


Introduction
Intelligent driving systems can improve safety and reduce traffic accidents effectively. The current intelligent assistance systems mainly include lane departure warning systems, lane-keeping systems, automatic cruise systems, automatic emergency braking systems, etc. However, the current intelligent driving systems still have many limitations and face many challenges in environmental understanding, decision, planning, and control. In these systems, the allocation mechanism of driving authority between human and machine is relatively simple, and a safe and flexible human-machine cooperative driving ability in a complex environment is not yet available. Drivers and intelligent driving systems can be complementary. Drivers have rich experience and common sense in terms of environmental understanding and cognition. Intelligent driving systems have the ability to continuously monitor the surrounding environment and can assist one in driving safely to reduce the driver's workload. The advanced stage of human-machine co-driving should be that the driver can get involved in all levels of perception, reasoning, decision making, and control. The advantages of a human driver and intelligent driving system should be integrated to achieve harmonization. How to integrate the advantages of drivers and intelligent driving systems through human-machine co-driving technology has become an important research topic of intelligent driving technology.
Regarding on the handover of driving authority between driver and vehicle in the driver assistance systems, the research mainly includes the scope of application of driving assistance systems [1], the human factors [2], the driving capability of the driver [3], and the authority interactions between the driving assistance system and driver [4]. The effect of an authority transition from autonomous driving mode to driver take-over mode varies with different drivers [5]. It is necessary to analyze the timing to switch the control authority between the driver and the driver assistance system [6]. It is necessary to judge whether the control authority can be transferred safely, whether the driver has the ability to control the vehicle safely, and whether the vehicle state will be in the controllable state-space after the control authority is switched. Differently from control authority switching, adjustable autonomy can set multiple levels of autonomy, and each level can set a different control ratio [7,8]. The driver and the machine can control the velocity and steer separately or together. According to the evaluation criteria, a certain level of autonomy can be selected [9]. The disadvantage of this method is that the autonomy level is divided into several fixed levels, which have poor flexibility. The control of the human and the machine is simply added, since the human's input is not fixed, the final effect is unpredictable. Some scholars proposed to use a new human-machine interaction interface to solve the problem of control authority interaction. One approach is the haptic shared control, in which both the driver and the intelligent driving system have authority over vehicle control. The driver is in the control loop all the time, and can actively respond to any scene. At the same time, the driver can continuously receive the haptic feedback provided by the intelligent driving system. Human-machine cooperative longitudinal control can be realized by using the accelerator pedal and the brake pedal [10,11]; human-machine cooperative lateral control can be realized by the steering wheel. Haptic shared control can be achieved through force feedback or stiffness feedback, thereby allowing a smooth transfer of control authority between the driver and the machine [12]. Sterling J. Anderson [13] used a method based on model predictive control to design a smooth proportional distribution relationship of human-machine control authority. When the risk reaches a certain level, the control authority will be gradually transferred from human to machine. Manabu et al. [14] proposed a weighted summation method to combine the driver's input with the automation's desired input. In this work, the authority weights are static during driving, which does not allow the driver to gain more control authority in a critical situation that cannot be properly handled by automation. Most of the above research focused on the problem of vehicle control when the path is predefined. Few research have discussed the problem of trajectory planning for semi-autonomous driving.
This paper discusses semi-autonomous driving technology from the perspective of trajectory planning. A lot of research has been done on trajectory planning for automated driving. Some approaches focus on computing collision-free trajectories using graph-search methods, such as A* [15], Hybrid A* [16], D* [17], and state-lattice [18]. A disadvantage of graph-search methods is that their results are related to the degree of discretization of sampling points or primitives. If the discretization is not fine enough, the method may not find a feasible path. Aiming at solving the above problem, incremental search methods are proposed, such as Expansive Spaces Tree (EST) [19], Rapidly-exploring Random Trees (RRT) [20], and Stable Sparse Trees (SST) [21]. If there exists a path and given enough time, the incremental search methods will find a feasible path. The graph-search methods and the incremental search methods are suitable for generating paths in an unknown static environment. They usually require too many computing resources, making them unable to react quickly in dynamic scenarios. The numerical optimization methods are often used to obtain smooth trajectories by minimizing or maximizing a cost function. In the artificial potential field methods, obstacles are assigned repulsive forces and the target zone is assigned attractive forces so that the vehicle can drive towards the goal zone while keeping away from the obstacles [22]. The trajectory with the deepest gradient can be chosen as the optimal result. Whereas, the artificial potential field methods face the problem of falling into local minima. Additionally, it is hard to reflect the non-holonomic characteristic of the vehicle. In order to overcome the disadvantages, there are some studies using sampling-based trajectory generation methods, such as polynomial spline [23][24][25]. The polynomial methods can generate paths with curvature bound constraints, and obtain suboptimal solutions in the discrete solution space considering the distance to obstacles and the costs of vehicle movement. One of the advantages of the polynomial methods is that the computational cost is relatively small, and the convergence can be guaranteed.
In this paper, we study the situation where the system detects a dangerous situation and assists the driver in avoiding collisions with detected obstacles. In order to reduce the system's intervention during normal driving, the system enters the semi-autonomous driving mode only when the system detects a dangerous situation. In order to solve the problem of the fusion of driver's input and machine's input at the decision level and the operational level, a human-machine collaborative trajectory planning algorithm is proposed that combines the driving behavior and the comprehensive information of the human, vehicle, and road. We adopted the hierarchical planning approach to construct our cooperative trajectory planner. The semi-autonomous driving system respects the driver's driving behavior at the decision level and driver's input at the operational level while planning the trajectory. The framework of the proposed approach is shown in Figure 1. The main contribution of this paper is that the proposed algorithm can perform trajectory planning in a human-machine collaborative manner while respecting the behavioral semantics and the input of the driver. The system interacts with the driver at both the decision level and the trajectory generation level. In addition, the proposed cooperative trajectory planning algorithm can generate trajectories for each specific driving maneuver. The computational cost can be reduced by generating fewer trajectories.
The remainder of this paper is organized as follows. Aiming at reducing conflicts between the driver and the semi-autonomous driving system, the algorithm reasons about the behavioral semantics of the current situation in Section 2. Then the algorithm makes collision avoidance decisions according to the behavioral semantic of the driver in Section 3. In Section 4, the human-machine cooperative trajectory planning algorithm considering the driver's input is proposed. Section 5 shows the experiment results. Conclusions are drawn in Section 6.

Behavioral Semantic Understanding
The rider-horse metaphor (or H-metaphor) describes a symbiotic system, in which the rider controls the horse through a combination of continuous and discrete inputs from the hand to the rein. The horse can understand human intentions through the reins, and the rider can understand the horse's intentions from the environment and the state of motion [26]. The horse strives to reduce the human's riding burdens according to the human's intentions. Similarly, the intelligent assistance system and the human are two dependent agents in a symbiotic system. The intelligent assistance system should understand the driver's behavioral semantic to resolve the conflicts between human and machine, and strive to fulfil the driver's intention if the intention is safe.
Driving maneuvering is very much dependent on its context. Each series of actions that a driver can take corresponds to a maneuver, such as lane-keeping, a lane-change, a left turn, or a right turn. Most current papers about semi-autonomous driving track a given path, and the input of the driver is treated as a disturbance, and the machine compensates for the driver's input. In order to achieve flexible interactions between people and machines, the human-machine co-driving system should have the ability to reason about vehicle movement trends based on behavioral semantics to identify whether the driving behavior is safe or not. The driver can inform the intelligent driving system of lane-changing intentions through the turning signal. Otherwise, the assistance system can understand the behavioral semantics of the driver according to the driver's driving operation, environment, and vehicle status.
In this paper, we propose a method for understanding the driver's behavior at the semantic level according to the operation command of the driver and the environmental information. The framework for the behavioral semantic understanding algorithm is shown in Figure 2.  There are three main steps for determining the driver's most likely behavioral semantics. Firstly, the virtual trajectories corresponding to specific semantic behaviors are generated. According to the traffic scenario, the vehicle movement is decomposed into lateral movement and longitudinal movement in the Frenét-Frame.
Secondly, according to the driver's input, the short-term trajectory is obtained using the constant turn rate and acceleration (CTRA) kinematics motion model.
Finally, the driver's most likely behavioral semantics is obtained by computing the similarity between the virtual trajectories of different behavioral semantics and the predicted trajectory.
The virtual long-term trajectory of candidate driving behaviors and the short-term predicted trajectory are shown in Figure 3. The trajectory τ long is long-term trajectory of a candidate driving behavior. The trajectory τ short is the short-term predicted trajectory.

The Virtual Long-Term Trajectories of Candidate Driving Maneuvers
In this paper, in order to reason about the behavioral semantics, the long-term trajectories representing candidate driving maneuvers are generated. An evasive motion model is used in which the lateral acceleration is assumed to be a sinusoidal function of time.
where a lat is the lateral acceleration in the Frenét-Frame, H is the total lateral distance to complete lane-change process in the Frenét-Frame, t lat is the total lateral motion time, y start is the initial lateral position before the lateral motion, and y target is the terminal lateral position, as shown in Figure 4. Given the maximum lateral acceleration a max ,lat and the total lateral distance H, the total lateral motion time t lat moving from y 0 to y target can be obtained.    The vehicle is assumed to move longitudinally with a constant acceleration.
Thus, the heading angle during the process of lateral motion can be obtained.
In order to generate the virtual lateral trajectories representing the corresponding behavioral semantics, it is necessary to find the appropriate target lateral position. In structured roads, the target lateral position can be selected based on the positions of obstacles and the centerline of the target lane. On an unstructured road, the appropriate target lateral position can be selected based on the positions of obstacles and the reference path provided by the global path planner. The minimum distance between the target lateral position and the boundary of obstacles is y. According to the relationship between the heading angle of the vehicle in the Frenét-Frame and the target lateral position, there are two cases, the details are as follows.
(1) If the heading angle in the Frenét-Frame is consistent with the direction of the target lateral position, as shown in Figure 3b, the long-term virtual trajectory for the left-side evasive maneuver can be obtained by utilizing the evasive motion model. Assuming that the vehicle follows the evasive motion model in Equation (1) and the current heading angle is ϕ, the time t ϕ required since the vehicle initiates lateral motion can be derived. If a lateral terminal position y target and current lateral terminal position y current in the Frenét-Frame are determined, y 0 and t ϕ can be obtained by sampling the y 0 and comparing y(t ϕ ) with y current .
The total lateral motion time t lat,le f t is obtained after y 0 is determined. Assuming that the evasive motion during [t ϕ , t lat,le f t ] follows the evasive motion model, the remaining trajectory from the current state to the target lateral position can be obtained as shown in Figure 3b. The remaining time t arrive,le f t to arrive at the target lateral position is defined as follows.
(2) If the heading angle in the Frenét-Frame is inconsistent with the direction of the target lateral position, the long-term virtual trajectory for the right-side evasive maneuver can be obtained as shown in Figure 3c. The virtual trajectory is divided into two parts. In the first part, the vehicle adjusts its heading angle to be parallel to the reference line. The lateral motion time for the first part is t adj . The vehicle is assumed to move at constant lateral acceleration a lat,adj during [0, t adj ]. In the second part, the trajectory obeys the evasive motion model. The lateral motion time for the second part is t lat,right . The remaining time t arrive,right to arrive at the right-side target lateral position is as follows.

Short-Term Motion Trajectory Prediction Based on Motion Model
Schubert R. et al. [27,28] compared different motion models and reached the conclusion that the CTRA model provides better performance than the constant turn rate and velocity (CTRV), the constant velocity (CV) and the constant acceleration (CA) models for short-term trajectory prediction. Utilizing the CTRA model, the velocity v x (t) and v y (t) can be derived based on the velocity and yaw angle [29].
where v(t) is the velocity at time t, a 0 is the current acceleration, v 0 is the current speed, ω 0 is the current yaw rate, and ϕ 0 is the current heading angle.
κ 0 is the current path curvature. Therefore, x(t) and y(t) can be obtained.

The Most Likely Behavioral Semantics
This paper compares the similarity of two trajectories by calculating the distance between them. This paper compares the similarity of two trajectories by calculating the distance between them. the nearest N sampling points are used to calculate the results. The similarity of the trajectories is compared by calculating the weighted average distance.
where D i is the distance of two points at the same prediction time, w i is the coefficients. In order to prevent the uncertainty and interference in the measurement, a larger weight w i is set for the closer pair of points. A smaller distance between trajectories means that the trajectories are more similar and the driver is more likely to choose the semantic behavior. If the distance between the short-term predicted trajectory and the virtual long-term trajectory is below a threshold, the vehicle is considered to be driving in the corresponding driving maneuver.

Interactive Decision Making
According to the driver's behavioral semantics, the system needs to determine whether the vehicle is in a safe driving area. If the state is safe, and there is still a certain safety margin for the driver, there should be no intervention. Otherwise, if the safety margin is reduced to a certain degree, the machine will intervene and the system will enter the semiautonomous driving mode. The system should respect the driver's behavioral semantics, and generate trajectories according to the driver's current behavioral semantics if there still exists a safety margin.

The Driving Envelope for Candidate Driving Behaviors
For the obstacle avoidance scenario as shown in Figure 5, given the minimum lateral distance to the obstacle, the algorithm judges whether there is a feasible obstacle avoidance evasive corridor by searching the lateral non-obstacle position on both sides of the obstacle. If there is a feasible lateral evasive corridor, the lateral position with a suitable distance from the obstacle is selected as the innermost lateral target position, and the lateral position with a suitable distance from the boundary of road is selected as the outermost lateral target position. After the lateral target positions on both sides are selected, different levels of safety driving envelope for obstacle avoidance behavior are generated to identify the safety level of the current situation.
In this paper, the driving envelope for each driving maneuver is generated in the Frenét-Frame, as is shown in Figure 5. The τ outside is the boundary trajectory, which takes the outermost lateral safe position as the target lateral position.
Trajectory τ 1 keeps a safe distance from the front obstacle. Taking the innermost lateral safe position as the target lateral position, τ 1 is the trajectory that longitudinally moves at a constant speed, and laterally follows the evasive motion model. If the τ 1 for the left and the right evasive maneuvers exist and do not collide with τ outside , then the evasive maneuvers are safe for the driver. The driver can avoid a collision from both the left-side and the right-side without braking. Warnings should not be provided in this situation.
Trajectory τ 2 is a critical trajectory with a constant longitudinal speed that will not collide with the obstacle. Taking the innermost lateral safe position as the target lateral position, τ 2 is the trajectory that longitudinally moves at a constant speed, and laterally follows the evasive motion model. If the trajectories τ 2 for one side cannot be generated because the safe distance for τ 2 is not satisfied, or the τ outside of that side collides with τ 2 , the vehicle can perform evasive behavior from that side by steering combined with braking. Then the vehicle's evasive behavior for that side is in the level one warning zone.
Trajectory τ 3 is a critical trajectory with a defined maximum deceleration that will not collide with the obstacle. Taking the innermost lateral safe position as the target lateral position, τ 3 is the trajectory that longitudinally decelerates at maximum constant deceleration a lonmax , and laterally follows the evasive motion model. If the trajectories τ 3 for one side cannot be generated because of the safe distance for τ 3 not being satisfied, or the τ outside of that side collides with τ 3 , then the vehicle's evasive behavior for that side is not safe. Then the vehicle's evasive behavior for that side is in the level two warning zone. τoutside τ1 τ2 τ3

Timing for Intervention
Based on the driving envelope of candidate driving maneuvers and the understanding of behavioral semantics, the system can judge the safety level of the driver's maneuver at the decision level. The system can provide corresponding assistance to the driver. It is important to find the proper timing for providing assistance. If the system intervenes too early, it will interfere with the normal driving experience. If the intervention is too late, the system may miss the opportunity to avoid obstacles safely. It is necessary to ensure the existence of feasible obstacle avoidance trajectories during the intervention process. At the same time, it is necessary to minimize unnecessary interference with the driver.
In this paper, we determine the timing for intervention by calculating the probability of violating the driving envelope. There is a certain degree of uncertainty in the driver's operation. When using the CTRA model, the uncertainty can be represented by a probability model, and the possible positions of each time step can be obtained. In [30], the vehicle was assumed to move according to a predefined motion model that considers uncertainty. The intervention timing was determined by the collision probability with traffic participants. In this paper, intervention timing is determined by calculating the probability of violating the safe driving envelope. When the probability of violating the safe driving envelope reaches a threshold, the system can provide a safety warning and intervention. This proposed method can guarantee that the collision avoidance trajectories exist when the system provides assistance.
The state of the vehicle is defined as X = [x, y, θ, v, a, ω] T , where (x, y) stands for the vehicle position, θ stands for the yaw angle, v stands for the vehicle velocity, a represents the acceleration, and ω represents the yaw rate. The state vector of the vehicle at k + 1(k = 0, 1, 2, ...) is X(k + 1). The nonlinear motion model is described in Equation (11).
where T is the sampling period. The process noise vector W(k) corresponds to a zero-mean white Gaussian noise, representing noises in acceleration and yaw rate. The relationship between the noise vector and the covariance matrix is E[WW T ] = Q. The covariance matrix Q = diag(0; 0; 0; 0; σ 2 a ; σ 2 ω ). ∆x(k) and ∆y(k) are defined as follows.
Given the vehicle state and the covariance within a predefined prediction horizon, we randomly generate N particles for each future time step. For example, the prediction results at the future time steps of 0.5 s, 1 s, 1.5 s, and 2 s are shown in Figure 6. For each particle, we check if the particle is outside of the driving envelope of different safety levels, as shown in Figure 7. The more particles outside the driving envelope, the greater the probability of violating the driving envelope. The probability of violating the driving envelope is defined as follows.
where N outside denotes the number of particles outside of the driving envelope.
In order to reduce the computational cost of computing the probability of violating the driving envelope, we compute the predicted position (x T , y T ) at the predefined time T without considering the uncertainty at first. If the position (x T , y T ) is near enough to the boundary of driving envelope, then we generate the particles and compute the probability.
If the probability of violating the driving envelope of a specific safety level reaches a certain threshold, the system can provide the corresponding assistance to the driving, such as warning or intervention. For example, the generated particles at the future time step of 1.5 s are shown in Figure 7. If the p outside of outside the trajectory τ 2 is beyond a threshold, the system can provide a safety warning. If the p outside of outside the trajectory τ 3 is beyond a threshold, the system can provide intervention. τoutside τ1 τ2 τ3 Figure 7. The probability of violating the driving envelope.

Evaluation of Driving Behaviors
For obstacle avoidance behavior, the safety of driving behaviors can be obtained according to the driving envelope. If the current driving behavior is unsafe, the algorithm can choose a safe driving behavior through behavioral decision-making. Besides, a cost function is designed to evaluate the quality of driving behaviors. The collision avoidance scenario is shown in Figure 8. The designed cost function for evaluating the evasive maneuver is as follows. In this cost function, the evasive behavior of steering combined with braking is considered.
where t arrive is the time to arrive at the safe target lateral position next to the obstacle, which is defined in Equations (6) and (7), and a req,ev is the minimum required deceleration to ensure that no collision occurs. The designed cost function for stopping to avoid collision is as follows.
where a req,br is the minimum required deceleration to ensure that no collision occurs.

Human-Machine Cooperative Trajectory Planning
There are three main objectives for human-machine cooperative trajectory planning. The first one is that the behavior of the machine should satisfy the driver's intentions as much as possible. The second one is ensuring the least modifications to the driver's intentions, and only intervening when necessary. Third, driving comfort and safety need to be ensured.
Most of the existing semi-autonomous driving systems use the model predictive control algorithm, which needs precise vehicle model parameters, including tire parameters, body mass, friction coefficient, etc. In [31], data-driven adaptive dynamic programming and an iterative learning scheme were adopted for learning the control law of semi-autonomous driving for lane keeping. In references [32,33], the authors put forward a Takagi-Sugeno fuzzy model-based shared control method for lane-keeping assistance systems. In reference [34], the system intervened when the vehicle deviated from the reference path by a certain distance, or the steering angle deviated from the reference steering angle to a certain degree. Given a predefined path, the output was obtained by solving the control optimization problem. In this paper, semi-autonomous driving is realized from the perspective of trajectory planning. The vehicle does not need to follow a predefined target path. The system can analyze the safety of candidate driving maneuvers using the proposed method in Section 3, and plan a safe trajectory. The trajectory is generated according to the driver's behavioral semantics at the decision level, and according to the driver's input at the operational level.
In [35,36], an approach that provides a flexible way to allocate authority for semiautonomous driving is proposed. The paper focuses on the situations wherein the vehicle is always in the semi-autonomous driving mode: the driver performs the evasive maneuver to avoid collisions when the obstacles are undetected by the system. At the trajectory generation level, the machine generates trajectories using polynomials and evaluates the trajectories according to the driver's input. Compared with the previous literature about semi-autonomous driving, this paper does not set a fixed path for the vehicle to follow, and the weight of the human-machine control authority is not fixed. Differently from the semi-autonomous driving approach proposed in [35,36], in this paper, we study the situations where the obstacles are detected by the system, and the system assists the driver to avoid collisions. The conditions for initiating the intervention are introduced in Section 3. The system enters the semi-autonomous driving mode only when the system detects a dangerous situation, so that the frequency of interventions can be reduced during normal driving situations. In addition, this paper considers more constraints than the method proposed in [35,36].
In this paper, the trajectory planning problem is decomposed into high-level behavioral decision-making problems and low-level trajectory planning problems within the safe boundaries. The trajectory algorithm in this paper generates safe motion boundaries for different behaviors and decomposes the trajectory planning problem into sub-problems of trajectory planning within the safety boundaries corresponding to different behaviors.

Generation of Candidate Trajectories
The polynomial methods can generate trajectories with curvature-bound constraints, and obtain a suboptimal solution in the discrete solution space considering the distance to obstacles and the costs of vehicle movement [37,38]. In this paper, we generate the candidate trajectories according to the driver's behavioral semantics if they are judged safe. The fifth-order polynomial in the Frenét-Frame is used to represent the lateral and longitudinal motion.
The coefficients of the quintic polynomial are calculated based on the initial and the terminal states, including the values of position, velocity, and acceleration. Assuming that the initial lateral state is d 0ḋ0d0 , and the terminal lateral state is d TḋTdT , the following matrix can be obtained.
By substituting t 0 = 0 and the time T into the equation, the coefficients can be obtained as follows.
After reaching the target lateral position, the lateral velocity and lateral acceleration are both zero. The terminal state is [d T 0 0]. In order to ensure that the lateral movement is safe and comfortable, the lateral acceleration needs to be within a certain range. |d| a latmax . The lateral motion components of the trajectory can be generated by sampling the time. Similarly, the coefficients for longitudinal motion can be obtained.
In order to keep most of the trajectories within the safety boundary to reduce the time for collision checking, the evasive motion model in Section 2.1 is used to guide the selection of parameters for generating trajectories. The time t arrive to arrive at the target lateral position from the current lateral position can be obtained using the evasive motion model, as introduced in Equations (6) and (7). The time t bound for the longitudinal motion to reach the boundary of the driving envelope can be obtained, as shown in Figure 9. The approximate total time T is in the following range.
where E is a constant for adjusting the total time T.
tarrive τevasive tbound Figure 9. The total time T for trajectory generation.

Evaluation of Candidate Trajectories
The driver's driving intentions need to be respected for semi-autonomous driving. In this paper, the trajectories are planned on the basis of understanding the driver's behavioral semantics to obtain the corresponding human-machine cooperative driving trajectory.A cost function is designed to evaluate the trajectory so that the path keeps a safe distance from obstacles while keeping close to the predicted vehicle trajectory under the current steering angle. After obtaining a series of candidate trajectories, the trajectory with the lowest cost is selected. Finally, a trajectory is obtained which avoids collisions with obstacles while respecting the semantics of driving behavior.
In [35,36], the machine predicted the driver's target lateral position; the trajectories were evaluated according to the deviation between the chosen target lateral position and the predicted target lateral position. However, when the driver makes mistakes, the predicted target lateral position according to the driver's input may not be safe. Since the penalty for avoiding obstacles is not added in the proposed method, the system will not assist the driver in avoiding collisions with detected obstacles using the proposed trajectory evaluation cost function. In this paper, we assume that the obstacles are detected. In this paper, we only generate and evaluate trajectories for the safe target lateral positions. The way of considering the driver's input is also different. The path which is more similar to the predicted path according to the driver's input is given a smaller penalty so that sudden changes of the steering wheel will be reduced during the intervention process, and the chosen trajectory will be closer to the driver's intention.

The Cost of the Road Boundary
The motivation for the road boundary cost is to prevent vehicles from crossing the road boundary. Drivers are usually expected to drive near the centerline of the lane. The driver may deviate from the centerline of the lane in the process of driving. In order to prevent frequent interventions in a safe situation, the lateral position of the target is allowed to deviate from the centerline of the road by a certain distance. The following cost function is designed for the road boundary.
J rb = c rb l target − l center 2 |l target − l center | > l thresh 0 |l target − l center | l thresh (19) where l target indicates the target lateral position of the trajectory and l center is the lateral position of the centerline. An example of the cost of the road boundary is shown in Figure 10.

The Cost of Longitudinal Motion Smoothness
Vehicle motion is affected by tire friction, road conditions, vehicle inertia, engine power, etc., so longitudinal acceleration and deceleration are limited. Sudden changes in acceleration can lead to tire wear and fuel waste, and cause an uncomfortable driving experience. In order to make the velocity and acceleration change smoothly, and make the longitudinal velocity of each point be close to the reference velocity, the cost of longitudinal motion was designed to be as follows.
where ... s (t) represents the acceleration of longitudinal motion,ṡ(t) represents the longitudinal velocity of each point,ṡ f (t) represents the reference longitudinal velocity of each point, and c js and c vs are the weighting coefficients.

The Cost of Lateral Motion Smoothness
Excessive lateral acceleration can cause sudden changes in steering, which can cause an uncomfortable experience. The acceleration and speed of the lateral movement of the vehicle should change smoothly. The cost of lateral motion is designed as follows.
where ... d( t) represents lateral jerk and c d is the weighting coefficient for lateral motion smoothness.

The Cost of Stability
In order to prevent the vehicle from swinging, the cost of stability is added. The higher the similarity between the selected path for this frame and the previous frame, the more stable the path will be. In order to avoid an excessive difference between the selected paths in two adjacent frames, a cost is added for evaluating the similarity between the candidate paths and the path selected in the previous frame.
where α prev ∈ (0, 1) is the attenuation coefficient that increases with the path length, which is used to reduce the influence of farther waypoints on the stability cost; c prev is the weighting coefficient. As the distance between the waypoint and the current vehicle position increases, the influence of the waypoint is smaller. I c is the number of waypoints considered, p k,i is the ith waypoint on the candidate trajectory τ k , τ prev is the selected trajectory in the previous frame, and dist p k,i , τ pre represents the distance from p k,i to τ prev . Frequent changes in the selected target lateral position will affect the stability of the vehicle. A penalty for the selected target lateral position is designed to improve the stability. The distance between the selected target lateral position and the current lateral position should not be too large.
J target = c di f (y pre,lat − y target,lat ) 2 + c targlat y 2 target,lat (23) where |y pre,lat − y target,lat | is the distance between the target lateral position in this frame and the previous frame; y target,lat is the selected lateral position in this frame; c di f and c targlat are weighting coefficients for lateral target position.

The Cost of Similarity to Driving Intentions
The motivation of this cost is to fuse the driver's input in trajectory planning. If the vehicle is in semi-autonomous driving mode, the driver and the machine have control authority at the same time. In order to make the final trajectory closer to the driving intention at the operation level, a trajectory closer to the predicted trajectory based on the driver's input will be assigned a smaller penalty. The candidate trajectories and the trajectory predicted according to the driver's operation are shown in Figure 11. The similarity cost reflects the similarity of the candidate trajectories to the trajectory predicted according to the driver's operation.
where α intention ∈ (0, 1) is the attenuation coefficient which increases with the path length, I c is the number of waypoints considered, p k,i is the ith waypoint on the candidate trajectory τ k , τ pred is the predicted trajectory of the vehicle based on the driver's manipulation, and dist p k,i , τ pre represents the distance from p k,i to τ pred .
Short-term predicted trajectory Candidate trajectories Figure 11. The candidate trajectories and the short-term predicted trajectory.

The Cost of Non-Crossable Obstacles
The cost of obstacles can keep the vehicle away from the obstacles, which cannot be crossed, such as pedestrians and parked vehicles. Collision with such non-crossable obstacles should be avoided.
where c shape is a coefficient that influences the shape of the potential field of a non-crossable obstacle; d sta i is the distance from the waypoint to the static obstacle. The distance to the non-crossable obstacle can be obtained from the dist map. The three-dimensional graphical representation of the function defined in Equation (25) is illustrated in Figure 12.

The Total Cost
To select the optimal trajectory among the candidate trajectories, the above evaluation indicators are weighted and summed, and the cost of each candidate trajectory can be obtained as follows.
The choice of coefficients is a multi-objective optimization problem. In this paper, we tune the feasible choice for the coefficients until the balance of multiple goals is reached. For example, if there is a significant jump in the target lateral position, we increase the coefficient of stability cost to obtain a more stable path. If the trajectory is too close to the obstacle, we adjust the obstacle-related coefficient c sta i and c shape to keep the vehicle far away from the obstacles. At last, the trajectory τ k * with the lowest cost is selected from the candidate trajectories set for the specific behavior.

Experiments and Discussions
The experimental platform modified by the Red Flag EHS3 was used to test the proposed algorithm. A human drove the vehicle at about 20 km/h, and a dummy was placed in front of the vehicle. The experimental scenario is shown in Figure 13. The semiautonomous system judged the behavioral semantics of the driver, and provided warnings and interventions when it was necessary. In order to resolve the conflict between the driver and the machine, the system needed to reason about the behavioral semantics of the driver. The long-term virtual trajectories of the candidate evasive maneuvers and the short-term predicted trajectory are shown in Figure 14.  The map in Figure 14 was generated based on the Lidar point cloud. As shown in Figure 14a, the dummy was about 25 m ahead. The gray parts in the pictures represent obstacles; the black part represents the non-obstacle area. A reference path is provided to clarify the direction of the road, shown as the blue line. The driver had three candidate maneuvers according to the environment, namely, a left evasive maneuver, a braking maneuver, a right evasive maneuver. The yellow lines represent the long-term virtual trajectories of evasive maneuver from the left-side and right-side of the dummy. The light green line represents the short-term predicted trajectory based on the CTRA motion model according to the current vehicle state.
The similarities between the short-term predicted trajectory and the three candidate maneuvers can be reflected by the distances between them, which are shown in Figure 15. As is shown in Figure 15, after 3 s, the distance of the left evasive maneuver was smaller, which is in line with the actual left-side evasive maneuver.
Left evasive maneuver Brake Right evasive maneuver The costs for the left evasive maneuver and the right evasive maneuver are shown in Figure 16. After 5 s, the steering wheel was continuously turned to the left, the cost of avoiding obstacles on the left side gradually decreased, and the cost of avoiding obstacles on the right side gradually increased. The driving envelopes of different safety levels are shown in Figure 17. The red lines represent the critical trajectory with the deceleration of −2 m/s 2 that will not collide with the obstacle, corresponding to the boundary trajectory τ 3 in Figure 5. The yellow lines represent the boundary trajectory which takes the outermost lateral safe position as the target lateral position, corresponding to the boundary trajectory τ outside in Figure 5. The orange lines represent the critical trajectory with constant longitudinal speed that will not collide with the obstacle, corresponding to the boundary trajectory τ 2 in Figure 5.  The system can judge the safety of evasive maneuver from the left corridor using the method proposed in Section 3. As is shown in Figure 17a, the boundary trajectory τ 2 of safety level 2 for both sides existed; the evasive behavior for both sides could be achieved by steering. As is shown in Figure 17b, the boundary trajectory τ 2 of safety level 2 for the right side did not exist; the boundary trajectory τ 3 of safety level 3 for the right side existed; the right evasive behavior could be achieved by steering combined with braking, and for the left side, the collision could be avoided just by steering. At 3.2 s, as shown in Figure 15, the distance between the predicted path using CTRA model and the evasive path from the left side was smaller than that of the right side. The probability of driving from the left side was higher than that from the right side. When the probability of violating the boundary of left safety level 2 reached the predetermined threshold, the system provided a safety warning to the driver. As is shown in Figure 17c, the boundary trajectory τ 2 of safety level 2 for both sides did not exist; the boundary trajectory τ 3 of safety level 3 for both sides existed; the vehicle needed to slow down and steer to avoid collisions from both sides. As shown in Figure 17d, the boundary trajectory τ 3 of safety level 3 for the right evasive behavior did not exist; it was not safe to choose the right side to avoid the collision at the deceleration of −2 m/s 2 . The boundary trajectory τ 3 of safety level 3 for the left evasive behavior existed; it was safe to choose the left side to avoid the collision by braking combined with steering.
Considering the prediction results of the driver's behavioral semantics, the system can infer that the driver is driving from the left side of the obstacle. When the probability of violating the left level 3 driving envelope reached the predefined threshold, the system started to intervene. At 4.5 s, the generated candidate trajectories from the left side of the obstacle are shown in Figure 18a. The final selected trajectory for the left side considering the input of the driver is shown in Figure 18b.  The proposed human-machine cooperative trajectory generation method can generate the trajectories according to the driver's behavioral semantics. If the driver's behavior semantics are not considered, and the trajectories are generated in the entire available state space, the computational burden will increase. The candidate and selected trajectories for the both candidate driving maneuvers are shown in Figure 19. Since the number of the generated trajectories was more than that of the trajectories according to the driver's behavioral semantics, the computational time was longer. The code was implemented in C++ using an Intel I7-3520 CPU running at 3.4 GHz. The average total time for generating the trajectories for the both sides for the situation in Figure 19 was about 46 ms. The average total time for generating the trajectories for only the left side for the situation in Figure 19 was about 25 ms. The driving envelope introduced in Section 3 was used to judge the safety level of the driver's behavioral semantics. If the state was safe, the system did not intervene. The system can generate trajectories only after a safety warning is issued and the driver does not take any corrective measures, thereby further reducing the computational burden.  The experimental results are shown in Figure 20. The machine issued a warning at 3.2 s, when the vehicle speed was 19.5 km/h. After the warning was issued, if the driver did not take corrective action, the steering angle was insufficient for collision avoidance. The machine started a steering intervention and speed intervention at 4.3 s. The machine ended its intervention at 9.3 s, at which time the vehicle reached a safe state, and the heading angle of the vehicle was consistent with the direction of the reference path. The interface of the human-machine cooperative trajectory planning program is shown in Figure 21. The interface when the system provides safety warning is shown in Figure 21a, the interface when the semi-autonomous system intervenes is shown in Figure 21b.
Seven drivers were invited to take the same evasive tests. The subjects were between 26 and 45 years old. The dummy was about 40 m ahead, and the vehicle's speed was about 20 km/h. The initial lateral positions and heading angles were slightly different for each test. The experimental results of evasive action from the left side are shown in Figure 22. The experimental results of evasive action from the right side are shown in Figure 23. In order to make the picture clearer, the time axis of each set of data was shifted. The timings of providing warnings for each test were shifted to the same time.
(a) The interface when the system provides safety warning.
(b) The interface when the system enters co-driving mode.   In Figures 22 and 23, the blue vertical dashed line indicates the moment when the warning was issued; the red vertical dashed line indicates the moment when the intervention was provided; the green vertical dashed line indicates the moment when the intervention was over. The experiment results show that when the vehicle is close to an obstacle and the steering angle is insufficient, the system can provide safety warnings and interventions to successfully help the driver avoid a collision with an obstacle.
The proposed method generates trajectories based on the driver's behavioral semantics. The stability of the proposed method can be guaranteed at the decision level. Once the driver's behavioral semantics are determined, the system can judge the safety level of the corresponding driving behavior, and generate safe trajectories for the driving behavior. If the vehicle drives straightly toward the obstacle, the system will evaluate the candidate's driving behaviors using the method in Sections 3.2 and 3.3. A safe driving behavior will be selected as the final decision result. The system tends to plan trajectories according to the driver's behavioral semantics. If the driver's behavioral semantics are not safe, the system can choose another safe driving behavior.
The proposed algorithm can provide safety warnings and interventions when the obstacle is correctly detected and the situation is judged as dangerous. The system intervenes by adding torque to the steering wheel and applying braking force to the brake pedal. If the sensor fails to detect the obstacle, the semi-autonomous driving system will not provide assistance to the driver. If the sensors detect false obstacles, and initiate interventions, the driver can exit the semi-autonomous driving mode. In the test vehicle, the driver could exit the semi-autonomous driving mode by pressing a button. If the driver's toque on the steering wheel reaches a predefined threshold, the system can also exit the semi-autonomous driving mode.
Since the driver is in the loop, the driver may change the input during the humanmachine interaction period. When the system detects that the driver's toque is greater than zero, then the trajectory should be regenerated for each time period. Otherwise, if the driver's torque is zero, the system will check whether the previously generated trajectory is safe. If the previous trajectory is safe, the vehicle can follow the previous planned trajectory.

Conclusions
In this paper, a novel human-machine cooperative trajectory planning algorithm for semi-autonomous driving was proposed. The proposed algorithm comprehensively considers the safe motion boundary constraints, driving behavioral semantics, vehicle safety limits, comfort, etc. The trajectory planning algorithm is able to obtain a trajectory that avoids collisions with dynamic obstacles while respecting the driver's behavioral semantics at the decision level. A designed cost function is used to select a path that is close to the predicted vehicle trajectory according to the control input of the driver at the operation level. The feasibility of the proposed algorithm was validated by real vehicle experiments. The experimental results show that the proposed semi-autonomous system can issue safety warnings to the driver, and provide steering and speed interventions to successfully help the driver avoid collisions.
In this paper, the safety-related parameters in the experiments were set to be the same for different drivers. Each driver's driving ability and driving habits were different. The maximum lateral acceleration, maximum deceleration, and reaction time vary for each driver, which will influence the timing for providing safety warnings and trajectory planning. In the future, we will continue to study the methods to extract the personal features to improve the performance of the system.