{'fraction_non_alphanumeric': 0.03329820864067439, 'fraction_numerical': 0.0073059360730593605, 'mean_word_length': 4.6012197521148925, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Multistage Stochastic Model Predictive Control for Urban Automated Driving

Trajectory planning in urban automated driving is challenging because of the high uncertainty resulting from the unknown future motion of other traffic participants. Robust approaches guarantee safety, but tend to result in overly conservative motion planning. Hence, we propose to use Stochastic Model Predictive Control for vehicle control in urban driving, allowing to efficiently plan the vehicle trajectory, while maintaining the risk probability sufficiently low. For motion optimization, we propose to use a two-stage hierarchical structure that plans the trajectory and the maneuver separately. A high-level layer takes advantage of a long prediction horizon and of an abstract model to plan the optimal maneuver, and a lower level is in charge of executing the selected maneuver by properly planning the vehicle's trajectory. Numerical simulations are included, showing the potential of our proposal.


I. INTRODUCTION
This work has been accepted to the IEEE 2021 International Conference on Intelligent Transportation Systems. The published version may be found at https://doi.org/10.1109/ITSC48978.2021.9564572.
Compared to automated highway driving, autonomous driving in urban scenarios presents several new challenges. The urban framework is populated by many traffic participants like cars, cyclists, and pedestrians, showing extremely different behaviours, and generating large uncertainty. Complexity arises also due to the fact that various different maneuvers are possible, depending on the traffic conditions and rules, and on the road geometry. Furthermore, in contrast to the highway framework, maneuver switches appear more frequently, to adapt the driving to the changing environment.
In order to deal with the challenges of the urban environment, learning-based methods are appealing [1]. They allow for a flexible motion, able to handle several possible configurations with no need for rigidly defined switching rules, which is extremely convenient to face complex situations typical for the European urban road environment [2]. Yet, safety is hardly provable, requiring additional structures [3], which increase the complexity of those algorithms.
Alternatively, Stochastic Model Predictive Control (SMPC) represents an attractive option to cope with the urban driving complexity. Model Predictive Control (MPC) computes a sequence of inputs minimizing a cost function over a finite prediction horizon, guaranteeing the satisfaction of a set of constraints. Only the first input of the sequence is applied, and, as soon as a new state measurement is available, the optimal control problem is solved again in a receding horizon manner. The possibility to reward control goals (through the design of the cost function) and to express necessary requirements (constraints) makes MPC T suitable for the autonomous driving application [4]. To cope with uncertainties, Robust MPC (RMPC) considers a worst-case scenario, ensuring a safe motion for each possible circumstance. In [5] safe corridors are derived, where the autonomous vehicle can drive ensuring collision avoidance for any realization of the other vehicles' motion. Still, this method is likely to result in an excessively cautious controller producing unnaturally conservative behaviors, up to the point that under particular conditions the automated vehicle can not take action at all, as briefly discussed in [6].
Differently from RMPC, in SMPC safety constraints are designed in a probabilistic fashion, and the resulting control action must guarantee that the probability of constraint violation is lower than a user-defined risk parameter. This formulation makes SMPC particularly well suited to deal with the uncertain urban framework, since the choice of the acceptable risk level allows to balance the trade-off between safety and efficiency. SMPC is widely used for autonomous driving in highway-like scenarios [7], [8], [9], but little attention is dedicated to the typical urban framework, where stops are required to avoid collisions with crossing pedestrians or upcoming vehicles at intersections.
Moreover, it is beneficial to take a long prediction horizon into account, allowing to reveal superior maneuver choices, which would prove to be efficient in the long run. Yet, a detailed model is not necessarily useful to optimally plan long-term maneuvers, and a simplified one, considering the dominant dynamics only, may suffice. Additionally, due to the accumulated action of uncertainty, it is not reasonable to rely on detailed prediction models for long-term predictions. In [10], [11] a detailed model is used for short-term predictions, and a simplified one for long-term predictions. Furthermore, a long prediction horizon causes a computational burden difficult to cope with in a quick real-time computation. Move blocking approaches [12] and non-uniformly spaced horizon techniques [13] are proposed to tackle the computational burden resulting from a long horizon. However, these methods do not allow to explicitly distinguish between short-term and long-term actions, solving both at once. This is not ideal for autonomous urban driving, where we can differentiate between trajectory planning, concerning low-level control actions (instant acceleration, steering angle) to drive the vehicle in the short term, and maneuver planning, focusing on more high-level actions (cruise speed planning, lane changing) to be determined considering a longer horizon. It is convenient to deal with maneuver planning and trajectory planning separately, since they have different time scales, and need to be updated with different frequency.
In order to separate the maneuver and trajectory planning, a hierarchical MPC approach is well suited. This technique is extensively employed to handle systems with multiple time scales [14]. The usage of hierarchical structures in the framework of autonomous driving has already been proposed [15], [16]. In [17] a high-level layer is used to select discrete maneuver states through pre-defined switching rules, resulting in different setups (e.g., tuning the weighting matrices in the objective function) for the underlying model predictive trajectory guidance module. However, these works take advantage of the high level of the hierarchy to decide on the maneuver planning in the short term, whereas in urban automated driving it is beneficial to use the high-level reasoning for a long-horizon optimization.
The main contribution of this work is applying SMPC to autonomous urban driving. Starting from a stochastic description of the future motion of the other traffic participants (other vehicles, pedestrians), safety conditions for the ego vehicle are derived, resulting in constraints ensuring that the probability of collision remains below the user-defined acceptable risk level. Moreover, to properly plan the motion in the long run, we propose to use a hierarchical structure composed of two layers. On the one hand, the high-level maneuver planner uses a simple model and a large sampling time, and takes advantage of a long horizon to optimize the maneuver. On the other hand, the low-level trajectory planner is in charge of determining the short-term optimal control actions to execute the selected maneuver, considering the detailed model. This control structure allows to benefit from a long-term view, without increasing the computational effort of the trajectory planner. Moreover, maneuver planning and trajectory planning are solved independently, explicitly optimizing each task separately, taking into account different characteristic time scales.
The reminder of the paper is organized as follows. In Section II an overview of the control hierarchy is outlined. Section III presents the dynamical models used. The details concerning the low-level trajectory planner and the highlevel maneuver planner are given in Section IV and in Section V, respectively. Numerical simulations are presented in Section VI. Conclusions and future research directions are discussed in Section VII.

II. CONTROL ALGORITHM OVERVIEW
In this section, an overview of the control hierarchy is given, highlighting the role of each layer, and the connections between them. The proposed control algorithm is composed of two layers. Both the layers work in a receding horizon setting, selecting the optimal sequence of control actions by minimizing a properly designed cost function, while meeting the requirements formulated as a set of constraints. A scheme of the control hierarchy is represented in Fig. 1.
The lower layer determines the immediate control actions to be applied on the system. A detailed model is used to compute the new optimal control input every time a new  measurement of the state is available, and the constraints guarantee safety up to the user-defined probability. The high-level layer is an additional structure, used to benefit from a long-term view in the optimization. The goal of this layer is not to determine the control input to be directly applied on the system, but rather to benefit from a long prediction horizon and provide this information to the low-level controller. For this reason, the optimization variable of this level is the reference trajectory used by the low-level controller, which is determined considering a longer prediction horizon. Moreover, since the reference trajectory must not be updated too often, a longer sampling time is used. Furthermore, the model used by the high-level controller is chosen to be an abstraction of the low-level one, including only the information that can be predicted in a sufficiently reliable way even in the long term. Also, not necessarily all the state features (e.g. the lateral displacement) are relevant to decide the maneuver. Finally, the cost function and the constraints are based on the low-level ones, but adapted to be consistent with the high-level model.

III. DYNAMICAL MODELS
This section introduces the dynamical model used by the SMPC algorithm to plan the ego vehicle (EV) trajectory, together with the dynamical models of the target vehicles (TVs) and of the pedestrians, which are used to predict future states and to generate safety constraints accordingly.

A. Ego Vehicle Model
To predict the EV states within the prediction horizon, we used a kinematic bicycle model, expressed in the roadaligned reference frame of a (possibly curved) reference path, assumed known. The EV state is defined as ξ = [s, d, φ, v] ⊤ , where (s, d) are the longitudinal and lateral position of the center of mass of the vehicle along the road, respectively, φ is the orientation of the vehicle with respect to the road itself, and v is the linear velocity of the EV. The input vector is u = [a, δ] ⊤ , with acceleration a and front steering angle δ. Let l f and l r be the distances from the front and rear axles, respectively, to the center of gravity. Moreover, let κ(s) be the local curvature of the reference path expressed as a function of the curvilinear coordinate s.
The nonlinear continuous-time dynamics is [18] where α = arctan lr lf+lr tan δ . Assumption 1: During the motion, the spatial state components (s, d) are such that d = 1 κ(s) . Assumption 1 is needed to avoid singularity issues, and it is realistic, as the curvature κ of a road is typically small, and the controller keeps the lateral displacement d limited.
A discrete-time linear model is obtained from (1) along the lines of [6]. At first, the nonlinear dynamics is linearized around the current state where Then, the discrete-time model is obtained as: where with zero-order hold of sampling time T . In order to simplify the computation, the discretization is performed under the approximation that k ′ (s 0 ) = 0, where k ′ is the derivative of the path curvature with respect to the longitudinal position s. Moreover, the EV is subject to the following constraints where ∆u k = u k − u k−1 , and w lane and w veh are the lane and vehicle width, respectively. (5a) is formulated to ensure the EV shape never exceeds the lane bounds. Constraints (5) yield the set of admissible states Ξ and inputs U.

B. Target Vehicle Model
In order to generate the safety constraints to avoid collisions, a prediction of the future positions ξ TV k of the TVs is needed. We use a discrete-time point-mass model [19] where ξ TV = [x TV , v TV x , y TV , v TV y ] ⊤ is the TV state, composed of longitudinal position x TV and velocity v TV x , and lateral position y TV and velocity v TV y , expressed in the inertial world frame, and u TV is the system input, consisting of the longitudinal and lateral accelerations. The TV matrices are We assume the input to be the sum of a feedback termũ TV and a perturbation term w TV k . The feedback term is designed to correct possible deviations from the desired trajectory ξ TV ref , and is given byũ where ∆ξ TV , and K is designed according to a linear quadratic control strategy, where we assume the longitudinal reference trajectory is only given in terms of velocity. To model the uncertainty of the future TV motion, we assume w TV k to be independent zero-mean Gaussian noises with covariance matrix Σ TV w . Moreover, we assume that the TV input u TV is saturated between u TV min and u TV max .

C. Pedestrian Model
To compute the prediction of the future states of the pedestrians, we refer to the model in [20], which reflects the model used for the TV. The pedestrian state is ξ P = [x P , v P x , y P , v P y ] ⊤ , and the dynamics is where A and B are as in (8). The pedestrian noise w P k is an independent zero-mean Gaussian noise with covariance matrix Σ P w . Observe that the pedestrian input is modeled as pure noise, with no stabilizing feedback loop.

IV. TRAJECTORY PLANNING
In the following, the details of the low-level SMPC algorithm used for the trajectory planning are discussed.

A. Safety Distance
In this section, a safety distance to be observed from each traffic participant is derived, so that the collision is avoided at least with the required probability β. Considering the TV, along the lines of [6], the safety distance can be obtained as with l TV veh the TV length, and ∆s TV stop the distance needed to stop if the EV is driving faster. e TV s,k takes into account the uncertainty on the TV position, and ǫ TV safe is an extra safety parameter. a TV k is computed for each prediction step k. In the following, the superscript TV is omitted for readability.
The term e s,k deterministically increases the safety distance such that the considered region contains the TV position with probability β. Given the linear model (6), and the 1) TV same lane 2) TV intersection 3) Pedestrian Gaussian distribution of the noise w k , the prediction error covariance matrix Σ e k is obtained propagating the uncertainty starting from the initialization Σ e 0 = 0 (the current TV position is assumed to be perfectly known). From Σ e k , we obtain the standard deviation of the longitudinal position prediction error σ s,k , and, using the standard approximation explained in detail in [6], the term e s,k = σ s,k √ γ is derived, where γ = −2 ln(1 − β). The same procedure is repeated to obtain the safety distance from the pedestrian a P k . Note that, even though a TV k and a P k have been derived in a probabilistic framework, they determine a deterministic safety area around the predicted position of each other traffic participant. As a result, the chance constraints can be reformulated as deterministic constraints preventing the EV from entering the safety areas, as explained in Section IV-B.

