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

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 https://discourse.ros.org/t/using-cla... - 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
0

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

lucasw gravatar image

It sounds like there will be proper support for this in the future https://github.com/ros2/rclcpp/issues... (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/i... .

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/b...

edit flag offensive delete link more

Question Tools

2 followers

Stats

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

Seen: 639 times

Last updated: Feb 21 '19