flexcomm_bridge is a ROS 2 - Jazzy package that bridges ROS topics and MQTT topics.
It supports bidirectional forwarding, JSON payload conversion, and optional location-based MQTT topic namespacing.
- Install runtime dependencies:
sudo apt update
sudo apt install -y mosquitto mosquitto-clients ros-jazzy-rclpy ros-jazzy-std-msgs- Build and source:
colcon build --packages-select flexcomm_bridge
source install/setup.bash- Start MQTT broker and bridge in separate terminals:
mosquitto -vsource install/setup.bash
ros2 run flexcomm_bridge bridge_node- Verify MQTT -> ROS 2:
# Terminal A
source install/setup.bash
ros2 topic echo /flexcomm/in
# Terminal B
mosquitto_pub -h localhost -t "bridge/demo_site/server/instructions" -m '"hello from mqtt"'- Verify ROS 2 -> MQTT:
# Terminal A
mosquitto_sub -h localhost -t "bridge/demo_site/server/status" -v
# Terminal B
source install/setup.bash
ros2 topic pub --once /flexcomm/out std_msgs/msg/String '{data: "hello from ros2"}'- ROS 2 -> MQTT and MQTT -> ROS 2 forwarding
- Config-driven topic mapping
- Optional MQTT namespacing via
namespace_rootandlocation_id - Local, public-safe defaults for first run
- MQTT transport via
paho-mqtt
- ROS 2 (Jazzy or compatible)
- Python 3.10+
- MQTT broker (examples use Mosquitto)
Install common runtime dependencies:
sudo apt update
sudo apt install -y mosquitto mosquitto-clients ros-jazzy-rclpy ros-jazzy-std-msgs- Node executable:
bridge_node = flexcomm_bridge.bridge_node:main - Launch file:
flexcomm_bridge/launch/bridge.launch.py - Effective runtime config:
config/bridge_config.yaml
Start a local MQTT broker:
mosquitto -vRun the bridge node:
source install/setup.bash
ros2 run flexcomm_bridge bridge_nodeOr with launch file:
source install/setup.bash
ros2 launch flexcomm_bridge bridge.launch.pyOverride config path at runtime:
source install/setup.bash
ros2 run flexcomm_bridge bridge_node --ros-args -p config_path:=/absolute/path/to/bridge_config.yamlDefault config file: config/bridge_config.yaml
- MQTT broker:
localhost:1883 - Namespace root:
bridge - Location ID:
demo_site - ROS inbound topic:
/flexcomm/in - ROS outbound topic:
/flexcomm/out - MQTT inbound topic (effective):
bridge/demo_site/server/instructions - MQTT outbound topic (effective):
bridge/demo_site/server/status
The runtime config is config/bridge_config.yaml.
Top-level fields:
protocol: MQTT transport settings (host,port, TLS, credentials)namespace_root: MQTT topic root to namespace (defaultbridge)location_id: Injected into topics undernamespace_rootconnections: List of bridge mappings
Connection entry format:
- ros_topic: /example/in
flexcomm_topic: bridge/server/input
message_type: std_msgs/msg/String
direction: mqtt_to_rosdirection values:
mqtt_to_rosros_to_mqttbidirectional
- If
location_idis empty, topic names are used as-is. - If
location_idis set, only topics undernamespace_rootare namespaced. - Example with defaults:
- Config topic:
bridge/server/status - Effective MQTT topic:
bridge/demo_site/server/status
- Config topic:
- Message conversion lives in
flexcomm_bridge/message_utils.py. - Dynamic message imports and connection wiring live in
flexcomm_bridge/bridge_node.py. - To add a new mapping, add an entry under
connectionswith a valid ROS message type string (package/msg/Type).
- Startup logs show:
- Loaded config path
- Effective namespace root and location
- Applied topic transformations
- MQTT subscriptions/publications
For live troubleshooting:
mosquitto_sub -h localhost -t "#" -v- Keep production secrets out of git. Use local overrides (for example
config/bridge_config.local.yaml) or environment-based injection in your deployment setup. - This repository is intentionally generic and does not require project-specific infrastructure to run locally.
- Bridge starts but no messages pass: verify broker is reachable with
mosquitto_sub -h localhost -t "#" -v. - Bridge starts but no messages pass: confirm the effective namespaced topic matches your publisher/subscriber topic.
- Bridge starts but no messages pass: check the ROS topic type matches
message_typein config. ros2 topic pubexits with an error: ensure ROS environment is sourced in that terminal (source install/setup.bash).
MIT License. See LICENSE.
- Contributing guide:
CONTRIBUTING.md - Security policy:
SECURITY.md - Pull request template:
.github/PULL_REQUEST_TEMPLATE.md - Issue templates:
.github/ISSUE_TEMPLATE/ - Continuous integration:
.github/workflows/ci.yml