Nodes with same name in different packages
Hello,
I am new to ROS and I have a question regarding ROS nodes. Is it possible to create two nodes with same name in different packages?
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
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:
name=""
in your launch files, use anonymous names, or use the __name:=
parameter to change the node name when starting it from the command linePackage 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)
It should be set_target_properties(packageB-node PROPERTIES OUTPUT_NAME node) instead of set_target_properties(getpose_grade OUTPUT_NAME getpose)
Just to add to this, since I stumpled upon it today:
AFAIK it is also possible to have multiple nodes with the same name in different packages if you are not building with catkin_make
, but instead with catkin_make_isolated
or catkin_tools
, since with these tools every package has it's own build space. That way you will also not have to apply the workaround @ahendrix suggested.
Asked: 2017-03-03 16:02:10 -0600
Seen: 2,447 times
Last updated: Feb 19 '18