Here, $\Delta d$ was the lateral distance between the goal lane and the final chosen lane, and $\Delta s$ was the longitudinal distance from the vehicle to the goal.
损失函数产生的值在0-1范围内
.h函数
1 2 3 4 5 6 7 8 9 10
#ifndef COST_H #define COST_H //goal_lane:目标道路 //intended_lane:预期车道 有助于计算检查向左、右变道是否可行 //final_lane:the lane of the vehicle at the end of the trajectory // distance_to_goal:举例目标的举例 double goal_distance_cost(int goal_lane, int intended_lane, int final_lane, double distance_to_goal);
#endif // COST_H
cost 函数
1 2 3 4 5 6 7 8 9 10
double goal_distance_cost(int goal_lane, int intended_lane, int final_lane, double distance_to_goal) { // The cost increases with both the distance of intended lane from the goal // and the distance of the final lane from the goal. The cost of being out // of the goal lane also becomes larger as the vehicle approaches the goal. int delta_d = 2.0 * goal_lane - intended_lane - final_lane; double cost = 1 - exp(-(std::abs(delta_d) / distance_to_goal));