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

ROS2 transfer the same message on the same topic without redundancy

asked 2020-07-22 07:47:43 -0600

maxime gravatar image

updated 2020-07-22 11:42:37 -0600

  • On Node_1, I'm publishing to /telemetry.
  • On Node_2, I'm subscribing on /telemetry & publishing the SAME message back on /telemetry (in order for Node_3 to receive it). I do not create a new message. I just publish back the one received.
  • On Node_3, I'm subscribing to /telemetry.

----

  • Node_1 & Node_2 are in Network_A.
  • Node_2 & Node_3 are in Network_B.

----

As Node_2 is subscribing and publishing in the same topic, the message are going back and forth inside the node.

How do I make Node_2 not sending back to himself the message transferred ? I thought messages were not received twice so I assumed it would work. Seems like not.

UPDATE

After few check, if I create one message and publish it twice, then I'll receive it twice.

How can I avoid this ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-22 08:47:54 -0600

ivanpauno gravatar image

Hi Maxime,

I'm subscribing on /telemetry & publishing the SAME message back

Though you're publishing the same message you received, you're actually publishing a "new" message.

As Node_2 is subscribing and publishing in the same topic, the message are going back and forth inside the node.

There's a [ignore_local_publication]https://gith...) option, but that flag was always ignored in rmw_fastrtps. So, yes you're going to receive the same message you published back and forth.

How do I make Node_2 not sending back to himself the message transferred ? I thought messages were not received twice so I assumed it would work. Seems like not.

I would recommend using a different topic.

Node_1 & Node_2 are in Network_A. Node_2 & Node_3 are in Network_B.

Are you sure Node_3 isn't receiving messages from Node_1 directly? In the case the answer is no, is Node_3 receiving messages from Node_2? I don't recall how FastRTPS handled multiple network interfaces.

Best, Ivan

edit flag offensive delete link more

Comments

Hello and thanks for your answer !

I tried the ignore local publication options but as you guessed, it did not work.

No, Node_3 doesn't receive messages from Node_1. Would be weird if it would do it by default in my opinion. However, is there anyway to do it ?

Lastly, in the system we are building, several networks are involved. Therefore, we would need a way to pass/transfer/republish a message without modifying its publisher and metadata in order for the message to be unique and considered as one message through all the networks.

Is there any way to do that ?

maxime gravatar image maxime  ( 2020-07-22 09:12:06 -0600 )edit

If you're republishing it, it can't be the "same" message according to the transport. The canonical way to do this is to use different topics as Ivan suggested.

This sounds a lot like an XY problem I suggest you take a step back and ask about your higher level problem. You're trying to do things that aren't clear to us why you'd want to do them seem to be based on unstated assumptions about how things can or should work.

tfoote gravatar image tfoote  ( 2020-07-22 13:10:53 -0600 )edit

Hey @tfoote, thanks for your comment.

Having 2 different topics, means that if X Node republish the msg received then they will create X new message on the other topic. And this might lead to a problem at some point if we have a lot of Node. And is also an ugly way to do it, in my opinion.

The idea I had was to take the message received and to publish it back AS IS. In order for the one that already received it to discard it by default using FastRTPS and to therefore don't surcharge the network with useless new message.

I feel the idea of what I want to do is pretty straightforward and can be understand. If every-time X Node receive a message and republish it to a new /topic, OK it will be transmitted but it means that on the end subscriber I'll ...(more)

maxime gravatar image maxime  ( 2020-07-23 01:16:45 -0600 )edit

Having 2 different topics, means that if X Node republish the msg received then they will create X new message on the other topic

Republishing the message in another topic is as efficient as republishing it in the same topic. Re-using the same topic doesn't have a benefit.

The idea I had was to take the message received and to publish it back AS IS. In order for the one that already received it to discard it by default using FastRTPS and to therefore don't surcharge the network with useless new message.

As commented above, if you republish the message it will actually generate network traffic. It doesn't matter if the topic is the same one.

If every-time X Node receive a message and republish it to a new /topic, OK it will be transmitted but it means that on the end subscriber I'll have to ...

(more)
ivanpauno gravatar image ivanpauno  ( 2020-07-23 08:07:06 -0600 )edit

I don't know exactly how your native FastRTPS application worked, maybe it would be interesting if you can share it. Then we can try to create the closest ROS 2 example that works in the same (or a similar way).

ivanpauno gravatar image ivanpauno  ( 2020-07-23 08:09:05 -0600 )edit

I haven't done anything with FastRTPS. I'm using the basic config that ROS2 provides. Also haven't created a FastRTPS application either.

The thing is that we have multiple networks, VPN (through 3G) & radio-network (through IP radios). And multiple systems - one of them is a relay Node. The relay node is both connected to the VPN and to the radio-network. The idea is that, whatever it receives, it republishes back AS IS - ideally to the other network only but as of now if it just republishes back to all networks it's fine. The idea is when the 3G fails, as the message go through radio-network, it eventually end up being republished by a relay node to the VPN network

If we start republishing messages on a new topic THEN we need to add an extra piece of code (and extra piece of data in our messages ...(more)

maxime gravatar image maxime  ( 2020-07-27 02:51:09 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2020-07-22 07:47:43 -0600

Seen: 1,270 times

Last updated: Jul 22 '20