Skip to content

Commit fbff622

Browse files
h-ohtapre-commit-ci[bot]
authored andcommitted
fix(behavior_path): fix base points vanishing and inconsistent lane_ids on the spline interpolated path (#929)
* add base points to resampled path in behavior_path * Revert "fix(behavior_path): only apply spline interpolation for its output, not for turn_signal processing (#909)" This reverts commit c80c986. * ci(pre-commit): autofix * fix insert * fix: not interpolate behavior velocity path * Revert "Revert "fix(behavior_path): only apply spline interpolation for its output, not for turn_signal processing (#909)"" This reverts commit e6dd540. --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ffbf01b commit fbff622

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

planning/behavior_path_planner/src/path_utilities.cpp

+24-10
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,18 @@ double calcPathArcLength(const PathWithLaneId & path, size_t start, size_t end)
9090
PathWithLaneId resamplePathWithSpline(const PathWithLaneId & path, double interval)
9191
{
9292
const auto base_points = calcPathArcLengthArray(path);
93-
const auto sampling_points = tier4_autoware_utils::arange(0.0, base_points.back(), interval);
93+
auto sampling_points = tier4_autoware_utils::arange(0.0, base_points.back(), interval);
94+
95+
constexpr double epsilon = 0.01;
96+
for (const auto & b : base_points) {
97+
const auto is_almost_same_value = std::find_if(
98+
sampling_points.begin(), sampling_points.end(),
99+
[&](const auto v) { return std::abs(v - b) < epsilon; });
100+
if (is_almost_same_value == sampling_points.end()) {
101+
sampling_points.push_back(b);
102+
}
103+
}
104+
std::sort(sampling_points.begin(), sampling_points.end());
94105

95106
if (base_points.empty() || sampling_points.empty()) {
96107
return path;
@@ -122,22 +133,25 @@ PathWithLaneId resamplePathWithSpline(const PathWithLaneId & path, double interv
122133

123134
// For LaneIds, Type, Twist
124135
//
125-
// ------|----|----|----|----|----|----|-------> resampled
126-
// [0] [1] [2] [3] [4] [5] [6]
136+
// ------|----|----|----|----|----|----|----|--------> resampled
137+
// [0] [1] [2] [3] [4] [5] [6] [7]
127138
//
128-
// --------|---------------|----------|---------> base
129-
// [0] [1] [2]
139+
// ------|---------------|----------|-------|---> base
140+
// [0] [1] [2] [3]
130141
//
131-
// resampled[0~3] = base[0]
132-
// resampled[4~5] = base[1]
133-
// resampled[6] = base[2]
142+
// resampled[0] = base[0]
143+
// resampled[1~3] = base[1]
144+
// resampled[4~5] = base[2]
145+
// resampled[6~7] = base[3]
134146
//
135147
size_t base_idx{0};
136148
for (size_t i = 0; i < resampled_path.points.size(); ++i) {
137-
while (base_idx < base_points.size() - 1 && sampling_points.at(i) > base_points.at(base_idx)) {
149+
while (base_idx < base_points.size() - 1 &&
150+
((sampling_points.at(i) > base_points.at(base_idx)) ||
151+
(sampling_points.at(i) - base_points.at(base_idx)) > 1e-3)) {
138152
++base_idx;
139153
}
140-
size_t ref_idx = std::max(static_cast<int>(base_idx) - 1, 0);
154+
size_t ref_idx = std::max(static_cast<int>(base_idx), 0);
141155
if (i == resampled_path.points.size() - 1) {
142156
ref_idx = base_points.size() - 1; // for last point
143157
}

planning/behavior_velocity_planner/src/node.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,10 @@ void BehaviorVelocityPlannerNode::onTrigger(
420420
const auto filtered_path = filterLitterPathPoint(to_path(velocity_planned_path));
421421

422422
// interpolation
423-
const auto interpolated_path_msg = interpolatePath(filtered_path, forward_path_length_);
423+
// const auto interpolated_path_msg = interpolatePath(filtered_path, forward_path_length_);
424424

425425
// check stop point
426-
auto output_path_msg = filterStopPathPoint(interpolated_path_msg);
426+
auto output_path_msg = filterStopPathPoint(filtered_path);
427427
output_path_msg.header.frame_id = "map";
428428
output_path_msg.header.stamp = this->now();
429429

0 commit comments

Comments
 (0)