Пример #1
0
class Sliders(QWidget):
    def __init__(self, parent=None):
        super(Sliders, self).__init__(parent)

        self.model = MAVModel(chapter=5)

        self.layout = QVBoxLayout()
        self.numOfSliders = 2

        self.airspeed = mySlider(self.numOfSliders,
                                 0,
                                 maxV=50,
                                 minV=10,
                                 intV=P.Va0,
                                 gain=1,
                                 name='Airspeed',
                                 model=self.model)
        self.altitude = mySlider(self.numOfSliders,
                                 1,
                                 maxV=300,
                                 minV=0,
                                 intV=P.altitude0,
                                 gain=1,
                                 name='Altitude',
                                 model=self.model)
        self.course_angle = mySlider(self.numOfSliders,
                                     2,
                                     maxV=180,
                                     minV=-180,
                                     intV=0,
                                     gain=np.pi / 180.0,
                                     name='Course Angle',
                                     model=self.model)

        self.layout.addWidget(QLabel('Airspeed'))
        self.layout.addWidget(self.airspeed.slider)
        self.layout.addWidget(QLabel('Altitude'))
        self.layout.addWidget(self.altitude.slider)
        self.layout.addWidget(QLabel('course_angle'))
        self.layout.addWidget(self.course_angle.slider)

        self.setLayout(self.layout)
        self.setWindowTitle("Control Values")
        self.resize(500, 300)
        self.move(20, 20)

        self.thread = Viewer(self.model)
        self.thread.draw_mav(self.model.Output())
        self.thread.start()
        # QtGui.QApplication.instance().exec_()

    def getInputValue(self):
        """
        :return: The current values of the sliders in a list
        """
        values = [
            self.X.getValue(),
            self.Y.getValue(),
            self.Z.getValue(),
            self.roll.getValue(),
            self.pitch.getValue(),
            self.yaw.getValue()
        ]
        return values
Пример #2
0
class Sliders(QWidget):
    def __init__(self, parent=None):
        super(Sliders, self).__init__(parent)

        self.model = MAVModel(chapter=4)

        self.layout = QVBoxLayout()
        self.numOfSliders = 6

        self.deltaA = mySlider(self.numOfSliders,
                               0,
                               maxV=15,
                               minV=-15,
                               intV=P.deltaA0 * 180 / np.pi,
                               gain=np.pi / 180.0,
                               name='delta A',
                               model=self.model)
        self.deltaE = mySlider(self.numOfSliders,
                               1,
                               maxV=60,
                               minV=-60,
                               intV=P.deltaE0 * 180 / np.pi,
                               gain=np.pi / 180.0,
                               name='delta E',
                               model=self.model)
        self.deltaR = mySlider(self.numOfSliders,
                               2,
                               maxV=5,
                               minV=-5,
                               intV=P.deltaR0 * 180 / np.pi,
                               gain=np.pi / 180.0,
                               name='delta R',
                               model=self.model)
        self.deltaT = mySlider(self.numOfSliders,
                               3,
                               maxV=1,
                               minV=0,
                               intV=P.deltaT0,
                               gain=1,
                               name='delta T',
                               model=self.model)

        self.layout.addWidget(QLabel('Delta A'))
        self.layout.addWidget(self.deltaA.slider)
        self.layout.addWidget(QLabel('Delta E'))
        self.layout.addWidget(self.deltaE.slider)
        self.layout.addWidget(QLabel('Delta R'))
        self.layout.addWidget(self.deltaR.slider)
        self.layout.addWidget(QLabel('Delta T'))
        self.layout.addWidget(self.deltaT.slider)

        self.setLayout(self.layout)
        self.setWindowTitle("Control Values")
        self.resize(500, 300)
        self.move(20, 20)

        self.thread = Viewer(self.model, 16)
        self.thread.draw_mav(self.model.Output())
        self.thread.start()
        # QtGui.QApplication.instance().exec_()

    def getInputValue(self):
        """
        :return: The current values of the sliders in a list
        """
        values = [
            self.X.getValue(),
            self.Y.getValue(),
            self.Z.getValue(),
            self.roll.getValue(),
            self.pitch.getValue(),
            self.yaw.getValue()
        ]
        return values