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

Roslaunch blocking message publication

asked 2016-03-16 00:59:07 -0500

Cerin gravatar image

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?

edit retag flag offensive close merge delete

Comments

Do you see your topic with rostopic list ? Is your node doing anything other than publishing?

ahendrix gravatar image ahendrix  ( 2016-03-16 01:20:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2016-03-16 03:09:34 -0500

Cerin gravatar image

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.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-03-16 00:59:07 -0500

Seen: 564 times

Last updated: Mar 16 '16