Skip to content

Instantly share code, notes, and snippets.

@AdroitAnandAI
Created August 12, 2021 05:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AdroitAnandAI/e504a81b721ca23cc6bc21122df3356a to your computer and use it in GitHub Desktop.
Save AdroitAnandAI/e504a81b721ca23cc6bc21122df3356a to your computer and use it in GitHub Desktop.
SLAM visualization with MQTT
# 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