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

Sending messages from MQTT #52

Closed niomate closed 3 years ago

niomate commented 3 years ago

Hi just a question since I could not find anything about it in here. How would I go about sending a message from MQTT to a ROS-topic ? What format is expected ?

I tried something along the lines of

mqtt pub -t command -m "{'data':  'move'}" 

The data printed in

mqtt sub -t command --jsonOutput

looked exactly the same as the data received from rostopic pub.

I set up the bridge following the tutorial precisely, so that should not be an issue.

I also tried sending data from python

import paho.mqtt.publish as publish
import json
publish.single("command", json.dumps({"data": "move next"}))
publish.single("command", "move next"}))

and Node-Red

[{"id":"a6fe74db.61f648","type":"inject","z":"ffe42276.7efb1","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"\"move next\"","payloadType":"str","x":790,"y":500,"wires":[["61ab1db.5bc4164"]]}]

but nothing seemed to work.

So how would I do that ?

Regards

niomate commented 3 years ago

I seem to have overlooked a tiny typo in the configuration file. Sorry for opening up an issue for that. Have a nice day !