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

Set node name, namespace, remappings after class_loader createInstance?

asked 2019-02-11 09:19:24 -0500

lucasw gravatar image

How do I set the node name, namespace, or remappings of a node created with class_loader createInstance?

There's a discussion on discourse from 2017 - manage nodes are the solution?

This is the composition demo code:

loader = new class_loader::ClassLoader(library_path);
std::string class_name = ...
auto node = loader->createInstance<rclcpp::Node>(class_name);

After that it is too late to set node parameters.

Maybe something like this:

auto lifecycle_node = loader->createInstance<rclcpp_lifecycle::LifecycleNode>(class_name);

Followed by what to set the node parameters? Would it work with any composable node?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-02-21 10:27:10 -0500

lucasw gravatar image

It sounds like there will be proper support for this in the future (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 .

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,
           arguments, parameters);

edit flag offensive delete link more

Question Tools



Asked: 2019-02-11 09:19:24 -0500

Seen: 638 times

Last updated: Feb 21 '19