Skip to content

Commit

Permalink
Planning: set speed limit to avoid creeping forward.
Browse files Browse the repository at this point in the history
  • Loading branch information
lianglia-apollo authored and ycool committed Aug 27, 2018
1 parent 5d19e87 commit 31735f0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
4 changes: 2 additions & 2 deletions modules/planning/common/planning_gflags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,8 @@ DEFINE_bool(use_planning_fallback, true,
DEFINE_double(fallback_total_time, 3.0, "total fallback trajectory time");
DEFINE_double(fallback_time_unit, 0.02,
"fallback trajectory unit time in seconds");
DEFINE_bool(enable_polynomial_speed_fallback, false,
"True to enable polynomial speed fallback.");
DEFINE_double(polynomial_speed_fallback_velocity, 3.5,
"velocity to use polynomial speed fallback.");

// navigation mode
DEFINE_double(navigation_fallback_cruise_time, 8.0,
Expand Down
2 changes: 1 addition & 1 deletion modules/planning/common/planning_gflags.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ DECLARE_double(bound_buffer);
DECLARE_bool(use_planning_fallback);
DECLARE_double(fallback_total_time);
DECLARE_double(fallback_time_unit);
DECLARE_bool(enable_polynomial_speed_fallback);
DECLARE_double(polynomial_speed_fallback_velocity);

// navigation mode
DECLARE_double(navigation_fallback_cruise_time);
Expand Down
24 changes: 11 additions & 13 deletions modules/planning/planner/em/em_planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,9 @@ Status EMPlanner::PlanOnReferenceLine(

if (!ret.ok() || reference_line_info->speed_data().Empty()) {
ADEBUG << "Speed fallback.";
GenerateFallbackSpeedProfile(reference_line_info,
reference_line_info->mutable_speed_data());

*reference_line_info->mutable_speed_data() =
GenerateFallbackSpeedProfile(*reference_line_info);
reference_line_info->AddCost(kSpeedOptimizationFallbackClost);
}

Expand Down Expand Up @@ -399,16 +400,14 @@ void EMPlanner::GenerateFallbackPathProfile(
path_data->SetDiscretizedPath(DiscretizedPath(std::move(path_points)));
}

void EMPlanner::GenerateFallbackSpeedProfile(
const ReferenceLineInfo* reference_line_info, SpeedData* speed_data) {
if (FLAGS_enable_polynomial_speed_fallback) {
*speed_data = GenerateStopProfileFromPolynomial(
reference_line_info->AdcPlanningPoint().v(),
reference_line_info->AdcPlanningPoint().a());
SpeedData EMPlanner::GenerateFallbackSpeedProfile(
const ReferenceLineInfo& reference_line_info) {
const double init_v = reference_line_info.AdcPlanningPoint().v();
const double init_a = reference_line_info.AdcPlanningPoint().a();
if (init_v > FLAGS_polynomial_speed_fallback_velocity) {
return GenerateStopProfileFromPolynomial(init_v, init_a);
} else {
*speed_data =
GenerateStopProfile(reference_line_info->AdcPlanningPoint().v(),
reference_line_info->AdcPlanningPoint().a());
return GenerateStopProfile(init_v, init_a);
}
}

Expand All @@ -429,8 +428,7 @@ SpeedData EMPlanner::GenerateStopProfile(const double init_speed,
double v = 0.0;
s = std::fmax(pre_s,
pre_s + 0.5 * (pre_v + (pre_v + unit_t * acc)) * unit_t);
v = std::fmax(0.0,
pre_v + unit_t * acc);
v = std::fmax(0.0, pre_v + unit_t * acc);
speed_data.AppendSpeedPoint(s, t, v, acc, 0.0);
pre_s = s;
pre_v = v;
Expand Down
4 changes: 2 additions & 2 deletions modules/planning/planner/em/em_planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ class EMPlanner : public Planner {
void GenerateFallbackPathProfile(const ReferenceLineInfo* reference_line_info,
PathData* path_data);

void GenerateFallbackSpeedProfile(
const ReferenceLineInfo* reference_line_info, SpeedData* speed_data);
SpeedData GenerateFallbackSpeedProfile(
const ReferenceLineInfo& reference_line_info);

SpeedData GenerateStopProfile(const double init_speed,
const double init_acc) const;
Expand Down

0 comments on commit 31735f0

Please sign in to comment.