Ask Your Question
0

Receiving subscribing data delayed between multiple devices

asked 2018-07-19 13:58:42 -0500

Passless11 gravatar image

I'm new to ROS and do not fully understand how its messaging system works.

I have two Raspberry Pi 3's that are communicating with each other over a local network. On one of the pi's, it takes a string input from the user through the console and publishes it to a topic. The other raspberry pi then subscribes to the topic, receives the user-inputted string, edits it, and then prints it to its terminal.

The problem I'm having is when I first publish to the topic, the subscribing node does not take the string data until I publish to the topic for a second time. I would like the subscribing node to edit and print the string as soon as the data is published to the topic. Does anyone know how this could be done?

edit retag flag offensive close merge delete

Comments

Seems like either your program somehow ignores the first message or it didn't get it. Rostopic echo the topic you are listening to in the receiving PI before you send it. If it doesn't echo it, it didn't go through. It's impossible to tell what is going wrong from the information you have provided.

Reamees gravatar image Reamees  ( 2018-07-20 01:33:50 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2018-07-20 08:22:15 -0500

gvdhoorn gravatar image

Please use the search: subscribing takes time. Setting up connections between publishers and subscribers takes time. If you don't allow for this setup, published msgs are lost (ie: no one is listening).

If you don't want to lose any messages, then bare publish-subscribe in ROS 1 is not what you should use. Services or actions might be more suitable.

Alternatively: consider using ros::Publisher::getNumSubscribers() and waiting for at least a single subscriber before publishing anything.

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

1 follower

Stats

Asked: 2018-07-19 13:58:42 -0500

Seen: 60 times

Last updated: Jul 20 '18