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

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

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

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="mainprogram.py" name="nodename" output="screen">

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

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
3

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

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

Comments

Thanks for the clarification!

Zhoulai Fu gravatar image Zhoulai Fu  ( 2018-03-20 10:34:23 -0500 )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 -0500 )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 -0500 )edit

Question Tools

1 follower

Stats

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

Seen: 379 times

Last updated: Mar 20 '18