Model predictive trajectory#
Abstract#
Model Predictive Trajectory (MPT) calculates the trajectory that meets the following conditions.
- Kinematically feasible for linear vehicle kinematics model
- Collision free with obstacles and road boundaries
Conditions for collision free is considered to be not hard constraints but soft constraints. When the optimization failed or the optimized trajectory is not collision free, the output trajectory will be previously generated trajectory.
Trajectory near the ego must be stable, therefore the condition where trajectory points near the ego are the same as previously generated trajectory is considered, and this is the only hard constraints in MPT.
Flowchart#
Vehicle kinematics#
As the following figure, we consider the bicycle kinematics model in the frenet frame to track the reference path. At time step \(k\), we define lateral distance to the reference path, heading angle against the reference path, and steer angle as \(y_k\), \(\theta_k\), and \(\delta_k\) respectively.
Assuming that the commanded steer angle is \(\delta_{des, k}\), the kinematics model in the frenet frame is formulated as follows. We also assume that the steer angle \(\delta_k\) is first-order lag to the commanded one.
Linearization#
Then we linearize these equations. \(y_k\) and \(\theta_k\) are tracking errors, so we assume that those are small enough. Therefore \(\sin \theta_k \approx \theta_k\).
Since \(\delta_k\) is a steer angle, it is not always small. By using a reference steer angle \(\delta_{\mathrm{ref}, k}\) calculated by the reference path curvature \(\kappa_k\), we express \(\delta_k\) with a small value \(\Delta \delta_k\).
Note that the steer angle \(\delta_k\) is within the steer angle limitation \(\delta_{\max}\). When the reference steer angle \(\delta_{\mathrm{ref}, k}\) is larger than the steer angle limitation \(\delta_{\max}\), and \(\delta_{\mathrm{ref}, k}\) is used to linearize the steer angle, \(\Delta \delta_k\) is \(\Delta \delta_k = \delta - \delta_{\mathrm{ref}, k} = \delta_{\max} - \delta_{\mathrm{ref}, k}\), and the absolute \(\Delta \delta_k\) gets larger. Therefore, we have to apply the steer angle limitation to \(\delta_{\mathrm{ref}, k}\) as well.
\(\mathrm{clamp}(v, v_{\min}, v_{\max})\) is a function to convert \(v\) to be larger than \(v_{\min}\) and smaller than \(v_{\max}\).
Using this \(\delta_{\mathrm{ref}, k}\), \(\tan \delta_k\) is linearized as follows.
One-step state equation#
Based on the linearization, the error kinematics is formulated with the following linear equations,
which can be formulated as follows with the state \(\mathbf{x}\), control input \(u\) and some matrices, where \(\mathbf{x} = (y_k, \theta_k)\)
Time-series state equation#
Then, we formulate time-series state equation by concatenating states, control inputs and matrices respectively as
where
In detail, each matrices are constructed as follows.
Free-boundary-conditioned time-series state equation#
For path planning which does not start from the current ego pose, \(\mathbf{x}_0\) should be the design variable of optimization. Therefore, we make \(\mathbf{u}'\) by concatenating \(\mathbf{x}_0\) and \(\mathbf{u}\), and redefine \(\mathbf{x}\) as follows.
Then we get the following state equation
which is in detail
Objective function#
The objective function for smoothing and tracking is shown as follows, which can be formulated with value function matrices \(Q, R\).
As mentioned before, the constraints to be collision free with obstacles and road boundaries are formulated to be soft constraints. Assuming that the lateral distance to the road boundaries or obstacles from the back wheel center, front wheel center, and the point between them are \(y_{\mathrm{base}, k}, y_{\mathrm{top}, k}, y_{\mathrm{mid}, k}\) respectively, and slack variables for each point are \(\lambda_{\mathrm{base}}, \lambda_{\mathrm{top}}, \lambda_{\mathrm{mid}}\), the soft constraints can be formulated as follows.
Since \(y_{\mathrm{base}, k}, y_{\mathrm{top}, k}, y_{\mathrm{mid}, k}\) is formulated as a linear function of \(y_k\), the objective function for soft constraints is formulated as follows.
Slack variables are also design variables for optimization. We define a vector \(\mathbf{v}\), that concatenates all the design variables.
The summation of these two objective functions is the objective function for the optimization problem.
As mentioned before, we use hard constraints where some trajectory points in front of the ego are the same as the previously generated trajectory points. This hard constraints is formulated as follows.
Finally we transform those objective functions to the following QP problem, and solve it.
Constraints#
Steer angle limitation#
Steer angle has a limitation \(\delta_{max}\) and \(\delta_{min}\). Therefore we add linear inequality equations.
Collision free#
To realize collision-free trajectory planning, we have to formulate constraints that the vehicle is inside the road and also does not collide with obstacles in linear equations. For linearity, we implemented some methods to approximate the vehicle shape with a set of circles, that is reliable and easy to implement.
- Bicycle Model
- Uniform Circles
- Fitting Uniform Circles
Now we formulate the linear constraints where a set of circles on each trajectory point is collision-free. By using the drivable area, we calculate upper and lower boundaries along reference points, which will be interpolated on any position on the trajectory. NOTE that upper and lower boundary is left and right, respectively.
Assuming that upper and lower boundaries are \(b_l\), \(b_u\) respectively, and \(r\) is a radius of a circle, lateral deviation of the circle center \(y'\) has to be
Based on the following figure, \(y'\) can be formulated as follows.
Note that longitudinal position of the circle center and the trajectory point to calculate boundaries are different. But each boundaries are vertical against the trajectory, resulting in less distortion by the longitudinal position difference since road boundaries does not change so much. For example, if the boundaries are not vertical against the trajectory and there is a certain difference of longitudinal position between the circe center and the trajectory point, we can easily guess that there is much more distortion when comparing lateral deviation and boundaries.
We will explain options for optimization.
L-infinity optimization#
The above formulation is called L2 norm for slack variables.
Instead, if we use L-infinity norm where slack variables are shared by enabling l_inf_norm
.
Tips for stable trajectory planning#
In order to make the trajectory optimization problem stabler to solve, the boundary constraint which the trajectory footprints should be inside and optimization weights are modified.
Keep minimum boundary width#
The drivable area's width is sometimes smaller than the vehicle width since the behavior module does not consider the width. To realize the stable trajectory optimization, the drivable area's width is guaranteed to be larger than the vehicle width and an additional margin in a rule-based way.
We cannot distinguish the boundary by roads from the boundary by obstacles for avoidance in the motion planner, the drivable area is modified in the following multi steps assuming that \(l_{width}\) is the vehicle width and \(l_{margin}\) is an additional margin.
Extend violated boundary#
Avoid sudden steering#
When the obstacle suddenly appears which is determined to avoid by the behavior module, the drivable area's shape just in front of the ego will change, resulting in the sudden steering. To prevent this, the drivable area's shape close to the ego is fixed as previous drivable area's shape.
Assume that \(v_{ego}\) is the ego velocity, and \(t_{fix}\) is the time to fix the forward drivable area's shape.
Calculate avoidance cost#
Change optimization weights#
Assume that \(c\) is the normalized avoidance cost, \(w^{\mathrm{lat}}\) is the weight for lateral error, \(w^{\mathrm{yaw}}\) is the weight for yaw error, and other variables are as follows.
Parameter | Type | Description |
---|---|---|
\(w^{\mathrm{steer}}_{\mathrm{normal}}\) | double | weight for steering minimization in normal cases |
\(w^{\mathrm{steer}}_{\mathrm{avoidance}}\) | double | weight for steering minimization in avoidance cases |
\(w^{\mathrm{lat}}_{\mathrm{normal}}\) | double | weight for lateral error minimization in normal cases |
\(w^{\mathrm{lat}}_{\mathrm{avoidance}}\) | double | weight for lateral error minimization in avoidance cases |
\(w^{\mathrm{yaw}}_{\mathrm{normal}}\) | double | weight for yaw error minimization in normal cases |
\(w^{\mathrm{yaw}}_{\mathrm{avoidance}}\) | double | weight for yaw error minimization in avoidance cases |