srobo / sr-robot3-j5

Python 3 API for Student Robotics Kit - Built with j5
MIT License
4 stars 1 forks source link

Update MQTT #80

Closed WillB97 closed 1 year ago

WillB97 commented 1 year ago

Fixes the issue with make_safe not running when killed from the webUI when used with https://github.com/srobo/astoria/pull/180.

Decouples the MQTT section of Astoria from sr-robot3, the message structures are still imported from Astoria. To avoid the issues surrounding appropriate methods to do async event loop clean up in a largely synchronous codebase, this moves to using the paho-mqtt library which uses a background thread to handle the network loop. Cleanup is then handled by an atexit handler to disconnect and close the network loop thread.

To keep it simple there is a single long running client that is created within the robot's init routine and metadata and wait_start are done by temporarily subscribing to the relevant topics. Timeouts are used on the threading Events to prevent indefinite blocking.

WillB97 commented 1 year ago

This actually merged @ e2cef81, github seems to have glitched.

trickeydan commented 1 year ago
Screenshot 2022-11-19 at 20 22 31

much glitch lol