Roslaunch blocking message publication
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:
<launch>
<node name="mypub" pkg="mypackage" type="mypub_node.py" output="screen">
</node>
</launch>
And the node seems to start up cleanly with the output:
started roslaunch server http://localhost:60558/
SUMMARY
========
PARAMETERS
* /rosdistro: indigo
* /rosversion: 1.11.16
NODES
/
mypub (mypackage/mypub_node.py)
ROS_MASTER_URI=http://localhost:11311
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.0.0.0 0
[DEBUG] [WallTime: 1458106329.537606] bound to 0.0.0.0 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.0.0.0 0
[DEBUG] [WallTime: 1458107532.212995] bound to 0.0.0.0 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?
Do you see your topic with
rostopic list
? Is your node doing anything other than publishing?