groove-x / mqtt_bridge

mqtt_bridge provides a functionality to bridge between ROS and MQTT in bidirectional
MIT License
159 stars 146 forks source link

ros2 subscribe bug #73

Open jsb04 opened 1 year ago

jsb04 commented 1 year ago

Hi,

I think there is a bug/mistake in the Ros2 branch; while ros2 topics are subscribed to I don't think mqtt topics are subscribed because the initialization of the bridges happens before the mqtt client is connected so the subscription message is never sent. See lines 74 to 80 of https://github.com/groove-x/mqtt_bridge/blob/ros2/mqtt_bridge/app.py:

    # configure bridges
    bridges = []
    for bridge_args in bridge_params:
        bridges.append(create_bridge(**bridge_args,ros_node=mqtt_node))

    # start MQTT loop
    mqtt_client.loop_start()

This can be fixed by moving the last 2 lines to above line 74. Am I missing something or does anyone else agree that this is a bug/issue?