Skip to content

Commit 2ac9b00

Browse files
committed
include primitive example in readme
1 parent 1a0b2cf commit 2ac9b00

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

README.md

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ docker run --rm --network host --name mosquitto eclipse-mosquitto
5757

5858
The *mqtt_client* is best configured with a ROS parameter *yaml* file. The configuration shown below (also see [`params.yaml`](launch/params.yaml)) allows an exchange of messages as follows:
5959

60-
- ROS messages received locally on topic `/ping` are sent to the broker on MQTT topic `pingpong`
61-
- MQTT messages received from the broker on MQTT topic `pingpong` are published locally on ROS topic `/pong`
60+
- ROS messages received locally on ROS topic `/ping` are sent to the broker on MQTT topic `pingpong`;
61+
- MQTT messages received from the broker on MQTT topic `pingpong` are published locally on ROS topic `/pong`;
62+
- MQTT messages received sent by other non-ROS clients and received from the broker on MQTT topic `primitive` are published locally as primitive ROS messages (`bool`, `int`, `float`, `string`) on ROS topic `/primitive`.
6263

6364
```yaml
6465
broker:
@@ -71,6 +72,9 @@ bridge:
7172
mqtt2ros:
7273
- mqtt_topic: pingpong
7374
ros_topic: /pong
75+
- mqtt_topic: primitive
76+
ros_topic: /primitive
77+
primitive: true
7478
```
7579
7680
#### Demo Client Launch
@@ -82,33 +86,44 @@ roslaunch mqtt_client standalone.launch
8286
```
8387

8488
```txt
85-
[ WARN] [1652888439.858857758]: Parameter 'broker/tls/enabled' not set, defaulting to '0'
86-
[ WARN] [1652888439.859706411]: Parameter 'client/id' not set, defaulting to ''
87-
[ WARN] [1652888439.859717540]: Client buffer can not be enabled when client ID is empty
88-
[ WARN] [1652888439.860144376]: Parameter 'client/clean_session' not set, defaulting to '1'
89-
[ WARN] [1652888439.860366209]: Parameter 'client/keep_alive_interval' not set, defaulting to '0.000000'
90-
[ WARN] [1652888439.860583442]: Parameter 'client/max_inflight' not set, defaulting to '65535'
91-
[ INFO] [1652888439.860924591]: Bridging ROS topic '/ping' to MQTT topic 'pingpong'
92-
[ INFO] [1652888439.860967600]: Bridging MQTT topic 'pingpong' to ROS topic '/pong'
93-
[ INFO] [1652888439.861800203]: Connecting to broker at 'tcp://localhost:1883' ...
94-
[ INFO] [1652888440.062255501]: Connected to broker at 'tcp://localhost:1883'
89+
[ WARN] [1665521116.598414724]: Parameter 'broker/tls/enabled' not set, defaulting to '0'
90+
[ WARN] [1665521116.598987895]: Parameter 'client/id' not set, defaulting to ''
91+
[ WARN] [1665521116.599000755]: Client buffer can not be enabled when client ID is empty
92+
[ WARN] [1665521116.599293016]: Parameter 'client/clean_session' not set, defaulting to '1'
93+
[ WARN] [1665521116.599543528]: Parameter 'client/keep_alive_interval' not set, defaulting to '60.000000'
94+
[ WARN] [1665521116.599792350]: Parameter 'client/max_inflight' not set, defaulting to '65535'
95+
[ INFO] [1665521116.600156748]: Bridging ROS topic '/ping' to MQTT topic 'pingpong'
96+
[ INFO] [1665521116.600202047]: Bridging MQTT topic 'pingpong' to ROS topic '/pong'
97+
[ INFO] [1665521116.600219366]: Bridging MQTT topic 'primitive' to primitive ROS topic '/primitive'
98+
[ INFO] [1665521116.600988342]: Connecting to broker at 'tcp://localhost:1883' ...
99+
[ INFO] [1665521116.701596581]: Connected to broker at 'tcp://localhost:1883'
95100
```
96101

97102
Note that the *mqtt_client* successfully connected to the broker and also echoed which ROS/MQTT topics are being bridged.
98103

99-
In order to test the communication, publish any message on ROS topic `/ping` and wait for a response on ROS topic `/pong`. To this end, open two new terminals and execute the following commands.
104+
In order to test the communication among `mqtt_client`, publish any message on ROS topic `/ping` and wait for a response on ROS topic `/pong`. In order to test the communication between other MQTT clients and the `mqtt_client`, directly publish any message on MQTT topic `primitive` and wait for a response on ROS topic `/primitive`. To this end, open four new terminals and execute the following commands.
100105

101106
```bash
102-
# 1st terminal: listen on /pong
107+
# 1st terminal: listen for ROS messages on /pong
103108
rostopic echo /pong
104109
```
105110

106111
```bash
107-
# 2nd terminal: publish to /ping
112+
# 2nd terminal: publish ROS message to /ping
108113
rostopic pub -r 1 /ping std_msgs/String "Hello MQTT!"
109114
```
110115

111-
If everything works as expected, a new message should be printed in the first terminal once a second.
116+
```bash
117+
# 3rd terminal: listen for ROS messages on /primitive
118+
rostopic echo /primitive
119+
```
120+
121+
```bash
122+
# 4th terminal: publish MQTT message to primitive
123+
docker run --rm --network host eclipse-mosquitto mosquitto_pub -h localhost -t "primitive" --repeat 10 --repeat-delay 1 -m 3.14
124+
```
125+
126+
If everything works as expected, a new message should be printed in the first and third terminal once a second.
112127

113128
### Launch
114129

launch/params.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,6 @@ bridge:
88
mqtt2ros:
99
- mqtt_topic: pingpong
1010
ros_topic: /pong
11+
- mqtt_topic: primitive
12+
ros_topic: /primitive
13+
primitive: true

0 commit comments

Comments
 (0)