Rosanswers logo


Im trying to use a specific node (program A) as a test program being executed once taking the value to be published on a topic (lets call it "foo").

Program B is already subscribed to this topic and is running in a loop.

Program A will be ran like this: "rosrun package node argument", and published the argument (a number) to topic "foo".

program B never receives this message. My idea at this point is the fact that they never get to pair up with tcp with the use of the master node since the subscribing node isnt really subscribed.

Is there any way of making this executable able to send to the looped node B? or is there a specific reason this doesnt work?

I know this might seem like a stupid idea, but it is necessary for testing of the robot, and I dont know how to pass values to a running node for it to then publish.

In advance, thanks.

Originally posted by andreasvo on ROS Answers with karma: 7 on 2017-06-22

Post score: 0


1 Answer 1


Rosanswers logo

You most probably terminate your program immediately after calling pub.publish(msg) so that the publisher has no time to actually send the message. Could you show your code? The hacky solution is to simply wait a bit after sending, you could also check if the other node is listening with pub.getNumSubscribers().

Originally posted by NEngelhard with karma: 3519 on 2017-06-22

This answer was ACCEPTED on the original site

Post score: 2

Original comments

Comment by andreasvo on 2017-06-22:
The code is large, this is the chain of events though:

  1. A topic holder node starts the topic and holds it alive.
  2. Subscriber node starts subscribes.
  3. Publisher node advertises every time it is launched and publishes to that topic.

The issue might be trying to publish from a second node?

Comment by andreasvo on 2017-06-22:
pub.getNumSubscribers() gave 0.


Your Answer

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