Created
August 12, 2021 05:00
-
-
Save AdroitAnandAI/e504a81b721ca23cc6bc21122df3356a to your computer and use it in GitHub Desktop.
SLAM visualization with MQTT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# At the MQTT Transmission side | |
data2Transmit = np.array([x, y, theta]) | |
# Map which is saved as a bytearray is appended at the end | |
if scan_count % 30 == 0: | |
client.publish("safetycam/topic/slamviz", \\ | |
data2Transmit.tobytes() + mapbytes) | |
# At the MQTT receiving side | |
# As 3 float values takes 8*3 = 24 bytes | |
robotPos_bytes = msg.payload[:24] | |
map_bytes = msg.payload[24:] | |
robotPos = np.frombuffer(robotPos_bytes, dtype='float64') | |
robotPos = np.array(robotPos) | |
x, y, theta = robotPos | |
viz.display(x / 1000., y / 1000., theta, map_bytes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment