ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

How to set NodeOptions for a ComposableNode in a .launch.py file?

asked 2021-03-17 16:17:44 -0500

jschornak gravatar image

I'm modifying a ROS2 node to be a component, and I'm trying to set additional node options when launching this node. Here is a snippet from a genericized but representative launch file:

def generate_launch_description():
        container = ComposableNodeContainer(
            name='test_container',
            namespace='/',
            package='rclcpp_components',
            executable='component_container',
            composable_node_descriptions=[
                ComposableNode(
                    package='my_package',
                    plugin='my_package::MyComponentNode',
                    name='test_node',
                    extra_arguments=[{'use_intra_process_comms' : True, 'automatically_declare_parameters_from_overrides': True, 'allow_undeclared_parameters': True}]),
            ],
    )
    return LaunchDescription([container] )

In my node's constructor I'm querying the options that were passed in:

class MyComponentNode : public rclcpp::Node
{
public:
  MyComponentNode(const rclcpp::NodeOptions& options) : rclcpp::Node("test_node", options)
  {      
    RCLCPP_INFO_STREAM(LOGGER, "use_intraprocess_comms: " << get_node_options().use_intra_process_comms() << " allow undeclared params: " << get_node_options().allow_undeclared_parameters() << " auto declare params: " << get_node_options().automatically_declare_parameters_from_overrides());
  }
}

I can see that use_intra_process_comms is being set correctly (and I can toggle it between True and False by changing my launch file), but automatically_declare_parameters_from_overrides and allow_undeclared_parameters are not set to True like I would expect:

[component_container-4] [INFO] [1616010417.606922763] [test_node]: use_intraprocess_comms: 1 allow undeclared params: 0 auto declare params: 0

What is the correct way to do this?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-03-18 08:22:29 -0500

jafar_abdi gravatar image

Looking at the source code of the component_manager, it looks like only use_intra_process_comms can be set from extra_arguments the other arguments will be ignored

edit flag offensive delete link more

Question Tools

3 followers

Stats

Asked: 2021-03-17 16:17:44 -0500

Seen: 1,188 times

Last updated: Mar 18 '21