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

ROS publishers & subscribers still transmitting data after roscore closed

asked 2019-07-26 13:38:50 -0600

ratelle gravatar image

Hi,

I am working on a scale city project where we will have some cars running along a track connected to a watchtower. We have decided to use ROS for the project and are running Kinetic on Ubuntu 16.04 on RPi 3 B+'s. Today we were testing how ROS behaves in the event of internet failure and are a bit stumped:

We have one node on a Pi publishing sensor data. On my laptop, I am running roscore and subscribing to said data. On the pi, we set: ROS_MASTER_URI=http://(my computer's name).local:11311/ ROS_IP=(hostname -I)

We then launch roscore on my system. Then, we run the simple publishing script on the RPi (very, very simple -- similar to the publisher example code). Next, I run the subscriber on my computer. Data is printed as expected. However -- when I kill roscore, the data keeps transmitting and printing. If I reboot roscore, it continues to transmit.

This is extremely convenient for us, but why exactly is this happening? Shouldn't I expect connection between the two machines to cease once roscore has closed?

Thank you.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2019-07-26 23:12:24 -0600

updated 2019-07-26 23:14:42 -0600

As far as I know the subscriber and publisher nodes only communicate with roscore when declaring that they are subscribing or publishing a certain topic, service, parameter etc... After that, the nodes communicate with each other directly.

You can think of roscore as a sort of DNS. Once the nodes have discovered each other, they don't need to talk to roscore any more.

You can easily verify this behavior by opening 3 terminals. On the first one you run roscore, on the second one you run rostopic pub /my_int std_msgs/Int32 "data: 42" -r 1 (this will publish an integer with value 42 every second on a topic named /my_int) and on the third terminal run rostopic echo /my_int.

You will see the following output on the third terminal:

data: 42
---
data: 42
---
data: 42
---

After that, if you kill roscore on the first terminal you will see that the publisher and the subscriber are unaffected and messages data: 42 will keep piling up on the third terminal.

The problem is if roscore dies and a new node wants to register itself as a publisher or as a subscriber it will not be able to and will give you an error.

For your application you might be interested in looking into ROS2. No roscore is needed any more.

edit flag offensive delete link more

Comments

What the OP decribes would seem to come down to an misunderstanding of how TCPROS works: it's not like MQTT where the broker is always needed. Nodes communicate peer-to-peer as soon as the initial connection has been setup, as exemplified by the series of commands shown by @Martin Peris.

gvdhoorn gravatar image gvdhoorn  ( 2019-07-28 12:01:23 -0600 )edit

Question Tools

Stats

Asked: 2019-07-26 13:38:50 -0600

Seen: 381 times

Last updated: Jul 26 '19