Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can create multiple nodes with the same name in different packages, but there are two things to watch out for if you really want to do this:

  • ROS requires each node to have a unique name at runtime, so you'll need to give each node a different name="" in your launch files, use anonymous names, or use the __name:= parameter to change the node name when starting it from the command line
  • Since a catkin workspace is a single cmake project, each target name needs to be unique across the entire workspace. To get around this, you'll need to use a unique name for each target, and then set the executable name afterwards with set_target_properties:

    Package A cmakelists.txt:

    add_executable(packageA-node node.cpp) set_target_properties(packageA-node OUTPUT_NAME node)

    Package B cmakelists.txt

    add_executable(packageB-node node.cpp) set_target_properties(packageB-node OUTPUT_NAME node)

You can create multiple nodes with the same name in different packages, but there are two things to watch out for if you really want to do this:

  • ROS requires each node to have a unique name at runtime, so you'll need to give each node a different name="" in your launch files, use anonymous names, or use the __name:= parameter to change the node name when starting it from the command line
  • Since a catkin workspace is a single cmake project, each target name needs to be unique across the entire workspace. To get around this, you'll need to use a unique name for each target, and then set the executable name afterwards with set_target_properties:

Package A cmakelists.txt:

add_executable(packageA-node node.cpp)
 set_target_properties(packageA-node OUTPUT_NAME node)

node)

Package B cmakelists.txt

add_executable(packageB-node node.cpp)
 set_target_properties(packageB-node OUTPUT_NAME node)

node)