Ejemplo n.º 1
0
class MainWindow(QMainWindow, Ui_MainWindow):

    updGUI = pyqtSignal()

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop = TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.teleop.setVisible(True)
        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)
        self.sensorsCheck.stateChanged.connect(self.showSensorsWidget)

        self.rotationDial.valueChanged.connect(self.rotationChange)
        self.altdSlider.valueChanged.connect(self.altitudeChange)

        self.cameraWidget = ColorFilterWidget(self)
        self.sensorsWidget = SensorsWidget(self)
        self.changeCamButton.clicked.connect(self.changeCamera)

        self.trackingCommunicator = Communicator()

        self.pushButton.clicked.connect(self.pushClicked)
        self.pushButton.setCheckable(True)
        self.resetButton.clicked.connect(self.resetClicked)
        self.takeoffButton.clicked.connect(self.takeOffClicked)
        self.camera1 = CameraWidget(self)

        self.takeoff = False
        self.reset = False
        self.record = False

    def getDrone(self):
        return self.drone

    def setDrone(self, drone):
        self.drone = drone

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def getAlgorithm(self):
        return self.algorithm

    def updateGUI(self):
        self.camera1.updateImage()
        self.sensorsWidget.sensorsUpdate.emit()

    def pushClicked(self):
        if self.pushButton.isChecked():
            icon = QtGui.QIcon()
            self.pushButton.setText('Stop Code')
            self.pushButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.pushButton.setText('Play Code')
            self.pushButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.pushButton.setIcon(icon)
            self.algorithm.stop()
            self.rotationDial.setValue(self.altdSlider.maximum() / 2)
            self.altdSlider.setValue(self.altdSlider.maximum() / 2)
            self.drone.sendCMDVel(0, 0, 0, 0, 0, 0)
            self.teleop.stopSIG.emit()

    def takeOffClicked(self):
        if (self.takeoff == True):
            self.takeoffButton.setText("Take Off")
            self.drone.land()
            self.takeoff = False
        else:
            self.takeoffButton.setText("Land")
            self.drone.takeoff()
            self.takeoff = True

    def resetClicked(self):
        if self.reset == True:
            self.resetButton.setText("Reset")
            self.drone.reset()
            self.reset = False
        else:
            self.resetButton.setText("Unreset")
            self.drone.reset()
            self.reset = True
            self.rotationDial.setValue(self.altdSlider.maximum() / 2)
            self.altdSlider.setValue(self.altdSlider.maximum() / 2)
            self.drone.sendCMDVel(0, 0, 0, 0, 0, 0)
            self.teleop.stopSIG.emit()

    def changeCamera(self):
        self.drone.toggleCam()

    def showSensorsWidget(self, state):
        if state == Qt.Checked:
            self.sensorsWidget.show()
        else:
            self.sensorsWidget.close()

    def closeSensorsWidget(self):
        self.sensorsCheck.setChecked(False)

    def rotationChange(self, value):
        value = (1.0 / (self.rotationDial.maximum() / 2)) * (
            value - (self.rotationDial.maximum() / 2))
        self.rotValue.setText('%.2f' % value)
        self.drone.setYaw(value)
        self.drone.sendVelocities()

    def altitudeChange(self, value):
        value = (1.0 / (self.altdSlider.maximum() / 2)) * (
            value - (self.altdSlider.maximum() / 2))
        self.altdValue.setText('%.2f' % value)
        self.drone.setVZ(value)
        self.drone.sendVelocities()

    def setXYValues(self, newX, newY):
        self.XValue.setText('%.2f' % newX)
        self.YValue.setText('%.2f' % newY)
        self.drone.setVX(-newY)
        self.drone.setVY(-newX)
        self.drone.sendVelocities()

    def closeEvent(self, event):
        self.algorithm.kill()
        self.drone.__camera.stop()
        #self.navdata.stop()
        self.drone.__pose.stop()
        event.accept()
