def _createUI(self): mainLayout = QtGui.QVBoxLayout() #mainLayout.setMargin(0) #mainLayout.addSpacing(5) # Channel 1 lChannel1 = HeadingLabel() lChannel1.setText("Channel 1") mainLayout.addWidget(lChannel1) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel1 = PositionBar() self.posBarChannel1.setMinimumWidth(250) self.posBarChannel1.setMinimumHeight(30) self.posBarChannel1.setMaximumHeight(30) self.posBarChannel1.setValue(0) self.posBarChannel1.setMoveable(False) layout.addWidget(self.posBarChannel1) self.lcdChannel1Value = QtGui.QLCDNumber() self.lcdChannel1Value.setMaximumHeight(25) self.lcdChannel1Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel1Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 2 lChannel2 = HeadingLabel() lChannel2.setText("Channel 2") mainLayout.addWidget(lChannel2) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel2 = PositionBar() self.posBarChannel2.setMinimumWidth(250) self.posBarChannel2.setMinimumHeight(30) self.posBarChannel2.setMaximumHeight(30) self.posBarChannel2.setValue(0) self.posBarChannel2.setMoveable(False) layout.addWidget(self.posBarChannel2) self.lcdChannel2Value = QtGui.QLCDNumber() self.lcdChannel2Value.setMaximumHeight(25) self.lcdChannel2Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel2Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 3 lChannel3 = HeadingLabel() lChannel3.setText("Channel 3") mainLayout.addWidget(lChannel3) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel3 = PositionBar() self.posBarChannel3.setMinimumWidth(250) self.posBarChannel3.setMinimumHeight(30) self.posBarChannel3.setMaximumHeight(30) self.posBarChannel3.setValue(0) self.posBarChannel3.setMoveable(False) layout.addWidget(self.posBarChannel3) self.lcdChannel3Value = QtGui.QLCDNumber() self.lcdChannel3Value.setMaximumHeight(25) self.lcdChannel3Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel3Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 4 lChannel4 = HeadingLabel() lChannel4.setText("Channel 4") mainLayout.addWidget(lChannel4) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel4 = PositionBar() self.posBarChannel4.setMinimumWidth(250) self.posBarChannel4.setMinimumHeight(30) self.posBarChannel4.setMaximumHeight(30) self.posBarChannel4.setValue(0) self.posBarChannel4.setMoveable(False) layout.addWidget(self.posBarChannel4) self.lcdChannel4Value = QtGui.QLCDNumber() self.lcdChannel4Value.setMaximumHeight(25) self.lcdChannel4Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel4Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 5 lChannel5 = HeadingLabel() lChannel5.setText("Channel 5") mainLayout.addWidget(lChannel5) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel5 = PositionBar() self.posBarChannel5.setMinimumWidth(250) self.posBarChannel5.setMinimumHeight(30) self.posBarChannel5.setMaximumHeight(30) self.posBarChannel5.setValue(0) self.posBarChannel5.setMoveable(False) layout.addWidget(self.posBarChannel5) self.lcdChannel5Value = QtGui.QLCDNumber() self.lcdChannel5Value.setMaximumHeight(25) self.lcdChannel5Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel5Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 6 lChannel6 = HeadingLabel() lChannel6.setText("Channel 6") mainLayout.addWidget(lChannel6) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel6 = PositionBar() self.posBarChannel6.setMinimumWidth(250) self.posBarChannel6.setMinimumHeight(30) self.posBarChannel6.setMaximumHeight(30) self.posBarChannel6.setValue(0) self.posBarChannel6.setMoveable(False) layout.addWidget(self.posBarChannel6) self.lcdChannel6Value = QtGui.QLCDNumber() self.lcdChannel6Value.setMaximumHeight(25) self.lcdChannel6Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel6Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addSpacing(30) # Channel 7 lChannel7 = HeadingLabel() lChannel7.setText("Channel 7") mainLayout.addWidget(lChannel7) layout = QtGui.QHBoxLayout() layout.addSpacing(15) lValue = QtGui.QLabel("Value") layout.addWidget(lValue) layout.addSpacing(15) self.posBarChannel7 = PositionBar() self.posBarChannel7.setMinimumWidth(250) self.posBarChannel7.setMinimumHeight(30) self.posBarChannel7.setMaximumHeight(30) self.posBarChannel7.setValue(0) self.posBarChannel7.setMoveable(False) layout.addWidget(self.posBarChannel7) self.lcdChannel7Value = QtGui.QLCDNumber() self.lcdChannel7Value.setMaximumHeight(25) self.lcdChannel7Value.setSegmentStyle(QtGui.QLCDNumber.Filled) layout.addWidget(self.lcdChannel7Value) layout.addStretch() mainLayout.addLayout(layout) mainLayout.addStretch() self.setLayout(mainLayout)
def _createUi(self): """Initializes the UI.""" mainLayout = QtGui.QVBoxLayout() # Stabilization Coefficients groupBox = QtGui.QGroupBox("Rate Stabilization (Inner Loop)") gridLayout = QtGui.QGridLayout() groupBox.setLayout(gridLayout) mainLayout.addWidget(groupBox) gridLayout.setSpacing(4) gridLayout.setColumnMinimumWidth(0, 20) gridLayout.setColumnMinimumWidth(1, 80) gridLayout.setColumnMinimumWidth(2, 20) gridLayout.setColumnMinimumWidth(3, 100) gridLayout.setColumnMinimumWidth(4, 100) gridLayout.setColumnMinimumWidth(5, 100) gridLayout.setColumnMinimumWidth(6, 100) gridLayout.setColumnMinimumWidth(7, 150) gridLayout.setColumnStretch(0, 0) gridLayout.setColumnStretch(1, 1) gridLayout.setColumnStretch(2, 0) gridLayout.setColumnStretch(3, 1) gridLayout.setColumnStretch(4, 1) gridLayout.setColumnStretch(5, 1) gridLayout.setColumnStretch(6, 1) gridLayout.setColumnStretch(7, 2) # Add spacer items spacer = QtGui.QSpacerItem(20, 20) gridLayout.addItem(spacer, 0, 0) spacer = QtGui.QSpacerItem(20, 20) gridLayout.addItem(spacer, 0, 2) spacer = QtGui.QSpacerItem(150, 20) gridLayout.addItem(spacer, 0, 7) spacer = QtGui.QSpacerItem(50, 120) gridLayout.addItem(spacer, 8, 0) # Headers header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Proportional") gridLayout.addWidget(header, 0, 3) header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Integral") gridLayout.addWidget(header, 0, 4) header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Derivative") gridLayout.addWidget(header, 0, 5) header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("ILimit") gridLayout.addWidget(header, 0, 6) # Roll coefficients label = QtGui.QLabel("Roll") gridLayout.addWidget(label, 1, 1) self.spbRollKp = QtGui.QDoubleSpinBox() self.spbRollKp.setDecimals(5) self.spbRollKp.setMinimum(0) self.spbRollKp.setMaximum(5000) self.spbRollKp.setMinimumWidth(150) gridLayout.addWidget(self.spbRollKp, 1, 3) self.spbRollKi = QtGui.QDoubleSpinBox() self.spbRollKi.setDecimals(5) self.spbRollKi.setMinimum(0) self.spbRollKi.setMaximum(5000) self.spbRollKi.setMinimumWidth(150) gridLayout.addWidget(self.spbRollKi, 1, 4) self.spbRollKd = QtGui.QDoubleSpinBox() self.spbRollKd.setDecimals(5) self.spbRollKd.setMinimum(0) self.spbRollKd.setMaximum(5000) self.spbRollKd.setMinimumWidth(150) gridLayout.addWidget(self.spbRollKd, 1, 5) self.spbRollILimit = QtGui.QDoubleSpinBox() self.spbRollILimit.setDecimals(5) self.spbRollILimit.setMinimum(0) self.spbRollILimit.setMaximum(5000) self.spbRollILimit.setMinimumWidth(150) gridLayout.addWidget(self.spbRollILimit, 1, 6) # Pitch coefficients label = QtGui.QLabel("Pitch") gridLayout.addWidget(label, 2, 1) self.spbPitchKp = QtGui.QDoubleSpinBox() self.spbPitchKp.setDecimals(5) self.spbPitchKp.setMinimum(0) self.spbPitchKp.setMaximum(5000) self.spbPitchKp.setMinimumWidth(150) gridLayout.addWidget(self.spbPitchKp, 2, 3) self.spbPitchKi = QtGui.QDoubleSpinBox() self.spbPitchKi.setDecimals(5) self.spbPitchKi.setMinimum(0) self.spbPitchKi.setMaximum(5000) self.spbPitchKi.setMinimumWidth(150) gridLayout.addWidget(self.spbPitchKi, 2, 4) self.spbPitchKd = QtGui.QDoubleSpinBox() self.spbPitchKd.setDecimals(5) self.spbPitchKd.setMinimum(0) self.spbPitchKd.setMaximum(5000) self.spbPitchKd.setMinimumWidth(150) gridLayout.addWidget(self.spbPitchKd, 2, 5) self.spbILimitPitch = QtGui.QDoubleSpinBox() self.spbILimitPitch.setDecimals(5) self.spbILimitPitch.setMinimum(0) self.spbILimitPitch.setMaximum(5000) self.spbILimitPitch.setMinimumWidth(150) gridLayout.addWidget(self.spbILimitPitch, 2, 6) # Yaw coefficients label = QtGui.QLabel("Yaw") gridLayout.addWidget(label, 3, 1) self.spbYawKp = QtGui.QDoubleSpinBox() self.spbYawKp.setDecimals(5) self.spbYawKp.setMinimum(0) self.spbYawKp.setMaximum(5000) self.spbYawKp.setMinimumWidth(150) gridLayout.addWidget(self.spbYawKp, 3, 3) self.spbYawKi = QtGui.QDoubleSpinBox() self.spbYawKi.setDecimals(5) self.spbYawKi.setMinimum(0) self.spbYawKi.setMaximum(5000) self.spbYawKi.setMinimumWidth(150) gridLayout.addWidget(self.spbYawKi, 3, 4) self.spbYawKd = QtGui.QDoubleSpinBox() self.spbYawKd.setDecimals(5) self.spbYawKd.setMinimum(0) self.spbYawKd.setMaximum(5000) self.spbYawKd.setMinimumWidth(150) gridLayout.addWidget(self.spbYawKd, 3, 5) self.spbILimitYaw = QtGui.QDoubleSpinBox() self.spbILimitYaw.setDecimals(5) self.spbILimitYaw.setMinimum(0) self.spbILimitYaw.setMaximum(5000) self.spbILimitYaw.setMinimumWidth(150) gridLayout.addWidget(self.spbILimitYaw, 3, 6) # DCM Constants groupBox = QtGui.QGroupBox("Attitude Stabilization (Outer Loop)") gridLayout = QtGui.QGridLayout() groupBox.setLayout(gridLayout) gridLayout.setSpacing(4) mainLayout.addWidget(groupBox) gridLayout.setColumnMinimumWidth(0, 20) gridLayout.setColumnMinimumWidth(1, 80) gridLayout.setColumnMinimumWidth(2, 20) gridLayout.setColumnMinimumWidth(3, 100) gridLayout.setColumnMinimumWidth(4, 100) gridLayout.setColumnMinimumWidth(5, 150) gridLayout.setColumnStretch(0, 0) gridLayout.setColumnStretch(1, 1) gridLayout.setColumnStretch(2, 0) gridLayout.setColumnStretch(3, 1) gridLayout.setColumnStretch(4, 1) gridLayout.setColumnStretch(5, 2) # Add spacer items spacer = QtGui.QSpacerItem(20, 20) gridLayout.addItem(spacer, 0, 0) spacer = QtGui.QSpacerItem(20, 20) gridLayout.addItem(spacer, 0, 2) spacer = QtGui.QSpacerItem(150, 20) gridLayout.addItem(spacer, 0, 5) spacer = QtGui.QSpacerItem(50, 120) gridLayout.addItem(spacer, 3, 0) # Headers header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Proportional") gridLayout.addWidget(header, 0, 3) header = HeadingLabel() header.setText("Integral") header.setTextAlign(QtCore.Qt.AlignHCenter) gridLayout.addWidget(header, 0, 4) # DCM Roll/Pitch label = QtGui.QLabel("Roll/Pitch") gridLayout.addWidget(label, 1, 1) self.spbDcmRollPitchPFactor = QtGui.QDoubleSpinBox() self.spbDcmRollPitchPFactor.setDecimals(5) self.spbDcmRollPitchPFactor.setMinimum(0) self.spbDcmRollPitchPFactor.setMaximum(5000) self.spbDcmRollPitchPFactor.setMinimumWidth(150) gridLayout.addWidget(self.spbDcmRollPitchPFactor, 1, 3) self.spbDcmRollPitchIFactor = QtGui.QDoubleSpinBox() self.spbDcmRollPitchIFactor.setDecimals(5) self.spbDcmRollPitchIFactor.setMinimum(0) self.spbDcmRollPitchIFactor.setMaximum(5000) self.spbDcmRollPitchIFactor.setMinimumWidth(150) gridLayout.addWidget(self.spbDcmRollPitchIFactor, 1, 4) # DCM Yaw label = QtGui.QLabel("Yaw") gridLayout.addWidget(label, 2, 1) self.spbDcmYawPFactor = QtGui.QDoubleSpinBox() self.spbDcmYawPFactor.setDecimals(5) self.spbDcmYawPFactor.setMinimum(0) self.spbDcmYawPFactor.setMaximum(5000) self.spbDcmYawPFactor.setMinimumWidth(150) gridLayout.addWidget(self.spbDcmYawPFactor, 2, 3) self.spbDcmYawIFactor = QtGui.QDoubleSpinBox() self.spbDcmYawIFactor.setDecimals(5) self.spbDcmYawIFactor.setMinimum(0) self.spbDcmYawIFactor.setMaximum(5000) self.spbDcmYawIFactor.setMinimumWidth(150) gridLayout.addWidget(self.spbDcmYawIFactor, 2, 4) # Stick range and limits groupBox = QtGui.QGroupBox("Stick ranges and limits") gridLayout = QtGui.QGridLayout() groupBox.setLayout(gridLayout) gridLayout.setSpacing(4) mainLayout.addWidget(groupBox) gridLayout.setColumnMinimumWidth(0, 20) gridLayout.setColumnMinimumWidth(1, 80) gridLayout.setColumnMinimumWidth(2, 20) gridLayout.setColumnMinimumWidth(3, 100) gridLayout.setColumnMinimumWidth(4, 100) gridLayout.setColumnMinimumWidth(5, 100) gridLayout.setColumnMinimumWidth(6, 150) gridLayout.setColumnStretch(0, 0) gridLayout.setColumnStretch(1, 1) gridLayout.setColumnStretch(2, 0) gridLayout.setColumnStretch(3, 1) gridLayout.setColumnStretch(4, 1) gridLayout.setColumnStretch(5, 1) gridLayout.setColumnStretch(6, 2) # Add spacer items spacer = QtGui.QSpacerItem(20, 20) gridLayout.addItem(spacer, 0, 0) spacer = QtGui.QSpacerItem(20, 20) gridLayout.addItem(spacer, 0, 2) spacer = QtGui.QSpacerItem(150, 20) gridLayout.addItem(spacer, 0, 6) spacer = QtGui.QSpacerItem(50, 120) gridLayout.addItem(spacer, 4, 0) # Headers header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Roll") gridLayout.addWidget(header, 0, 3) header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Pitch") gridLayout.addWidget(header, 0, 4) header = HeadingLabel() header.setTextAlign(QtCore.Qt.AlignHCenter) header.setText("Yaw") gridLayout.addWidget(header, 0, 5) # Full stick angle label = QtGui.QLabel("Full Stick Angle (deg)") gridLayout.addWidget(label, 1, 1) self.spbStickAngleRoll = QtGui.QDoubleSpinBox() self.spbStickAngleRoll.setMinimumWidth(150) gridLayout.addWidget(self.spbStickAngleRoll, 1, 3) self.spbStickAnglePitch = QtGui.QDoubleSpinBox() self.spbStickAnglePitch.setMinimumWidth(150) gridLayout.addWidget(self.spbStickAnglePitch, 1, 4) self.spbStickAngleYaw = QtGui.QDoubleSpinBox() self.spbStickAngleYaw.setMinimumWidth(150) gridLayout.addWidget(self.spbStickAngleYaw, 1, 5) # Full stick rate label = QtGui.QLabel("Full Stick Rate (deg/s)") gridLayout.addWidget(label, 2, 1) self.spbStickRateRoll = QtGui.QDoubleSpinBox() self.spbStickRateRoll.setMinimumWidth(150) gridLayout.addWidget(self.spbStickRateRoll, 2, 3) self.spbStickRatePitch = QtGui.QDoubleSpinBox() self.spbStickRatePitch.setMinimumWidth(150) gridLayout.addWidget(self.spbStickRatePitch, 2, 4) self.spbStickRateYaw = QtGui.QDoubleSpinBox() self.spbStickRateYaw.setMinimumWidth(150) gridLayout.addWidget(self.spbStickRateYaw, 2, 5) # Maximum rate in attitude mode label = QtGui.QLabel("Maximum Rate in Attitude Mode (deg/s)") gridLayout.addWidget(label, 3, 1) self.spbStickMaxRateAttRoll = QtGui.QDoubleSpinBox() self.spbStickMaxRateAttRoll.setMinimumWidth(150) gridLayout.addWidget(self.spbStickMaxRateAttRoll, 3, 3) self.spbStickMaxRateAttPitch = QtGui.QDoubleSpinBox() self.spbStickMaxRateAttPitch.setMinimumWidth(150) gridLayout.addWidget(self.spbStickMaxRateAttPitch, 3, 4) self.spbStickMaxRateAttYaw = QtGui.QDoubleSpinBox() self.spbStickMaxRateAttYaw.setMinimumWidth(150) gridLayout.addWidget(self.spbStickMaxRateAttYaw, 3, 5) mainLayout.addStretch() # Bottom buttons hLayout = QtGui.QHBoxLayout() self.bRestoreFactory = QtGui.QPushButton("Restore Factory Settings") self.bRestoreFactory.clicked.connect(self._onbRestoreFactoryClicked) hLayout.addWidget(self.bRestoreFactory) self.bReloadFromBoard = QtGui.QPushButton("Reload data from board") self.bReloadFromBoard.clicked.connect(self._onbReloadFromBoard) hLayout.addWidget(self.bReloadFromBoard) hLayout.addStretch() self.saveButton = QtGui.QPushButton("Save") self.saveButton.setEnabled(False) self.saveButton.clicked.connect(self._onSaveButtonClicked) hLayout.addWidget(self.saveButton) self.applyButton = QtGui.QPushButton("Apply") self.applyButton.setEnabled(False) self.applyButton.clicked.connect(self._onApplyButtonClicked) hLayout.addWidget(self.applyButton) mainLayout.addLayout(hLayout) # Set main layout self.setLayout(mainLayout) # Connect all signals self._connectSignals()