Ask Your Question
1

Tutorial Question: Writing a Simple Publisher and Subscriber (C++)

asked 2012-08-08 06:07:59 -0600

bg_ros gravatar image

updated 2012-08-08 12:48:07 -0600

Eric Perko gravatar image

i'm new to ROS and following the standard tutorial given on the ROS.ORG site. While running based on the topic of writing a simple publisher and subscriber, the outputs for talker and listener are shown below:

Talker output:

[INFO] hello world 1
[INFO] hello world 2
[INFO] hello world 3
[INFO] hello world 4
[INFO] hello world 5
[INFO] hello world 6
[INFO] hello world 7
[INFO] hello world 8

Listener output

[INFO] hello world 3
[INFO] hello world 4
[INFO] hello world 5
[INFO] hello world 6
[INFO] hello world 7
[INFO] hello world 8


It seems that "hello world 0", "hello world 1" and "hello world 2" are missing from the listener.

I have used the original source code given on the topic.

Is this normal, how come they are missing?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2012-08-08 06:35:41 -0600

dornhege gravatar image

This is normal.

Your code starts publishing right away, but in the background the two nodes first have to find each other and handle out a connection. Until that is done the messages are published to nowhere.

You can check when there is a connection by using pub.getNumSubscribers().

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-08-08 06:07:59 -0600

Seen: 320 times

Last updated: Aug 08 '12