DriveWorks SDK Reference
3.5.78 Release
For Test and Development only

Cost Function
Note
SW Release Applicability: This tutorial is applicable to modules in NVIDIA DRIVE Software releases.

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:

const dwMapsLane* lane,
bool forward,
float32_t length,
uint32_t laneChangeCount,
dwMapsSide laneChangeSide,
const dwMapsGeoPoint* gpsPathPoint,
uint32_t gpsPathPointCount,
bool ignoreHeight,
const dwMapsLane* neighborLane,
void* context);

The parameters are:

  • the lane
  • the driving direction on that lane geometry
  • the length of the lane in meters
  • the number of lane changes
  • the lane change side relative to polyline direction (note that it can be opposite to driving direction)
  • the vector of gps path points
  • the number of gps path points in gpsPathPoint
  • flag to ignore the height of each gps coordinate
  • ‘neighborLane’ is the lane on the next Lane Plan Segment that is connected to the target lane of the current segment
  • ‘context’ is a user pointer that is passed through the API from the ‘run’ call

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.