Ejemplo n.º 2
0
class MainWindow(QMainWindow, Ui_MainWindow):

    updGUI = pyqtSignal()

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop = TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.record = False

        self.updGUI.connect(self.updateGUI)

        self.cameraCheck.stateChanged.connect(self.showCameraWidget)
        self.sensorsCheck.stateChanged.connect(self.showSensorsWidget)
        self.colorFilterCheck.stateChanged.connect(self.showColorFilterWidget)

        self.rotationDial.valueChanged.connect(self.rotationChange)
        self.altdSlider.valueChanged.connect(self.altitudeChange)

        self.cameraWidget = CameraWidget(self)
        self.sensorsWidget = SensorsWidget(self)
        self.colorFilterWidget = ColorFilterWidget(self)

        self.cameraCommunicator = Communicator()
        self.colorFilterCommunicator = Communicator()
        self.trackingCommunicator = Communicator()

        # self.stopButton.clicked.connect(self.stopClicked)
        self.playstopButton.clicked.connect(self.playstopClicked)
        self.resetButton.clicked.connect(self.resetClicked)
        self.takeoffButton.clicked.connect(self.takeOffClicked)
        self.takeoff = False
        self.reset = False

    def getCamera(self):
        return self.camera

    def setCamera(self, camera):
        self.camera = camera

    def getNavData(self):
        return self.navdata

    def setNavData(self, navdata):
        self.navdata = navdata

    def getPose3D(self):
        return self.pose

    def setPose3D(self, pose):
        self.pose = pose

    def getCMDVel(self):
        return self.cmdvel

    def setCMDVel(self, cmdvel):
        self.cmdvel = cmdvel

    def getExtra(self):
        return self.extra

    def setExtra(self, extra):
        self.extra = extra

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def getAlgorithm(self):
        return self.algorithm

    def updateGUI(self):
        self.cameraWidget.imageUpdate.emit()
        self.sensorsWidget.sensorsUpdate.emit()
        self.colorFilterWidget.imageUpdate.emit()

    def playstopClicked(self):
        if self.playstopButton.isChecked():
            if self.record == True:
                self.extra.record(True)
            self.playstopButton.setText("Stop code")
            self.playstopButton.setStyleSheet("background-color: #ec7063")
            self.playstopButton.setIcon(self.icon1)
            self.algorithm.play()
        else:
            if self.record == True:
                self.extra.record(False)
            self.algorithm.stop()
            self.playstopButton.setStyleSheet("background-color: #7dcea0")
            self.playstopButton.setText("Play code")
            self.playstopButton.setIcon(self.icon)
            self.rotationDial.setValue(self.altdSlider.maximum() / 2)
            self.altdSlider.setValue(self.altdSlider.maximum() / 2)
            self.cmdvel.sendCMDVel(0, 0, 0, 0, 0, 0)
            self.teleop.stopSIG.emit()

    def takeOffClicked(self):
        if (self.takeoff == True):
            self.takeoffButton.setText("Take Off")
            self.extra.land()
            self.takeoff = False
        else:
            self.takeoffButton.setText("Land")
            self.extra.takeoff()
            self.takeoff = True

    def resetClicked(self):
        if self.reset == True:
            self.resetButton.setText("Reset")
            self.extra.reset()
            self.reset = False
        else:
            self.resetButton.setText("Unreset")
            self.extra.reset()
            self.reset = True

    def showCameraWidget(self, state):
        if state == Qt.Checked:
            self.cameraWidget.show()
        else:
            self.cameraWidget.close()

    def closeCameraWidget(self):
        self.cameraCheck.setChecked(False)

    def showColorFilterWidget(self, state):
        if state == Qt.Checked:
            self.colorFilterWidget.show()
        else:
            self.colorFilterWidget.close()

    def closeColorFilterWidget(self):
        self.colorFilterCheck.setChecked(False)

    def showSensorsWidget(self, state):
        if state == Qt.Checked:
            self.sensorsWidget.show()
        else:
            self.sensorsWidget.close()

    def closeSensorsWidget(self):
        self.sensorsCheck.setChecked(False)

    def rotationChange(self, value):
        value = (1.0 / (self.rotationDial.maximum() / 2)) * (
            value - (self.rotationDial.maximum() / 2))
        self.rotValue.setText('%.2f' % value)
        self.cmdvel.setYaw(value)
        self.cmdvel.sendVelocities()

    def altitudeChange(self, value):
        value = (1.0 / (self.altdSlider.maximum() / 2)) * (
            value - (self.altdSlider.maximum() / 2))
        self.rotValue.setText('%.2f' % value)
        self.cmdvel.setVZ(value)
        self.cmdvel.sendVelocities()

    def setXYValues(self, newX, newY):
        self.XValue.setText('%.2f' % newX)
        self.YValue.setText('%.2f' % newY)
        self.cmdvel.setVX(-newY)
        self.cmdvel.setVY(-newX)
        self.cmdvel.sendVelocities()

    def closeEvent(self, event):
        self.algorithm.kill()
        self.camera.client.stop()
        self.navdata.stop()
        self.pose.stop()
        event.accept()
Ejemplo n.º 3
0
class MainWindow(QMainWindow, Ui_MainWindow):

    updGUI = pyqtSignal()

    def __init__(self, camera, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)

        self.camera = camera

        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)

        self.cameraCheck.stateChanged.connect(self.showCameraWidget)
        self.colorFilterCheck.stateChanged.connect(self.showColorFilterWidget)

        self.cameraWidget = CameraWidget(self)
        self.colorFilterWidget = ColorFilterWidget(self)

        self.cameraCommunicator = Communicator()
        self.colorFilterCommunicator = Communicator()
        self.trackingCommunicator = Communicator()

        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)

    def getCamera(self):
        return self.camera

    def setCamera(self, camera):
        self.camera = camera

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def getAlgorithm(self):
        return self.algorithm

    def updateGUI(self):
        self.cameraWidget.imageUpdate.emit()
        self.colorFilterWidget.imageUpdate.emit()

    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.playButton.setStyleSheet("background-color: #7dcea0")
            self.algorithm.stop()

    def showCameraWidget(self, state):
        if state == Qt.Checked:
            self.cameraWidget.show()
        else:
            self.cameraWidget.close()

    def closeCameraWidget(self):
        self.cameraCheck.setChecked(False)

    def showColorFilterWidget(self, state):
        if state == Qt.Checked:
            self.colorFilterWidget.show()
        else:
            self.colorFilterWidget.close()

    def closeColorFilterWidget(self):
        self.colorFilterCheck.setChecked(False)

    def closeEvent(self, event):
        self.algorithm.kill()
        self.colorFilterWidget.closeEvent(event)
        self.closeColorFilterWidget()
        self.closeCameraWidget()
        self.camera.client.stop()
        event.accept()