B. Safety Constraints
In this section, we derive the deterministic constraints to ensure the EV does not enter the safety areas of the other traffic participants derived in section IV-A. Each possible scenario is considered separately, and the constraints are represented in Fig. 2. The constraints are derived considering a simple urban environment composed of roads with a single lane (per direction) and an intersection. Moreover, it is assumed the EV can measure the state of other traffic participants in road-aligned coordinates. Note that a new constraint is generated for each traffic participant.
1) TV in same lane: If a TV is in the same lane in front, the EV must stay behind. Thus, the following constraint is generated, ensuring the safety distance a TV k is always kept 2) TV at intersection: If the EV is approaching the intersection, planning a left turn, and a TV is predicted to cross the intersection before the EV can leave the intersection free, then the EV must wait before entering the intersection, giving the right of way. As a result, a constraint is generated before the intersection area 3) Pedestrian: When a pedestrian is predicted to cross the road, the EV must safely stop before. Thus, we have

C. Optimal Control Problem
Given the EV model (4), the state and input constraints from (5), and the positional constraints derived in Section IV-B, the full optimal control problem for the low-level trajectory planner is formulated: where N is the prediction horizon, Q, R, S, and P are positive semi-definite weighting matrices, and, for the input difference, u −1 is the last applied input. Note that the positional constraint coefficients q s , q d , and q t in (16g), which are a reformulation of the constraints (13), (14), and (15), can be computed from the current EV state and the predicted TV and pedestrian states, before the optimization starts. As a result, the optimal control problem (16) is a quadratic program with linear constraints.

V. MANEUVER PLANNING
In this section, the high-level maneuver planner is introduced, specifying the motivation, the details of the model being used, the constraints generation, and the cost function.

A. High-Level Models
The scope of the maneuver planner is to determine the optimal sequence of high-level actions, considering the future behavior of the other vehicles in a long prediction horizon. However, planning maneuvers in the long run requires fewer details with respect to the immediate trajectory planning for the short term. Moreover, due to the uncertainty of the behavior of the other traffic participants, a detailed prediction of other vehicles or pedestrians for farther steps would not be reliable. For this reason, here we present simplified models, which are used at the higher level to predict the only information which can be predicted reliably enough even in the long term, and which is needed to plan the maneuver.
Given the simple structure of the road, the main maneuver the EV can plan is to accelerate or decelerate, for example in order to reach the intersection when it is free, avoiding a full stop that might otherwise be required. In order to determine the optimal speed, we only consider the position of the EV along the (fixed) reference path, which evolves according to a point-mass model dynamics with piece-wise constant speed, without paying attention to lateral displacements. As a result, the high-level dynamics is where the input ν is the speed, and h is the prediction step of the high-level maneuver planner. T H and N H are the sampling time and the prediction horizon of the high-level model, respectively, and we assume N H T H ≥ N T . The simplified model is subject to input constraints in the form ν max (s h ) is the maximum speed allowed depending on the position s h , and might be lower than v max in (5b), e.g., to take into account that it is unrealistic to drive at the maximum speed in highly curved stretches. This constraint makes the prediction more reliable, since the simplified model does not take the path's curvature into account.
Concerning the other traffic participants, it is enough to predict their longitudinal position along the path, in order to formulate the constraints of Section V-B. This can be obtained by computing the equivalent of models (6) and (10) with a time-step T H , and by projecting the position of the TV and the pedestrian on the reference path, obtaining s TV h and s P h . Firstly, the point-mass linear model matrices (8) are recomputed using T H in place of T , obtaining A H and B H . The feedback gain K from (9) is also substituted by K H , which is computed so that the closed-loop matrix A H + B H K H is the equivalent of A + BK with a sampling time T H instead of T . Then, an appropriate noise is obtained, considering the average of thek = ⌊ TH T ⌋ noises w TV k , . . . , w TV k+k−1 affecting the TV within a high-level sampling time T H . The average noise w TV h is still a zero-mean Gaussian, and, being w TV k independent, its variance is The same procedure is repeated for the pedestrian noise w P h .

