How can I set a node name when using composing nodes with rclcpp?
I'm initializing nodes like so:
rclcpp::executors::SingleThreadedExecutor exec;
std::vector<rclcpp::Parameter> laser_params = {rclcpp::Parameter("ip_address", "192.168.0.11")};
rclcpp::NodeOptions laser_options;
laser_options.parameter_overrides(laser_params);
auto laser_node = std::make_shared<urg_node::UrgNode>(laser_options);
exec.add_node(laser_node);
Which works fine, until I add a second node of the same type. I feel like I should be able to pass in a name
argument to the node constructor, similar to rclcpp::Node. I noticed that many ros2-included nodes, like laser_proc and urg_node have hardcoded node names. For now, I've modified urg_node
's constructor to have a name argument, which works, but I don't feel like I'm supposed to do this for all other nodes as well.
When using a launch.py file with ComposableNodeContainer
and ComposableNode
, I can pass a name
argument to a node and be done with it.
How should I set a node name when running nodes in rclcpp?
I think I'm supposed to be remapping something, but I don't know how.