Ejemplo n.º 4
0
class Ui_MainWindow(object):
    IMAGE_COLS_MAX = 640
    IMAGE_ROWS_MAX = 360
    LINX = 0.3
    LINY = 0.3
    LINZ = 0.8
    ANGZ = 1.0
    ANGY = 0.0
    ANGX = 0.0

    def setupUI(self, MainWindow):
        ## All GUI components of the main window are built here

        self.setWindowTitle("Color filter")

        # VerticalLayout with 2 rows
        vlayout = QVBoxLayout(MainWindow)
        vlayout.setSpacing(0)

        vlayout.setContentsMargins(0, 0, 0, 0)
        # Row 1
        groupbox_1 = QGroupBox()
        groupbox_1.setContentsMargins(0, 0, 0, 0)
        hlayout = QHBoxLayout()
        hlayout.setContentsMargins(0, 0, 0, 0)

        hlayout.setAlignment(Qt.AlignCenter)

        # Row 1 Col 1
        groupbox_1_1 = QGroupBox()
        vlayout_inner = QVBoxLayout()
        vlayout_inner.setContentsMargins(0, 0, 0, 0)
        vlayout_inner.setAlignment(Qt.AlignCenter)
        text1 = "Live Video Stream"
        window_1_label = QLabel()
        window_1_label.setAlignment(Qt.AlignCenter)
        window_1_label.setText(text1)
        vlayout_inner.addWidget(window_1_label)
        self.imgLabelColor = QLabel()
        self.imgLabelColor.setFixedSize(640, 360)
        self.imgLabelColor.setAlignment(Qt.AlignCenter)
        vlayout_inner.addWidget(self.imgLabelColor)
        groupbox_1_1.setLayout(vlayout_inner)
        hlayout.addWidget(groupbox_1_1)

        # Row 1 Col 2

        groupbox_1_2 = QGroupBox()
        vlayout_inner = QVBoxLayout()
        vlayout_inner.setContentsMargins(0, 0, 0, 0)
        vlayout_inner.setAlignment(Qt.AlignCenter)
        text2 = "Output after thresholding"
        window_2_label = QLabel()
        window_2_label.setAlignment(Qt.AlignCenter)
        window_2_label.setText(text2)
        vlayout_inner.addWidget(window_2_label)
        self.imgLabelBlackWhite = QLabel()
        self.imgLabelBlackWhite.setAlignment(Qt.AlignCenter)
        self.imgLabelBlackWhite.setFixedSize(640, 360)
        vlayout_inner.addWidget(self.imgLabelBlackWhite)
        groupbox_1_2.setLayout(vlayout_inner)
        hlayout.addWidget(groupbox_1_2)
        groupbox_1.setLayout(hlayout)
        vlayout.addWidget(groupbox_1)

        # ROW 2

        groupbox_2 = QGroupBox()
        groupbox_2.setContentsMargins(0, 0, 0, 0)
        h_3layout = QHBoxLayout()
        h_3layout.setContentsMargins(0, 0, 0, 0)

        # Row 2 Col 1

        groupbox_2_1 = QGroupBox()

        h2layout = QVBoxLayout()
        h2layout.setAlignment(Qt.AlignCenter)
        text3 = 'Final Processed Image'
        window_3_label = QLabel()
        window_3_label.setAlignment(Qt.AlignCenter)
        window_3_label.setText(text3)
        h2layout.addWidget(window_3_label)
        self.detectedImage = QLabel()
        self.detectedImage.setAlignment(Qt.AlignCenter)
        self.detectedImage.setFixedSize(640, 360)
        h2layout.addWidget(self.detectedImage)
        groupbox_2_1.setLayout(h2layout)
        h_3layout.addWidget(groupbox_2_1, 75)

        # Row 2 Col 2
        groupbox_2_2 = QGroupBox()
        self.v3_layout = QVBoxLayout()
        self.v3_layout.setAlignment(Qt.AlignCenter)
        self.v3_layout.addSpacing(30)
        self.v3_layout.setAlignment(Qt.AlignCenter)
        self.centralwidget = QtWidgets.QWidget()
        self.playButton = QtWidgets.QPushButton(self.centralwidget)
        self.playButton.setFixedSize(QSize(200, 100))
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal,
                       QtGui.QIcon.Off)
        self.playButton.setObjectName("playButton")
        self.v3_layout.addWidget(self.playButton, 60)
        self.logo = LogoWidget(self, 200, 100)
        self.logo.setVisible(True)
        self.v3_layout.addWidget(self.logo, 40)
        groupbox_2_2.setLayout(self.v3_layout)
        h_3layout.addWidget(groupbox_2_2, 25)
        groupbox_2.setLayout(h_3layout)
        vlayout.addWidget(groupbox_2)

        icon = QtGui.QIcon()

        self.playButton.setIcon(icon)

        self.retranslateUi(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        self.playButton.setText(_translate("MainWindow", "Play Code"))

    def getCamera(self):
        return self.camera

    def setCamera(self, camera):
        self.camera = camera

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def getAlgorithm(self):
        return self.algorithm

    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.playButton.setStyleSheet("background-color: #7dcea0")
            self.algorithm.stop()

    def closeEvent(self, event):
        self.algorithm.kill()
        self.camera.client.stop()

        event.accept()

    def setColorImage(self):
        img = self.camera.getImage()

        if img is not None:
            image = QImage(img.data, img.shape[1], img.shape[0],
                           img.shape[1] * img.shape[2], QImage.Format_RGB888)

            self.imgLabelColor.setPixmap(QPixmap.fromImage(image))

    def setThresholdImage(self):
        img = self.getCamera().getThresholdImage()
        if img is not None:
            image = QImage(img.data, img.shape[1], img.shape[0],
                           img.shape[1] * img.shape[2], QImage.Format_RGB888)
            self.imgLabelBlackWhite.setPixmap(QPixmap.fromImage(image))

    def setDetectImage(self):
        img = self.getCamera().getDetectImage()
        if img is not None:
            image = QImage(img.data, img.shape[1], img.shape[0],
                           img.shape[1] * img.shape[2], QImage.Format_RGB888)
            image1 = image.scaledToHeight(360)
            self.detectedImage.setPixmap(QPixmap.fromImage(image1))

    def updateImage(self):

        self.setThresholdImage()
        self.setDetectImage()

    def updateCamImage(self):
        self.setColorImage()
class MainWindow(QMainWindow, Ui_MainWindow):

    updGUI = pyqtSignal()

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop = TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.record = False

        self.updGUI.connect(self.updateGUI)

        self.segmentCheck.stateChanged.connect(self.showSegmentWidget)

        self.segmentWidget = SegmentWidget(self)

        self.segmentCommunicator = Communicator()
        self.trackingCommunicator = Communicator()

        #self.stopButton.clicked.connect(self.stopClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        self.resetButton.clicked.connect(self.resetClicked)
        self.takeoff = False
        self.reset = False

    def setCamera(self, camera):
        self.camera = camera
        #self.cameraWidget.show() #uncomment if wanted to see the image of the
        #camera whenever you start the execution

    def getCamera(self):
        return self.camera

    def setMotors(self, motors):
        self.motors = motors

    def getMotors(self):
        return self.motors

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def getAlgorithm(self):
        return self.algorithm

    def updateGUI(self):
        self.segmentWidget.imageUpdate.emit()

    def playClicked(self):
        if self.playButton.isChecked():
            self.segmentWidget.show()
            self.segmentCheck.setChecked(True)
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.teleop.stopSIG.emit()

    #def stopClicked(self):
    #   self.algorithm.stop()
    #   self.teleop.stopSIG.emit()
    # ponerrrrr: self.teleop.returnToOrigin()

    def resetClicked(self):
        if self.reset == True:
            self.resetButton.setText("Reset")
            self.reset = False
        else:
            self.resetButton.setText("Unreset")
            self.reset = True

    def showSegmentWidget(self, state):
        if state == Qt.Checked:
            self.segmentWidget.show()
        else:
            self.segmentWidget.close()

    def closeSegmentWidget(self):
        self.segmentCheck.setChecked(False)

    def setXYValues(self, newX, newY):
        limits = self.motors.getLimits()
        pan = newX * limits.maxPan
        tilt = -newY * limits.maxTilt

        self.YValue.setText(str(tilt))
        self.XValue.setText(str(pan))
        #self.YValue.setText("{:.0f}".format(tilt))
        #self.XValue.setText("{:.0f}".format(pan))
        if (self.motors):
            self.motors.setPTMotorsData(pan, tilt, limits.maxPanSpeed,
                                        limits.maxTiltSpeed)

    def closeEvent(self, event):
        self.algorithm.kill()
        self.camera.client.stop()
        self.closeSegmentWidget()
        event.accept()
Ejemplo n.º 6
0
class MainWindow(QMainWindow, Ui_MainWindow):

    getPathSig = QtCore.pyqtSignal(list)
    updGUI = QtCore.pyqtSignal()

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop = TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.map = Map(self)
        self.mapLayout.addWidget(self.map)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)
        self.getPathButton.clicked.connect(self.getPathClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        #self.stopButton.clicked.connect(self.stopClicked)

        plannerList = [
            'RRTstar', 'SORRTstar', 'BITstar', 'FMTstar', 'InformedRRTstar',
            'PRMstar'
        ]
        self.plannerBox.addItems(plannerList)
        # objectiveList = ['PathClearance', 'PathLength', 'ThresholdPathLength', 'WeightedLengthAndClearanceCombo']
        # self.objectiveBox.addItems(objectiveList)

    def setSensor(self, sensor):
        self.sensor = sensor

    def getSensor(self):
        return self.sensor

    def getMotors(self):
        return self.motors

    def setMotors(self, motors):
        self.motors = motors

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def setVelocity(self, vel):
        self.vel = vel

    def getVelocity(self):
        return self.vel

    def getAlgorithm(self):
        return self.algorithm

    def setGrid(self, grid):
        self.grid = grid
        self.grid.setMap(self.map.map)

    def updateGUI(self):
        self.map.updateMap(self.grid)

    def width(self):
        return self.map.width

    def height(self):
        return self.map.height

    def worldWidth(self):
        return self.map.worldWidth

    def worldHeight(self):
        return self.map.worldHeight

    def origX(self):
        return self.map.originX

    def origY(self):
        return self.map.originY

    def mapAngle(self):
        return self.map.mapAngle

    def getPathClicked(self):
        pList = []
        pList.append(self.getPlanner())
        #pList.append(self.getObjective())
        pList.append(self.getRunTime())
        self.getPathSig.emit(pList)

    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.setXYValues(0, 0)
            self.teleop.stopSIG.emit()

    def setXYValues(self, newW, newV):
        self.WValue.setText(str(newW))
        self.VValue.setText(str(-newV))
        myW = newW * self.vel.getMaxW()
        myV = -newV * self.vel.getMaxV()
        self.vel.setV(myV)
        self.vel.setW(myW)

    def getPlanner(self):
        planner = self.plannerBox.currentText()
        return planner

    def getObjective(self):
        objective = self.objectiveBox.currentText()
        return objective

    def getRunTime(self):
        runtime = str(self.runtimeBox.value())
        return runtime
Ejemplo n.º 7
0
class MainWindow(QMainWindow, Ui_MainWindow):

    getPathSig = QtCore.pyqtSignal()
    updGUI = QtCore.pyqtSignal()

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop = TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.map = Map(self)
        self.mapLayout.addWidget(self.map)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)
        self.getPathButton.clicked.connect(self.getPathClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        #self.stopButton.clicked.connect(self.stopClicked)

    def setSensor(self, sensor):
        self.sensor = sensor

    def getSensor(self):
        return self.sensor

    def getMotors(self):
        return self.motors

    def setMotors(self, motors):
        self.motors = motors

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def setVelocity(self, vel):
        self.vel = vel

    def getVelocity(self):
        return self.vel

    def getAlgorithm(self):
        return self.algorithm

    def setGrid(self, grid):
        self.grid = grid
        self.grid.setMap(self.map.map)

    def updateGUI(self):
        self.map.updateMap(self.grid)

    def width(self):
        return self.map.width

    def height(self):
        return self.map.height

    def worldWidth(self):
        return self.map.worldWidth

    def worldHeight(self):
        return self.map.worldHeight

    def origX(self):
        return self.map.originX

    def origY(self):
        return self.map.originY

    def mapAngle(self):
        return self.map.mapAngle

    def getPathClicked(self):
        self.getPathSig.emit()

    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.setXYValues(0, 0)
            self.teleop.stopSIG.emit()

    def setXYValues(self, newW, newV):
        self.WValue.setText(str(newW))
        self.VValue.setText(str(-newV))
        myW = newW * self.vel.getMaxW()
        myV = -newV * self.vel.getMaxV()
        self.vel.setV(myV)
        self.vel.setW(myW)
Ejemplo n.º 8
0
class MainWindow(QMainWindow, Ui_MainWindow):
    
    updGUI=pyqtSignal()
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)

        self.logo = LogoWidget(self, self.logoLayout.parent().width(), self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)


        self.updGUI.connect(self.updateGUI)
        
        self.cameraCheck.stateChanged.connect(self.showCameraWidget)
        self.colorFilterCheck.stateChanged.connect(self.showColorFilterWidget)
        
        self.cameraWidget=CameraWidget(self)
        self.colorFilterWidget=ColorFilterWidget(self)

        self.cameraCommunicator=Communicator()
        self.colorFilterCommunicator=Communicator()
        self.trackingCommunicator = Communicator()

        #self.stopButton.clicked.connect(self.stopClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        #self.resetButton.clicked.connect(self.resetClicked)
        #self.takeoffButton.clicked.connect(self.takeOffClicked)
        self.takeoff=False
      
    def getCamera(self):
        return self.camera

    def setCamera(self,camera):
        self.camera = camera


    def setAlgorithm(self, algorithm ):
        self.algorithm=algorithm

    def getAlgorithm(self):
        return self.algorithm
    
    def updateGUI(self):
        self.cameraWidget.imageUpdate.emit()
        self.colorFilterWidget.imageUpdate.emit()


    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.playButton.setStyleSheet("background-color: #7dcea0")
            self.algorithm.stop()
    
        
    def showCameraWidget(self,state):
        if state == Qt.Checked:
            self.cameraWidget.show()
        else:
            self.cameraWidget.close()
            
    def closeCameraWidget(self):
        self.cameraCheck.setChecked(False)

    def showColorFilterWidget(self,state):
        if state == Qt.Checked:
            self.colorFilterWidget.show()
        else:
            self.colorFilterWidget.close()

    def closeColorFilterWidget(self):
        self.colorFilterCheck.setChecked(False)
    

    def closeEvent(self, event):
        self.algorithm.kill()
        self.camera.client.stop()
        event.accept()
