41 lines
1.0 KiB
Python
41 lines
1.0 KiB
Python
from PyQt6.QtWidgets import QApplication
|
|
|
|
from src.bot import Bot
|
|
from src.command import CarControl
|
|
from src.recorder import RecorderWindow
|
|
from src.snapshot import Snapshot
|
|
|
|
|
|
class ExampleBot(Bot):
|
|
def nn_infer(self, snapshot: Snapshot) -> list[tuple[CarControl, bool]]:
|
|
# Do smart NN inference here
|
|
return [(CarControl.FORWARD, True)]
|
|
|
|
def on_snapshot_received(self, snapshot: Snapshot):
|
|
controls: list[tuple[CarControl, bool]] = self.nn_infer(snapshot)
|
|
for control, active in controls:
|
|
self.recorder.on_car_controlled(control, active)
|
|
|
|
|
|
def main():
|
|
import sys
|
|
|
|
def except_hook(cls, exception, traceback):
|
|
sys.__excepthook__(cls, exception, traceback)
|
|
|
|
sys.excepthook = except_hook
|
|
|
|
app: QApplication = QApplication(sys.argv)
|
|
recorder: RecorderWindow = RecorderWindow("localhost", 5000)
|
|
bot: ExampleBot = ExampleBot(recorder)
|
|
|
|
app.aboutToQuit.connect(recorder.shutdown)
|
|
recorder.register_bot(bot)
|
|
recorder.show()
|
|
|
|
app.exec()
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|