from PyQt5.QtWidgets import QApplication
from interfaces.camera import ListenerCamera
from interfaces.motors import PublisherMotors
from interfaces.point import ListenerPoint, PublisherPoint

if __name__ == "__main__":

    cameraL = ListenerCamera("/TurtlebotROS/cameraL/image_raw")
    cameraR = ListenerCamera("/TurtlebotROS/cameraR/image_raw")
    #motors = PublisherMotors("/TurtlebotROS/cmd_vel", 4, 0.3)

    pointTopic = "/TurtlebotROS/point"
    publishPoint = PublisherPoint(pointTopic)
    listenPoint = ListenerPoint(pointTopic)

    algorithm = MyAlgorithm(cameraL, cameraR, publishPoint)

    app = QApplication(sys.argv)
    myGUI = MainWindow()
    myGUI.setCamera(cameraL, 'left')
    myGUI.setCamera(cameraR, 'right')
    myGUI.setPlot(listenPoint)
    myGUI.setAlgorithm(algorithm)
    myGUI.show()

    t2 = ThreadGUI(myGUI)
    t2.daemon = True
    t2.start()

    sys.exit(app.exec_())