ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Is there a way to avoid overwriting node name when launching a node?

asked 2018-03-20 09:34:31 -0600

If I understand correctly, to run a node, you have to use a launch file, and each launch file includes something of the kind

  <node pkg="pkgname" type="" name="nodename" output="screen">

where nodename will overwrite the node name specified in rospy.init_node("...") of

Then, why does it make sense to name a node with rospy.init_node("..."), provided that that name will be overwritten anyway?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2018-03-20 09:50:02 -0600

gvdhoorn gravatar image

If I understand correctly, to run a node, you have to use a launch file [..]

No, that is not correct.

Nodes are 'just' binaries that happen to use ROS infrastructure for the input and output. So they can be run directly as you would any other binary (ie: ./name_of_binary, or $CATKIN_WS/devel/lib/$PKG/$BINARY). In that case the node would use the name that is hard-coded in the source.

rosrun $PKG $BINARY also does not override the name.

edit flag offensive delete link more


Thanks for the clarification!

Zhoulai Fu gravatar image Zhoulai Fu  ( 2018-03-20 10:34:23 -0600 )edit

By the way, is that correct that all nodes that you can invoke from a package PKG located at $CATKIN_WS/devel/lib/$PKG/? (Apparently no: I just checked the mavros package. It has >5 launch files, yet only two executable in dev/lib/mavros/mavros. But where are the other nodes, if any?)

Zhoulai Fu gravatar image Zhoulai Fu  ( 2018-03-20 10:38:11 -0600 )edit

All ROS nodes are either binaries or scripts. If they are scripts, they might not be placed in the devel/lib location, but be kept in the source space of your workspace.

But in principle: yes, you should be able to start all nodes as normal programs.

gvdhoorn gravatar image gvdhoorn  ( 2018-03-20 10:50:21 -0600 )edit

Question Tools

1 follower


Asked: 2018-03-20 09:34:31 -0600

Seen: 295 times

Last updated: Mar 20 '18