diff --git a/planning/behavior_path_planner/src/behavior_path_planner_node.cpp b/planning/behavior_path_planner/src/behavior_path_planner_node.cpp index 51587e7efa286..952ef9a067378 100644 --- a/planning/behavior_path_planner/src/behavior_path_planner_node.cpp +++ b/planning/behavior_path_planner/src/behavior_path_planner_node.cpp @@ -1405,9 +1405,16 @@ void BehaviorPathPlannerNode::publishPathCandidate( } for (auto & module : manager->getSceneModules()) { - path_candidate_publishers_.at(module->name()) - ->publish( - convertToPath(module->getPathCandidate(), module->isExecutionReady(), planner_data)); + const auto & status = module->getCurrentStatus(); + const auto candidate_path = std::invoke([&]() { + if (status == ModuleStatus::SUCCESS || status == ModuleStatus::FAILURE) { + // clear candidate path if the module is finished + return convertToPath(nullptr, false, planner_data); + } + return convertToPath(module->getPathCandidate(), module->isExecutionReady(), planner_data); + }); + + path_candidate_publishers_.at(module->name())->publish(candidate_path); } } }