# Trajectory Optimization with Dynamic Drivable Corridor-Based Collision Avoidance
## 3 Collision Avoidance Constraint Formulation
### Grid-Based Obstacle Modeling  
In practical collision detection, environmental obstacles often exhibit complex shapes and diverse types, leading to high computational complexity if processed directly. To address this issue, we introduce a grid-based discretization approach. By converting complex obstacles into a series of regular axis-aligned bounding boxes (AABBs), the spatial representation of obstacles is significantly simplified.  
The implementation approach consists of three key steps. First, environmental obstacles are sampled to generate a set of scattered obstacle points. Next, defining the grid map range is essential. Since distant obstacles typically do not pose a safety threat during vehicle navigation, they can be ignored to reduce collision detection targets and computational complexity. This principle is also applied in grid discretization: The considered region of  
Figure 2: Schematics of vehicle shape reduction and obstacle expansion: (**a**) vehicle representation using two discs and (**b**) vehicle and obstacles before transformation. (**c**) Vehicle and obstacles after transformation.  
the grid map is restricted to include only areas relevant to trajectory planning, ensuring that extraneous obstacle points outside its boundaries are excluded. Finally, the remaining discrete obstacle points within the grid map range are converted into occupied grid cells, forming the basis for subsequent collision checking.  
The selection of the grid map range is as follows: Since the DC is constructed based on the initial path, the grid map range must fully cover the entire initial path. Additionally, extra space is reserved to account for potential obstacles and path variations, ensuring the smooth construction of the DC. The specific range selection is shown in the following formula:  
\[\begin{array}{l}x_{\min}=\min(X)-\Delta\text{d},\\ x_{\max}=\max(X)+\Delta\text{d},\\ y_{\min}=\min(Y)-\Delta\text{d},\\ y_{\max}=\max(Y)+\Delta\text{d}.\end{array} \tag{9}\]  
The set \(X=\{x_{1},x_{2},\cdots,x_{n}\}\) represents the set of all x-coordinates on the initial path, and \(Y=\{y_{1},y_{2},\cdots,y_{n}\}\) represents the set of all y-coordinates on the initial path. \(\Delta\text{d}\) denotes the reserved space, which must be greater than or equal to the maximum length of DC.  
For obstacle points located outside the range of the grid map, they are directly discarded, effectively filtering out the influence of distant obstacles and improving computational efficiency.  
For those within the grid map, their corresponding grid coordinates are computed based on their positions, and the associated cells are marked as occupied (see the grey-shaded grid cells in Figure 3).  
Through this grid-based discretization process, collision detection targets in the environment are transformed from complex and irregularly shaped obstacles into a series of discrete, regularly shaped occupied grid cells. Compared to handling the original complex obstacles, using these regular grid cells simplifies the collision detection process and facilitates more efficient modeling and computation.