ros2 / ros2/rclcpp

Global __node argument causes node name collisions

Open
#843 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
805
Forks
564
Avg merge
1d 17h
Merged PRs (30d)
27

Description

When spawning a process that has multiple internal nodes, the __node:=some_node_name argument applies to all nodes in that process. Take, for instance, the TransformListener, which spawns a node to hold its subscription. If multiple TransformListeners are used, those nodes might have different names by default, but passing the command line __node option causes these to get started with the same name.

This makes things like setting arguments, calling services, and sometimes just setting up publishers/subscribers fail in various ways and has been pervasive in the Navigation2 stack: https://github.com/ros-planning/navigation2/issues/842

A couple possible resolutions:

  1. Handle duplicate node names in the same process more gracefully.
  2. Only respect the global __node option for the first node created in a process.
  3. Make __node only select the prefix to the node name. If multiple nodes are attempted to be created with the same name, append a (sequential?) suffix to uniquify them.
  4. Add a parameter to the Node constructor to ignore the global node name override but respect the other global options. (this doesn't fully solve the problem of unique names, since the node is now responsible for making sure they're globally unique and any API that creates nodes must now enforce it).
  5. Deprecate the global __node option and respect the node name passed to the Node constructor (Then launch_ros.actions.Node will have to use more targeted remapping to ensure that subnodes are

Discussion of a hacky workaround (pass __node argument to internal nodes to override the top-level __node argument) can be found here https://github.com/ros2/geometry2/pull/159

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review how the global __node argument is applied when multiple nodes are created in one process, using TransformListener as the concrete case described. Compare the four proposed resolutions and determine how duplicate names, remapping, and internal-node behavior should work; done requires an agreed solution that avoids collisions without breaking existing global options.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend-api-design
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.