Rosanswers logo

I have two simple Python nodes, a publisher outputting data at /mypub/data and a subscriber consuming that data.

When I run them using rosrun, everything works perfectly, but when I launch each of them using roslaunch, the subscriber never receives any topics being output by the publisher.

Logging inside the publisher shows messages are being published and rosmsg list|grep -i mypackage shows my message type has been generated, but when my publisher is running and publishing, rostopic echo /mypub/data shows nothing and appears to hang.

My publisher's launch file is trivial:

   <node name="mypub" pkg="mypackage" type="mypub_node.py" output="screen">

And the node seems to start up cleanly with the output:

started roslaunch server http://localhost:60558/


 * /rosdistro: indigo
 * /rosversion: 1.11.16

    mypub (mypackage/mypub_node.py)


core service [/rosout] found
process[mypub-1]: started with pid [12609]
[DEBUG] [WallTime: 1458106329.532694] init_node, name[/mypub], pid[12609]
[DEBUG] [WallTime: 1458106329.535395] binding to 0
[DEBUG] [WallTime: 1458106329.537606] bound to 49259
[DEBUG] [WallTime: 1458106329.540770] ... service URL is rosrpc://localhost:49259
[DEBUG] [WallTime: 1458106329.542789] [/mypub/get_loggers]: new Service instance
[DEBUG] [WallTime: 1458106329.554825] ... service URL is rosrpc://localhost:49259
[DEBUG] [WallTime: 1458106329.556568] [/mypub/set_logger_level]: new Service instance
  self.packet_pub = rospy.Publisher('~data', msgs.Data)
[DEBUG] [WallTime: 1458106329.639749] ... service URL is rosrpc://localhost:49259

If I start it instead with rosrun, like:

rosrun mypackage mypub_node.py

it again seems to start cleanly, with output:

[DEBUG] [WallTime: 1458107532.209104] init_node, name[/mypub], pid[13349]
[DEBUG] [WallTime: 1458107532.211273] binding to 0
[DEBUG] [WallTime: 1458107532.212995] bound to 37078
[DEBUG] [WallTime: 1458107532.215700] ... service URL is rosrpc://localhost:37078
[DEBUG] [WallTime: 1458107532.217320] [/mypub/get_loggers]: new Service instance
[DEBUG] [WallTime: 1458107532.228779] ... service URL is rosrpc://localhost:37078
[DEBUG] [WallTime: 1458107532.230445] [/mypub/set_logger_level]: new Service instance
[DEBUG] [WallTime: 1458107532.320980] ... service URL is rosrpc://localhost:37078
[DEBUG] [WallTime: 1458107532.323380] [/mypub/packet_write]: new Service instance

and then rostopic echo /mypub/data successfully shows the messages.

What's the difference between these two calls? Why is roslaunch preventing messages from being visible outside the node?

Originally posted by Cerin on ROS Answers with karma: 940 on 2016-03-16

Post score: 0

Original comments

Comment by ahendrix on 2016-03-16:
Do you see your topic with rostopic list ? Is your node doing anything other than publishing?


1 Answer 1


Rosanswers logo

The problem was that my node was initializing itself with the name "MyPub", whereas in the launch file I was using "mypub". I didn't realize the XML name overrode the node's internal name or that it was case sensitive. After I made them the same, everything started working.

Originally posted by Cerin with karma: 940 on 2016-03-16

This answer was ACCEPTED on the original site

Post score: 0


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.