Ejemplo n.º 9
0
class MainWindow(QMainWindow, Ui_MainWindow):

    getPathSig = QtCore.pyqtSignal(list)
    updGUI = QtCore.pyqtSignal()

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop = TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.map = Map(self)
        self.mapLayout.addWidget(self.map)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self,
                               self.logoLayout.parent().width(),
                               self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)
        self.getPathButton.clicked.connect(self.getPathClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        #self.stopButton.clicked.connect(self.stopClicked)

        # plannerList = ['RRTstar', 'SORRTstar','BITstar', 'FMTstar', 'InformedRRTstar', 'PRMstar']
        # self.plannerBox.addItems(plannerList)
        # objectiveList = ['PathClearance', 'PathLength', 'ThresholdPathLength', 'WeightedLengthAndClearanceCombo']
        # self.objectiveBox.addItems(objectiveList)
        self.liftDropButton.clicked.connect(self.liftDropExecute)
        self.liftDropButton.setCheckable(True)
        self.jointForce = 0
        self.pub = rospy.Publisher('amazon_warehouse_robot/joint_cmd',
                                   Float32,
                                   queue_size=10)

        self.gotoPointButton.clicked.connect(self.gotoPointExecute)
        self.gotoPointButton.setCheckable(True)

    def setSensor(self, sensor):
        self.sensor = sensor

    def getSensor(self):
        return self.sensor

    def getMotors(self):
        return self.motors

    def setMotors(self, motors):
        self.motors = motors

    def setAlgorithm(self, algorithm):
        self.algorithm = algorithm

    def setVelocity(self, vel):
        self.vel = vel

    def getVelocity(self):
        return self.vel

    def getAlgorithm(self):
        return self.algorithm

    def setGrid(self, grid):
        self.grid = grid
        self.grid.setMap(self.map.map)

    def updateGUI(self):
        self.map.updateMap(self.grid)

    def width(self):
        return self.map.width

    def height(self):
        return self.map.height

    def worldWidth(self):
        return self.map.worldWidth

    def worldHeight(self):
        return self.map.worldHeight

    def origX(self):
        return self.map.originX

    def origY(self):
        return self.map.originY

    def mapAngle(self):
        return self.map.mapAngle

    def getPathClicked(self):
        pList = []
        # pList.append(self.getPlanner())
        #pList.append(self.getObjective())
        # pList.append(self.getRunTime())
        self.getPathSig.emit(pList)

    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"),
                           QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.setXYValues(0, 0)
            self.teleop.stopSIG.emit()

    def setXYValues(self, newW, newV):
        # self.WValue.setText(str(newW))
        # self.VValue.setText(str(-newV))
        myW = newW * self.vel.getMaxW()
        myV = -newV * self.vel.getMaxV()
        self.vel.setV(myV)
        self.vel.setW(myW)

    def getPlanner(self):
        planner = self.plannerBox.currentText()
        return planner

    def getObjective(self):
        objective = self.objectiveBox.currentText()
        return objective

    def getRunTime(self):
        runtime = str(self.runtimeBox.value())
        return runtime

    def liftDropExecute(self):
        #print ('Lift/Drop Button Clicked')
        if self.jointForce != 25:
            self.jointForce = 25
            self.pub.publish(self.jointForce)
            self.liftDropButton.setText("Drop")
            print('Platform Lifted!')
        else:
            self.jointForce = 0
            self.pub.publish(self.jointForce)
            self.liftDropButton.setText("Lift")
            print('Platform Dropped!')

    def gotoPointExecute(self):
        self.algorithm.setNewPalletFlag(self.playButton.isChecked())

    def setDestinyXYValues(self, newX, newY):
        self.XValue.setText(str(newX))
        self.YValue.setText(str(newY))

    def setPositionXYValues(self, newX, newY):
        self.VValue.setText(str(newX))
        self.WValue.setText(str(newY))
Ejemplo n.º 10
0
class MainWindow(QMainWindow, Ui_MainWindow):
    
    updGUI=pyqtSignal()
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop=TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self, self.logoLayout.parent().width(), self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.record = False

        self.updGUI.connect(self.updateGUI)
        
        self.cameraCheck.stateChanged.connect(self.showCameraWidget)
        self.sensorsCheck.stateChanged.connect(self.showSensorsWidget)
        
        self.rotationDial.valueChanged.connect(self.rotationChange)
        self.altdSlider.valueChanged.connect(self.altitudeChange)
        
        self.cameraWidget=CameraWidget(self)
        self.sensorsWidget=SensorsWidget(self)

        self.cameraCommunicator=Communicator()
        self.trackingCommunicator = Communicator()

        #self.stopButton.clicked.connect(self.stopClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        self.resetButton.clicked.connect(self.resetClicked)
        self.takeoffButton.clicked.connect(self.takeOffClicked)
        self.takeoff=False
        self.reset=False
      
    def getCamera(self):
        return self.camera

    def setCamera(self,camera):
        self.camera = camera

    def getNavData(self):
        return self.navdata

    def setNavData(self,navdata):
        self.navdata = navdata

    def getPose3D(self):
        return self.pose

    def setPose3D(self,pose):
        self.pose = pose

    def getCMDVel(self):
        return self.cmdvel

    def setCMDVel(self,cmdvel):
        self.cmdvel = cmdvel

    def getExtra(self):
        return self.extra

    def setExtra(self,extra):
        self.extra = extra

    def setAlgorithm(self, algorithm ):
        self.algorithm=algorithm

    def getAlgorithm(self):
        return self.algorithm
    
    def updateGUI(self):
        self.cameraWidget.imageUpdate.emit()
        self.sensorsWidget.sensorsUpdate.emit()  
    
    def playClicked(self):
        if self.playButton.isChecked():
            if self.record == True:
                self.extra.record(True)
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            if self.record == True:
                self.extra.record(False)
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.rotationDial.setValue(self.altdSlider.maximum()/2)
            self.altdSlider.setValue(self.altdSlider.maximum()/2)
            self.cmdvel.sendCMDVel(0,0,0,0,0,0)
            self.teleop.stopSIG.emit()
    
    def takeOffClicked(self):
        if(self.takeoff==True):
            self.takeoffButton.setText("Take Off")
            self.extra.land()
            self.takeoff=False
        else:
            self.takeoffButton.setText("Land")    
            self.extra.takeoff()
            self.takeoff=True

    def resetClicked(self):
        if self.reset == True:
            self.resetButton.setText("Reset")
            self.extra.reset()
            self.reset=False
        else:
            self.resetButton.setText("Unreset")
            self.extra.reset()
            self.reset=True
        
    def showCameraWidget(self,state):
        if state == Qt.Checked:
            self.cameraWidget.show()
        else:
            self.cameraWidget.close()
            
    def closeCameraWidget(self):
        self.cameraCheck.setChecked(False)
        
    def showSensorsWidget(self,state):
        if state == Qt.Checked:
            self.sensorsWidget.show()           
        else:
            self.sensorsWidget.close() 

    def closeSensorsWidget(self):
        self.sensorsCheck.setChecked(False)
    
    def rotationChange(self,value):
        value=(1.0/(self.rotationDial.maximum()/2))*(value - (self.rotationDial.maximum()/2))
        self.rotValue.setText('%.2f' % value)  
        self.cmdvel.setYaw(value)
        self.cmdvel.sendVelocities()

    def altitudeChange(self,value):
        value=(1.0/(self.altdSlider.maximum()/2))*(value - (self.altdSlider.maximum()/2))
        self.altdValue.setText('%.2f' % value)
        self.cmdvel.setVZ(value)
        self.cmdvel.sendVelocities()

    def setXYValues(self,newX,newY):
        self.XValue.setText('%.2f' % newX)
        self.YValue.setText('%.2f' % newY)
        self.cmdvel.setVX(-newY)
        self.cmdvel.setVY(-newX)
        self.cmdvel.sendVelocities()

    def closeEvent(self, event):
        self.algorithm.kill()
        self.camera.stop()
        self.navdata.stop()
        self.pose.stop()
        event.accept()
Ejemplo n.º 11
0
class MainWindow(QMainWindow, Ui_MainWindow):
    
    updGUI=pyqtSignal()
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop=TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self, self.logoLayout.parent().width(), self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.record = False

        self.updGUI.connect(self.updateGUI)
        
        self.segmentCheck.stateChanged.connect(self.showSegmentWidget)
        
        self.segmentWidget=SegmentWidget(self)

        self.segmentCommunicator=Communicator()
        self.trackingCommunicator = Communicator()

        #self.stopButton.clicked.connect(self.stopClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        self.resetButton.clicked.connect(self.resetClicked)
        self.takeoff=False
        self.reset=False
      
    def setCamera(self, camera):
        self.camera = camera
        #self.cameraWidget.show() #uncomment if wanted to see the image of the 
                                  #camera whenever you start the execution

    def getCamera(self):
        return self.camera

    def setMotors(self, motors):
        self.motors = motors

    def getMotors(self):
		return self.motors

    def setAlgorithm(self, algorithm ):
        self.algorithm=algorithm

    def getAlgorithm(self):
        return self.algorithm
    
    def updateGUI(self):
        self.segmentWidget.imageUpdate.emit()
    
    def playClicked(self):
        if self.playButton.isChecked():
            self.segmentWidget.show()
            self.segmentCheck.setChecked(True)
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.teleop.stopSIG.emit()
    
    #def stopClicked(self):        
     #   self.algorithm.stop()
     #   self.teleop.stopSIG.emit()
        # ponerrrrr: self.teleop.returnToOrigin()

    def resetClicked(self):
        if self.reset == True:
            self.resetButton.setText("Reset")
            self.reset=False
        else:
            self.resetButton.setText("Unreset")
            self.reset=True

    def showSegmentWidget(self,state):
        if state == Qt.Checked:
            self.segmentWidget.show()
        else:
            self.segmentWidget.close()
            
    def closeSegmentWidget(self):
        self.segmentCheck.setChecked(False)

    def setXYValues(self, newX, newY):
        limits = self.motors.getLimits()
        pan =  newX*limits.maxPan
        tilt = - newY*limits.maxTilt

        self.YValue.setText(str(tilt))
        self.XValue.setText(str(pan))
        #self.YValue.setText("{:.0f}".format(tilt))
        #self.XValue.setText("{:.0f}".format(pan))
        if (self.motors):
            self.motors.setPTMotorsData(pan, tilt, limits.maxPanSpeed, limits.maxTiltSpeed)

    def closeEvent(self, event):
        self.algorithm.kill()
        self.camera.client.stop()
        self.closeSegmentWidget()
        event.accept()
class MainWindow(QMainWindow, Ui_MainWindow):
    
    getPathSig = QtCore.pyqtSignal()
    updGUI = QtCore.pyqtSignal()
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop=TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.map = Map(self)
        self.mapLayout.addWidget(self.map)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self, self.logoLayout.parent().width(), self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)
        self.getPathButton.clicked.connect(self.getPathClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.stopButton.clicked.connect(self.stopClicked)
      
    def setSensor(self, sensor):
        self.sensor = sensor
           
    def getSensor(self):
        return self.sensor

    def getMotors(self):
        return self.motors

    def setMotors(self,motors):
        self.motors=motors

    def setAlgorithm(self, algorithm ):
        self.algorithm=algorithm

    def setVelocity(self, vel):
        self.vel = vel

    def getVelocity(self):
        return self.vel

    def getAlgorithm(self):
        return self.algorithm
    
    def setGrid(self, grid):
        self.grid = grid
        self.grid.setMap(self.map.map)

    def updateGUI(self):
        self.map.updateMap(self.grid)
    
    def width(self):
        return self.map.width

    def height(self):
        return self.map.height

    def worldWidth(self):
        return self.map.worldWidth

    def worldHeight(self):
        return self.map.worldHeight

    def origX(self):
        return self.map.originX

    def origY(self):
        return self.map.originY

    def mapAngle(self):
        return self.map.mapAngle

    def getPathClicked(self):
        self.getPathSig.emit()

    def playClicked(self):
        print("Play clicked")
        self.algorithm.play()
    
    def stopClicked(self):
        print("Stop clicked")
        self.algorithm.stop()
        self.setXYValues(0, 0)
        self.teleop.stopSIG.emit()

    def setXYValues(self,newW,newV):
        self.WValue.setText(str(newW))
        self.VValue.setText(str(-newV))
        myW = newW * self.vel.getMaxW()
        myV = -newV * self.vel.getMaxV()
        self.vel.setV(myV)
        self.vel.setW(myW)
Ejemplo n.º 13
0
class MainWindow(QMainWindow, Ui_MainWindow):
    
    getPathSig = QtCore.pyqtSignal()
    updGUI = QtCore.pyqtSignal()
    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent)
        self.setupUi(self)
        self.teleop=TeleopWidget(self)
        self.tlLayout.addWidget(self.teleop)
        self.map = Map(self)
        self.mapLayout.addWidget(self.map)
        self.teleop.setVisible(True)

        self.logo = LogoWidget(self, self.logoLayout.parent().width(), self.logoLayout.parent().height())
        self.logoLayout.addWidget(self.logo)
        self.logo.setVisible(True)

        self.updGUI.connect(self.updateGUI)
        self.getPathButton.clicked.connect(self.getPathClicked)
        self.playButton.clicked.connect(self.playClicked)
        self.playButton.setCheckable(True)
        #self.stopButton.clicked.connect(self.stopClicked)
      
    def setSensor(self, sensor):
        self.sensor = sensor
           
    def getSensor(self):
        return self.sensor

    def getMotors(self):
        return self.motors

    def setMotors(self,motors):
        self.motors=motors

    def setAlgorithm(self, algorithm ):
        self.algorithm=algorithm

    def setVelocity(self, vel):
        self.vel = vel

    def getVelocity(self):
        return self.vel

    def getAlgorithm(self):
        return self.algorithm
    
    def setGrid(self, grid):
        self.grid = grid
        self.grid.setMap(self.map.map)

    def updateGUI(self):
        self.map.updateMap(self.grid)
    
    def width(self):
        return self.map.width

    def height(self):
        return self.map.height

    def worldWidth(self):
        return self.map.worldWidth

    def worldHeight(self):
        return self.map.worldHeight

    def origX(self):
        return self.map.originX

    def origY(self):
        return self.map.originY

    def mapAngle(self):
        return self.map.mapAngle

    def getPathClicked(self):
        self.getPathSig.emit()

    def playClicked(self):
        if self.playButton.isChecked():
            icon = QtGui.QIcon()
            self.playButton.setText("Stop Code")
            self.playButton.setStyleSheet("background-color: #ec7063")
            icon.addPixmap(QtGui.QPixmap(":/images/stop.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.algorithm.play()
        else:
            icon = QtGui.QIcon()
            self.playButton.setStyleSheet("background-color: #7dcea0")
            icon.addPixmap(QtGui.QPixmap(":/images/play.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
            self.playButton.setIcon(icon)
            self.playButton.setText("Play Code")
            self.algorithm.stop()
            self.setXYValues(0, 0)
            self.teleop.stopSIG.emit()

    def setXYValues(self,newW,newV):
        self.WValue.setText(str(newW))
        self.VValue.setText(str(-newV))
        myW = newW * self.vel.getMaxW()
        myV = -newV * self.vel.getMaxV()
        self.vel.setV(myV)
        self.vel.setW(myW)