NCRL_MQTT

Server

$ cd /etc/mosquitto $ vim mosquitto.conf # 修改完後,重起服務 $ sudo systemctl status mosquitto

Client

Client OS ubuntu 20.04

Client OS not ubuntu 20.04

1. Prerequisites

For Linux : $ sudo apt-get install docker.io For Rpi : $ curl -fsSL https://get.docker.com/ | sh # 打完下面這行要logout $ sudo usermod -aG docker ${使用者名稱}
  • download ncrl_mqtt repo
$ cd # download repo for docker usage $ git clone https://github.com/leeandy0822/ncrl_mqtt.git $ cd ncrl_mqtt # run docker $ source docker_run.sh #catkin_make and load env parameters $ source env.sh

2. 更改 broker host IP

$ roscd mqtt_client $ cd launch $ vim params.yaml

3. Enable the mqtt_ros service

$ roslaunch mqtt_client standalone.launch

4. Check the ros topics

ROS Input MQTT ROS_Output
/ping/ros /pingpong/ros /pong/ros
/ping/primitive /pingpong/primitive /pong/primitive

Authorization

1. broker 端新增 password file

  • move to /etc/mosquito
$ cd /etc/mosquito # 新增一個 password file $ sudo mosquitto_passwd -c <password file name> <name> # example $ sudo mosquitto_passwd -c password ncqq # 打密碼和確認密碼(這裡設定ee405423) $ vim password # username:log

2. 重啟 broker 端 server

$ sudo service mosquitto restart

3. 所有 client 都要新增 password 設定

  • 開啟 mqtt_client/launch/params.yaml
$ cd ws/src/mqtt_client/launch $ vim params.yaml # 在 broker 下面新增 user: 和 pass: # 帳號密碼要與上面password file 一致

Select a repo