The cost function of the Dijkstra search through the graph of connected lanes and lane changes can be customized by implementing the following function callback:
The parameters are:
The default cost function tries to minimize driving time and penalizes lane changes by 10 seconds of driving. If there are only 2 waypoints (start/end) given, cost will only depend on timeCost and laneChangeCost. Otherwise we take into account the distToSeg cost per lane and take the minimum across a road segment. The distToSeg cost assigns a cost to a lane segment that does not align with the given waypoints. For example a lane that touches a gps waypoint segment but does not follow it will get a non-zero cost. The parameters forward, laneChangeSide, neighborLane and context are ignored by the default function.