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(behavior_path_planner): allow reroute when always executable module running or candidate modules is running #5786

Merged
merged 1 commit into from
Dec 5, 2023
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 @@ -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 @@ -549,18 +549,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 @@ -65,9 +65,9 @@
}
}

void PlannerManager::removeScenePlugin(rclcpp::Node & node, const std::string & name)

Check warning on line 68 in planning/behavior_path_planner/src/planner_manager.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/planner_manager.cpp#L68

Added line #L68 was not covered by tests
{
auto it = std::remove_if(manager_ptrs_.begin(), manager_ptrs_.end(), [&](const auto plugin) {

Check warning on line 70 in planning/behavior_path_planner/src/planner_manager.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/planner_manager.cpp#L70

Added line #L70 was not covered by tests
return plugin->name() == name;
});

Expand All @@ -76,11 +76,11 @@
node.get_logger(),
"The scene plugin '" << name << "' is not found in the registered modules.");
} else {
manager_ptrs_.erase(it, manager_ptrs_.end());

Check warning on line 79 in planning/behavior_path_planner/src/planner_manager.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/planner_manager.cpp#L79

Added line #L79 was not covered by tests
processing_time_.erase(name);
RCLCPP_INFO_STREAM(node.get_logger(), "The scene plugin '" << name << "' is unloaded.");
}
}

Check warning on line 83 in planning/behavior_path_planner/src/planner_manager.cpp

View check run for this annotation

Codecov / codecov/patch

planning/behavior_path_planner/src/planner_manager.cpp#L83

Added line #L83 was not covered by tests

BehaviorModuleOutput PlannerManager::run(const std::shared_ptr<PlannerData> & data)
{
Expand Down Expand Up @@ -263,10 +263,7 @@
// 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
Loading