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

Register multiple nodes with single plugin #68

Merged

Conversation

MarqRazz
Copy link
Collaborator

@MarqRazz MarqRazz commented May 9, 2024

I'm working on a package that has lots of behaviors and would like to put them all into a single plugin. This PR adds the macro so user can register one or more custom Nodes into a factory that also need access to the BT::RosNodeParams.

@marj3220
Copy link
Contributor

I currently have an issue where my custom ROS2 behaviors can't set params (my issue: #69). I believe this PR will help my current issues.

@marj3220
Copy link
Contributor

Thank you @MarqRazz. The TreeExecutor system has greatly helped with my project's architecture.

@MarqRazz
Copy link
Collaborator Author

Thank you @MarqRazz. The TreeExecutor system has greatly helped with my project's architecture.

I'm glad you have found this useful @marj3220! I agree that this PR should get around your issue. FYI you also have the option of just setting the value that gets used by default_port_value like action_name directly in the tree.xml file.

@facontidavide facontidavide merged commit 6247e2e into BehaviorTree:humble May 12, 2024
2 checks passed
@marj3220
Copy link
Contributor

@MarqRazz Quick question. Why is the params a const? How can I assign the attributes of the param attribute if it is a constant? This might be a miscomprehension on my part from my lack of C++ knowledge.

@MarqRazz
Copy link
Collaborator Author

The params are const so that each plugin does not mutate them or have to worry about properly restoring the default values.

Have you tried making a copy and passing it into your behaviors...

BT_REGISTER_ROS_NODES(factory, params)
{
  BT::RosNodeParams my_params(params);
  my_params.default_port_value = "TopicName";
  my_params.server_timeout = std::chrono::milliseconds(5000);
  factory.registerNodeType<SomeBehavior>("SomeBehavior", my_params);
}

@marj3220
Copy link
Contributor

The params are const so that each plugin does not mutate them or have to worry about properly restoring the default values.

Have you tried making a copy and passing it into your behaviors...

BT_REGISTER_ROS_NODES(factory, params)
{
  BT::RosNodeParams my_params(params);
  my_params.default_port_value = "TopicName";
  my_params.server_timeout = std::chrono::milliseconds(5000);
  factory.registerNodeType<SomeBehavior>("SomeBehavior", my_params);
}

You are very right! Thank you for your help. I truly appreciate it!

@MarqRazz MarqRazz deleted the pr-register_multiple_nodes branch May 13, 2024 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants