-
Notifications
You must be signed in to change notification settings - Fork 20
MQTT Publish Controller
MQTT is a Machine-to-Machine communication protocol supporting a lightweight publish/subscribe message transport. It is commonly used in IoT and home automation appliances. This Remo hardware controller will allow commands received from the remo site to be published to a MQTT broker. Various remote robots, devices, and software can subscribe to the MQTT broker to receive messages. This configuration will allow the command processing to be decoupled from the Remo client software both in software processing and, if you choose, the network/system location.
Using the MQTT Pub hardware with Remo, you can broadcast the command messages from the site to many different devices in your robot environment. It would also be possible to publish messages to devices that already have an MQTT interface.
A common example would be to separate the video/audio streaming services from the command processing software. That is, you could support a camera with video that is on a separate computer/raspberry pi than the robot or robots.
The mqtt_pub.py
script is an impolementation of the Remo client hardware controller. The script uses the Eclipse Foundation Paho Python library.
It contains methos for setup()
and move()
. On setup()
the script will load all configurations. It will create an MQTT client and attach handlers for connection, disconnection, and message publishing.
When move()
is called, the script will attempt a connection to the configured MQTT broker, publish the 'command' arguments, and disconnect.
The mqtt_pub
script does not contain the MQTT broker, or subscription methods.
To use the mqtt_pub
script, the mqtt library 'paho' must be installed on the machine with the remo client software. Instructions for the installation of paho MQTT can be found here
In addition, to use the mqtt capabilities, a MQTT broker must be available to be connected and running. The Mosquitto project has a Broker as well as a command line publish and subscribe clients. Information on Mosquitto can be found here. Information on installing a Mosquitto Broker on a Raspberry Pi can be found here.
Finally, the robot that will use the MQTT message stream will need to have software that can subscribe to the MQTT broker then take action on the messages. This software is not difficult to write using the paho library in python.
To use the mqtt_pub
controller software, it must be configured to operate in the controller.conf
file.
[robot]
type=mqtt_pub
[mqtt_pub]
# If you are using MQTT you need to suply the host IP address, port, and Topic.
# host should be the IP address where the MQTT broker is running.
# port is typically 1883
# topic is your choice, but it needs to match with the robot subscribers
host=192.168.178.88
port=1883
topic=Remo/command
- Adafruit Motor Hat
- Adafruit PWM / Servo Hat
- Anki Cozmo on MacOS/Linux
- Anki Cozmo on Windows
- Cytron MDD10 10 Amp Motor Driver
- GoPiGo2
- GoPiGo3
- L298N Dual Motor Driver
- MAX7219 SPI LED Driver
- MotoZero 4 Motor Controller
- MQTT Publish Controller
- OWI 535 Robotic Arm (USB Controller)
- Serial Based Controllers (Parallaxy or Arduinos)
- PiBorg ThunderBorg Motor Driver
- Pololu Daul MC33926 Motor Driver (experimental)
- Pololu DRV8835 Dual Motor Driver
- Pololu Maestro Servo Controller (experimental)