Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I publish same ROS topic on multiple MQTT messages? #18

Open
Lakshay011 opened this issue Apr 20, 2023 · 3 comments
Open

How can I publish same ROS topic on multiple MQTT messages? #18

Lakshay011 opened this issue Apr 20, 2023 · 3 comments

Comments

@Lakshay011
Copy link

Lakshay011 commented Apr 20, 2023

We attempted to publish a ROS topic message on multiple MQTT topics, but only one of the topics received the message. Is there a way to publish a single ROS message to multiple MQTT topics?

Config File:

broker:
    host: localhost
    port: 1883
bridge:
    ros2mqtt:
        -ros_topic: /agv/scan
         mqtt_topic: agv_mqtt/scan/ros1
         -ros_topic: /agv/scan
         mqtt_topic: agv_mqtt/scan/ros2
        -ros_topic: /agv/scan
         mqtt_topic: agv_mqtt/scan/primitive/ros1
         primitive: true
@lreiher
Copy link
Member

lreiher commented Apr 26, 2023

Hi, sorry for the delayed response.

What you are reporting is actually expected behavior. We are storing the ROS subscribers in a map structure, such that we can only store one ros2mqtt connection per ROS topic (see this line of code).

I guess we could change this behavior or at least issue a warning, but first, could you please describe why you would want to publish the same data to multiple topics?

@Lakshay011
Copy link
Author

Apologies for the delay in getting back to you.

We currently have a situation where we need to transmit Lidar data to both a ROS-based environment and a web-based environment for visualization. The ROS-based environment is capable of decoding non-primitive data, whereas the web-based environment lacks a decoding library that can convert this data into a ROS object. Therefore, our aim is to send the Lidar data as primitive data to enable easy decoding.

If you are aware of any library that can assist us in decoding non-primitive messages into ROS object on the web side, please inform us.

@lreiher
Copy link
Member

lreiher commented May 11, 2023

For the web based interpretation, it would probably help a lot if we had #9, unfortunately that's an open issue at the moment.

For the other issue, that we cannot publish the same ROS topic to multiple MQTT topics, you would have two options at the moment:

  • If you are familiar with C++ code, you could probably fix the current implementation pretty quickly to support multiple MQTT targets for each ROS topic, see my first answer.
  • Otherwise, you could use topic_tools/relay to relay the ROS topic to a second topic that you would then both forward individually to MQTT.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants