Skip to content

Commit

Permalink
chore(behavior_velocity): make implementation simpler
Browse files Browse the repository at this point in the history
Signed-off-by: tanaka3 <ttatcoder@outlook.jp>
  • Loading branch information
taikitanaka3 committed Mar 10, 2022
1 parent ac3c150 commit 3bcee0b
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,10 @@ void clipPathByLength(
const PathWithLaneId & path, PathWithLaneId & clipped, const double max_length)
{
double length_sum = 0;
auto p0 = path.points.at(0);
for (int i = 0; i < static_cast<int>(path.points.size()); i++) {
const auto & p1 = path.points.at(i);
length_sum += tier4_autoware_utils::calcDistance2d(p0, p1);
clipped.points.emplace_back(path.points.front());
for (int i = 1; i < static_cast<int>(path.points.size()); i++) {
length_sum += tier4_autoware_utils::calcDistance2d(path.points.at(i - 1), path.points.at(i));
if (length_sum > max_length) return;
p0 = p1;
clipped.points.emplace_back(path.points.at(i));
}
}
Expand Down

0 comments on commit 3bcee0b

Please sign in to comment.