Skip to content

Commit ee9a389

Browse files
authored
feat(behavior_path_planner): keep original points in resampling of pull over (#2478)
* feat(behavior_path_planner): keep original points in resampling Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Update planning/behavior_path_planner/src/path_utilities.cpp Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * change motion_utils::overlap_threshold to 0.2 and use it Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Revert "change motion_utils::overlap_threshold to 0.2 and use it" This reverts commit edfb2d5. Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * keep input points only in pull over Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Add comment of temporary processe Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent f8af70c commit ee9a389

File tree

4 files changed

+29
-5
lines changed

4 files changed

+29
-5
lines changed

Diff for: planning/behavior_path_planner/include/behavior_path_planner/behavior_path_planner_node.hpp

+2
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ class BehaviorPathPlannerNode : public rclcpp::Node
168168
bool skipSmoothGoalConnection(
169169
const std::vector<std::shared_ptr<SceneModuleStatus>> & statuses) const;
170170

171+
bool keepInputPoints(const std::vector<std::shared_ptr<SceneModuleStatus>> & statuses) const;
172+
171173
/**
172174
* @brief skip smooth goal connection
173175
*/

Diff for: planning/behavior_path_planner/include/behavior_path_planner/path_utilities.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ std::vector<double> calcPathArcLengthArray(
4141
const PathWithLaneId & path, const size_t start = 0,
4242
const size_t end = std::numeric_limits<size_t>::max(), const double offset = 0.0);
4343

44-
PathWithLaneId resamplePathWithSpline(const PathWithLaneId & path, double interval);
44+
PathWithLaneId resamplePathWithSpline(
45+
const PathWithLaneId & path, const double interval, const bool keep_input_points = false);
4546

4647
Path toPath(const PathWithLaneId & input);
4748

Diff for: planning/behavior_path_planner/src/behavior_path_planner_node.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,9 @@ PathWithLaneId::SharedPtr BehaviorPathPlannerNode::getPath(
817817
connected_path = modifyPathForSmoothGoalConnection(*path);
818818
}
819819

820-
const auto resampled_path =
821-
util::resamplePathWithSpline(connected_path, planner_data_->parameters.path_interval);
820+
const auto resampled_path = util::resamplePathWithSpline(
821+
connected_path, planner_data_->parameters.path_interval,
822+
keepInputPoints(module_status_ptr_vec));
822823
return std::make_shared<PathWithLaneId>(resampled_path);
823824
}
824825

@@ -837,6 +838,22 @@ bool BehaviorPathPlannerNode::skipSmoothGoalConnection(
837838
return false;
838839
}
839840

841+
// This is a temporary process until motion planning can take the terminal pose into account
842+
bool BehaviorPathPlannerNode::keepInputPoints(
843+
const std::vector<std::shared_ptr<SceneModuleStatus>> & statuses) const
844+
{
845+
const auto target_module = "PullOver";
846+
847+
for (auto & status : statuses) {
848+
if (status->is_waiting_approval || status->status == BT::NodeStatus::RUNNING) {
849+
if (target_module == status->module_name) {
850+
return true;
851+
}
852+
}
853+
}
854+
return false;
855+
}
856+
840857
void BehaviorPathPlannerNode::onVelocity(const Odometry::ConstSharedPtr msg)
841858
{
842859
std::lock_guard<std::mutex> lock(mutex_pd_);

Diff for: planning/behavior_path_planner/src/path_utilities.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ std::vector<double> calcPathArcLengthArray(
5555
/**
5656
* @brief resamplePathWithSpline
5757
*/
58-
PathWithLaneId resamplePathWithSpline(const PathWithLaneId & path, double interval)
58+
PathWithLaneId resamplePathWithSpline(
59+
const PathWithLaneId & path, const double interval, const bool keep_input_points)
5960
{
6061
if (path.points.size() < 2) {
6162
return path;
@@ -66,7 +67,7 @@ PathWithLaneId resamplePathWithSpline(const PathWithLaneId & path, double interv
6667
transformed_path.at(i) = path.points.at(i).point;
6768
}
6869

69-
constexpr double epsilon = 0.01;
70+
constexpr double epsilon = 0.2;
7071
const auto has_almost_same_value = [&](const auto & vec, const auto x) {
7172
if (vec.empty()) return false;
7273
const auto has_close = [&](const auto v) { return std::abs(v - x) < epsilon; };
@@ -79,6 +80,9 @@ PathWithLaneId resamplePathWithSpline(const PathWithLaneId & path, double interv
7980
for (size_t i = 0; i < path.points.size(); ++i) {
8081
const double s = motion_utils::calcSignedArcLength(transformed_path, 0, i);
8182
for (const auto & lane_id : path.points.at(i).lane_ids) {
83+
if (keep_input_points && !has_almost_same_value(s_in, s)) {
84+
s_in.push_back(s);
85+
}
8286
if (
8387
std::find(unique_lane_ids.begin(), unique_lane_ids.end(), lane_id) !=
8488
unique_lane_ids.end()) {

0 commit comments

Comments
 (0)