Robotics StackExchange | Archived questions

[ROS2] Using create_sub_node leads to two nodes with same name

If I create a node, and then create a subnode, I see on the cmd line 2 nodes with same name!
I think this is a bug, or is this not the correct usage?

If you then check params for the base node, it's coincidence which params will be shown, either that of basenode or from subnode.

  //base_node and base_node/test are expected
  auto subnode = this->create_sub_node("test");  
  rclcpp::spin(subnode)

Asked by madmax on 2019-08-23 05:03:54 UTC

Comments

Answers

It looks like it is a bug (at least still present in October 2020): https://github.com/ros2/rclcpp/issues/731

Below, It is shown a possible workaround. You can just create a "full" new node extending the original node namespace (second parameter).

  auto subnode = rclcpp::Node::make_shared("test", parent_node->get_fully_qualified_name()));
  rclcpp::spin(subnode)

Asked by Pablo IƱigo Blasco on 2020-10-03 18:35:54 UTC

Comments