Skip to content

Commit

Permalink
feat(behavior_path_planner): allow reroute when always executable mod…
Browse files Browse the repository at this point in the history
…ule running or candidate modules is running (autowarefoundation#5786)

feat(behavior_path_planner): allow reroute when always executable module running or candidate modules

Signed-off-by: kosuke55 <[email protected]>
  • Loading branch information
kosuke55 authored Dec 5, 2023
1 parent be23154 commit b1680c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class BehaviorPathPlannerNode : public rclcpp::Node
/**
* @brief publish reroute availability
*/
void publish_reroute_availability();
void publish_reroute_availability() const;

/**
* @brief publish steering factor from intersection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ class PlannerManager
*/
bool hasApprovedModules() const { return !approved_module_ptrs_.empty(); }

bool hasNonAlwaysExecutableApprovedModules() const
{
return std::any_of(
approved_module_ptrs_.begin(), approved_module_ptrs_.end(),
[this](const auto & m) { return !getManager(m)->isAlwaysExecutableModule(); });
}

/**
* @brief check if there are candidate modules.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,14 @@ void BehaviorPathPlannerNode::publish_steering_factor(
steering_factor_interface_ptr_->publishSteeringFactor(get_clock()->now());
}

void BehaviorPathPlannerNode::publish_reroute_availability()
void BehaviorPathPlannerNode::publish_reroute_availability() const
{
const bool has_approved_modules = planner_manager_->hasApprovedModules();
const bool has_candidate_modules = planner_manager_->hasCandidateModules();

// In the current behavior path planner, we might get unexpected behavior when rerouting while
// modules other than lane follow are active. Therefore, rerouting will be allowed only when the
// lane follow module is running Note that if there is a approved module or candidate module, it
// means non-lane-following modules are runnning.
// In the current behavior path planner, we might encounter unexpected behavior when rerouting
// while modules other than lane following are active. If non-lane-following module except
// always-executable module is approved and running, rerouting will not be possible.
RerouteAvailability is_reroute_available;
is_reroute_available.stamp = this->now();
if (has_approved_modules || has_candidate_modules) {
if (planner_manager_->hasNonAlwaysExecutableApprovedModules()) {
is_reroute_available.availability = false;
} else {
is_reroute_available.availability = true;
Expand Down
5 changes: 1 addition & 4 deletions planning/behavior_path_planner/src/planner_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,7 @@ std::vector<SceneModulePtr> PlannerManager::getRequestModules(
// Condition 1: always executable module can be added regardless of the existence of other
// modules, so skip checking the existence of other modules.
// in other cases, need to check the existence of other modules and which module can be added.
const bool has_non_always_executable_module = std::any_of(
approved_module_ptrs_.begin(), approved_module_ptrs_.end(),
[this](const auto & m) { return !getManager(m)->isAlwaysExecutableModule(); });
if (!manager_ptr->isAlwaysExecutableModule() && has_non_always_executable_module) {
if (!manager_ptr->isAlwaysExecutableModule() && hasNonAlwaysExecutableApprovedModules()) {
// pairs of find_block_module and is_executable
std::vector<std::pair<std::function<bool(const SceneModulePtr &)>, std::function<bool()>>>
conditions;
Expand Down

0 comments on commit b1680c5

Please sign in to comment.