B. High-Level Constraints
In this section, the constraints of the high-level optimal control problem are formulated. Repeating the procedure of Section IV-A, the safety distances ρ TV h and ρ P h are derived, based on the statistic description of the high-level noises w TV h and w P h , respectively, and on the risk parameter β H . Similarly to the low-level case in Section IV-B, each case is considered separately and a proper constraint is generated. A scheme of the constraints is given in Fig. 3.

1) TV in front:
If a TV is predicted to occupy the same lane in front, a constraint is generated behind the TV Note that (20) is not needed for safety, guaranteed by the analogous condition (13) in the low level, but rather to make the maneuver planner aware of the future position of the TV, allowing to plan a smooth deceleration when needed.
2) TV crossing the path: When a TV is predicted to temporarily cross the path of the EV (e.g., at an intersection), the maneuver planner should take this into consideration and plan the speed accordingly. If possible, the EV could reach the intersection point before, when it is still free, or otherwise it could plan to decelerate, in order to smooth the motion and minimize the stop time. The constraint is designed as which can be reformulated in a quadratic expression where ∆ 1 and ∆ 2 collect the terms from (21), plus possible additional safety parameters. Note that not only constraint (22) is nonlinear, but it is also position dependent, and generates a non-connected admissible set.
3) Pedestrian: Similar to the previous case, if a pedestrian is predicted to cross the street, the EV should plan to get over the crossing point before the pedestrian starts to cross, or to decelerate to minimize the stop time potentially required.

