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

adding timeout for action client initialization #3029

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 @@ -90,7 +90,14 @@ class BtActionNode : public BT::ActionNodeBase

// Make sure the server is actually there before continuing
RCLCPP_DEBUG(node_->get_logger(), "Waiting for \"%s\" action server", action_name.c_str());
action_client_->wait_for_action_server();
static constexpr std::chrono::milliseconds wait_for_server_timeout =
std::chrono::milliseconds(1000);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hardcoded to a reasonable 1s now

if (!action_client_->wait_for_action_server(wait_for_server_timeout)) {
RCLCPP_ERROR(
node_->get_logger(), "\"%s\" action server not available after waiting for %li ms",
action_name.c_str(), wait_for_server_timeout.count());
throw std::runtime_error("Action server not available");
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,13 @@ bool BtActionServer<ActionT>::loadBehaviorTree(const std::string & bt_xml_filena
std::istreambuf_iterator<char>());

// Create the Behavior Tree from the XML input
tree_ = bt_->createTreeFromText(xml_string, blackboard_);
try {
tree_ = bt_->createTreeFromText(xml_string, blackboard_);
} catch (const std::exception & e) {
RCLCPP_ERROR(logger_, "Exception when loading BT: %s", e.what());
return false;
}

topic_logger_ = std::make_unique<RosTopicLogger>(client_node_, tree_);

current_bt_xml_filename_ = filename;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ NavigateThroughPosesNavigator::goalReceived(ActionT::Goal::ConstSharedPtr goal)

if (!bt_action_server_->loadBehaviorTree(bt_xml_filename)) {
RCLCPP_ERROR(
logger_, "BT file not found: %s. Navigation canceled.",
logger_, "Error loading XML file: %s. Navigation canceled.",
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
bt_xml_filename.c_str());
return false;
}
Expand Down