Skip to content

Commit

Permalink
feat(motion_velocity_smoother): add guard before interpolation (#1752)
Browse files Browse the repository at this point in the history
* feat(motion_velocity_smoother): add guard before interpolation

Signed-off-by: yutaka <purewater0901@gmail.com>

* udpate

Signed-off-by: yutaka <purewater0901@gmail.com>

Signed-off-by: yutaka <purewater0901@gmail.com>
  • Loading branch information
purewater0901 authored Sep 1, 2022
1 parent da61e26 commit d38d66a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,18 @@ bool calcStopVelocityWithConstantJerkAccLimit(
dists.push_back(dist);
}

if (
!interpolation_utils::isIncreasing(xs) || !interpolation_utils::isIncreasing(dists) ||
!interpolation_utils::isNotDecreasing(xs) || !interpolation_utils::isNotDecreasing(dists)) {
return false;
}

if (
xs.size() < 2 || vs.size() < 2 || as.size() < 2 || js.size() < 2 || dists.empty() ||
dists.front() < xs.front() || xs.back() < dists.back()) {
return false;
}

const auto vel_at_wp = interpolation::lerp(xs, vs, dists);
const auto acc_at_wp = interpolation::lerp(xs, as, dists);
const auto jerk_at_wp = interpolation::lerp(xs, js, dists);
Expand Down
12 changes: 12 additions & 0 deletions planning/motion_velocity_smoother/src/trajectory_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,18 @@ boost::optional<TrajectoryPoints> applyDecelFilterWithJerkConstraint(
distance_all.begin(), distance_all.end(), [&xs](double x) { return x > xs.back(); });
const std::vector<double> distance{distance_all.begin() + start_index, it_end};

if (
!interpolation_utils::isIncreasing(xs) || !interpolation_utils::isIncreasing(distance) ||
!interpolation_utils::isNotDecreasing(xs) || !interpolation_utils::isNotDecreasing(distance)) {
return {};
}

if (
xs.size() < 2 || vs.size() < 2 || as.size() < 2 || distance.empty() ||
distance.front() < xs.front() || xs.back() < distance.back()) {
return {};
}

const auto vel_at_wp = interpolation::lerp(xs, vs, distance);
const auto acc_at_wp = interpolation::lerp(xs, as, distance);

Expand Down

0 comments on commit d38d66a

Please sign in to comment.