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

Revision history [back]

It sounds like there will be proper support for this in the future https://github.com/ros2/rclcpp/issues/632 (update this answer when there is), but my current solution is a custom rclcpp that allows post-constructor initialization.

The custom rclcpp could be in a regular colcon_ws and all nodes that need to make use of it need to be there in source form as well to build off of it ( #q315794 deals with an issue related to that, the fix may be already released or will be soon)- but currently I'm building everything from source as described in https://github.com/lucasw/imgui_ros/issues/74#issuecomment-464469262 .

Then I can have a node loader node that has a service call to spawn nodes, and set all their settings:

node = loader->createInstance<rclcpp::Node>(full_node_plugin_name);
node->init(node_name, node_namespace,
           rclcpp::contexts::default_context::get_global_default_context(),
           arguments, parameters);

https://github.com/lucasw/imgui_ros/blob/node_init/internal_pub_sub/src/node_loader.cpp