Two-way communication between nodes?

asked 2013-12-11 05:50:54 -0500

MWrock gravatar image

I have two nodes that I want to send messages between. I need node1 to publish to topicA, and subscribe to topicB, while node2 publishes to topicB and subscribes to topicA. When I implement this, whichever node I launch first fails to subscribe and will only broadcast.

Is this some special case where I need to set up my publisher or subscriber differently?

I'm using ros::spinOnce() because I have other code that needs to run outside the callback. node2 also publishes to topicC and subscribes to topicD and topicE. Is there a limit on the number of publishers/subscribers?

edit retag flag offensive close merge delete

Comments

1

This *should* work. Can you pose the code for a a _minimal_ implementation where you see this effect?

lindzey gravatar image lindzey  ( 2013-12-11 09:39:46 -0500 )edit

Indeed, this should work. Can you elaborate on "fails to subscribe"? Is there an error message? Does the node not receive any messages? Does rostopic list show two unconnected topics by any chance?

autonomy gravatar image autonomy  ( 2013-12-12 06:55:40 -0500 )edit

rostopic shows that the nodes are connected. No error messages, just the callback functions never get called. I've found a workaround where I launch one node, let it create the publisher and then block while waiting for a cin. I launch the second node, create the subscriber and publisher then resume

MWrock gravatar image MWrock  ( 2013-12-13 06:51:12 -0500 )edit