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

Add namespace to action and service client names #1

Merged
merged 1 commit into from
Apr 27, 2020
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 @@ -36,6 +36,8 @@ class BtActionNode : public BT::ActionNodeBase
: BT::ActionNodeBase(xml_tag_name, conf), action_name_(action_name)
{
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");
std::string node_namespace;
node_namespace = node_->get_namespace();

// Initialize the input and output messages
goal_ = typename ActionT::Goal();
Expand All @@ -45,6 +47,10 @@ class BtActionNode : public BT::ActionNodeBase
if (getInput("server_name", remapped_action_name)) {
action_name_ = remapped_action_name;
}
// Append namespace to the action name
if(node_namespace.c_str()) {
action_name_ = node_namespace + "/" + action_name_;
}
createActionClient(action_name_);

// Give the derive class a chance to do any initialization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class BtServiceNode : public BT::SyncActionNode
: BT::SyncActionNode(service_node_name, conf), service_node_name_(service_node_name)
{
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node");
std::string node_namespace;
node_namespace = node_->get_namespace();

// Get the required items from the blackboard
server_timeout_ =
Expand All @@ -43,6 +45,10 @@ class BtServiceNode : public BT::SyncActionNode

// Now that we have node_ to use, create the service client for this BT service
getInput("service_name", service_name_);
// Append namespace to the action name
if(node_namespace.c_str()) {
service_name_ = node_namespace + "/" + service_name_;
}
service_client_ = node_->create_client<ServiceT>(service_name_);

// Make sure the server is actually there before continuing
Expand Down