29 double centripetal_acc_cost_sum = 0.0;
30 double centripetal_acc_cost_sqr_sum = 0.0;
31 for (
int i = 0; i < lane_sequence.path_point_size(); ++i) {
32 const auto& path_point = lane_sequence.
path_point(i);
33 double centripetal_acc = speed * speed * std::fabs(path_point.kappa());
34 double centripetal_acc_cost =
35 centripetal_acc / FLAGS_centripedal_acc_threshold;
36 centripetal_acc_cost_sum += centripetal_acc_cost;
37 centripetal_acc_cost_sqr_sum += centripetal_acc_cost * centripetal_acc_cost;
39 double mean_cost = centripetal_acc_cost_sqr_sum /
40 (centripetal_acc_cost_sum + FLAGS_double_precision);
41 return std::exp(-FLAGS_centripetal_acc_coeff * mean_cost);
45 const std::vector<TrajectoryPoint>& trajectory_points) {
46 for (
size_t i = 0; i + 1 < trajectory_points.size(); ++i) {
47 const auto& p0 = trajectory_points[i];
48 const auto& p1 = trajectory_points[i + 1];
49 double time_diff = std::abs(p1.relative_time() - p0.relative_time());
50 if (time_diff < FLAGS_double_precision) {
55 p1.path_point().theta() - p0.path_point().theta()));
56 double v = (p0.v() + p1.v()) * 0.5;
57 double angular_a = v * theta_diff / time_diff;
58 if (angular_a > FLAGS_centripedal_acc_threshold) {