37 double last_point_t = 0.0;
38 double last_point_s = 0.0;
39 if (!speed_data->empty()) {
40 last_point_t = speed_data->back().t();
41 last_point_s = speed_data->back().s();
43 if (last_point_t >= FLAGS_fallback_total_time) {
46 for (
double t = last_point_t + FLAGS_fallback_time_unit;
47 t < FLAGS_fallback_total_time; t += FLAGS_fallback_time_unit) {
53 const double distance,
const double max_speed) {
54 static constexpr double kConstDeceleration = -0.8;
55 static constexpr double kProceedingSpeed = 2.23;
56 const double proceeding_speed = std::fmin(max_speed, kProceedingSpeed);
57 const double distance_to_start_deceleration =
58 proceeding_speed * proceeding_speed / kConstDeceleration / 2;
59 bool is_const_deceleration_mode = distance < distance_to_start_deceleration;
61 double a = kConstDeceleration;
64 double v = proceeding_speed;
66 static constexpr double kDeltaT = 0.1;
69 while (s < distance && v > 0) {
70 if (is_const_deceleration_mode) {
73 double v_new = std::max(0.0, v + a * t);
74 s += kDeltaT * (v + v_new) / 2;
80 if (distance - s < distance_to_start_deceleration)
81 is_const_deceleration_mode =
true;