Feat: support coordinate road in TimeHeadway condition
This PR still uses branch version of mantle-api, but it is ready for review now. It will be updated after the PR in mantle-api merged.
This PR adds support for distance calculation in the road coordinate system. While it is primarily intended for use in the TimeHeadwayCondition, it can also be applied to other conditions.
Code Overview:
- The core functionality is implemented in the
GetLongitudinalRoadDistanceBetweenPositions
function. This function performs the following steps:
- Path Calculation: Computes the longest path between two positions.
- Logical Lane Path Conversion: Transforms the lane path into a logical lane path to obtain the road reference line for distance computation.
- Duplicate Removal: Removes duplicate reference lines, since multiple logical lanes may refer to the same road reference line.
- Distance Computation: Calculates the longitudinal road distance based on the size of the path and the projection of the start and target points onto the road reference lines.
- The above function uses
PathFinder
for the path calculation. (See the related issue for the previous implementation.) - In the conversion from
map_api
togtgen
, a mapping between lane IDs and logical lane IDs has been added to thegtgen
map to support logical lane path extraction from the original lane path.
Limitation:
Currently not supported:
- When either the start position or the target position is on a bidirectional road.
Related PRs:
Edited by Ziqi Zhou