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

Problem with Publish/Subscribe [closed]

asked 2013-05-25 02:32:32 -0500

MrSnail gravatar image

Basically, I have a node that is subscribed to 6 other nodes.

I have an initialize routine that needs a response from each node that they're done initializing. I get a fine response from 3 of them, but not the other 3. The weird thing is, they actually publish their message and can see it if I echo on the topic in the terminal, but the node receiving does not actually receive it. The even weirder part is, that if I publish to the topic with the message through the terminal, the receiving node actually reacts as it should.

I hope this makes sense.

Thanks in advance!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Philip
close date 2013-05-25 12:10:51

Comments

Are all nodes running on the same machine? Network set up correctly?

Ben_S gravatar image Ben_S  ( 2013-05-25 03:21:01 -0500 )edit

Yes, same machine.

MrSnail gravatar image MrSnail  ( 2013-05-25 03:25:53 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-05-25 11:01:37 -0500

Philip gravatar image

updated 2013-05-25 11:02:30 -0500

The six nodes send out one message each when they are done with initialization?

Then my first guess would be that there's some timing issue. Possibilities are e.g.

  • The "supervision node" starts listening only after the first messages are already sent
  • The three nodes publish immediately after advertising their publisher, before the "supervision node" is completely subscribed

First attempt at a solution: in the six nodes, include a delay of one or two seconds between creation of the publisher and publishing the first message. Start the supervision node first, then the other nodes. If this works, you found your culprit.

Also, you could enable latching:

When a connection is latched, the last message published is saved and automatically sent to any future subscribers that connect. This is useful for slow-changing to static data like a map. Note that if there are multiple publishers on the same topic, instantiated in the same node, then only the last published message from that node will be sent, as opposed to the last published message from each publisher on that single topic.


If both do not work, check if the subscriber and the publishers use the exact same message type. Differences (e.g. publishing std_msgs::Pose, subscribing to std_msgs::PoseStamped) might lead to not receiving anything.

edit flag offensive delete link more

Comments

Latching worked! Thank you.

MrSnail gravatar image MrSnail  ( 2013-05-25 11:48:35 -0500 )edit

Question Tools

Stats

Asked: 2013-05-25 02:32:32 -0500

Seen: 234 times

Last updated: May 25 '13