C. Optimal Control Problem
From the simplified models outlined in Section V-A, and the constraints in Section V-B, we can formulate the optimal control problem for the high-level maneuver planner: where ν −1 is set equal to the current speed v 0 , and set Z in (23e) compactly represents constraints (18), (20), and (22). The cost function (23a) is designed to penalize large accelerations, for sake of comfort and coherently with (16a), and to penalize deviations from a desired cruise speed. This second term is needed to avoid that the optimal control problem (23) admits the trivial optimal solution ν h = 0 ∀h when the current EV speed is zero. Note that the optimal reference speed ν h must be updated solving (23) once every T H seconds, and not at each iteration of the low-level controller.

VI. RESULTS
In this section, we discuss two numerical simulations developed in Matlab and based on the NMPC toolbox [21], showing the potential of the proposed control algorithm. We consider an urban intersection, see For performance comparison, the following cost function is used, resulting from the computation of the stage cost of (16a) for all the N sim steps of the simulation: The last component of deviation of the state with respect to the reference trajectory ∆ξ [4] in (25) is computed considering the desired cruise speed v ref = 10, independently of the optimal reference ν 0 computed by the maneuver planner.

A. Anticipating TV Scenario
In the first simulation, the EV initial state is ξ 0 = [−70, 0, 0, 10] ⊤ , and two TVs are present, one approaching the EV from the right, driving in the opposite direction If the high-level maneuver planner is not used, the EV drives at cruise speed v = 10 up to the intersection. Then, TV1 is predicted to occupy the intersection before the EV can safely leave it free, thus the EV stops. Afterwards, the EV turns and proceeds at cruise speed until it reaches TV2, which is driving slower. Eventually, the EV decelerates, in order to keep the safety distance from TV2, based on the risk parameter β TV . By decreasing the risk parameter β TV , the trajectory planner can execute a more aggressive and possibly efficient motion. Conversely, by requiring more safety, the safety distances derived in Section IV-A are enlarged, and this ultimately comes at the prices of a higher cost. SMPC permits to balance this trade-off, proving to be notably useful when the disturbances considered are unbounded, and cannot be handled by robust control approaches.
If the maneuver planner is active, the high-level predicts that a stop is necessary at the intersection and acts to prevent it from happening. Hence, a high reference speed is set at first, and the EV reaches the intersection while is still free, before being occupied by TV1. Then, the EV decelerates, reaching the desired cruise speed v ref = 10. Finally, as soon as TV2 is visible, a smooth deceleration is planned. Fig. 5 shows the speed profile of the EV if the high-level SMPC is inactive (green line) or active (blue), and the optimal reference speed v ref (red) dynamically computed by the maneuver planner solving (23). The maneuver planner allows to optimize the speed, avoiding the stop at the intersection, and making the deceleration smoother when needed. The benefit is also visible in terms of the cost function, since we have J sim,1a = 2215.8 for the first case, and J sim,1b = 781.2 if the maneuver planner is used.

