Advertisement
Guest User

Autonomous Topic Map

a guest
Nov 7th, 2023
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.86 KB | None | 0 0
  1. import time
  2. import math
  3.  
  4. from bell.avr.mqtt.client import MQTTModule
  5. from bell.avr.mqtt.payloads import AvrPcmSetBaseColorPayload, AvrPcmSetServoAbsPayload, AvrAutonomousPayload
  6. from loguru import logger
  7. # Okay
  8. class Sandbox(MQTTModule):
  9.     def __init__(self) -> None:
  10.         super().__init__()
  11.         logger.debug("Class initialized")
  12.         self.enabled = False
  13.         self.topic_map = {"avr/autonomous": self.on_autonomous_message}
  14.  
  15.     def on_autonomous_message(self, payload: AvrAutonomousPayload) -> None:
  16.         self.enabled = payload["enable"]
  17.  
  18.     def autonomous_code(self) -> None:
  19.         while self.enabled:
  20.             box.send_message("avr/pcm/set_base_color", {"wrgb": [255, 255, 255, 255]})
  21.             print("Autonomous Flight Enabled")
  22.             time.sleep(1)
  23.  
  24. if __name__ == "__main__":
  25.     box = Sandbox()
  26.     box.run_non_blocking()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement