Skip to content

Commit b1680c5

Browse files
authored
feat(behavior_path_planner): allow reroute when always executable module running or candidate modules is running (#5786)
feat(behavior_path_planner): allow reroute when always executable module running or candidate modules Signed-off-by: kosuke55 <kosuke.tnp@gmail.com>
1 parent be23154 commit b1680c5

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

planning/behavior_path_planner/include/behavior_path_planner/behavior_path_planner_node.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class BehaviorPathPlannerNode : public rclcpp::Node
173173
/**
174174
* @brief publish reroute availability
175175
*/
176-
void publish_reroute_availability();
176+
void publish_reroute_availability() const;
177177

178178
/**
179179
* @brief publish steering factor from intersection

planning/behavior_path_planner/include/behavior_path_planner/planner_manager.hpp

+7
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ class PlannerManager
226226
*/
227227
bool hasApprovedModules() const { return !approved_module_ptrs_.empty(); }
228228

229+
bool hasNonAlwaysExecutableApprovedModules() const
230+
{
231+
return std::any_of(
232+
approved_module_ptrs_.begin(), approved_module_ptrs_.end(),
233+
[this](const auto & m) { return !getManager(m)->isAlwaysExecutableModule(); });
234+
}
235+
229236
/**
230237
* @brief check if there are candidate modules.
231238
*/

planning/behavior_path_planner/src/behavior_path_planner_node.cpp

+5-9
Original file line numberDiff line numberDiff line change
@@ -551,18 +551,14 @@ void BehaviorPathPlannerNode::publish_steering_factor(
551551
steering_factor_interface_ptr_->publishSteeringFactor(get_clock()->now());
552552
}
553553

554-
void BehaviorPathPlannerNode::publish_reroute_availability()
554+
void BehaviorPathPlannerNode::publish_reroute_availability() const
555555
{
556-
const bool has_approved_modules = planner_manager_->hasApprovedModules();
557-
const bool has_candidate_modules = planner_manager_->hasCandidateModules();
558-
559-
// In the current behavior path planner, we might get unexpected behavior when rerouting while
560-
// modules other than lane follow are active. Therefore, rerouting will be allowed only when the
561-
// lane follow module is running Note that if there is a approved module or candidate module, it
562-
// means non-lane-following modules are runnning.
556+
// In the current behavior path planner, we might encounter unexpected behavior when rerouting
557+
// while modules other than lane following are active. If non-lane-following module except
558+
// always-executable module is approved and running, rerouting will not be possible.
563559
RerouteAvailability is_reroute_available;
564560
is_reroute_available.stamp = this->now();
565-
if (has_approved_modules || has_candidate_modules) {
561+
if (planner_manager_->hasNonAlwaysExecutableApprovedModules()) {
566562
is_reroute_available.availability = false;
567563
} else {
568564
is_reroute_available.availability = true;

planning/behavior_path_planner/src/planner_manager.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -263,10 +263,7 @@ std::vector<SceneModulePtr> PlannerManager::getRequestModules(
263263
// Condition 1: always executable module can be added regardless of the existence of other
264264
// modules, so skip checking the existence of other modules.
265265
// in other cases, need to check the existence of other modules and which module can be added.
266-
const bool has_non_always_executable_module = std::any_of(
267-
approved_module_ptrs_.begin(), approved_module_ptrs_.end(),
268-
[this](const auto & m) { return !getManager(m)->isAlwaysExecutableModule(); });
269-
if (!manager_ptr->isAlwaysExecutableModule() && has_non_always_executable_module) {
266+
if (!manager_ptr->isAlwaysExecutableModule() && hasNonAlwaysExecutableApprovedModules()) {
270267
// pairs of find_block_module and is_executable
271268
std::vector<std::pair<std::function<bool(const SceneModulePtr &)>, std::function<bool()>>>
272269
conditions;

0 commit comments

Comments
 (0)