Skip to content

Commit

Permalink
fix(obstacle_avoidance_planner): fix inf loop in mpt (autowarefoundat…
Browse files Browse the repository at this point in the history
…ion#1881)

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>

Signed-off-by: Takayuki Murooka <takayuki5168@gmail.com>
  • Loading branch information
takayuki5168 authored and boyali committed Oct 19, 2022
1 parent da3b530 commit 044d16e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions planning/obstacle_avoidance_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,19 @@ Trajectories ObstacleAvoidancePlanner::optimizeTrajectory(
return getPrevTrajs(p.path.points);
}

// NOTE: Elastic band sometimes diverges with status = "OSQP_SOLVED".
constexpr double max_path_change_diff = 1.0e4;
for (size_t i = 0; i < eb_traj->size(); ++i) {
const auto & eb_pos = eb_traj->at(i).pose.position;
const auto & path_pos = path.points.at(std::min(i, path.points.size() - 1)).pose.position;

const double diff_x = eb_pos.x - path_pos.x;
const double diff_y = eb_pos.y - path_pos.y;
if (max_path_change_diff < std::abs(diff_x) || max_path_change_diff < std::abs(diff_y)) {
return getPrevTrajs(path.points);
}
}

// EB has to be solved twice before solving MPT with fixed points
// since the result of EB is likely to change with/without fixing (1st/2nd EB)
// that makes MPT fixing points worse.
Expand Down

0 comments on commit 044d16e

Please sign in to comment.