Skip to content

Commit d93fead

Browse files
Allow for no progress checkers to be configured (#5701)
Signed-off-by: SteveMacenski <stevenmacenski@gmail.com>
1 parent b261989 commit d93fead

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

nav2_controller/src/controller_server.cpp

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ ControllerServer::on_configure(const rclcpp_lifecycle::State & state)
146146
for (size_t i = 0; i != progress_checker_ids_.size(); i++) {
147147
progress_checker_ids_concat_ += progress_checker_ids_[i] + std::string(" ");
148148
}
149+
if (progress_checker_ids_concat_.empty()) {
150+
progress_checker_ids_concat_ = "(none)";
151+
}
149152

150153
RCLCPP_INFO(
151154
get_logger(),
@@ -388,6 +391,22 @@ bool ControllerServer::findProgressCheckerId(
388391
const std::string & c_name,
389392
std::string & current_progress_checker)
390393
{
394+
if (progress_checkers_.size() == 0) {
395+
if (c_name.empty()) {
396+
RCLCPP_DEBUG(
397+
get_logger(),
398+
"No progress checker configured and none requested. Progress checking will be bypassed.");
399+
current_progress_checker = "";
400+
return true;
401+
} else {
402+
RCLCPP_ERROR(
403+
get_logger(), "FollowPath called with progress_checker name %s in parameter"
404+
" 'current_progress_checker', but no progress checkers are configured.",
405+
c_name.c_str());
406+
return false;
407+
}
408+
}
409+
391410
if (progress_checkers_.find(c_name) == progress_checkers_.end()) {
392411
if (progress_checkers_.size() == 1 && c_name.empty()) {
393412
RCLCPP_WARN_ONCE(
@@ -447,7 +466,9 @@ void ControllerServer::computeControl()
447466
}
448467

449468
setPlannerPath(goal->path);
450-
progress_checkers_[current_progress_checker_]->reset();
469+
if (!current_progress_checker_.empty()) {
470+
progress_checkers_[current_progress_checker_]->reset();
471+
}
451472

452473
last_valid_cmd_time_ = now();
453474
rclcpp::WallRate loop_rate(controller_frequency_);
@@ -610,8 +631,10 @@ void ControllerServer::computeAndPublishVelocity()
610631
throw nav2_core::ControllerTFError("Failed to obtain robot pose");
611632
}
612633

613-
if (!progress_checkers_[current_progress_checker_]->check(pose)) {
614-
throw nav2_core::FailedToMakeProgress("Failed to make progress");
634+
if (!current_progress_checker_.empty()) {
635+
if (!progress_checkers_[current_progress_checker_]->check(pose)) {
636+
throw nav2_core::FailedToMakeProgress("Failed to make progress");
637+
}
615638
}
616639

617640
geometry_msgs::msg::Twist twist = getThresholdedTwist(odom_sub_->getRawTwist());
@@ -740,7 +763,9 @@ void ControllerServer::updateGlobalPath()
740763
get_logger(), "Change of progress checker %s requested, resetting it",
741764
goal->progress_checker_id.c_str());
742765
current_progress_checker_ = current_progress_checker;
743-
progress_checkers_[current_progress_checker_]->reset();
766+
if (!current_progress_checker_.empty()) {
767+
progress_checkers_[current_progress_checker_]->reset();
768+
}
744769
}
745770
} else {
746771
std::shared_ptr<Action::Result> result = std::make_shared<Action::Result>();

0 commit comments

Comments
 (0)