Skip to content

Commit

Permalink
fix(behavior_velocity): avoid to insert the same point
Browse files Browse the repository at this point in the history
Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp>
  • Loading branch information
TomohitoAndo committed Apr 15, 2022
1 parent f68121e commit 16e909f
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,13 @@ TrajectoryPointWithIdx getLerpTrajectoryPointWithIdx(
tier4_autoware_utils::calcLongitudinalOffsetToSegment(points, nearest_seg_idx, point);
const double len_segment =
tier4_autoware_utils::calcSignedArcLength(points, nearest_seg_idx, nearest_seg_idx + 1);
const double interpolate_ratio = std::clamp(len_to_interpolated / len_segment, 0.0, 1.0);

// avoid to insert the same point
constexpr double epsilon = 1e-3;
const double ratio_min = epsilon;
const double ratio_max = 1.0 - epsilon;
const double interpolate_ratio =
std::clamp(len_to_interpolated / len_segment, ratio_min, ratio_max);
{
const size_t i = nearest_seg_idx;
const auto & pos0 = points.at(i).pose.position;
Expand Down

0 comments on commit 16e909f

Please sign in to comment.