ros2 mqtt-client installation and testing

The mqtt_client package provides a ROS Nodelet or ROS 2 component node that enables connected ROS-based devices or robots to use the MQTT protocol to exchange ROS messages through an
MQTT broker. This generally applies to any ROS message type. mqtt_client can also exchange raw messages with MQTT clients running on non-ROS-based devices.

Source code address:

https://github.com/ika-rwth-aachen/mqtt_client

Install

sudo apt update

安装mqtt-client 语句
sudo apt install ros-$ROS_DISTRO-mqtt-client

$ROS_DISTRO is your ros version number

sudo apt install ros-humble-mqtt-client

Insert image description here

Modify configuration file

cd /opt/ros/humble/share/mqtt_client/config

Insert image description here

vim params.ros2.yaml

Change it to your own address
Insert image description here

start up

ros2 launch mqtt_client standalone.launch.ros2.xml

Start successfully
Insert image description here
Test:

Publish messages on ros side

ros2 topic pub /ping/ros std_msgs/msg/String "{data: \"Hello MQTT\"}"

Insert image description here

Local computer client listening
Insert image description here

Guess you like

Origin blog.csdn.net/hai411741962/article/details/134593264