Closed MarqRazz closed 5 months ago
I currently have an issue where my custom ROS2 behaviors can't set params (my issue: https://github.com/BehaviorTree/BehaviorTree.ROS2/issues/69). I believe this PR will help my current issues.
Thank you @MarqRazz. The TreeExecutor system has greatly helped with my project's architecture.
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.
@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.
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);
}
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!
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
.