Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(motion_velocity_smoother): add guard before interpolation #1752

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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