B. Pedestrian Crossing Scenario
In the second simulation, the EV initial state is ξ 0 = [−100, 0, 0, 10] ⊤ , and a pedestrian intends to cross the street in front of the intersection (ξ P 0 = [−15, 0, −11, 1.2] ⊤ ), see Fig. 4. No TV is considered in this scenario. Without the maneuver planner, at first the EV proceeds at cruise speed. Then, it rapidly decelerates, to keep the desired distance from the pedestrian, according to the risk parameter β P , until the pedestrian completes crossing. Then, the EV accelerates again to reach the desired cruise speed v ref = 10.
Conversely, if the maneuver planner is used, the EV stop caused by the crossing pedestrian is predicted. Yet, now the maneuver planner cannot set the speed in order to safely pass before the pedestrian crosses, and therefore an initial deceleration is planned. In such a way, the EV can safely pass the crossing point without stopping, since the pedestrian is already on the other side of the street.
The speed profile of the EV for this scenario is shown in Fig. 6, if the maneuver planner is inactive (green line) or active (blue). The optimal reference speed v ref is represented in red. Even though the maneuver planner effectively avoids the full stop, the speed is significantly decreased in the first stretch, and the overall cost is J sim,2b = 2049.2, which is slightly higher than in the cost in the first case, J sim,2a = 1992.0, if the high-level maneuver planner is inactive.

VII. CONCLUSION
In this work we applied SMPC to urban autonomous driving. A proper choice of the risk parameter β allows to balance between safety and conservativeness. In the tradeoff, requiring the safety constraints hold only up to a certain probability allows to plan an efficient motion, whereas the risk level is kept limited. Moreover, the hierarchical control structure is beneficial since it allows to plan separately the short-term trajectory and the long-term maneuver (i.e., the speed in the considered example). As a result, the speed of the autonomous vehicle can be set so as to smooth the motion, taking into account foreseen future stops caused by other road participants, and to avoid stops if possible.
Concerning future research, this method could be applied to more complex scenarios, where a richer set of high-level maneuvers must be considered, e.g., lane change decisions. Moreover, formal conditions guaranteeing that this two-level optimization framework is effective should be investigated.