mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-30 15:52:12 +01:00
Merge remote-tracking branch 'origin/next' into Brian-PipXtreme-V2
This commit is contained in:
commit
998cc5c022
24
Makefile
24
Makefile
@ -68,7 +68,7 @@ help:
|
|||||||
@echo " Here is a summary of the available targets:"
|
@echo " Here is a summary of the available targets:"
|
||||||
@echo
|
@echo
|
||||||
@echo " [Tool Installers]"
|
@echo " [Tool Installers]"
|
||||||
@echo " qt_sdk_install - Install the QT v4.6.2 tools"
|
@echo " qt_sdk_install - Install the QT v4.7.3 tools"
|
||||||
@echo " arm_sdk_install - Install the Code Sourcery ARM gcc toolchain"
|
@echo " arm_sdk_install - Install the Code Sourcery ARM gcc toolchain"
|
||||||
@echo " openocd_install - Install the OpenOCD JTAG daemon"
|
@echo " openocd_install - Install the OpenOCD JTAG daemon"
|
||||||
@echo " stm32flash_install - Install the stm32flash tool for unbricking boards"
|
@echo " stm32flash_install - Install the stm32flash tool for unbricking boards"
|
||||||
@ -160,20 +160,30 @@ $(BUILD_DIR):
|
|||||||
###############################################################
|
###############################################################
|
||||||
|
|
||||||
# Set up QT toolchain
|
# Set up QT toolchain
|
||||||
QT_SDK_DIR := $(TOOLS_DIR)/qtsdk-2010.02
|
QT_SDK_DIR := $(TOOLS_DIR)/qtsdk-v1.2
|
||||||
|
|
||||||
.PHONY: qt_sdk_install
|
.PHONY: qt_sdk_install
|
||||||
qt_sdk_install: QT_SDK_URL := http://get.qt.nokia.com/qtsdk/qt-sdk-linux-x86-opensource-2010.02.bin
|
qt_sdk_install: QT_SDK_URL := http://www.developer.nokia.com/dp?uri=http://sw.nokia.com/id/8ea74da4-fec1-4277-8b26-c58cc82e204b/Qt_SDK_Lin32_offline
|
||||||
qt_sdk_install: QT_SDK_FILE := $(notdir $(QT_SDK_URL))
|
qt_sdk_install: QT_SDK_FILE := Qt_SDK_Lin32_offline_v1_2_en.run
|
||||||
|
#qt_sdk_install: QT_SDK_URL := http://www.developer.nokia.com/dp?uri=http://sw.nokia.com/id/c365bbf5-c2b9-4dda-9c1f-34b2c8d07785/Qt_SDK_Lin32_offline_v1_1_2
|
||||||
|
#qt_sdk_install: QT_SDK_FILE := Qt_SDK_Lin32_offline_v1_1_2_en.run
|
||||||
# order-only prereq on directory existance:
|
# order-only prereq on directory existance:
|
||||||
qt_sdk_install : | $(DL_DIR) $(TOOLS_DIR)
|
qt_sdk_install : | $(DL_DIR) $(TOOLS_DIR)
|
||||||
qt_sdk_install: qt_sdk_clean
|
qt_sdk_install: qt_sdk_clean
|
||||||
# download the source only if it's newer than what we already have
|
# download the source only if it's newer than what we already have
|
||||||
$(V1) wget -N -P "$(DL_DIR)" "$(QT_SDK_URL)"
|
$(V1) wget -N --content-disposition -P "$(DL_DIR)" "$(QT_SDK_URL)"
|
||||||
|
|
||||||
|
# tell the user exactly which path they should select in the GUI
|
||||||
|
$(V1) echo "*** NOTE NOTE NOTE ***"
|
||||||
|
$(V1) echo "*"
|
||||||
|
$(V1) echo "* In the GUI, please use exactly this path as the installation path:"
|
||||||
|
$(V1) echo "* $(QT_SDK_DIR)"
|
||||||
|
$(V1) echo "*"
|
||||||
|
$(V1) echo "*** NOTE NOTE NOTE ***"
|
||||||
|
|
||||||
#installer is an executable, make it executable and run it
|
#installer is an executable, make it executable and run it
|
||||||
$(V1) chmod u+x "$(DL_DIR)/$(QT_SDK_FILE)"
|
$(V1) chmod u+x "$(DL_DIR)/$(QT_SDK_FILE)"
|
||||||
"$(DL_DIR)/$(QT_SDK_FILE)" --installdir "$(QT_SDK_DIR)"
|
$(V1) "$(DL_DIR)/$(QT_SDK_FILE)" -style cleanlooks
|
||||||
|
|
||||||
.PHONY: qt_sdk_clean
|
.PHONY: qt_sdk_clean
|
||||||
qt_sdk_clean:
|
qt_sdk_clean:
|
||||||
@ -257,7 +267,7 @@ stm32flash_clean:
|
|||||||
##############################
|
##############################
|
||||||
|
|
||||||
ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && echo "exists"), exists)
|
ifeq ($(shell [ -d "$(QT_SDK_DIR)" ] && echo "exists"), exists)
|
||||||
QMAKE=$(QT_SDK_DIR)/qt/bin/qmake
|
QMAKE=$(QT_SDK_DIR)/Desktop/Qt/4.8.0/gcc/bin/qmake
|
||||||
else
|
else
|
||||||
# not installed, hope it's in the path...
|
# not installed, hope it's in the path...
|
||||||
QMAKE=qmake
|
QMAKE=qmake
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Aircraft type:</string>
|
<string>Vehicle type:</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -173,7 +173,7 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="fwEngineChannel">
|
<widget class="QComboBox" name="fwEngineChannelBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select output channel for the engine</string>
|
<string>Select output channel for the engine</string>
|
||||||
</property>
|
</property>
|
||||||
@ -193,7 +193,7 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="fwAileron1Channel">
|
<widget class="QComboBox" name="fwAileron1ChannelBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select output channel for the first aileron (or elevon)</string>
|
<string>Select output channel for the first aileron (or elevon)</string>
|
||||||
</property>
|
</property>
|
||||||
@ -216,7 +216,7 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="fwAileron2Channel">
|
<widget class="QComboBox" name="fwAileron2ChannelBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -239,7 +239,7 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="fwElevator1Channel">
|
<widget class="QComboBox" name="fwElevator1ChannelBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select output channel for the first elevator</string>
|
<string>Select output channel for the first elevator</string>
|
||||||
</property>
|
</property>
|
||||||
@ -262,12 +262,12 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="1">
|
<item row="5" column="1">
|
||||||
<widget class="QComboBox" name="fwElevator2Channel">
|
<widget class="QComboBox" name="fwElevator2ChannelBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select output channel for a secondry elevator</string>
|
<string>Select output channel for a secondary elevator</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -279,7 +279,7 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="1">
|
<item row="6" column="1">
|
||||||
<widget class="QComboBox" name="fwRudder1Channel">
|
<widget class="QComboBox" name="fwRudder1ChannelBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select output channel for the first rudder</string>
|
<string>Select output channel for the first rudder</string>
|
||||||
</property>
|
</property>
|
||||||
@ -293,7 +293,7 @@ QGroupBox::title {
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1">
|
<item row="7" column="1">
|
||||||
<widget class="QComboBox" name="fwRudder2Channel">
|
<widget class="QComboBox" name="fwRudder2ChannelBox">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Select output channel for a secondary rudder</string>
|
<string>Select output channel for a secondary rudder</string>
|
||||||
</property>
|
</property>
|
||||||
@ -390,7 +390,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_18">
|
<widget class="QLabel" name="elevonSliderLabel1">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>50</string>
|
<string>50</string>
|
||||||
</property>
|
</property>
|
||||||
@ -446,7 +446,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_25">
|
<widget class="QLabel" name="elevonSliderLabel2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>50</string>
|
<string>50</string>
|
||||||
</property>
|
</property>
|
||||||
@ -533,6 +533,12 @@ margin:1px;</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="fwThrottleReset">
|
<widget class="QPushButton" name="fwThrottleReset">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Reset</string>
|
<string>Reset</string>
|
||||||
</property>
|
</property>
|
||||||
@ -681,7 +687,13 @@ margin:1px;</string>
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_22">
|
<layout class="QVBoxLayout" name="verticalLayout_22">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_43">
|
<widget class="QLabel" name="mrRollMixValue">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>30</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>100</string>
|
<string>100</string>
|
||||||
</property>
|
</property>
|
||||||
@ -692,6 +704,12 @@ margin:1px;</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSlider" name="mrRollMixLevel">
|
<widget class="QSlider" name="mrRollMixLevel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>35</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Weight of Roll mixing in percent.
|
<string>Weight of Roll mixing in percent.
|
||||||
Typical values are 100% for + configuration and 50% for X configuration on quads.</string>
|
Typical values are 100% for + configuration and 50% for X configuration on quads.</string>
|
||||||
@ -729,7 +747,13 @@ margin:1px;</string>
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_23">
|
<layout class="QVBoxLayout" name="verticalLayout_23">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_44">
|
<widget class="QLabel" name="mrYawPitchValue">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>100</string>
|
<string>100</string>
|
||||||
</property>
|
</property>
|
||||||
@ -740,6 +764,12 @@ margin:1px;</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSlider" name="mrPitchMixLevel">
|
<widget class="QSlider" name="mrPitchMixLevel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>35</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Weight of Pitch mixing in percent.
|
<string>Weight of Pitch mixing in percent.
|
||||||
Typical values are 100% for + configuration and 50% for X configuration on quads.</string>
|
Typical values are 100% for + configuration and 50% for X configuration on quads.</string>
|
||||||
@ -777,7 +807,13 @@ margin:1px;</string>
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_21">
|
<layout class="QVBoxLayout" name="verticalLayout_21">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_45">
|
<widget class="QLabel" name="mrYawMixValue">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>50</string>
|
<string>50</string>
|
||||||
</property>
|
</property>
|
||||||
@ -788,6 +824,12 @@ margin:1px;</string>
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSlider" name="mrYawMixLevel">
|
<widget class="QSlider" name="mrYawMixLevel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Weight of Yaw mixing in percent.
|
<string>Weight of Yaw mixing in percent.
|
||||||
Typical value is 50% for + or X configuration on quads.</string>
|
Typical value is 50% for + or X configuration on quads.</string>
|
||||||
@ -923,6 +965,12 @@ margin:1px;</string>
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Reset</string>
|
<string>Reset</string>
|
||||||
</property>
|
</property>
|
||||||
@ -992,7 +1040,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QComboBox" name="triYawChannel">
|
<widget class="QComboBox" name="triYawChannelBox">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -1046,7 +1094,7 @@ margin:1px;</string>
|
|||||||
<number>3</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="MotorOutputLabel1">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
|
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
|
||||||
color: rgb(255, 255, 255);
|
color: rgb(255, 255, 255);
|
||||||
@ -1060,7 +1108,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor1">
|
<widget class="QComboBox" name="multiMotorChannelBox1">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1081,7 +1129,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor2">
|
<widget class="QComboBox" name="multiMotorChannelBox2">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1102,7 +1150,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor3">
|
<widget class="QComboBox" name="multiMotorChannelBox3">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1123,7 +1171,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor4">
|
<widget class="QComboBox" name="multiMotorChannelBox4">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
<string>Assign your motor output channels using the drawing above as a reference. Respect propeller rotation.</string>
|
||||||
</property>
|
</property>
|
||||||
@ -1170,7 +1218,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor5">
|
<widget class="QComboBox" name="multiMotorChannelBox5">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -1200,7 +1248,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor6">
|
<widget class="QComboBox" name="multiMotorChannelBox6">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -1224,7 +1272,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor7">
|
<widget class="QComboBox" name="multiMotorChannelBox7">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -1248,7 +1296,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="1">
|
<item row="4" column="1">
|
||||||
<widget class="QComboBox" name="multiMotor8">
|
<widget class="QComboBox" name="multiMotorChannelBox8">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -1334,6 +1382,520 @@ margin:1px;</string>
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<widget class="QWidget" name="groundVehicle">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_3" stretch="0">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Vehicle type:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QComboBox" name="groundVehicleType"/>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_23">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Channel Assignment</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_15">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Output channel asignmets</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QFormLayout" name="formLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="gvEngineLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>77</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Engine</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QComboBox" name="gvEngineChannelBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for the engine</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="gvAileron1Label">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Aileron 1</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="gvAileron1ChannelBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for the first aileron (or elevon)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="gvAileron2Label">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>60</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Aileron 2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QComboBox" name="gvAileron2ChannelBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for the second aileron (or elevon)</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="gvMotor1Label">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Motor</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QComboBox" name="gvMotor1ChannelBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for the first motor</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="gvMotor2Label">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>47</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Motor 2</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QComboBox" name="gvMotor2ChannelBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for a second motor</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="gvSteering1Label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Front Steering</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QComboBox" name="gvSteering1ChannelBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for the first steering actuator</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="gvSteering2Label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Rear Steering</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QComboBox" name="gvSteering2ChannelBox">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Select output channel for a second steering actuator</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="differentialSteeringMixBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Expanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Differential Steering Mix</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_13">
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_14">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="differentialSteeringLabel1">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>65</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Left %</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="differentialSteeringSlider1">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="gvDiffSteering1Label">
|
||||||
|
<property name="text">
|
||||||
|
<string>50</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_15">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="differentialSteeringLabel2">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>50</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Right %</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QSlider" name="differentialSteeringSlider2">
|
||||||
|
<property name="maximum">
|
||||||
|
<number>100</number>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>50</number>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="gvDiffSteering2Label">
|
||||||
|
<property name="text">
|
||||||
|
<string>50</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gvThrottleCurve1GroupBox">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>100</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="title">
|
||||||
|
<string>Front throttle curve</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_16">
|
||||||
|
<item>
|
||||||
|
<widget class="MixerCurveWidget" name="groundVehicleThrottle1" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="sizeIncrement">
|
||||||
|
<size>
|
||||||
|
<width>10</width>
|
||||||
|
<height>10</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="gvThrottleCurve1Reset">
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="gvThrottleCurve1ItemValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>Val: 0.00</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="gvThrottleCurve2GroupBox">
|
||||||
|
<property name="title">
|
||||||
|
<string>Rear throttle curve</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout_17">
|
||||||
|
<item>
|
||||||
|
<widget class="MixerCurveWidget" name="groundVehicleThrottle2" native="true">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>200</width>
|
||||||
|
<height>200</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="gvThrottleCurve2Reset">
|
||||||
|
<property name="text">
|
||||||
|
<string>Reset</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="gvThrottleCurve2ItemValue">
|
||||||
|
<property name="text">
|
||||||
|
<string>Val: 0.00</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_13">
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_11">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="gvStatusLabel">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Mixer OK</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
<widget class="QWidget" name="custom">
|
<widget class="QWidget" name="custom">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
<layout class="QHBoxLayout" name="horizontalLayout_15">
|
||||||
<item>
|
<item>
|
||||||
@ -1990,7 +2552,7 @@ margin:1px;</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="feedForwardValue">
|
<widget class="QLabel" name="feedForwardSliderValue">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>30</width>
|
<width>30</width>
|
||||||
@ -2095,7 +2657,7 @@ Do it after accel time is setup.</string>
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_33">
|
<widget class="QLabel" name="maxAccelSliderValue">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>1000</string>
|
<string>1000</string>
|
||||||
</property>
|
</property>
|
||||||
@ -2329,7 +2891,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<customwidget>
|
<customwidget>
|
||||||
<class>ConfigccpmWidget</class>
|
<class>ConfigccpmWidget</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header>configccpmwidget.h</header>
|
<header>cfg_vehicletypes/configccpmwidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
@ -2340,7 +2902,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>feedForwardSlider</sender>
|
<sender>feedForwardSlider</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>feedForwardValue</receiver>
|
<receiver>feedForwardSliderValue</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -2356,7 +2918,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>maxAccelSlider</sender>
|
<sender>maxAccelSlider</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>label_33</receiver>
|
<receiver>maxAccelSliderValue</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -2372,7 +2934,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>elevonSlider1</sender>
|
<sender>elevonSlider1</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>label_18</receiver>
|
<receiver>elevonSliderLabel1</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -2388,12 +2950,12 @@ p, li { white-space: pre-wrap; }
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>elevonSlider2</sender>
|
<sender>elevonSlider2</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>label_25</receiver>
|
<receiver>elevonSliderLabel2</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
<x>124</x>
|
<x>362</x>
|
||||||
<y>126</y>
|
<y>299</y>
|
||||||
</hint>
|
</hint>
|
||||||
<hint type="destinationlabel">
|
<hint type="destinationlabel">
|
||||||
<x>124</x>
|
<x>124</x>
|
||||||
@ -2401,10 +2963,42 @@ p, li { white-space: pre-wrap; }
|
|||||||
</hint>
|
</hint>
|
||||||
</hints>
|
</hints>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>differentialSteeringSlider1</sender>
|
||||||
|
<signal>valueChanged(int)</signal>
|
||||||
|
<receiver>gvDiffSteering1Label</receiver>
|
||||||
|
<slot>setNum(int)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>124</x>
|
||||||
|
<y>126</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>315</x>
|
||||||
|
<y>391</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>differentialSteeringSlider2</sender>
|
||||||
|
<signal>valueChanged(int)</signal>
|
||||||
|
<receiver>gvDiffSteering2Label</receiver>
|
||||||
|
<slot>setNum(int)</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>124</x>
|
||||||
|
<y>126</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>390</x>
|
||||||
|
<y>391</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
<connection>
|
<connection>
|
||||||
<sender>mrPitchMixLevel</sender>
|
<sender>mrPitchMixLevel</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>label_44</receiver>
|
<receiver>mrPitchMixValue</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -2420,7 +3014,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>mrRollMixLevel</sender>
|
<sender>mrRollMixLevel</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>label_43</receiver>
|
<receiver>mrRollMixValue</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
@ -2436,7 +3030,7 @@ p, li { white-space: pre-wrap; }
|
|||||||
<connection>
|
<connection>
|
||||||
<sender>mrYawMixLevel</sender>
|
<sender>mrYawMixLevel</sender>
|
||||||
<signal>valueChanged(int)</signal>
|
<signal>valueChanged(int)</signal>
|
||||||
<receiver>label_45</receiver>
|
<receiver>mrYawMixValue</receiver>
|
||||||
<slot>setNum(int)</slot>
|
<slot>setNum(int)</slot>
|
||||||
<hints>
|
<hints>
|
||||||
<hint type="sourcelabel">
|
<hint type="sourcelabel">
|
||||||
|
@ -81,7 +81,7 @@ public:
|
|||||||
ConfigccpmWidget(QWidget *parent = 0);
|
ConfigccpmWidget(QWidget *parent = 0);
|
||||||
~ConfigccpmWidget();
|
~ConfigccpmWidget();
|
||||||
|
|
||||||
friend class ConfigAirframeWidget;
|
friend class ConfigVehicleTypeWidget;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_ccpmWidget *m_ccpm;
|
Ui_ccpmWidget *m_ccpm;
|
@ -0,0 +1,699 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file configfixedwidget.cpp
|
||||||
|
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup ConfigPlugin Config Plugin
|
||||||
|
* @{
|
||||||
|
* @brief ccpm configuration panel
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
//#include "configfixedwingwidget.h"
|
||||||
|
#include "configvehicletypewidget.h"
|
||||||
|
#include "mixersettings.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QtGui/QTextEdit>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <math.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "mixersettings.h"
|
||||||
|
#include "systemsettings.h"
|
||||||
|
#include "actuatorcommand.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to setup the UI
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::setupFixedWingUI(QString frameType)
|
||||||
|
{
|
||||||
|
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
|
||||||
|
// Setup the UI
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||||
|
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
|
||||||
|
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder1Label->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder2Label->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator1Label->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator2Label->setEnabled(true);
|
||||||
|
m_aircraft->fwAileron1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwAileron1Label->setEnabled(true);
|
||||||
|
m_aircraft->fwAileron2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwAileron2Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->fwAileron1Label->setText("Aileron 1");
|
||||||
|
m_aircraft->fwAileron2Label->setText("Aileron 2");
|
||||||
|
m_aircraft->fwElevator1Label->setText("Elevator 1");
|
||||||
|
m_aircraft->fwElevator2Label->setText("Elevator 2");
|
||||||
|
m_aircraft->elevonMixBox->setHidden(true);
|
||||||
|
|
||||||
|
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||||
|
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevon"));
|
||||||
|
m_aircraft->fwAileron1Label->setText("Elevon 1");
|
||||||
|
m_aircraft->fwAileron2Label->setText("Elevon 2");
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwElevator1Label->setEnabled(false);
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwElevator2Label->setEnabled(false);
|
||||||
|
m_aircraft->fwRudder1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder1Label->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder2Label->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator1Label->setText("Elevator 1");
|
||||||
|
m_aircraft->fwElevator2Label->setText("Elevator 2");
|
||||||
|
m_aircraft->elevonMixBox->setHidden(false);
|
||||||
|
m_aircraft->elevonLabel1->setText("Roll");
|
||||||
|
m_aircraft->elevonLabel2->setText("Pitch");
|
||||||
|
|
||||||
|
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
||||||
|
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Vtail"));
|
||||||
|
m_aircraft->fwRudder1ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwRudder1Label->setEnabled(false);
|
||||||
|
m_aircraft->fwRudder2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwRudder2Label->setEnabled(false);
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator1Label->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator1Label->setText("Vtail 1");
|
||||||
|
m_aircraft->fwElevator2Label->setText("Vtail 2");
|
||||||
|
m_aircraft->elevonMixBox->setHidden(false);
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator2Label->setEnabled(true);
|
||||||
|
m_aircraft->fwAileron1Label->setText("Aileron 1");
|
||||||
|
m_aircraft->fwAileron2Label->setText("Aileron 2");
|
||||||
|
m_aircraft->elevonLabel1->setText("Rudder");
|
||||||
|
m_aircraft->elevonLabel2->setText("Pitch");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to update the UI widget objects
|
||||||
|
*/
|
||||||
|
QString ConfigVehicleTypeWidget::updateFixedWingObjectsFromWidgets()
|
||||||
|
{
|
||||||
|
QString airframeType = "FixedWing";
|
||||||
|
|
||||||
|
// Save the curve (common to all Fixed wing frames)
|
||||||
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
|
||||||
|
// Remove Feed Forward, it is pointless on a plane:
|
||||||
|
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
||||||
|
field->setDouble(0);
|
||||||
|
|
||||||
|
field = obj->getField("ThrottleCurve1");
|
||||||
|
QList<double> curve = m_aircraft->fixedWingThrottle->getCurve();
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
|
||||||
|
//All airframe types must start with "FixedWing"
|
||||||
|
if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) {
|
||||||
|
airframeType = "FixedWing";
|
||||||
|
setupFrameFixedWing( airframeType );
|
||||||
|
} else if (m_aircraft->fixedWingType->currentText() == "Elevon") {
|
||||||
|
airframeType = "FixedWingElevon";
|
||||||
|
setupFrameElevon( airframeType );
|
||||||
|
} else { // "Vtail"
|
||||||
|
airframeType = "FixedWingVtail";
|
||||||
|
setupFrameVtail( airframeType );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now reflect those settings in the "Custom" panel as well
|
||||||
|
updateCustomAirframeUI();
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to refresh the UI widget values
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::refreshFixedWingWidgetsValues(QString frameType)
|
||||||
|
{
|
||||||
|
|
||||||
|
UAVDataObject* obj;
|
||||||
|
UAVObjectField *field;
|
||||||
|
|
||||||
|
// Then retrieve how channels are setup
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
field = obj->getField(QString("FixedWingThrottle"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwEngineChannelBox->setCurrentIndex(m_aircraft->fwEngineChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingRoll1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwAileron1ChannelBox->setCurrentIndex(m_aircraft->fwAileron1ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingRoll2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwAileron2ChannelBox->setCurrentIndex(m_aircraft->fwAileron2ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingPitch1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setCurrentIndex(m_aircraft->fwElevator1ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingPitch2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setCurrentIndex(m_aircraft->fwElevator2ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingYaw1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwRudder1ChannelBox->setCurrentIndex(m_aircraft->fwRudder1ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingYaw2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->fwRudder2ChannelBox->setCurrentIndex(m_aircraft->fwRudder2ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
if (frameType == "FixedWingElevon") {
|
||||||
|
// If the airframe is elevon, restore the slider setting
|
||||||
|
// Find the channel number for Elevon1 (FixedWingRoll1)
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
int chMixerNumber = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
||||||
|
if (chMixerNumber >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||||
|
field = obj->getField(mixerVectors.at(chMixerNumber));
|
||||||
|
int ti = field->getElementNames().indexOf("Roll");
|
||||||
|
m_aircraft->elevonSlider1->setValue(field->getDouble(ti)*100);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
m_aircraft->elevonSlider2->setValue(field->getDouble(ti)*100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (frameType == "FixedWingVtail") {
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
int chMixerNumber = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
|
||||||
|
if (chMixerNumber >=0) {
|
||||||
|
field = obj->getField(mixerVectors.at(chMixerNumber));
|
||||||
|
int ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
m_aircraft->elevonSlider1->setValue(field->getDouble(ti)*100);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
m_aircraft->elevonSlider2->setValue(field->getDouble(ti)*100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setup Elevator/Aileron/Rudder airframe.
|
||||||
|
|
||||||
|
If both Aileron channels are set to 'None' (EasyStar), do Pitch/Rudder mixing
|
||||||
|
|
||||||
|
Returns False if impossible to create the mixer.
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupFrameFixedWing(QString airframeType)
|
||||||
|
{
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwFixedWingChannelConfigError(airframeType);
|
||||||
|
|
||||||
|
// - At least Pitch and either Roll or Yaw
|
||||||
|
if (m_aircraft->fwEngineChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->fwElevator1ChannelBox->currentText() == "None" ||
|
||||||
|
((m_aircraft->fwAileron1ChannelBox->currentText() == "None") &&
|
||||||
|
(m_aircraft->fwRudder1ChannelBox->currentText() == "None"))) {
|
||||||
|
// TODO: explain the problem in the UI
|
||||||
|
// m_aircraft->fwStatusLabel->setText("ERROR: check channel assignment");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// Now setup the channels:
|
||||||
|
resetActuators();
|
||||||
|
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
|
||||||
|
// Elevator
|
||||||
|
UAVObjectField *field = obj->getField("FixedWingPitch1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwElevator1ChannelBox->currentText());
|
||||||
|
field = obj->getField("FixedWingPitch2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwElevator2ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Aileron
|
||||||
|
field = obj->getField("FixedWingRoll1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwAileron1ChannelBox->currentText());
|
||||||
|
field = obj->getField("FixedWingRoll2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwAileron2ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Rudder
|
||||||
|
field = obj->getField("FixedWingYaw1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwRudder1ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Throttle
|
||||||
|
field = obj->getField("FixedWingThrottle");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwEngineChannelBox->currentText());
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
// ... and compute the matrix:
|
||||||
|
// In order to make code a bit nicer, we assume:
|
||||||
|
// - Channel dropdowns start with 'None', then 0 to 7
|
||||||
|
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
// Disable all
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue("Disabled");
|
||||||
|
}
|
||||||
|
// and set only the relevant channels:
|
||||||
|
// Engine
|
||||||
|
int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Motor");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
// First of all reset the vector
|
||||||
|
resetField(field);
|
||||||
|
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
|
||||||
|
// Rudder
|
||||||
|
tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if rudder is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
} // Else: we have no rudder, only ailerons, we're fine with it.
|
||||||
|
|
||||||
|
// Ailerons
|
||||||
|
tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
// Only set Aileron 2 if Aileron 1 is defined
|
||||||
|
tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
}
|
||||||
|
} // Else we have no ailerons. Our consistency check guarantees we have
|
||||||
|
// rudder in this case, so we're fine with it too.
|
||||||
|
|
||||||
|
// Elevator
|
||||||
|
tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
// Only set Elevator 2 if it is defined
|
||||||
|
tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
m_aircraft->fwStatusLabel->setText("Mixer generated");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setup Elevon
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupFrameElevon(QString airframeType)
|
||||||
|
{
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwFixedWingChannelConfigError(airframeType);
|
||||||
|
|
||||||
|
// - At least Aileron1 and Aileron 2, and engine
|
||||||
|
if (m_aircraft->fwEngineChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->fwAileron1ChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->fwAileron2ChannelBox->currentText() == "None") {
|
||||||
|
// TODO: explain the problem in the UI
|
||||||
|
// m_aircraft->fwStatusLabel->setText("ERROR: check channel assignment");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetActuators();
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
|
||||||
|
// Elevons
|
||||||
|
UAVObjectField *field = obj->getField("FixedWingRoll1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwAileron1ChannelBox->currentText());
|
||||||
|
field = obj->getField("FixedWingRoll2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwAileron2ChannelBox->currentText());
|
||||||
|
// Rudder 1 (can be None)
|
||||||
|
field = obj->getField("FixedWingYaw1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwRudder1ChannelBox->currentText());
|
||||||
|
// Rudder 2 (can be None)
|
||||||
|
field = obj->getField("FixedWingYaw2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwRudder2ChannelBox->currentText());
|
||||||
|
// Throttle
|
||||||
|
field = obj->getField("FixedWingThrottle");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwEngineChannelBox->currentText());
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
// Save the curve:
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
// ... and compute the matrix:
|
||||||
|
// In order to make code a bit nicer, we assume:
|
||||||
|
// - Channel dropdowns start with 'None', then 0 to 7
|
||||||
|
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
// Disable all
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue("Disabled");
|
||||||
|
}
|
||||||
|
// and set only the relevant channels:
|
||||||
|
// Engine
|
||||||
|
int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Motor");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
// First of all reset the vector
|
||||||
|
resetField(field);
|
||||||
|
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
|
||||||
|
// Rudder 1
|
||||||
|
tmpVal = m_aircraft->fwRudder1ChannelBox->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if rudder 1 is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
} // Else: we have no rudder, only elevons, we're fine with it.
|
||||||
|
|
||||||
|
// Rudder 2
|
||||||
|
tmpVal = m_aircraft->fwRudder2ChannelBox->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if rudder 2 is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(-127, ti);
|
||||||
|
} // Else: we have no rudder, only elevons, we're fine with it.
|
||||||
|
|
||||||
|
tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
m_aircraft->fwStatusLabel->setText("Mixer generated");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setup VTail
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupFrameVtail(QString airframeType)
|
||||||
|
{
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwFixedWingChannelConfigError(airframeType);
|
||||||
|
|
||||||
|
// - At least Pitch1 and Pitch2, and engine
|
||||||
|
if (m_aircraft->fwEngineChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->fwElevator1ChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->fwElevator2ChannelBox->currentText() == "None") {
|
||||||
|
// TODO: explain the problem in the UI
|
||||||
|
// m_aircraft->fwStatusLabel->setText("WARNING: check channel assignment");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
resetActuators();
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
|
||||||
|
// Elevons
|
||||||
|
UAVObjectField *field = obj->getField("FixedWingPitch1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwElevator1ChannelBox->currentText());
|
||||||
|
field = obj->getField("FixedWingPitch2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwElevator2ChannelBox->currentText());
|
||||||
|
field = obj->getField("FixedWingRoll1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwAileron1ChannelBox->currentText());
|
||||||
|
field = obj->getField("FixedWingRoll2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwAileron2ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Throttle
|
||||||
|
field = obj->getField("FixedWingThrottle");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->fwEngineChannelBox->currentText());
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
// ... and compute the matrix:
|
||||||
|
// In order to make code a bit nicer, we assume:
|
||||||
|
// - Channel dropdowns start with 'None', then 0 to 7
|
||||||
|
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
// Disable all
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue("Disabled");
|
||||||
|
}
|
||||||
|
// and set only the relevant channels:
|
||||||
|
// Engine
|
||||||
|
int tmpVal = m_aircraft->fwEngineChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Motor");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
// First of all reset the vector
|
||||||
|
resetField(field);
|
||||||
|
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
|
||||||
|
tmpVal = m_aircraft->fwAileron1ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(127,ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
tmpVal = m_aircraft->fwAileron2ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(-127,ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now compute the VTail
|
||||||
|
tmpVal = m_aircraft->fwElevator1ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
||||||
|
|
||||||
|
tmpVal = m_aircraft->fwElevator2ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
m_aircraft->fwStatusLabel->setText("Mixer generated");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::throwFixedWingChannelConfigError(QString airframeType)
|
||||||
|
{
|
||||||
|
//Initialize configuration error flag
|
||||||
|
bool error=false;
|
||||||
|
|
||||||
|
//Create a red block. All combo boxes are the same size, so any one should do as a model
|
||||||
|
int size = m_aircraft->fwEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||||
|
QPixmap pixmap(size,size);
|
||||||
|
pixmap.fill(QColor("red"));
|
||||||
|
|
||||||
|
if (airframeType == "FixedWing" ) {
|
||||||
|
if (m_aircraft->fwEngineChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_aircraft->fwElevator1ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((m_aircraft->fwAileron1ChannelBox->currentText() == "None") && (m_aircraft->fwRudder1ChannelBox->currentText() == "None")) {
|
||||||
|
pixmap.fill(QColor("green"));
|
||||||
|
m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
m_aircraft->fwRudder1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
m_aircraft->fwRudder1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
} else if (airframeType == "FixedWingElevon"){
|
||||||
|
if (m_aircraft->fwEngineChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_aircraft->fwAileron1ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_aircraft->fwAileron2ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwAileron2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ( airframeType == "FixedWingVtail"){
|
||||||
|
if (m_aircraft->fwEngineChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_aircraft->fwElevator1ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if(m_aircraft->fwElevator2ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error){
|
||||||
|
m_aircraft->fwStatusLabel->setText(QString("<font color='red'>ERROR: Assign all necessary channels</font>"));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,751 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file configgroundvehiclemwidget.cpp
|
||||||
|
* @author K. Sebesta & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup ConfigPlugin Config Plugin
|
||||||
|
* @{
|
||||||
|
* @brief ccpm configuration panel
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
//#include "configgroundvehiclewidget.h"
|
||||||
|
#include "configvehicletypewidget.h"
|
||||||
|
#include "mixersettings.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QtGui/QTextEdit>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <math.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "mixersettings.h"
|
||||||
|
#include "systemsettings.h"
|
||||||
|
#include "actuatorcommand.h"
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to setup the UI
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::setupGroundVehicleUI(QString frameType)
|
||||||
|
{
|
||||||
|
m_aircraft->differentialSteeringMixBox->setHidden(true);
|
||||||
|
//STILL NEEDS WORK
|
||||||
|
// Setup the UI
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Ground"));
|
||||||
|
|
||||||
|
m_aircraft->gvEngineChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->gvEngineLabel->setEnabled(false);
|
||||||
|
|
||||||
|
|
||||||
|
m_aircraft->gvAileron1ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->gvAileron1Label->setEnabled(false);
|
||||||
|
|
||||||
|
m_aircraft->gvAileron2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->gvAileron2Label->setEnabled(false);
|
||||||
|
|
||||||
|
if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"){ //Tank
|
||||||
|
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Differential (tank)"));
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvMotor1Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvMotor2Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvMotor1Label->setText("Left motor");
|
||||||
|
m_aircraft->gvMotor2Label->setText("Right motor");
|
||||||
|
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->gvSteering1Label->setEnabled(false);
|
||||||
|
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->gvSteering2Label->setEnabled(false);
|
||||||
|
|
||||||
|
m_aircraft->gvSteering2Label->setText("Rear steering");
|
||||||
|
|
||||||
|
m_aircraft->differentialSteeringMixBox->setHidden(false);
|
||||||
|
|
||||||
|
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve");
|
||||||
|
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve");
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle
|
||||||
|
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Motorcycle"));
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->gvMotor1Label->setEnabled(false);
|
||||||
|
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvMotor2Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvMotor1Label->setText("Front motor");
|
||||||
|
m_aircraft->gvMotor2Label->setText("Rear motor");
|
||||||
|
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvSteering1Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvSteering2Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvSteering2Label->setText("Balancing");
|
||||||
|
|
||||||
|
m_aircraft->differentialSteeringMixBox->setHidden(true);
|
||||||
|
|
||||||
|
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
|
||||||
|
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
|
||||||
|
}
|
||||||
|
else {//Car
|
||||||
|
m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)"));
|
||||||
|
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvMotor1Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvMotor2Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvMotor1Label->setText("Front motor");
|
||||||
|
m_aircraft->gvMotor2Label->setText("Rear motor");
|
||||||
|
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvSteering1Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->gvSteering2Label->setEnabled(true);
|
||||||
|
|
||||||
|
m_aircraft->differentialSteeringMixBox->setHidden(true);
|
||||||
|
|
||||||
|
m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve");
|
||||||
|
m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to update the UI widget objects
|
||||||
|
*/
|
||||||
|
QString ConfigVehicleTypeWidget::updateGroundVehicleObjectsFromWidgets()
|
||||||
|
{
|
||||||
|
QString airframeType = "GroundVehicleCar";
|
||||||
|
|
||||||
|
// Save the curve (common to all ground vehicle frames)
|
||||||
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
|
||||||
|
// Remove Feed Forward, it is pointless on a ground vehicle:
|
||||||
|
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
||||||
|
field->setDouble(0);
|
||||||
|
|
||||||
|
field = obj->getField("ThrottleCurve1");
|
||||||
|
QList<double> curve = m_aircraft->groundVehicleThrottle1->getCurve();
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
|
||||||
|
field = obj->getField("ThrottleCurve2");
|
||||||
|
curve = m_aircraft->groundVehicleThrottle2->getCurve();
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
|
||||||
|
//All airframe types must start with "GroundVehicle"
|
||||||
|
if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)" ) {
|
||||||
|
airframeType = "GroundVehicleCar";
|
||||||
|
setupGroundVehicleCar(airframeType);
|
||||||
|
} else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") {
|
||||||
|
airframeType = "GroundVehicleDifferential";
|
||||||
|
setupGroundVehicleDifferential(airframeType);
|
||||||
|
} else { // "Motorcycle"
|
||||||
|
airframeType = "GroundVehicleMotorcycle";
|
||||||
|
setupGroundVehicleMotorcycle(airframeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now reflect those settings in the "Custom" panel as well
|
||||||
|
updateCustomAirframeUI();
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to refresh the UI widget values
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::refreshGroundVehicleWidgetsValues(QString frameType)
|
||||||
|
{
|
||||||
|
|
||||||
|
UAVDataObject* obj;
|
||||||
|
UAVObjectField *field;
|
||||||
|
|
||||||
|
//THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE
|
||||||
|
// Retrieve channel setup values
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
field = obj->getField(QString("FixedWingThrottle"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvEngineChannelBox->setCurrentIndex(m_aircraft->gvEngineChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingRoll1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvAileron1ChannelBox->setCurrentIndex(m_aircraft->gvAileron1ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("FixedWingRoll2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvAileron2ChannelBox->setCurrentIndex(m_aircraft->gvAileron2ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("GroundVehicleThrottle1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setCurrentIndex(m_aircraft->gvMotor1ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("GroundVehicleThrottle2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setCurrentIndex(m_aircraft->gvMotor2ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("GroundVehicleSteering1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setCurrentIndex(m_aircraft->gvSteering1ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
field = obj->getField(QString("GroundVehicleSteering2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setCurrentIndex(m_aircraft->gvSteering2ChannelBox->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
if (frameType == "GroundVehicleDifferential") {
|
||||||
|
//CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE
|
||||||
|
// If the vehicle type is "differential", restore the slider setting
|
||||||
|
|
||||||
|
// Find the channel number for Motor1
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
|
||||||
|
if (chMixerNumber >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
||||||
|
field = obj->getField(mixerVectors.at(chMixerNumber));
|
||||||
|
int ti = field->getElementNames().indexOf("Roll");
|
||||||
|
m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100);
|
||||||
|
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (frameType == "GroundVehicleMotorcycle") {
|
||||||
|
//CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE
|
||||||
|
// obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
// Q_ASSERT(obj);
|
||||||
|
// int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
|
||||||
|
// if (chMixerNumber >=0) {
|
||||||
|
// field = obj->getField(mixerVectors.at(chMixerNumber));
|
||||||
|
// int ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100);
|
||||||
|
//
|
||||||
|
// ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
// m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setup balancing ground vehicle.
|
||||||
|
|
||||||
|
Returns False if impossible to create the mixer.
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupGroundVehicleMotorcycle(QString airframeType){
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwGroundVehicleChannelConfigError(airframeType);
|
||||||
|
|
||||||
|
// - Motor, steering, and balance
|
||||||
|
if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" ||
|
||||||
|
(m_aircraft->gvSteering1ChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->gvSteering2ChannelBox->currentText() == "None") )
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Now setup the channels:
|
||||||
|
resetActuators();
|
||||||
|
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
|
||||||
|
// Left motor
|
||||||
|
UAVObjectField *field = obj->getField("GroundVehicleThrottle1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvMotor1ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Right motor
|
||||||
|
field = obj->getField("GroundVehicleThrottle2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvMotor2ChannelBox->currentText());
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
// ... and compute the matrix:
|
||||||
|
// In order to make code a bit nicer, we assume:
|
||||||
|
// - Channel dropdowns start with 'None', then 0 to 7
|
||||||
|
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
|
||||||
|
int tmpVal, ti;
|
||||||
|
|
||||||
|
// Disable all output channels
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
|
||||||
|
//Disable output channel
|
||||||
|
field->setValue("Disabled");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set all mixer values to zero
|
||||||
|
foreach(QString mixer, mixerVectors) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
resetField(field);
|
||||||
|
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Motor
|
||||||
|
// Setup motor
|
||||||
|
tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo"); //Set motor mixer type to Servo
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward
|
||||||
|
field->setValue(127, ti);
|
||||||
|
|
||||||
|
//Steering
|
||||||
|
// Setup steering
|
||||||
|
tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo"); //Set motor mixer type to Servo
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw"); //Set steering response to roll
|
||||||
|
field->setValue(-127, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll"); //Set steering response to roll
|
||||||
|
field->setValue(-127, ti);
|
||||||
|
|
||||||
|
//Balancing
|
||||||
|
// Setup balancing servo
|
||||||
|
tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo"); //Set motor mixer type to Servo
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw"); //Set balance response to yaw
|
||||||
|
field->setValue(127, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll"); //Set balance response to roll
|
||||||
|
field->setValue(127, ti);
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
//Output success message
|
||||||
|
m_aircraft->gvStatusLabel->setText("Mixer generated");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setup differentially steered ground vehicle.
|
||||||
|
|
||||||
|
Returns False if impossible to create the mixer.
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupGroundVehicleDifferential(QString airframeType){
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwGroundVehicleChannelConfigError(airframeType);
|
||||||
|
|
||||||
|
// - Left and right steering
|
||||||
|
if ( m_aircraft->gvMotor2ChannelBox->currentText() == "None" ||
|
||||||
|
m_aircraft->gvSteering1ChannelBox->currentText() == "None")
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Now setup the channels:
|
||||||
|
resetActuators();
|
||||||
|
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
|
||||||
|
// Left motor
|
||||||
|
UAVObjectField *field = obj->getField("GroundVehicleThrottle1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvMotor1ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Right motor
|
||||||
|
field = obj->getField("GroundVehicleThrottle2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvMotor2ChannelBox->currentText());
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
// ... and compute the matrix:
|
||||||
|
// In order to make code a bit nicer, we assume:
|
||||||
|
// - Channel dropdowns start with 'None', then 0 to 7
|
||||||
|
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
|
||||||
|
int tmpVal, ti;
|
||||||
|
|
||||||
|
// Disable all output channels
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
|
||||||
|
//Disable output channel
|
||||||
|
field->setValue("Disabled");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set all mixer values to zero
|
||||||
|
foreach(QString mixer, mixerVectors) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
resetField(field);
|
||||||
|
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Motor
|
||||||
|
// Setup left motor
|
||||||
|
tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo"); //Set motor mixer type to Servo
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve1"); //Set motor to full forward
|
||||||
|
field->setValue(127, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn right with increasing throttle
|
||||||
|
field->setValue(127, ti);
|
||||||
|
|
||||||
|
// Setup right motor
|
||||||
|
tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo"); //Set motor mixer type to Servo
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2"); //Set motor to full forward
|
||||||
|
field->setValue(127, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw"); //Set motor to turn left with increasing throttle
|
||||||
|
field->setValue(-127, ti);
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
//Output success message
|
||||||
|
m_aircraft->gvStatusLabel->setText("Mixer generated");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Setup steerable ground vehicle.
|
||||||
|
|
||||||
|
Returns False if impossible to create the mixer.
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupGroundVehicleCar(QString airframeType)
|
||||||
|
{
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwGroundVehicleChannelConfigError(airframeType);
|
||||||
|
|
||||||
|
// - At least one motor and one steering servo
|
||||||
|
if ((m_aircraft->gvMotor1ChannelBox->currentText() == "None" &&
|
||||||
|
m_aircraft->gvMotor2ChannelBox->currentText() == "None") ||
|
||||||
|
(m_aircraft->gvSteering1ChannelBox->currentText() == "None" &&
|
||||||
|
m_aircraft->gvSteering2ChannelBox->currentText() == "None"))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// else{
|
||||||
|
// // m_aircraft->gvStatusLabel->setText("Mixer generated");
|
||||||
|
// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvSteering1Label->setText(htmlText->toPlainText());
|
||||||
|
// delete htmlText;
|
||||||
|
//
|
||||||
|
// htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvSteering2Label->setText(htmlText->toPlainText());
|
||||||
|
// delete htmlText;
|
||||||
|
//
|
||||||
|
// htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvMotor1Label->setText(htmlText->toPlainText());
|
||||||
|
// delete htmlText;
|
||||||
|
//
|
||||||
|
// htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvMotor2Label->setText(htmlText->toPlainText());
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Now setup the channels:
|
||||||
|
resetActuators();
|
||||||
|
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
|
||||||
|
// Front motor
|
||||||
|
UAVObjectField *field = obj->getField("GroundVehicleThrottle1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvMotor1ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Rear motor
|
||||||
|
field = obj->getField("GroundVehicleThrottle2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvMotor2ChannelBox->currentText());
|
||||||
|
|
||||||
|
// // Aileron
|
||||||
|
// field = obj->getField("FixedWingRoll1");
|
||||||
|
// Q_ASSERT(field);
|
||||||
|
// field->setValue(m_aircraft->fwAileron1ChannelBox->currentText());
|
||||||
|
//
|
||||||
|
// field = obj->getField("FixedWingRoll2");
|
||||||
|
// Q_ASSERT(field);
|
||||||
|
// field->setValue(m_aircraft->fwAileron2ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Front steering
|
||||||
|
field = obj->getField("GroundVehicleSteering1");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvSteering1ChannelBox->currentText());
|
||||||
|
|
||||||
|
// Rear steering
|
||||||
|
field = obj->getField("GroundVehicleSteering2");
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue(m_aircraft->gvSteering2ChannelBox->currentText());
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
// ... and compute the matrix:
|
||||||
|
// In order to make code a bit nicer, we assume:
|
||||||
|
// - Channel dropdowns start with 'None', then 0 to 7
|
||||||
|
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
|
||||||
|
int tmpVal, ti;
|
||||||
|
|
||||||
|
// Disable all output channels
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
|
||||||
|
//Disable output channel
|
||||||
|
field->setValue("Disabled");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set all mixer values to zero
|
||||||
|
foreach(QString mixer, mixerVectors) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
resetField(field);
|
||||||
|
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(0, ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Steering
|
||||||
|
// Only set front steering if it is defined
|
||||||
|
tmpVal = m_aircraft->gvSteering1ChannelBox->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if steering is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
} // Else: we have no front steering. We're fine with it as long as we have rear steering
|
||||||
|
|
||||||
|
// Only set rear steering if it is defined
|
||||||
|
tmpVal = m_aircraft->gvSteering2ChannelBox->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if steering is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(-127, ti);
|
||||||
|
} // Else: we have no rear steering. We're fine with it as long as we have front steering
|
||||||
|
|
||||||
|
// Motor
|
||||||
|
// Only set front motor if it is defined
|
||||||
|
tmpVal = m_aircraft->gvMotor1ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only set rear motor if it is defined
|
||||||
|
tmpVal = m_aircraft->gvMotor2ChannelBox->currentIndex()-1;
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
//Output success message
|
||||||
|
m_aircraft->gvStatusLabel->setText("Mixer generated");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::throwGroundVehicleChannelConfigError(QString airframeType)
|
||||||
|
{
|
||||||
|
//Initialize configuration error flag
|
||||||
|
bool error=false;
|
||||||
|
|
||||||
|
|
||||||
|
//Create a red block. All combo boxes are the same size, so any one should do as a model
|
||||||
|
int size = m_aircraft->gvEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||||
|
QPixmap pixmap(size,size);
|
||||||
|
pixmap.fill(QColor("red"));
|
||||||
|
|
||||||
|
if (airframeType == "GroundVehicleCar" ) { //Car
|
||||||
|
if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None"){
|
||||||
|
pixmap.fill(QColor("green"));
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
// m_aircraft->gvMotor1Label->setText("<font color='red'>" + m_aircraft->gvMotor1Label->text() + "</font>");
|
||||||
|
// m_aircraft->gvMotor2Label->setText("<font color='red'>" + m_aircraft->gvMotor2Label->text() + "</font>");
|
||||||
|
error=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvMotor1Label->setText(htmlText->toPlainText());
|
||||||
|
// delete htmlText;
|
||||||
|
//
|
||||||
|
// htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvMotor2Label->setText(htmlText->toPlainText());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
// m_aircraft->gvStatusLabel->setText("<font color='red'>ERROR: check steering channel assignment</font>");
|
||||||
|
// m_aircraft->gvSteering1Label->setText("<font color='red'>" + m_aircraft->gvSteering1Label->text() + "</font>");
|
||||||
|
// m_aircraft->gvSteering2Label->setText("<font color='red'>" + m_aircraft->gvSteering2Label->text() + "</font>");
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvSteering1Label->setText(htmlText->toPlainText());
|
||||||
|
// delete htmlText;
|
||||||
|
//
|
||||||
|
// htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags.
|
||||||
|
// m_aircraft->gvSteering2Label->setText(htmlText->toPlainText());
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (airframeType == "GroundVehicleDifferential"){ //Tank
|
||||||
|
if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" || m_aircraft->gvMotor2ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
//Always reset
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
} else if ( airframeType == "GroundVehicleMotorcycle"){ //Motorcycle
|
||||||
|
if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None"){
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" && m_aircraft->gvSteering2ChannelBox->currentText() == "None") {
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
error=true;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
//Always reset
|
||||||
|
m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error){
|
||||||
|
m_aircraft->gvStatusLabel->setText(QString("<font color='red'>ERROR: Assign all necessary channels</font>"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,1146 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file configmultirotorwidget.cpp
|
||||||
|
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup ConfigPlugin Config Plugin
|
||||||
|
* @{
|
||||||
|
* @brief ccpm configuration panel
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
//#include "configmultirotorwidget.h"
|
||||||
|
#include "configvehicletypewidget.h"
|
||||||
|
#include "mixersettings.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QtGui/QTextEdit>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#include <QBrush>
|
||||||
|
#include <math.h>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
|
#include "mixersettings.h"
|
||||||
|
#include "systemsettings.h"
|
||||||
|
#include "actuatorcommand.h"
|
||||||
|
|
||||||
|
//#define Pi 3.14159265358979323846
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to setup the UI
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::setupMultiRotorUI(QString frameType)
|
||||||
|
{
|
||||||
|
if (frameType == "Tri" || frameType == "Tricopter Y") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
||||||
|
quad->setElementId("tri");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes...
|
||||||
|
for (int i=1; i <=3; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
//and grey out all unused motor channel boxes
|
||||||
|
for (int i=4; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(true);
|
||||||
|
} else if (frameType == "QuadX" || frameType == "Quad X") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X"));
|
||||||
|
quad->setElementId("quad-X");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes...
|
||||||
|
for (int i=1; i <=4; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
//and grey out all unused motor channel boxes
|
||||||
|
for (int i=5; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(50);
|
||||||
|
} else if (frameType == "QuadP" || frameType == "Quad +") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad +"));
|
||||||
|
quad->setElementId("quad-plus");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes...
|
||||||
|
for (int i=1; i <=4; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
//and grey out all unused motor channel boxes
|
||||||
|
for (int i=5; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(100);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(50);
|
||||||
|
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
||||||
|
quad->setElementId("quad-hexa");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes...
|
||||||
|
for (int i=1; i <=6; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
//and grey out all unused motor channel boxes
|
||||||
|
for (int i=7; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(33);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(33);
|
||||||
|
} else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
||||||
|
quad->setElementId("quad-hexa-H");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes...
|
||||||
|
for (int i=1; i <=6; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
//and grey out all unused motor channel boxes
|
||||||
|
for (int i=7; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(33);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(33);
|
||||||
|
|
||||||
|
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
||||||
|
quad->setElementId("hexa-coax");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes...
|
||||||
|
for (int i=1; i <=6; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
//and grey out all unused motor channel boxes
|
||||||
|
for (int i=7; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(100);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(66);
|
||||||
|
|
||||||
|
} else if (frameType == "Octo" || frameType == "Octocopter") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter"));
|
||||||
|
quad->setElementId("quad-octo");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes
|
||||||
|
for (int i=1; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(33);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(33);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(25);
|
||||||
|
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
||||||
|
quad->setElementId("quad-octo-v");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes
|
||||||
|
for (int i=1; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(25);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(25);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(25);
|
||||||
|
|
||||||
|
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
||||||
|
quad->setElementId("octo-coax-P");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes
|
||||||
|
for (int i=1; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(100);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(100);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(50);
|
||||||
|
|
||||||
|
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
||||||
|
quad->setElementId("octo-coax-X");
|
||||||
|
|
||||||
|
//Enable all necessary motor channel boxes
|
||||||
|
for (int i=1; i <=8; i++) {
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i));
|
||||||
|
combobox->setEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_aircraft->triYawChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(50);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(50);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to update the UI widget objects
|
||||||
|
*/
|
||||||
|
QString ConfigVehicleTypeWidget::updateMultiRotorObjectsFromWidgets()
|
||||||
|
{
|
||||||
|
QString airframeType;
|
||||||
|
QList<QString> motorList;
|
||||||
|
|
||||||
|
// We can already setup the feedforward here, as it is common to all platforms
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
||||||
|
field->setDouble((double)m_aircraft->feedForwardSlider->value()/100);
|
||||||
|
field = obj->getField(QString("AccelTime"));
|
||||||
|
field->setDouble(m_aircraft->accelTime->value());
|
||||||
|
field = obj->getField(QString("DecelTime"));
|
||||||
|
field->setDouble(m_aircraft->decelTime->value());
|
||||||
|
field = obj->getField(QString("MaxAccel"));
|
||||||
|
field->setDouble(m_aircraft->maxAccelSlider->value());
|
||||||
|
|
||||||
|
// Curve is also common to all quads:
|
||||||
|
field = obj->getField("ThrottleCurve1");
|
||||||
|
QList<double> curve = m_aircraft->multiThrottleCurve->getCurve();
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
||||||
|
airframeType = "QuadP";
|
||||||
|
setupQuad(true);
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Quad X") {
|
||||||
|
airframeType = "QuadX";
|
||||||
|
setupQuad(false);
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter") {
|
||||||
|
airframeType = "Hexa";
|
||||||
|
setupHexa(true);
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter X") {
|
||||||
|
airframeType = "HexaX";
|
||||||
|
setupHexa(false);
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter Y6") {
|
||||||
|
airframeType = "HexaCoax";
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(6);
|
||||||
|
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox5->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox6->currentText() == "None" ) {
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE"
|
||||||
|
<< "VTOLMotorS" << "VTOLMotorSE";
|
||||||
|
setupMotors(motorList);
|
||||||
|
|
||||||
|
// Motor 1 to 6, Y6 Layout:
|
||||||
|
// pitch roll yaw
|
||||||
|
double mixer [8][3] = {
|
||||||
|
{ 0.5, 1, -1},
|
||||||
|
{ 0.5, 1, 1},
|
||||||
|
{ 0.5, -1, -1},
|
||||||
|
{ 0.5, -1, 1},
|
||||||
|
{ -1, 0, -1},
|
||||||
|
{ -1, 0, 1},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0}
|
||||||
|
};
|
||||||
|
setupMultiRotorMixer(mixer);
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") {
|
||||||
|
airframeType = "Octo";
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(8);
|
||||||
|
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox5->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox6->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox7->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox8->currentText() == "None") {
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||||
|
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||||
|
setupMotors(motorList);
|
||||||
|
// Motor 1 to 8:
|
||||||
|
// pitch roll yaw
|
||||||
|
double mixer [8][3] = {
|
||||||
|
{ 1, 0, -1},
|
||||||
|
{ 1, -1, 1},
|
||||||
|
{ 0, -1, -1},
|
||||||
|
{ -1, -1, 1},
|
||||||
|
{ -1, 0, -1},
|
||||||
|
{ -1, 1, 1},
|
||||||
|
{ 0, 1, -1},
|
||||||
|
{ 1, 1, 1}
|
||||||
|
};
|
||||||
|
setupMultiRotorMixer(mixer);
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") {
|
||||||
|
airframeType = "OctoV";
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(8);
|
||||||
|
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox5->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox6->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox7->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox8->currentText() == "None") {
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||||
|
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||||
|
setupMotors(motorList);
|
||||||
|
// Motor 1 to 8:
|
||||||
|
// IMPORTANT: Assumes evenly spaced engines
|
||||||
|
// pitch roll yaw
|
||||||
|
double mixer [8][3] = {
|
||||||
|
{ 0.33, -1, -1},
|
||||||
|
{ 1 , -1, 1},
|
||||||
|
{ -1 , -1, -1},
|
||||||
|
{ -0.33, -1, 1},
|
||||||
|
{ -0.33, 1, -1},
|
||||||
|
{ -1 , 1, 1},
|
||||||
|
{ 1 , 1, -1},
|
||||||
|
{ 0.33, 1, 1}
|
||||||
|
};
|
||||||
|
setupMultiRotorMixer(mixer);
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") {
|
||||||
|
airframeType = "OctoCoaxP";
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(8);
|
||||||
|
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox5->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox6->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox7->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox8->currentText() == "None") {
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||||
|
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||||
|
setupMotors(motorList);
|
||||||
|
// Motor 1 to 8:
|
||||||
|
// pitch roll yaw
|
||||||
|
double mixer [8][3] = {
|
||||||
|
{ 1, 0, -1},
|
||||||
|
{ 1, 0, 1},
|
||||||
|
{ 0, -1, -1},
|
||||||
|
{ 0, -1, 1},
|
||||||
|
{ -1, 0, -1},
|
||||||
|
{ -1, 0, 1},
|
||||||
|
{ 0, 1, -1},
|
||||||
|
{ 0, 1, 1}
|
||||||
|
};
|
||||||
|
setupMultiRotorMixer(mixer);
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") {
|
||||||
|
airframeType = "OctoCoaxX";
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(8);
|
||||||
|
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox5->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox6->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox7->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox8->currentText() == "None") {
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE"
|
||||||
|
<< "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW";
|
||||||
|
setupMotors(motorList);
|
||||||
|
// Motor 1 to 8:
|
||||||
|
// pitch roll yaw
|
||||||
|
double mixer [8][3] = {
|
||||||
|
{ 1, 1, -1},
|
||||||
|
{ 1, 1, 1},
|
||||||
|
{ 1, -1, -1},
|
||||||
|
{ 1, -1, 1},
|
||||||
|
{ -1, -1, -1},
|
||||||
|
{ -1, -1, 1},
|
||||||
|
{ -1, 1, -1},
|
||||||
|
{ -1, 1, 1}
|
||||||
|
};
|
||||||
|
setupMultiRotorMixer(mixer);
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
|
||||||
|
} else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") {
|
||||||
|
airframeType = "Tri";
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(3);
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ) {
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
if (m_aircraft->triYawChannelBox->currentText() == "None") {
|
||||||
|
m_aircraft->mrStatusLabel->setText("<font color='red'>Error: Assign a Yaw channel</font>");
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
|
||||||
|
setupMotors(motorList);
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
field = obj->getField("FixedWingYaw1");
|
||||||
|
field->setValue(m_aircraft->triYawChannelBox->currentText());
|
||||||
|
|
||||||
|
// Motor 1 to 6, Y6 Layout:
|
||||||
|
// pitch roll yaw
|
||||||
|
double mixer [8][3] = {
|
||||||
|
{ 0.5, 1, 0},
|
||||||
|
{ 0.5, -1, 0},
|
||||||
|
{ -1, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0}
|
||||||
|
};
|
||||||
|
setupMultiRotorMixer(mixer);
|
||||||
|
|
||||||
|
int tmpVal = m_aircraft->triYawChannelBox->currentIndex()-1;
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
field = obj->getField(mixerTypes.at(tmpVal));
|
||||||
|
field->setValue("Servo");
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
resetField(field);
|
||||||
|
int ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(127,ti);
|
||||||
|
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
|
||||||
|
}
|
||||||
|
// Now reflect those settings in the "Custom" panel as well
|
||||||
|
updateCustomAirframeUI();
|
||||||
|
|
||||||
|
return airframeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function to refresh the UI widget values
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::refreshMultiRotorWidgetsValues(QString frameType)
|
||||||
|
{
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
// Retrieve settings
|
||||||
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
UAVObjectField *field;
|
||||||
|
|
||||||
|
if (frameType == "QuadP") {
|
||||||
|
// Motors 1/2/3/4 are: N / E / S / W
|
||||||
|
field = obj->getField(QString("VTOLMotorN"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorS"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = field->getDouble(i)/1.27;
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = (1-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = -field->getDouble(i)/1.27;
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
} else if (frameType == "QuadX") {
|
||||||
|
// Motors 1/2/3/4 are: NW / NE / SE / SW
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = field->getDouble(i)/1.27;
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = 1-field->getDouble(i)/1.27;
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = field->getDouble(i)/1.27;
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
} else if (frameType == "Hexa") {
|
||||||
|
// Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW
|
||||||
|
field = obj->getField(QString("VTOLMotorN"));
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSE"));
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorS"));
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSW"));
|
||||||
|
m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1;
|
||||||
|
if(tmpVal>-1)
|
||||||
|
{
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(1-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (frameType == "HexaX") {
|
||||||
|
// Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorE"));
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSE"));
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSW"));
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorW"));
|
||||||
|
m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(1-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
} else if (frameType == "HexaCoax") {
|
||||||
|
// Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorW"));
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorE"));
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorS"));
|
||||||
|
m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSE"));
|
||||||
|
m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(2*field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
} else if (frameType == "Octo" || frameType == "OctoV" ||
|
||||||
|
frameType == "OctoCoaxP") {
|
||||||
|
// Motors 1 to 8 are N / NE / E / etc
|
||||||
|
field = obj->getField(QString("VTOLMotorN"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorS"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox7->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox8->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
if (frameType == "Octo") {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
} else if (frameType == "OctoV") {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Yaw");
|
||||||
|
double val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
tmpVal = m_aircraft->multiMotorChannelBox2->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
i = field->getElementNames().indexOf("Pitch");
|
||||||
|
val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
|
||||||
|
} else if (frameType == "OctoCoaxP") {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
tmpVal = m_aircraft->multiMotorChannelBox3->currentIndex()-1;
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (frameType == "OctoCoaxX") {
|
||||||
|
// Motors 1 to 8 are N / NE / E / etc
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorN"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox4->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox5->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorS"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox6->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorSW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox7->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox8->setCurrentIndex(m_aircraft->multiMotorChannelBox4->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
||||||
|
// This assumes that all vectors are identical - if not, the user should use the
|
||||||
|
// "custom" setting.
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Yaw");
|
||||||
|
val = floor(-field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrYawMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
} else if (frameType == "Tri") {
|
||||||
|
// Motors 1 to 8 are N / NE / E / etc
|
||||||
|
field = obj->getField(QString("VTOLMotorNW"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox1->setCurrentIndex(m_aircraft->multiMotorChannelBox1->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorNE"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox2->setCurrentIndex(m_aircraft->multiMotorChannelBox2->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("VTOLMotorS"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->multiMotorChannelBox3->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
field = obj->getField(QString("FixedWingYaw1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
m_aircraft->triYawChannelBox->setCurrentIndex(m_aircraft->multiMotorChannelBox3->findText(field->getValue().toString()));
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
int tmpVal= m_aircraft->multiMotorChannelBox1->currentIndex()-1;
|
||||||
|
// tmpVal will be -1 if value is set to "None"
|
||||||
|
if (tmpVal > -1) {
|
||||||
|
field = obj->getField(mixerVectors.at(tmpVal));
|
||||||
|
int i = field->getElementNames().indexOf("Pitch");
|
||||||
|
double val = floor(2*field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrPitchMixLevel->setValue(val);
|
||||||
|
i = field->getElementNames().indexOf("Roll");
|
||||||
|
val = floor(field->getDouble(i)/1.27);
|
||||||
|
m_aircraft->mrRollMixLevel->setValue(val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function: setupQuadMotor
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::setupQuadMotor(int channel, double pitch, double roll, double yaw)
|
||||||
|
{
|
||||||
|
qDebug()<<QString("Setup quad motor channel=%0 pitch=%1 roll=%2 yaw=%3").arg(channel).arg(pitch).arg(roll).arg(yaw);
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
UAVObjectField *field = obj->getField(mixerTypes.at(channel));
|
||||||
|
field->setValue("Motor");
|
||||||
|
field = obj->getField(mixerVectors.at(channel));
|
||||||
|
// First of all reset the vector
|
||||||
|
resetField(field);
|
||||||
|
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(127, ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(roll*127,ti);
|
||||||
|
qDebug()<<"Set roll="<<roll*127;
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(pitch*127,ti);
|
||||||
|
qDebug()<<"Set pitch="<<pitch*127;
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(yaw*127,ti);
|
||||||
|
qDebug()<<"Set yaw="<<yaw*127;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper function: setup motors. Takes a list of channel names in input.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::setupMotors(QList<QString> motorList)
|
||||||
|
{
|
||||||
|
resetActuators();
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
UAVObjectField *field;
|
||||||
|
QList<QComboBox*> mmList;
|
||||||
|
mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
|
||||||
|
<< m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
|
||||||
|
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
|
||||||
|
foreach (QString motor, motorList) {
|
||||||
|
field = obj->getField(motor);
|
||||||
|
field->setValue(mmList.takeFirst()->currentText());
|
||||||
|
}
|
||||||
|
//obj->updated(); // Save...
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set up a Quad-X or Quad-P mixer
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupQuad(bool pLayout)
|
||||||
|
{
|
||||||
|
// Check coherence:
|
||||||
|
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(4);
|
||||||
|
|
||||||
|
// - Four engines have to be defined
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None") {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QList<QString> motorList;
|
||||||
|
if (pLayout) {
|
||||||
|
motorList << "VTOLMotorN" << "VTOLMotorE" << "VTOLMotorS"
|
||||||
|
<< "VTOLMotorW";
|
||||||
|
} else {
|
||||||
|
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorSE"
|
||||||
|
<< "VTOLMotorSW";
|
||||||
|
}
|
||||||
|
setupMotors(motorList);
|
||||||
|
|
||||||
|
// Now, setup the mixer:
|
||||||
|
// Motor 1 to 4, X Layout:
|
||||||
|
// pitch roll yaw
|
||||||
|
// {0.5 ,0.5 ,-0.5 //Front left motor (CW)
|
||||||
|
// {0.5 ,-0.5 ,0.5 //Front right motor(CCW)
|
||||||
|
// {-0.5 ,-0.5 ,-0.5 //rear right motor (CW)
|
||||||
|
// {-0.5 ,0.5 ,0.5 //Rear left motor (CCW)
|
||||||
|
double xMixer [8][3] = {
|
||||||
|
{ 1, 1, -1},
|
||||||
|
{ 1, -1, 1},
|
||||||
|
{-1, -1, -1},
|
||||||
|
{-1, 1, 1},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0}
|
||||||
|
};
|
||||||
|
//
|
||||||
|
// Motor 1 to 4, P Layout:
|
||||||
|
// pitch roll yaw
|
||||||
|
// {1 ,0 ,-0.5 //Front motor (CW)
|
||||||
|
// {0 ,-1 ,0.5 //Right motor(CCW)
|
||||||
|
// {-1 ,0 ,-0.5 //Rear motor (CW)
|
||||||
|
// {0 ,1 ,0.5 //Left motor (CCW)
|
||||||
|
double pMixer [8][3] = {
|
||||||
|
{ 1, 0, -1},
|
||||||
|
{ 0, -1, 1},
|
||||||
|
{-1, 0, -1},
|
||||||
|
{ 0, 1, 1},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (pLayout) {
|
||||||
|
setupMultiRotorMixer(pMixer);
|
||||||
|
} else {
|
||||||
|
setupMultiRotorMixer(xMixer);
|
||||||
|
}
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Set up a Hexa-X or Hexa-P mixer
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupHexa(bool pLayout)
|
||||||
|
{
|
||||||
|
// Check coherence:
|
||||||
|
//Show any config errors in GUI
|
||||||
|
throwMultiRotorChannelConfigError(6);
|
||||||
|
|
||||||
|
// - Four engines have to be defined
|
||||||
|
if (m_aircraft->multiMotorChannelBox1->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox2->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox3->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox4->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox5->currentText() == "None" ||
|
||||||
|
m_aircraft->multiMotorChannelBox6->currentText() == "None") {
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<QString> motorList;
|
||||||
|
if (pLayout) {
|
||||||
|
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorSE"
|
||||||
|
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorNW";
|
||||||
|
} else {
|
||||||
|
motorList << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
||||||
|
<< "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
||||||
|
}
|
||||||
|
setupMotors(motorList);
|
||||||
|
|
||||||
|
// and set only the relevant channels:
|
||||||
|
|
||||||
|
// Motor 1 to 6, P Layout:
|
||||||
|
// pitch roll yaw
|
||||||
|
// 1 { 0.3 , 0 ,-0.3 // N CW
|
||||||
|
// 2 { 0.3 ,-0.5 , 0.3 // NE CCW
|
||||||
|
// 3 {-0.3 ,-0.5 ,-0.3 // SE CW
|
||||||
|
// 4 {-0.3 , 0 , 0.3 // S CCW
|
||||||
|
// 5 {-0.3 , 0.5 ,-0.3 // SW CW
|
||||||
|
// 6 { 0.3 , 0.5 , 0.3 // NW CCW
|
||||||
|
|
||||||
|
double pMixer [8][3] = {
|
||||||
|
{ 1, 0, -1},
|
||||||
|
{ 1, -1, 1},
|
||||||
|
{-1, -1, -1},
|
||||||
|
{-1, 0, 1},
|
||||||
|
{-1, 1, -1},
|
||||||
|
{ 1, 1, 1},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
//
|
||||||
|
// Motor 1 to 6, X Layout:
|
||||||
|
// 1 [ 0.5, -0.3, -0.3 ] NE
|
||||||
|
// 2 [ 0 , -0.3, 0.3 ] E
|
||||||
|
// 3 [ -0.5, -0.3, -0.3 ] SE
|
||||||
|
// 4 [ -0.5, 0.3, 0.3 ] SW
|
||||||
|
// 5 [ 0 , 0.3, -0.3 ] W
|
||||||
|
// 6 [ 0.5, 0.3, 0.3 ] NW
|
||||||
|
double xMixer [8][3] = {
|
||||||
|
{ 1, -1, -1},
|
||||||
|
{ 0, -1, 1},
|
||||||
|
{ -1, -1, -1},
|
||||||
|
{ -1, 1, 1},
|
||||||
|
{ 0, 1, -1},
|
||||||
|
{ 1, 1, 1},
|
||||||
|
{ 0, 0, 0},
|
||||||
|
{ 0, 0, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
if (pLayout) {
|
||||||
|
setupMultiRotorMixer(pMixer);
|
||||||
|
} else {
|
||||||
|
setupMultiRotorMixer(xMixer);
|
||||||
|
}
|
||||||
|
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function sets up the multirotor mixer values.
|
||||||
|
*/
|
||||||
|
bool ConfigVehicleTypeWidget::setupMultiRotorMixer(double mixerFactors[8][3])
|
||||||
|
{
|
||||||
|
qDebug()<<"Mixer factors";
|
||||||
|
qDebug()<<mixerFactors[0][0]<<" "<<mixerFactors[0][1]<<" "<<mixerFactors[0][2];
|
||||||
|
qDebug()<<mixerFactors[1][0]<<" "<<mixerFactors[1][1]<<" "<<mixerFactors[1][2];
|
||||||
|
qDebug()<<mixerFactors[2][0]<<" "<<mixerFactors[2][1]<<" "<<mixerFactors[2][2];
|
||||||
|
qDebug()<<mixerFactors[3][0]<<" "<<mixerFactors[3][1]<<" "<<mixerFactors[3][2];
|
||||||
|
qDebug()<<mixerFactors[4][0]<<" "<<mixerFactors[4][1]<<" "<<mixerFactors[4][2];
|
||||||
|
qDebug()<<mixerFactors[5][0]<<" "<<mixerFactors[5][1]<<" "<<mixerFactors[5][2];
|
||||||
|
qDebug()<<mixerFactors[6][0]<<" "<<mixerFactors[6][1]<<" "<<mixerFactors[6][2];
|
||||||
|
qDebug()<<mixerFactors[7][0]<<" "<<mixerFactors[7][1]<<" "<<mixerFactors[7][2];
|
||||||
|
|
||||||
|
UAVObjectField *field;
|
||||||
|
QList<QComboBox*> mmList;
|
||||||
|
mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3
|
||||||
|
<< m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6
|
||||||
|
<< m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8;
|
||||||
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
// 1. Assign the servo/motor/none for each channel
|
||||||
|
// Disable all
|
||||||
|
foreach(QString mixer, mixerTypes) {
|
||||||
|
field = obj->getField(mixer);
|
||||||
|
Q_ASSERT(field);
|
||||||
|
field->setValue("Disabled");
|
||||||
|
}
|
||||||
|
// and enable only the relevant channels:
|
||||||
|
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;
|
||||||
|
double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100;
|
||||||
|
double yFactor = (double)m_aircraft->mrYawMixLevel->value()/100;
|
||||||
|
qDebug()<<QString("pFactor=%0 rFactor=%1 yFactor=%2").arg(pFactor).arg(rFactor).arg(yFactor);
|
||||||
|
for (int i=0 ; i<8; i++) {
|
||||||
|
if(mmList.at(i)->isEnabled())
|
||||||
|
{
|
||||||
|
int channel = mmList.at(i)->currentIndex()-1;
|
||||||
|
if (channel > -1)
|
||||||
|
setupQuadMotor(channel, mixerFactors[i][0]*pFactor,
|
||||||
|
rFactor*mixerFactors[i][1], yFactor*mixerFactors[i][2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// obj->updated();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function displays text and color formatting in order to help the user understand what channels have not yet been configured.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::throwMultiRotorChannelConfigError(int numMotors)
|
||||||
|
{
|
||||||
|
//Initialize configuration error flag
|
||||||
|
bool error=false;
|
||||||
|
|
||||||
|
//Iterate through all instances of multiMotorChannelBox
|
||||||
|
for (int i=0; i<numMotors; i++) {
|
||||||
|
//Fine widgets with text "multiMotorChannelBox.x", where x is an integer
|
||||||
|
QComboBox *combobox = qFindChild<QComboBox*>(this, "multiMotorChannelBox" + QString::number(i+1));
|
||||||
|
if (combobox){ //if QLabel exists
|
||||||
|
QLabel *label = qFindChild<QLabel*>(this, "MotorOutputLabel" + QString::number(i+1));
|
||||||
|
if (combobox->currentText() == "None") {
|
||||||
|
|
||||||
|
// label->setText("<font color='red'>" + label->text() + "</font>");
|
||||||
|
|
||||||
|
int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize);
|
||||||
|
QPixmap pixmap(size,size);
|
||||||
|
pixmap.fill(QColor("red"));
|
||||||
|
combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes
|
||||||
|
// combobox->setStyleSheet("QComboBox { color: red}");
|
||||||
|
error=true;
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes
|
||||||
|
// combobox->setStyleSheet("color: black;");
|
||||||
|
// QTextEdit* htmlText=new QTextEdit(label->text()); // htmlText is any QString with html tags.
|
||||||
|
// label->setText(htmlText->toPlainText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (error){
|
||||||
|
m_aircraft->mrStatusLabel->setText(QString("<font color='red'>ERROR: Assign all %1 motor channels</font>").arg(numMotors));
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,9 @@ DEFINES += CONFIG_LIBRARY
|
|||||||
QT += svg
|
QT += svg
|
||||||
include(config_dependencies.pri)
|
include(config_dependencies.pri)
|
||||||
INCLUDEPATH += ../../libs/eigen
|
INCLUDEPATH += ../../libs/eigen
|
||||||
|
|
||||||
OTHER_FILES += Config.pluginspec
|
OTHER_FILES += Config.pluginspec
|
||||||
|
|
||||||
HEADERS += configplugin.h \
|
HEADERS += configplugin.h \
|
||||||
configgadgetconfiguration.h \
|
configgadgetconfiguration.h \
|
||||||
configgadgetwidget.h \
|
configgadgetwidget.h \
|
||||||
@ -14,12 +16,12 @@ HEADERS += configplugin.h \
|
|||||||
fancytabwidget.h \
|
fancytabwidget.h \
|
||||||
configinputwidget.h \
|
configinputwidget.h \
|
||||||
configoutputwidget.h \
|
configoutputwidget.h \
|
||||||
configairframewidget.h \
|
configvehicletypewidget.h \
|
||||||
config_pro_hw_widget.h \
|
config_pro_hw_widget.h \
|
||||||
config_cc_hw_widget.h \
|
config_cc_hw_widget.h \
|
||||||
configahrswidget.h \
|
configahrswidget.h \
|
||||||
configccattitudewidget.h \
|
configccattitudewidget.h \
|
||||||
configccpmwidget.h \
|
cfg_vehicletypes/configccpmwidget.h \
|
||||||
configstabilizationwidget.h \
|
configstabilizationwidget.h \
|
||||||
assertions.h \
|
assertions.h \
|
||||||
calibration.h \
|
calibration.h \
|
||||||
@ -39,12 +41,11 @@ SOURCES += configplugin.cpp \
|
|||||||
fancytabwidget.cpp \
|
fancytabwidget.cpp \
|
||||||
configinputwidget.cpp \
|
configinputwidget.cpp \
|
||||||
configoutputwidget.cpp \
|
configoutputwidget.cpp \
|
||||||
configairframewidget.cpp \
|
configvehicletypewidget.cpp \
|
||||||
config_pro_hw_widget.cpp \
|
config_pro_hw_widget.cpp \
|
||||||
config_cc_hw_widget.cpp \
|
config_cc_hw_widget.cpp \
|
||||||
configahrswidget.cpp \
|
configahrswidget.cpp \
|
||||||
configccattitudewidget.cpp \
|
configccattitudewidget.cpp \
|
||||||
configccpmwidget.cpp \
|
|
||||||
configstabilizationwidget.cpp \
|
configstabilizationwidget.cpp \
|
||||||
twostep.cpp \
|
twostep.cpp \
|
||||||
legacy-calibration.cpp \
|
legacy-calibration.cpp \
|
||||||
@ -55,6 +56,10 @@ SOURCES += configplugin.cpp \
|
|||||||
inputchannelform.cpp \
|
inputchannelform.cpp \
|
||||||
configcamerastabilizationwidget.cpp \
|
configcamerastabilizationwidget.cpp \
|
||||||
configtxpidwidget.cpp \
|
configtxpidwidget.cpp \
|
||||||
|
cfg_vehicletypes/configmultirotorwidget.cpp \
|
||||||
|
cfg_vehicletypes/configgroundvehiclewidget.cpp \
|
||||||
|
cfg_vehicletypes/configfixedwingwidget.cpp \
|
||||||
|
cfg_vehicletypes/configccpmwidget.cpp \
|
||||||
outputchannelform.cpp
|
outputchannelform.cpp
|
||||||
FORMS += airframe.ui \
|
FORMS += airframe.ui \
|
||||||
cc_hw_settings.ui \
|
cc_hw_settings.ui \
|
||||||
|
@ -1,2221 +0,0 @@
|
|||||||
/**
|
|
||||||
******************************************************************************
|
|
||||||
*
|
|
||||||
* @file configairframewidget.cpp
|
|
||||||
* @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
|
||||||
* @{
|
|
||||||
* @addtogroup ConfigPlugin Config Plugin
|
|
||||||
* @{
|
|
||||||
* @brief Airframe configuration panel
|
|
||||||
*****************************************************************************/
|
|
||||||
/*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but
|
|
||||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
||||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
||||||
* for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along
|
|
||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
||||||
*/
|
|
||||||
#include "configairframewidget.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QtGui/QWidget>
|
|
||||||
#include <QtGui/QTextEdit>
|
|
||||||
#include <QtGui/QVBoxLayout>
|
|
||||||
#include <QtGui/QPushButton>
|
|
||||||
#include <math.h>
|
|
||||||
#include <QDesktopServices>
|
|
||||||
#include <QUrl>
|
|
||||||
#include "systemsettings.h"
|
|
||||||
#include "mixersettings.h"
|
|
||||||
#include "actuatorsettings.h"
|
|
||||||
#include <QEventLoop>
|
|
||||||
|
|
||||||
/**
|
|
||||||
Helper delegate for the custom mixer editor table.
|
|
||||||
Taken straight from Qt examples, thanks!
|
|
||||||
*/
|
|
||||||
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
|
|
||||||
: QItemDelegate(parent)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
|
|
||||||
const QStyleOptionViewItem &/* option */,
|
|
||||||
const QModelIndex &/* index */) const
|
|
||||||
{
|
|
||||||
QSpinBox *editor = new QSpinBox(parent);
|
|
||||||
editor->setMinimum(-127);
|
|
||||||
editor->setMaximum(127);
|
|
||||||
|
|
||||||
return editor;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpinBoxDelegate::setEditorData(QWidget *editor,
|
|
||||||
const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
int value = index.model()->data(index, Qt::EditRole).toInt();
|
|
||||||
|
|
||||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
|
||||||
spinBox->setValue(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
|
||||||
const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
|
||||||
spinBox->interpretText();
|
|
||||||
int value = spinBox->value();
|
|
||||||
|
|
||||||
model->setData(index, value, Qt::EditRole);
|
|
||||||
}
|
|
||||||
|
|
||||||
void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
|
|
||||||
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
|
|
||||||
{
|
|
||||||
editor->setGeometry(option.rect);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ConfigAirframeWidget::ConfigAirframeWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
|
||||||
{
|
|
||||||
m_aircraft = new Ui_AircraftWidget();
|
|
||||||
m_aircraft->setupUi(this);
|
|
||||||
|
|
||||||
addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD);
|
|
||||||
|
|
||||||
addUAVObject("SystemSettings");
|
|
||||||
addUAVObject("MixerSettings");
|
|
||||||
addUAVObject("ActuatorSettings");
|
|
||||||
|
|
||||||
|
|
||||||
ffTuningInProgress = false;
|
|
||||||
ffTuningPhase = false;
|
|
||||||
|
|
||||||
QStringList channels;
|
|
||||||
channels << "None";
|
|
||||||
for (int i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
|
|
||||||
mixerTypes << QString("Mixer%1Type").arg(i+1);
|
|
||||||
mixerVectors << QString("Mixer%1Vector").arg(i+1);
|
|
||||||
channels << QString("Channel%1").arg(i+1);
|
|
||||||
}
|
|
||||||
|
|
||||||
QStringList airframeTypes;
|
|
||||||
airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Custom";
|
|
||||||
m_aircraft->aircraftType->addItems(airframeTypes);
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(1);
|
|
||||||
|
|
||||||
QStringList fixedWingTypes;
|
|
||||||
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
|
||||||
m_aircraft->fixedWingType->addItems(fixedWingTypes);
|
|
||||||
|
|
||||||
QStringList multiRotorTypes;
|
|
||||||
multiRotorTypes << "Quad +" << "Quad X" << "Hexacopter" << "Octocopter" << "Hexacopter X" << "Octocopter V" << "Octo Coax +"
|
|
||||||
<< "Octo Coax X" << "Hexacopter Y6" << "Tricopter Y";
|
|
||||||
m_aircraft->multirotorFrameType->addItems(multiRotorTypes);
|
|
||||||
|
|
||||||
// Now load all the channel assignements for fixed wing
|
|
||||||
m_aircraft->fwElevator1Channel->addItems(channels);
|
|
||||||
m_aircraft->fwElevator2Channel->addItems(channels);
|
|
||||||
m_aircraft->fwEngineChannel->addItems(channels);
|
|
||||||
m_aircraft->fwRudder1Channel->addItems(channels);
|
|
||||||
m_aircraft->fwRudder2Channel->addItems(channels);
|
|
||||||
m_aircraft->fwAileron1Channel->addItems(channels);
|
|
||||||
m_aircraft->fwAileron2Channel->addItems(channels);
|
|
||||||
m_aircraft->multiMotor1->addItems(channels);
|
|
||||||
m_aircraft->multiMotor2->addItems(channels);
|
|
||||||
m_aircraft->multiMotor3->addItems(channels);
|
|
||||||
m_aircraft->multiMotor4->addItems(channels);
|
|
||||||
m_aircraft->multiMotor5->addItems(channels);
|
|
||||||
m_aircraft->multiMotor6->addItems(channels);
|
|
||||||
m_aircraft->multiMotor7->addItems(channels);
|
|
||||||
m_aircraft->multiMotor8->addItems(channels);
|
|
||||||
m_aircraft->triYawChannel->addItems(channels);
|
|
||||||
|
|
||||||
// Setup the Multirotor picture in the Quad settings interface
|
|
||||||
m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
||||||
QSvgRenderer *renderer = new QSvgRenderer();
|
|
||||||
renderer->load(QString(":/configgadget/images/quad-shapes.svg"));
|
|
||||||
quad = new QGraphicsSvgItem();
|
|
||||||
quad->setSharedRenderer(renderer);
|
|
||||||
quad->setElementId("quad-plus");
|
|
||||||
QGraphicsScene *scene = new QGraphicsScene(this);
|
|
||||||
scene->addItem(quad);
|
|
||||||
scene->setSceneRect(quad->boundingRect());
|
|
||||||
m_aircraft->quadShape->setScene(scene);
|
|
||||||
|
|
||||||
// Put combo boxes in line one of the custom mixer table:
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("Mixer1Type"));
|
|
||||||
QStringList list = field->getOptions();
|
|
||||||
for (int i=0;i<8;i++) {
|
|
||||||
QComboBox* qb = new QComboBox(m_aircraft->customMixerTable);
|
|
||||||
qb->addItems(list);
|
|
||||||
m_aircraft->customMixerTable->setCellWidget(0,i,qb);
|
|
||||||
}
|
|
||||||
|
|
||||||
SpinBoxDelegate *sbd = new SpinBoxDelegate();
|
|
||||||
for (int i=1;i<8; i++) {
|
|
||||||
m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
|
||||||
connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
|
||||||
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
|
|
||||||
|
|
||||||
connect(m_aircraft->fwThrottleReset, SIGNAL(clicked()), this, SLOT(resetFwMixer()));
|
|
||||||
connect(m_aircraft->mrThrottleCurveReset, SIGNAL(clicked()), this, SLOT(resetMrMixer()));
|
|
||||||
connect(m_aircraft->customReset1, SIGNAL(clicked()), this, SLOT(resetCt1Mixer()));
|
|
||||||
connect(m_aircraft->customReset2, SIGNAL(clicked()), this, SLOT(resetCt2Mixer()));
|
|
||||||
connect(m_aircraft->fixedWingThrottle, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateFwThrottleCurveValue(QList<double>,double)));
|
|
||||||
connect(m_aircraft->multiThrottleCurve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateMrThrottleCurveValue(QList<double>,double)));
|
|
||||||
connect(m_aircraft->customThrottle1Curve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateCustomThrottle1CurveValue(QList<double>,double)));
|
|
||||||
connect(m_aircraft->customThrottle2Curve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateCustomThrottle2CurveValue(QList<double>,double)));
|
|
||||||
|
|
||||||
// connect(m_aircraft->fwAileron1Channel, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleAileron2(int)));
|
|
||||||
// connect(m_aircraft->fwElevator1Channel, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleElevator2(int)));
|
|
||||||
|
|
||||||
// Now connect the three feed forward test checkboxes
|
|
||||||
connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
|
||||||
connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
|
||||||
connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
|
||||||
|
|
||||||
enableControls(false);
|
|
||||||
refreshWidgetsValues();
|
|
||||||
|
|
||||||
|
|
||||||
// Connect the help button
|
|
||||||
connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
|
||||||
addToDirtyMonitor();
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigAirframeWidget::~ConfigAirframeWidget()
|
|
||||||
{
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Slot for switching the airframe type. We do it explicitely
|
|
||||||
rather than a signal in the UI, because we want to force a fitInView of the quad shapes.
|
|
||||||
This is because this method (fitinview) only works when the widget is shown.
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::switchAirframeType(int index){
|
|
||||||
m_aircraft->airframesWidget->setCurrentIndex(index);
|
|
||||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
|
||||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
|
||||||
if (m_aircraft->aircraftType->findText("Custom")) {
|
|
||||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
|
||||||
for (int i=0;i<8;i++) {
|
|
||||||
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
|
||||||
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::showEvent(QShowEvent *event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(event)
|
|
||||||
// Thit fitInView method should only be called now, once the
|
|
||||||
// widget is shown, otherwise it cannot compute its values and
|
|
||||||
// the result is usually a ahrsbargraph that is way too small.
|
|
||||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
|
||||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
|
||||||
for (int i=0;i<8;i++) {
|
|
||||||
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
|
||||||
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::resizeEvent(QResizeEvent* event)
|
|
||||||
{
|
|
||||||
Q_UNUSED(event);
|
|
||||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
|
||||||
// Make the custom table columns autostretch:
|
|
||||||
m_aircraft->customMixerTable->resizeColumnsToContents();
|
|
||||||
for (int i=0;i<8;i++) {
|
|
||||||
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
|
||||||
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::toggleAileron2(int index)
|
|
||||||
{
|
|
||||||
if (index) {
|
|
||||||
m_aircraft->fwAileron2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwAileron2Label->setEnabled(true);
|
|
||||||
} else {
|
|
||||||
m_aircraft->fwAileron2Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwAileron2Label->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::toggleElevator2(int index)
|
|
||||||
{
|
|
||||||
if (index) {
|
|
||||||
m_aircraft->fwElevator2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator2Label->setEnabled(true);
|
|
||||||
} else {
|
|
||||||
m_aircraft->fwElevator2Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwElevator2Label->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::toggleRudder2(int index)
|
|
||||||
{
|
|
||||||
if (index) {
|
|
||||||
m_aircraft->fwRudder2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder2Label->setEnabled(true);
|
|
||||||
} else {
|
|
||||||
m_aircraft->fwRudder2Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwRudder2Label->setEnabled(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////
|
|
||||||
/// Feed Forward Testing
|
|
||||||
/////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
/**
|
|
||||||
Enables and runs feed forward testing
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::enableFFTest()
|
|
||||||
{
|
|
||||||
// Role:
|
|
||||||
// - Check if all three checkboxes are checked
|
|
||||||
// - Every other timer event: toggle engine from 45% to 55%
|
|
||||||
// - Every other time event: send FF settings to flight FW
|
|
||||||
if (m_aircraft->ffTestBox1->isChecked() &&
|
|
||||||
m_aircraft->ffTestBox2->isChecked() &&
|
|
||||||
m_aircraft->ffTestBox3->isChecked()) {
|
|
||||||
if (!ffTuningInProgress)
|
|
||||||
{
|
|
||||||
// Initiate tuning:
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
|
||||||
UAVObject::Metadata mdata = obj->getMetadata();
|
|
||||||
accInitialData = mdata;
|
|
||||||
mdata.flightAccess = UAVObject::ACCESS_READONLY;
|
|
||||||
obj->setMetadata(mdata);
|
|
||||||
}
|
|
||||||
// Depending on phase, either move actuator or send FF settings:
|
|
||||||
if (ffTuningPhase) {
|
|
||||||
// Send FF settings to the board
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
|
||||||
field->setDouble((double)m_aircraft->feedForwardSlider->value()/100);
|
|
||||||
field = obj->getField(QString("AccelTime"));
|
|
||||||
field->setDouble(m_aircraft->accelTime->value());
|
|
||||||
field = obj->getField(QString("DecelTime"));
|
|
||||||
field->setDouble(m_aircraft->decelTime->value());
|
|
||||||
field = obj->getField(QString("MaxAccel"));
|
|
||||||
field->setDouble(m_aircraft->maxAccelSlider->value());
|
|
||||||
obj->updated();
|
|
||||||
} else {
|
|
||||||
// Toggle motor state
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
|
||||||
double value = obj->getField("Throttle")->getDouble();
|
|
||||||
double target = (value < 0.5) ? 0.55 : 0.45;
|
|
||||||
obj->getField("Throttle")->setValue(target);
|
|
||||||
obj->updated();
|
|
||||||
}
|
|
||||||
ffTuningPhase = !ffTuningPhase;
|
|
||||||
ffTuningInProgress = true;
|
|
||||||
QTimer::singleShot(1000, this, SLOT(enableFFTest()));
|
|
||||||
} else {
|
|
||||||
// - If no: disarm timer, restore actuatorcommand metadata
|
|
||||||
// Disarm!
|
|
||||||
if (ffTuningInProgress) {
|
|
||||||
ffTuningInProgress = false;
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
|
||||||
UAVObject::Metadata mdata = obj->getMetadata();
|
|
||||||
mdata = accInitialData; // Restore metadata
|
|
||||||
obj->setMetadata(mdata);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Resets Fixed wing throttle mixer
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetFwMixer()
|
|
||||||
{
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
|
||||||
resetMixer(m_aircraft->fixedWingThrottle, field->getNumElements(),1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Resets Multirotor throttle mixer
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetMrMixer()
|
|
||||||
{
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
|
||||||
resetMixer(m_aircraft->multiThrottleCurve, field->getNumElements(),0.9);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Resets Custom throttle 1 mixer
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetCt1Mixer()
|
|
||||||
{
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
|
||||||
resetMixer(m_aircraft->customThrottle1Curve, field->getNumElements(),1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Resets Custom throttle 2 mixer
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetCt2Mixer()
|
|
||||||
{
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve2"));
|
|
||||||
resetMixer(m_aircraft->customThrottle2Curve, field->getNumElements(),1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Resets a mixer curve
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetMixer(MixerCurveWidget *mixer, int numElements, double maxvalue)
|
|
||||||
{
|
|
||||||
// Setup all Throttle1 curves for all types of airframes
|
|
||||||
mixer->initLinearCurve((quint32)numElements,maxvalue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Updates the currently moved throttle curve item value
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::updateFwThrottleCurveValue(QList<double> list, double value)
|
|
||||||
{
|
|
||||||
Q_UNUSED(list);
|
|
||||||
m_aircraft->fwThrottleCurveItemValue->setText(QString().sprintf("Val: %.2f",value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Updates the currently moved throttle curve item value
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::updateMrThrottleCurveValue(QList<double> list, double value)
|
|
||||||
{
|
|
||||||
Q_UNUSED(list);
|
|
||||||
m_aircraft->mrThrottleCurveItemValue->setText(QString().sprintf("Val: %.2f",value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Updates the currently moved throttle curve item value (Custom throttle 1)
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::updateCustomThrottle1CurveValue(QList<double> list, double value)
|
|
||||||
{
|
|
||||||
Q_UNUSED(list);
|
|
||||||
m_aircraft->customThrottleCurve1Value->setText(QString().sprintf("Val: %.2f",value));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Updates the currently moved throttle curve item value (Custom throttle 2)
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::updateCustomThrottle2CurveValue(QList<double> list, double value)
|
|
||||||
{
|
|
||||||
Q_UNUSED(list);
|
|
||||||
m_aircraft->customThrottleCurve2Value->setText(QString().sprintf("Val: %.2f",value));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**************************
|
|
||||||
* Aircraft settings
|
|
||||||
**************************/
|
|
||||||
/**
|
|
||||||
Refreshes the current value of the SystemSettings which holds the aircraft type
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::refreshWidgetsValues()
|
|
||||||
{
|
|
||||||
if(!allObjectsUpdated())
|
|
||||||
return;
|
|
||||||
bool dirty=isDirty();
|
|
||||||
// Get the Airframe type from the system settings:
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
UAVObjectField *field = obj->getField(QString("AirframeType"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
// At this stage, we will need to have some hardcoded settings in this code, this
|
|
||||||
// is not ideal, but here you go.
|
|
||||||
QString frameType = field->getValue().toString();
|
|
||||||
setupAirframeUI(frameType);
|
|
||||||
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
field = obj->getField(QString("ThrottleCurve1"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
QList<double> curveValues;
|
|
||||||
// If the 1st element of the curve is <= -10, then the curve
|
|
||||||
// is a straight line (that's how the mixer works on the mainboard):
|
|
||||||
if (field->getValue(0).toInt() <= -10) {
|
|
||||||
m_aircraft->multiThrottleCurve->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
m_aircraft->fixedWingThrottle->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
double temp=0;
|
|
||||||
double value;
|
|
||||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
|
||||||
value=field->getValue(i).toDouble();
|
|
||||||
temp+=value;
|
|
||||||
curveValues.append(value);
|
|
||||||
}
|
|
||||||
if(temp==0)
|
|
||||||
{
|
|
||||||
m_aircraft->multiThrottleCurve->initLinearCurve(field->getNumElements(),0.9);;
|
|
||||||
m_aircraft->fixedWingThrottle->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_aircraft->multiThrottleCurve->initCurve(curveValues);
|
|
||||||
m_aircraft->fixedWingThrottle->initCurve(curveValues);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Setup all Throttle1 curves for all types of airframes
|
|
||||||
// Load the Settings for fixed wing frames:
|
|
||||||
if (frameType.startsWith("FixedWing")) {
|
|
||||||
// Then retrieve how channels are setup
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
field = obj->getField(QString("FixedWingThrottle"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwEngineChannel->setCurrentIndex(m_aircraft->fwEngineChannel->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingRoll1"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwAileron1Channel->setCurrentIndex(m_aircraft->fwAileron1Channel->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingRoll2"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwAileron2Channel->setCurrentIndex(m_aircraft->fwAileron2Channel->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingPitch1"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwElevator1Channel->setCurrentIndex(m_aircraft->fwElevator1Channel->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingPitch2"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwElevator2Channel->setCurrentIndex(m_aircraft->fwElevator2Channel->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingYaw1"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwRudder1Channel->setCurrentIndex(m_aircraft->fwRudder1Channel->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingYaw2"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->fwRudder2Channel->setCurrentIndex(m_aircraft->fwRudder2Channel->findText(field->getValue().toString()));
|
|
||||||
|
|
||||||
if (frameType == "FixedWingElevon") {
|
|
||||||
// If the airframe is elevon, restore the slider setting
|
|
||||||
// Find the channel number for Elevon1 (FixedWingRoll1)
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
int chMixerNumber = m_aircraft->fwAileron1Channel->currentIndex()-1;
|
|
||||||
if (chMixerNumber >= 0) { // If for some reason the actuators were incoherent, we might fail here, hence the check.
|
|
||||||
field = obj->getField(mixerVectors.at(chMixerNumber));
|
|
||||||
int ti = field->getElementNames().indexOf("Roll");
|
|
||||||
m_aircraft->elevonSlider1->setValue(field->getDouble(ti)*100);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
m_aircraft->elevonSlider2->setValue(field->getDouble(ti)*100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (frameType == "FixedWingVtail") {
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
int chMixerNumber = m_aircraft->fwElevator1Channel->currentIndex()-1;
|
|
||||||
if (chMixerNumber >=0) {
|
|
||||||
field = obj->getField(mixerVectors.at(chMixerNumber));
|
|
||||||
int ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
m_aircraft->elevonSlider1->setValue(field->getDouble(ti)*100);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
m_aircraft->elevonSlider2->setValue(field->getDouble(ti)*100);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (frameType == "QuadX" || frameType == "QuadP" ||
|
|
||||||
frameType == "Hexa" || frameType == "Octo" ||
|
|
||||||
frameType == "HexaCoax" || frameType == "OctoV" ||
|
|
||||||
frameType == "HexaX" || frameType == "OctoCoaxP" ||
|
|
||||||
frameType == "OctoCoaxX" || frameType == "Tri") {
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
// Retrieve Multirotor settings
|
|
||||||
//////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
if (frameType == "QuadP") {
|
|
||||||
// Motors 1/2/3/4 are: N / E / S / W
|
|
||||||
field = obj->getField(QString("VTOLMotorN"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorS"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = field->getDouble(i)/1.27;
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = (1-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
eng = m_aircraft->multiMotor2->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = -field->getDouble(i)/1.27;
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
} else if (frameType == "QuadX") {
|
|
||||||
// Motors 1/2/3/4 are: NW / NE / SE / SW
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = field->getDouble(i)/1.27;
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = 1-field->getDouble(i)/1.27;
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = field->getDouble(i)/1.27;
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
} else if (frameType == "Hexa") {
|
|
||||||
// Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW
|
|
||||||
field = obj->getField(QString("VTOLMotorN"));
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSE"));
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorS"));
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSW"));
|
|
||||||
m_aircraft->multiMotor5->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
m_aircraft->multiMotor6->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
eng = m_aircraft->multiMotor2->currentIndex()-1;
|
|
||||||
if(eng>-1)
|
|
||||||
{
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(1-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (frameType == "HexaX") {
|
|
||||||
// Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorE"));
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSE"));
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSW"));
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorW"));
|
|
||||||
m_aircraft->multiMotor5->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
m_aircraft->multiMotor6->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
eng = m_aircraft->multiMotor2->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(1-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
} else if (frameType == "HexaCoax") {
|
|
||||||
// Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorW"));
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorE"));
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorS"));
|
|
||||||
m_aircraft->multiMotor5->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSE"));
|
|
||||||
m_aircraft->multiMotor6->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(2*field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
} else if (frameType == "Octo" || frameType == "OctoV" ||
|
|
||||||
frameType == "OctoCoaxP") {
|
|
||||||
// Motors 1 to 8 are N / NE / E / etc
|
|
||||||
field = obj->getField(QString("VTOLMotorN"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorS"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor5->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor6->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor7->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor8->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
if (frameType == "Octo") {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
eng = m_aircraft->multiMotor2->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
} else if (frameType == "OctoV") {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Yaw");
|
|
||||||
double val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
eng = m_aircraft->multiMotor2->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
i = field->getElementNames().indexOf("Pitch");
|
|
||||||
val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
|
|
||||||
} else if (frameType == "OctoCoaxP") {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
eng = m_aircraft->multiMotor3->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (frameType == "OctoCoaxX") {
|
|
||||||
// Motors 1 to 8 are N / NE / E / etc
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorN"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor4->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor5->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorS"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor6->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorSW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor7->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor8->setCurrentIndex(m_aircraft->multiMotor4->findText(field->getValue().toString()));
|
|
||||||
// Now, read the 1st mixer R/P/Y levels and initialize the mix sliders.
|
|
||||||
// This assumes that all vectors are identical - if not, the user should use the
|
|
||||||
// "custom" setting.
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Yaw");
|
|
||||||
val = floor(-field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
} else if (frameType == "Tri") {
|
|
||||||
// Motors 1 to 8 are N / NE / E / etc
|
|
||||||
field = obj->getField(QString("VTOLMotorNW"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor1->setCurrentIndex(m_aircraft->multiMotor1->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorNE"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor2->setCurrentIndex(m_aircraft->multiMotor2->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("VTOLMotorS"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->multiMotor3->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
field = obj->getField(QString("FixedWingYaw1"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->triYawChannel->setCurrentIndex(m_aircraft->multiMotor3->findText(field->getValue().toString()));
|
|
||||||
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
int eng= m_aircraft->multiMotor1->currentIndex()-1;
|
|
||||||
// eng will be -1 if value is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
int i = field->getElementNames().indexOf("Pitch");
|
|
||||||
double val = floor(2*field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(val);
|
|
||||||
i = field->getElementNames().indexOf("Roll");
|
|
||||||
val = floor(field->getDouble(i)/1.27);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(val);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
// Now, retrieve the Feedforward values:
|
|
||||||
field = obj->getField(QString("FeedForward"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->feedForwardSlider->setValue(field->getDouble()*100);
|
|
||||||
field = obj->getField(QString("AccelTime"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->accelTime->setValue(field->getDouble());
|
|
||||||
field = obj->getField(QString("DecelTime"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->decelTime->setValue(field->getDouble());
|
|
||||||
field = obj->getField(QString("MaxAccel"));
|
|
||||||
Q_ASSERT(field);
|
|
||||||
m_aircraft->maxAccelSlider->setValue(field->getDouble());
|
|
||||||
|
|
||||||
} else if (frameType == "HeliCP") {
|
|
||||||
m_aircraft->widget_3->requestccpmUpdate();
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Helicopter"));//"Helicopter"
|
|
||||||
} else if (frameType == "Custom") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Custom"));
|
|
||||||
}
|
|
||||||
|
|
||||||
updateCustomAirframeUI();
|
|
||||||
setDirty(dirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
\brief Sets up the mixer depending on Airframe type. Accepts either system settings or
|
|
||||||
combo box entry from airframe type, as those do not overlap.
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::setupAirframeUI(QString frameType)
|
|
||||||
{
|
|
||||||
bool dirty=isDirty();
|
|
||||||
if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") {
|
|
||||||
// Setup the UI
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
|
||||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder"));
|
|
||||||
m_aircraft->fwRudder1Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder1Label->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder2Label->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator1Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator1Label->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator2Label->setEnabled(true);
|
|
||||||
m_aircraft->fwAileron1Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwAileron1Label->setEnabled(true);
|
|
||||||
m_aircraft->fwAileron2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwAileron2Label->setEnabled(true);
|
|
||||||
|
|
||||||
m_aircraft->fwAileron1Label->setText("Aileron 1");
|
|
||||||
m_aircraft->fwAileron2Label->setText("Aileron 2");
|
|
||||||
m_aircraft->fwElevator1Label->setText("Elevator 1");
|
|
||||||
m_aircraft->fwElevator2Label->setText("Elevator 2");
|
|
||||||
m_aircraft->elevonMixBox->setHidden(true);
|
|
||||||
|
|
||||||
} else if (frameType == "FixedWingElevon" || frameType == "Elevon") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
|
||||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevon"));
|
|
||||||
m_aircraft->fwAileron1Label->setText("Elevon 1");
|
|
||||||
m_aircraft->fwAileron2Label->setText("Elevon 2");
|
|
||||||
m_aircraft->fwElevator1Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwElevator1Label->setEnabled(false);
|
|
||||||
m_aircraft->fwElevator2Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwElevator2Label->setEnabled(false);
|
|
||||||
m_aircraft->fwRudder1Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder1Label->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwRudder2Label->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator1Label->setText("Elevator 1");
|
|
||||||
m_aircraft->fwElevator2Label->setText("Elevator 2");
|
|
||||||
m_aircraft->elevonMixBox->setHidden(false);
|
|
||||||
m_aircraft->elevonLabel1->setText("Roll");
|
|
||||||
m_aircraft->elevonLabel2->setText("Pitch");
|
|
||||||
|
|
||||||
} else if (frameType == "FixedWingVtail" || frameType == "Vtail") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Fixed Wing"));
|
|
||||||
m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Vtail"));
|
|
||||||
m_aircraft->fwRudder1Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwRudder1Label->setEnabled(false);
|
|
||||||
m_aircraft->fwRudder2Channel->setEnabled(false);
|
|
||||||
m_aircraft->fwRudder2Label->setEnabled(false);
|
|
||||||
m_aircraft->fwElevator1Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator1Label->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator1Label->setText("Vtail 1");
|
|
||||||
m_aircraft->fwElevator2Label->setText("Vtail 2");
|
|
||||||
m_aircraft->elevonMixBox->setHidden(false);
|
|
||||||
m_aircraft->fwElevator2Channel->setEnabled(true);
|
|
||||||
m_aircraft->fwElevator2Label->setEnabled(true);
|
|
||||||
m_aircraft->fwAileron1Label->setText("Aileron 1");
|
|
||||||
m_aircraft->fwAileron2Label->setText("Aileron 2");
|
|
||||||
m_aircraft->elevonLabel1->setText("Rudder");
|
|
||||||
m_aircraft->elevonLabel2->setText("Pitch");
|
|
||||||
|
|
||||||
} else if (frameType == "QuadX" || frameType == "Quad X") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X"));
|
|
||||||
quad->setElementId("quad-X");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(false);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(50);
|
|
||||||
} else if (frameType == "QuadP" || frameType == "Quad +") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad +"));
|
|
||||||
quad->setElementId("quad-plus");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(false);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(100);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(50);
|
|
||||||
} else if (frameType == "Hexa" || frameType == "Hexacopter") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter"));
|
|
||||||
quad->setElementId("quad-hexa");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(false);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(33);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(33);
|
|
||||||
} else if (frameType == "Octo" || frameType == "Octocopter") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter"));
|
|
||||||
quad->setElementId("quad-octo");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(true);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(33);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(33);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(25);
|
|
||||||
} else if (frameType == "HexaX" || frameType == "Hexacopter X" ) {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter X"));
|
|
||||||
quad->setElementId("quad-hexa-H");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(false);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(33);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(33);
|
|
||||||
|
|
||||||
} else if (frameType == "OctoV" || frameType == "Octocopter V") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octocopter V"));
|
|
||||||
quad->setElementId("quad-octo-v");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(true);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(25);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(25);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(25);
|
|
||||||
|
|
||||||
} else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax +"));
|
|
||||||
quad->setElementId("octo-coax-P");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(true);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(100);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(100);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(50);
|
|
||||||
|
|
||||||
} else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Octo Coax X"));
|
|
||||||
quad->setElementId("octo-coax-X");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(true);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(50);
|
|
||||||
|
|
||||||
} else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Hexacopter Y6"));
|
|
||||||
quad->setElementId("hexa-coax");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(true);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(false);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(false);
|
|
||||||
m_aircraft->mrRollMixLevel->setValue(100);
|
|
||||||
m_aircraft->mrPitchMixLevel->setValue(50);
|
|
||||||
m_aircraft->mrYawMixLevel->setValue(66);
|
|
||||||
|
|
||||||
} else if (frameType == "Tri" || frameType == "Tricopter Y") {
|
|
||||||
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Multirotor"));
|
|
||||||
m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Tricopter Y"));
|
|
||||||
quad->setElementId("tri");
|
|
||||||
m_aircraft->multiMotor4->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor5->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor6->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor7->setEnabled(false);
|
|
||||||
m_aircraft->multiMotor8->setEnabled(false);
|
|
||||||
m_aircraft->triYawChannel->setEnabled(true);
|
|
||||||
|
|
||||||
}
|
|
||||||
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
|
||||||
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
|
||||||
setDirty(dirty);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Reset the contents of a field
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetField(UAVObjectField * field)
|
|
||||||
{
|
|
||||||
for (unsigned int i=0;i<field->getNumElements();i++) {
|
|
||||||
field->setValue(0,i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Reset actuator values
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::resetActuators()
|
|
||||||
{
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
QList<UAVObjectField*> fieldList = obj->getFields();
|
|
||||||
// Reset all assignements first:
|
|
||||||
foreach (UAVObjectField* field, fieldList) {
|
|
||||||
// NOTE: we assume that all options in ActuatorSettings are a channel assignement
|
|
||||||
// except for the options called "ChannelXXX"
|
|
||||||
if (field->getUnits().contains("channel")) {
|
|
||||||
field->setValue(field->getOptions().last());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Setup Elevator/Aileron/Rudder airframe.
|
|
||||||
|
|
||||||
If both Aileron channels are set to 'None' (EasyStar), do Pitch/Rudder mixing
|
|
||||||
|
|
||||||
Returns False if impossible to create the mixer.
|
|
||||||
*/
|
|
||||||
bool ConfigAirframeWidget::setupFrameFixedWing()
|
|
||||||
{
|
|
||||||
// Check coherence:
|
|
||||||
// - At least Pitch and either Roll or Yaw
|
|
||||||
if (m_aircraft->fwEngineChannel->currentText() == "None" ||
|
|
||||||
m_aircraft->fwElevator1Channel->currentText() == "None" ||
|
|
||||||
((m_aircraft->fwAileron1Channel->currentText() == "None") &&
|
|
||||||
(m_aircraft->fwRudder1Channel->currentText() == "None"))) {
|
|
||||||
// TODO: explain the problem in the UI
|
|
||||||
m_aircraft->fwStatusLabel->setText("ERROR: check channel assignment");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// Now setup the channels:
|
|
||||||
resetActuators();
|
|
||||||
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
|
|
||||||
// Elevator
|
|
||||||
UAVObjectField *field = obj->getField("FixedWingPitch1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwElevator1Channel->currentText());
|
|
||||||
field = obj->getField("FixedWingPitch2");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwElevator2Channel->currentText());
|
|
||||||
// Aileron
|
|
||||||
field = obj->getField("FixedWingRoll1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwAileron1Channel->currentText());
|
|
||||||
field = obj->getField("FixedWingRoll2");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwAileron2Channel->currentText());
|
|
||||||
// Rudder
|
|
||||||
field = obj->getField("FixedWingYaw1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwRudder1Channel->currentText());
|
|
||||||
// Throttle
|
|
||||||
field = obj->getField("FixedWingThrottle");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwEngineChannel->currentText());
|
|
||||||
|
|
||||||
obj->updated();
|
|
||||||
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
// ... and compute the matrix:
|
|
||||||
// In order to make code a bit nicer, we assume:
|
|
||||||
// - Channel dropdowns start with 'None', then 0 to 7
|
|
||||||
|
|
||||||
// 1. Assign the servo/motor/none for each channel
|
|
||||||
// Disable all
|
|
||||||
foreach(QString mixer, mixerTypes) {
|
|
||||||
field = obj->getField(mixer);
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue("Disabled");
|
|
||||||
}
|
|
||||||
// and set only the relevant channels:
|
|
||||||
// Engine
|
|
||||||
int eng = m_aircraft->fwEngineChannel->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Motor");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
// First of all reset the vector
|
|
||||||
resetField(field);
|
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
|
|
||||||
// Rudder
|
|
||||||
eng = m_aircraft->fwRudder1Channel->currentIndex()-1;
|
|
||||||
// eng will be -1 if rudder is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
} // Else: we have no rudder, only ailerons, we're fine with it.
|
|
||||||
|
|
||||||
// Ailerons
|
|
||||||
eng = m_aircraft->fwAileron1Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
// Only set Aileron 2 if Aileron 1 is defined
|
|
||||||
eng = m_aircraft->fwAileron2Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
}
|
|
||||||
} // Else we have no ailerons. Our consistency check guarantees we have
|
|
||||||
// rudder in this case, so we're fine with it too.
|
|
||||||
|
|
||||||
// Elevator
|
|
||||||
eng = m_aircraft->fwElevator1Channel->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
// Only set Elevator 2 if it is defined
|
|
||||||
eng = m_aircraft->fwElevator2Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->updated();
|
|
||||||
m_aircraft->fwStatusLabel->setText("Mixer generated");
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Setup Elevon
|
|
||||||
*/
|
|
||||||
bool ConfigAirframeWidget::setupFrameElevon()
|
|
||||||
{
|
|
||||||
// Check coherence:
|
|
||||||
// - At least Aileron1 and Aileron 2, and engine
|
|
||||||
if (m_aircraft->fwEngineChannel->currentText() == "None" ||
|
|
||||||
m_aircraft->fwAileron1Channel->currentText() == "None" ||
|
|
||||||
m_aircraft->fwAileron2Channel->currentText() == "None") {
|
|
||||||
// TODO: explain the problem in the UI
|
|
||||||
m_aircraft->fwStatusLabel->setText("ERROR: check channel assignment");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
resetActuators();
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
|
|
||||||
// Elevons
|
|
||||||
UAVObjectField *field = obj->getField("FixedWingRoll1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwAileron1Channel->currentText());
|
|
||||||
field = obj->getField("FixedWingRoll2");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwAileron2Channel->currentText());
|
|
||||||
// Rudder 1 (can be None)
|
|
||||||
field = obj->getField("FixedWingYaw1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwRudder1Channel->currentText());
|
|
||||||
// Rudder 2 (can be None)
|
|
||||||
field = obj->getField("FixedWingYaw2");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwRudder2Channel->currentText());
|
|
||||||
// Throttle
|
|
||||||
field = obj->getField("FixedWingThrottle");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwEngineChannel->currentText());
|
|
||||||
|
|
||||||
obj->updated();
|
|
||||||
|
|
||||||
// Save the curve:
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
// ... and compute the matrix:
|
|
||||||
// In order to make code a bit nicer, we assume:
|
|
||||||
// - Channel dropdowns start with 'None', then 0 to 7
|
|
||||||
|
|
||||||
// 1. Assign the servo/motor/none for each channel
|
|
||||||
// Disable all
|
|
||||||
foreach(QString mixer, mixerTypes) {
|
|
||||||
field = obj->getField(mixer);
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue("Disabled");
|
|
||||||
}
|
|
||||||
// and set only the relevant channels:
|
|
||||||
// Engine
|
|
||||||
int eng = m_aircraft->fwEngineChannel->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Motor");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
// First of all reset the vector
|
|
||||||
resetField(field);
|
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
|
|
||||||
// Rudder 1
|
|
||||||
eng = m_aircraft->fwRudder1Channel->currentIndex()-1;
|
|
||||||
// eng will be -1 if rudder 1 is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
} // Else: we have no rudder, only elevons, we're fine with it.
|
|
||||||
|
|
||||||
// Rudder 2
|
|
||||||
eng = m_aircraft->fwRudder2Channel->currentIndex()-1;
|
|
||||||
// eng will be -1 if rudder 2 is set to "None"
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(-127, ti);
|
|
||||||
} // Else: we have no rudder, only elevons, we're fine with it.
|
|
||||||
|
|
||||||
eng = m_aircraft->fwAileron1Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
eng = m_aircraft->fwAileron2Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
obj->updated();
|
|
||||||
m_aircraft->fwStatusLabel->setText("Mixer generated");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Setup VTail
|
|
||||||
*/
|
|
||||||
bool ConfigAirframeWidget::setupFrameVtail()
|
|
||||||
{
|
|
||||||
// Check coherence:
|
|
||||||
// - At least Pitch1 and Pitch2, and engine
|
|
||||||
if (m_aircraft->fwEngineChannel->currentText() == "None" ||
|
|
||||||
m_aircraft->fwElevator1Channel->currentText() == "None" ||
|
|
||||||
m_aircraft->fwElevator2Channel->currentText() == "None") {
|
|
||||||
// TODO: explain the problem in the UI
|
|
||||||
m_aircraft->fwStatusLabel->setText("WARNING: check channel assignment");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
resetActuators();
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
|
|
||||||
// Elevons
|
|
||||||
UAVObjectField *field = obj->getField("FixedWingPitch1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwElevator1Channel->currentText());
|
|
||||||
field = obj->getField("FixedWingPitch2");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwElevator2Channel->currentText());
|
|
||||||
field = obj->getField("FixedWingRoll1");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwAileron1Channel->currentText());
|
|
||||||
field = obj->getField("FixedWingRoll2");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwAileron2Channel->currentText());
|
|
||||||
|
|
||||||
// Throttle
|
|
||||||
field = obj->getField("FixedWingThrottle");
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue(m_aircraft->fwEngineChannel->currentText());
|
|
||||||
|
|
||||||
obj->updated();
|
|
||||||
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
// ... and compute the matrix:
|
|
||||||
// In order to make code a bit nicer, we assume:
|
|
||||||
// - Channel dropdowns start with 'None', then 0 to 7
|
|
||||||
|
|
||||||
// 1. Assign the servo/motor/none for each channel
|
|
||||||
// Disable all
|
|
||||||
foreach(QString mixer, mixerTypes) {
|
|
||||||
field = obj->getField(mixer);
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue("Disabled");
|
|
||||||
}
|
|
||||||
// and set only the relevant channels:
|
|
||||||
// Engine
|
|
||||||
int eng = m_aircraft->fwEngineChannel->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Motor");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
// First of all reset the vector
|
|
||||||
resetField(field);
|
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
|
|
||||||
eng = m_aircraft->fwAileron1Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(127,ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
eng = m_aircraft->fwAileron2Channel->currentIndex()-1;
|
|
||||||
if (eng > -1) {
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(-127,ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now compute the VTail
|
|
||||||
eng = m_aircraft->fwElevator1Channel->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue((double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
|
||||||
|
|
||||||
eng = m_aircraft->fwElevator2Channel->currentIndex()-1;
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue((double)m_aircraft->elevonSlider2->value()*1.27, ti);
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(-(double)m_aircraft->elevonSlider1->value()*1.27,ti);
|
|
||||||
|
|
||||||
obj->updated();
|
|
||||||
m_aircraft->fwStatusLabel->setText("Mixer generated");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set up a complete mixer, taking a table of factors. The factors
|
|
||||||
shoudl mainly be +/- 1 factors, since they will be weighted by the
|
|
||||||
value of the Pitch/Roll/Yaw sliders.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
double xMixer [8][3] = {
|
|
||||||
P R Y
|
|
||||||
{ 1, 1, -1}, Motor 1
|
|
||||||
{ 1, -1, 1}, Motor 2
|
|
||||||
{-1, -1, -1}, Motor 3
|
|
||||||
{-1, 1, 1}, ...
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
bool ConfigAirframeWidget::setupMixer(double mixerFactors[8][3])
|
|
||||||
{
|
|
||||||
qDebug()<<"Mixer factors";
|
|
||||||
qDebug()<<mixerFactors[0][0]<<" "<<mixerFactors[0][1]<<" "<<mixerFactors[0][2];
|
|
||||||
qDebug()<<mixerFactors[1][0]<<" "<<mixerFactors[1][1]<<" "<<mixerFactors[1][2];
|
|
||||||
qDebug()<<mixerFactors[2][0]<<" "<<mixerFactors[2][1]<<" "<<mixerFactors[2][2];
|
|
||||||
qDebug()<<mixerFactors[3][0]<<" "<<mixerFactors[3][1]<<" "<<mixerFactors[3][2];
|
|
||||||
qDebug()<<mixerFactors[4][0]<<" "<<mixerFactors[4][1]<<" "<<mixerFactors[4][2];
|
|
||||||
qDebug()<<mixerFactors[5][0]<<" "<<mixerFactors[5][1]<<" "<<mixerFactors[5][2];
|
|
||||||
qDebug()<<mixerFactors[6][0]<<" "<<mixerFactors[6][1]<<" "<<mixerFactors[6][2];
|
|
||||||
qDebug()<<mixerFactors[7][0]<<" "<<mixerFactors[7][1]<<" "<<mixerFactors[7][2];
|
|
||||||
|
|
||||||
UAVObjectField *field;
|
|
||||||
QList<QComboBox*> mmList;
|
|
||||||
mmList << m_aircraft->multiMotor1 << m_aircraft->multiMotor2 << m_aircraft->multiMotor3
|
|
||||||
<< m_aircraft->multiMotor4 << m_aircraft->multiMotor5 << m_aircraft->multiMotor6
|
|
||||||
<< m_aircraft->multiMotor7 << m_aircraft->multiMotor8;
|
|
||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
// 1. Assign the servo/motor/none for each channel
|
|
||||||
// Disable all
|
|
||||||
foreach(QString mixer, mixerTypes) {
|
|
||||||
field = obj->getField(mixer);
|
|
||||||
Q_ASSERT(field);
|
|
||||||
field->setValue("Disabled");
|
|
||||||
}
|
|
||||||
// and enable only the relevant channels:
|
|
||||||
double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100;
|
|
||||||
double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100;
|
|
||||||
double yFactor = (double)m_aircraft->mrYawMixLevel->value()/100;
|
|
||||||
qDebug()<<QString("pFactor=%0 rFactor=%1 yFactor=%2").arg(pFactor).arg(rFactor).arg(yFactor);
|
|
||||||
for (int i=0 ; i<8; i++) {
|
|
||||||
if(mmList.at(i)->isEnabled())
|
|
||||||
{
|
|
||||||
int channel = mmList.at(i)->currentIndex()-1;
|
|
||||||
if (channel > -1)
|
|
||||||
setupQuadMotor(channel, mixerFactors[i][0]*pFactor,
|
|
||||||
rFactor*mixerFactors[i][1], yFactor*mixerFactors[i][2]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// obj->updated();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Help function: setupQuadMotor
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::setupQuadMotor(int channel, double pitch, double roll, double yaw)
|
|
||||||
{
|
|
||||||
qDebug()<<QString("Setup quad motor channel=%0 pitch=%1 roll=%2 yaw=%3").arg(channel).arg(pitch).arg(roll).arg(yaw);
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
UAVObjectField *field = obj->getField(mixerTypes.at(channel));
|
|
||||||
field->setValue("Motor");
|
|
||||||
field = obj->getField(mixerVectors.at(channel));
|
|
||||||
// First of all reset the vector
|
|
||||||
resetField(field);
|
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
field->setValue(127, ti);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(roll*127,ti);
|
|
||||||
qDebug()<<"Set roll="<<roll*127;
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue(pitch*127,ti);
|
|
||||||
qDebug()<<"Set pitch="<<pitch*127;
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(yaw*127,ti);
|
|
||||||
qDebug()<<"Set yaw="<<yaw*127;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Helper function: setup motors. Takes a list of channel names in input.
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::setupMotors(QList<QString> motorList)
|
|
||||||
{
|
|
||||||
resetActuators();
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
UAVObjectField *field;
|
|
||||||
QList<QComboBox*> mmList;
|
|
||||||
mmList << m_aircraft->multiMotor1 << m_aircraft->multiMotor2 << m_aircraft->multiMotor3
|
|
||||||
<< m_aircraft->multiMotor4 << m_aircraft->multiMotor5 << m_aircraft->multiMotor6
|
|
||||||
<< m_aircraft->multiMotor7 << m_aircraft->multiMotor8;
|
|
||||||
foreach (QString motor, motorList) {
|
|
||||||
field = obj->getField(motor);
|
|
||||||
field->setValue(mmList.takeFirst()->currentText());
|
|
||||||
}
|
|
||||||
//obj->updated(); // Save...
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set up a Quad-X or Quad-P
|
|
||||||
*/
|
|
||||||
bool ConfigAirframeWidget::setupQuad(bool pLayout)
|
|
||||||
{
|
|
||||||
// Check coherence:
|
|
||||||
// - Four engines have to be defined
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 4 motor channels");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QList<QString> motorList;
|
|
||||||
if (pLayout) {
|
|
||||||
motorList << "VTOLMotorN" << "VTOLMotorE" << "VTOLMotorS"
|
|
||||||
<< "VTOLMotorW";
|
|
||||||
} else {
|
|
||||||
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorSE"
|
|
||||||
<< "VTOLMotorSW";
|
|
||||||
}
|
|
||||||
setupMotors(motorList);
|
|
||||||
|
|
||||||
// Now, setup the mixer:
|
|
||||||
// Motor 1 to 4, X Layout:
|
|
||||||
// pitch roll yaw
|
|
||||||
// {0.5 ,0.5 ,-0.5 //Front left motor (CW)
|
|
||||||
// {0.5 ,-0.5 ,0.5 //Front right motor(CCW)
|
|
||||||
// {-0.5 ,-0.5 ,-0.5 //rear right motor (CW)
|
|
||||||
// {-0.5 ,0.5 ,0.5 //Rear left motor (CCW)
|
|
||||||
double xMixer [8][3] = {
|
|
||||||
{ 1, 1, -1},
|
|
||||||
{ 1, -1, 1},
|
|
||||||
{-1, -1, -1},
|
|
||||||
{-1, 1, 1},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
//
|
|
||||||
// Motor 1 to 4, P Layout:
|
|
||||||
// pitch roll yaw
|
|
||||||
// {1 ,0 ,-0.5 //Front motor (CW)
|
|
||||||
// {0 ,-1 ,0.5 //Right motor(CCW)
|
|
||||||
// {-1 ,0 ,-0.5 //Rear motor (CW)
|
|
||||||
// {0 ,1 ,0.5 //Left motor (CCW)
|
|
||||||
double pMixer [8][3] = {
|
|
||||||
{ 1, 0, -1},
|
|
||||||
{ 0, -1, 1},
|
|
||||||
{-1, 0, -1},
|
|
||||||
{ 0, 1, 1},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (pLayout) {
|
|
||||||
setupMixer(pMixer);
|
|
||||||
} else {
|
|
||||||
setupMixer(xMixer);
|
|
||||||
}
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Set up a Hexa-X or Hexa-P
|
|
||||||
*/
|
|
||||||
bool ConfigAirframeWidget::setupHexa(bool pLayout)
|
|
||||||
{
|
|
||||||
// Check coherence:
|
|
||||||
// - Four engines have to be defined
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor5->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor6->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 6 motor channels");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<QString> motorList;
|
|
||||||
if (pLayout) {
|
|
||||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorSE"
|
|
||||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorNW";
|
|
||||||
} else {
|
|
||||||
motorList << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
|
||||||
<< "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
|
||||||
}
|
|
||||||
setupMotors(motorList);
|
|
||||||
|
|
||||||
// and set only the relevant channels:
|
|
||||||
|
|
||||||
// Motor 1 to 6, P Layout:
|
|
||||||
// pitch roll yaw
|
|
||||||
// 1 { 0.3 , 0 ,-0.3 // N CW
|
|
||||||
// 2 { 0.3 ,-0.5 , 0.3 // NE CCW
|
|
||||||
// 3 {-0.3 ,-0.5 ,-0.3 // SE CW
|
|
||||||
// 4 {-0.3 , 0 , 0.3 // S CCW
|
|
||||||
// 5 {-0.3 , 0.5 ,-0.3 // SW CW
|
|
||||||
// 6 { 0.3 , 0.5 , 0.3 // NW CCW
|
|
||||||
|
|
||||||
double pMixer [8][3] = {
|
|
||||||
{ 1, 0, -1},
|
|
||||||
{ 1, -1, 1},
|
|
||||||
{-1, -1, -1},
|
|
||||||
{-1, 0, 1},
|
|
||||||
{-1, 1, -1},
|
|
||||||
{ 1, 1, 1},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
// Motor 1 to 6, X Layout:
|
|
||||||
// 1 [ 0.5, -0.3, -0.3 ] NE
|
|
||||||
// 2 [ 0 , -0.3, 0.3 ] E
|
|
||||||
// 3 [ -0.5, -0.3, -0.3 ] SE
|
|
||||||
// 4 [ -0.5, 0.3, 0.3 ] SW
|
|
||||||
// 5 [ 0 , 0.3, -0.3 ] W
|
|
||||||
// 6 [ 0.5, 0.3, 0.3 ] NW
|
|
||||||
double xMixer [8][3] = {
|
|
||||||
{ 1, -1, -1},
|
|
||||||
{ 0, -1, 1},
|
|
||||||
{ -1, -1, -1},
|
|
||||||
{ -1, 1, 1},
|
|
||||||
{ 0, 1, -1},
|
|
||||||
{ 1, 1, 1},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
if (pLayout) {
|
|
||||||
setupMixer(pMixer);
|
|
||||||
} else {
|
|
||||||
setupMixer(xMixer);
|
|
||||||
}
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Updates the custom airframe settings based on the current airframe.
|
|
||||||
|
|
||||||
Note: does NOT ask for an object refresh itself!
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::updateCustomAirframeUI()
|
|
||||||
{
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
|
||||||
QList<double> curveValues;
|
|
||||||
// If the 1st element of the curve is <= -10, then the curve
|
|
||||||
// is a straight line (that's how the mixer works on the mainboard):
|
|
||||||
if (field->getValue(0).toInt() <= -10) {
|
|
||||||
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
} else {
|
|
||||||
double temp=0;
|
|
||||||
double value;
|
|
||||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
|
||||||
value=field->getValue(i).toDouble();
|
|
||||||
temp+=value;
|
|
||||||
curveValues.append(value);
|
|
||||||
}
|
|
||||||
if(temp==0)
|
|
||||||
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
else
|
|
||||||
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
|
||||||
}
|
|
||||||
field = obj->getField(QString("ThrottleCurve2"));
|
|
||||||
curveValues.clear();;
|
|
||||||
// If the 1st element of the curve is <= -10, then the curve
|
|
||||||
// is a straight line (that's how the mixer works on the mainboard):
|
|
||||||
if (field->getValue(0).toInt() <= -10) {
|
|
||||||
m_aircraft->customThrottle2Curve->initLinearCurve(field->getNumElements(),(double)1);
|
|
||||||
} else {
|
|
||||||
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
|
||||||
curveValues.append(field->getValue(i).toDouble());
|
|
||||||
}
|
|
||||||
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the table:
|
|
||||||
for (int i=0; i<8; i++) {
|
|
||||||
field = obj->getField(mixerTypes.at(i));
|
|
||||||
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
|
||||||
QString s = field->getValue().toString();
|
|
||||||
q->setCurrentIndex(q->findText(s));
|
|
||||||
//bool en = (s != "Disabled");
|
|
||||||
field = obj->getField(mixerVectors.at(i));
|
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
m_aircraft->customMixerTable->item(1,i)->setText(field->getValue(ti).toString());
|
|
||||||
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
|
||||||
m_aircraft->customMixerTable->item(2,i)->setText(field->getValue(ti).toString());
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
m_aircraft->customMixerTable->item(3,i)->setText(field->getValue(ti).toString());
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
m_aircraft->customMixerTable->item(4,i)->setText(field->getValue(ti).toString());
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
m_aircraft->customMixerTable->item(5,i)->setText(field->getValue(ti).toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
Sends the config to the board (airframe type)
|
|
||||||
|
|
||||||
We do all the tasks common to all airframes, or family of airframes, and
|
|
||||||
we call additional methods for specific frames, so that we do not have a code
|
|
||||||
that is too heavy.
|
|
||||||
*/
|
|
||||||
void ConfigAirframeWidget::updateObjectsFromWidgets()
|
|
||||||
{
|
|
||||||
qDebug()<<"updateObjectsFromWidgets";
|
|
||||||
QString airframeType = "Custom";
|
|
||||||
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
|
||||||
// Save the curve (common to all Fixed wing frames)
|
|
||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
// Remove Feed Forward, it is pointless on a plane:
|
|
||||||
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
|
||||||
field->setDouble(0);
|
|
||||||
field = obj->getField("ThrottleCurve1");
|
|
||||||
QList<double> curve = m_aircraft->fixedWingThrottle->getCurve();
|
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) {
|
|
||||||
airframeType = "FixedWing";
|
|
||||||
setupFrameFixedWing();
|
|
||||||
} else if (m_aircraft->fixedWingType->currentText() == "Elevon") {
|
|
||||||
airframeType = "FixedWingElevon";
|
|
||||||
setupFrameElevon();
|
|
||||||
} else { // "Vtail"
|
|
||||||
airframeType = "FixedWingVtail";
|
|
||||||
setupFrameVtail();
|
|
||||||
}
|
|
||||||
// Now reflect those settings in the "Custom" panel as well
|
|
||||||
updateCustomAirframeUI();
|
|
||||||
} else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
|
|
||||||
|
|
||||||
QList<QString> motorList;
|
|
||||||
|
|
||||||
// We can already setup the feedforward here, as it is common to all platforms
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
|
||||||
field->setDouble((double)m_aircraft->feedForwardSlider->value()/100);
|
|
||||||
field = obj->getField(QString("AccelTime"));
|
|
||||||
field->setDouble(m_aircraft->accelTime->value());
|
|
||||||
field = obj->getField(QString("DecelTime"));
|
|
||||||
field->setDouble(m_aircraft->decelTime->value());
|
|
||||||
field = obj->getField(QString("MaxAccel"));
|
|
||||||
field->setDouble(m_aircraft->maxAccelSlider->value());
|
|
||||||
|
|
||||||
// Curve is also common to all quads:
|
|
||||||
field = obj->getField("ThrottleCurve1");
|
|
||||||
QList<double> curve = m_aircraft->multiThrottleCurve->getCurve();
|
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_aircraft->multirotorFrameType->currentText() == "Quad +") {
|
|
||||||
airframeType = "QuadP";
|
|
||||||
setupQuad(true);
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Quad X") {
|
|
||||||
airframeType = "QuadX";
|
|
||||||
setupQuad(false);
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter") {
|
|
||||||
airframeType = "Hexa";
|
|
||||||
setupHexa(true);
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") {
|
|
||||||
airframeType = "Octo";
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor5->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor6->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor7->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor8->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 8 motor channels");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
|
||||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
|
||||||
setupMotors(motorList);
|
|
||||||
// Motor 1 to 8:
|
|
||||||
// pitch roll yaw
|
|
||||||
double mixer [8][3] = {
|
|
||||||
{ 1, 0, -1},
|
|
||||||
{ 1, -1, 1},
|
|
||||||
{ 0, -1, -1},
|
|
||||||
{ -1, -1, 1},
|
|
||||||
{ -1, 0, -1},
|
|
||||||
{ -1, 1, 1},
|
|
||||||
{ 0, 1, -1},
|
|
||||||
{ 1, 1, 1}
|
|
||||||
};
|
|
||||||
setupMixer(mixer);
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter X") {
|
|
||||||
airframeType = "HexaX";
|
|
||||||
setupHexa(false);
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") {
|
|
||||||
airframeType = "OctoV";
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor5->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor6->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor7->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor8->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 8 motor channels");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
|
||||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
|
||||||
setupMotors(motorList);
|
|
||||||
// Motor 1 to 8:
|
|
||||||
// IMPORTANT: Assumes evenly spaced engines
|
|
||||||
// pitch roll yaw
|
|
||||||
double mixer [8][3] = {
|
|
||||||
{ 0.33, -1, -1},
|
|
||||||
{ 1 , -1, 1},
|
|
||||||
{ -1 , -1, -1},
|
|
||||||
{ -0.33, -1, 1},
|
|
||||||
{ -0.33, 1, -1},
|
|
||||||
{ -1 , 1, 1},
|
|
||||||
{ 1 , 1, -1},
|
|
||||||
{ 0.33, 1, 1}
|
|
||||||
};
|
|
||||||
setupMixer(mixer);
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") {
|
|
||||||
airframeType = "OctoCoaxP";
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor5->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor6->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor7->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor8->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 8 motor channels");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE"
|
|
||||||
<< "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW";
|
|
||||||
setupMotors(motorList);
|
|
||||||
// Motor 1 to 8:
|
|
||||||
// pitch roll yaw
|
|
||||||
double mixer [8][3] = {
|
|
||||||
{ 1, 0, -1},
|
|
||||||
{ 1, 0, 1},
|
|
||||||
{ 0, -1, -1},
|
|
||||||
{ 0, -1, 1},
|
|
||||||
{ -1, 0, -1},
|
|
||||||
{ -1, 0, 1},
|
|
||||||
{ 0, 1, -1},
|
|
||||||
{ 0, 1, 1}
|
|
||||||
};
|
|
||||||
setupMixer(mixer);
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") {
|
|
||||||
airframeType = "OctoCoaxX";
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor5->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor6->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor7->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor8->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 8 motor channels");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE"
|
|
||||||
<< "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW";
|
|
||||||
setupMotors(motorList);
|
|
||||||
// Motor 1 to 8:
|
|
||||||
// pitch roll yaw
|
|
||||||
double mixer [8][3] = {
|
|
||||||
{ 1, 1, -1},
|
|
||||||
{ 1, 1, 1},
|
|
||||||
{ 1, -1, -1},
|
|
||||||
{ 1, -1, 1},
|
|
||||||
{ -1, -1, -1},
|
|
||||||
{ -1, -1, 1},
|
|
||||||
{ -1, 1, -1},
|
|
||||||
{ -1, 1, 1}
|
|
||||||
};
|
|
||||||
setupMixer(mixer);
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter Y6") {
|
|
||||||
airframeType = "HexaCoax";
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor4->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor5->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor6->currentText() == "None" ) {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 6 motor channels");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE"
|
|
||||||
<< "VTOLMotorS" << "VTOLMotorSE";
|
|
||||||
setupMotors(motorList);
|
|
||||||
|
|
||||||
// Motor 1 to 6, Y6 Layout:
|
|
||||||
// pitch roll yaw
|
|
||||||
double mixer [8][3] = {
|
|
||||||
{ 0.5, 1, -1},
|
|
||||||
{ 0.5, 1, 1},
|
|
||||||
{ 0.5, -1, -1},
|
|
||||||
{ 0.5, -1, 1},
|
|
||||||
{ -1, 0, -1},
|
|
||||||
{ -1, 0, 1},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
setupMixer(mixer);
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
|
|
||||||
} else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") {
|
|
||||||
airframeType = "Tri";
|
|
||||||
if (m_aircraft->multiMotor1->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor2->currentText() == "None" ||
|
|
||||||
m_aircraft->multiMotor3->currentText() == "None" ) {
|
|
||||||
m_aircraft->mrStatusLabel->setText("ERROR: Assign 3 motor channels");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (m_aircraft->triYawChannel->currentText() == "None") {
|
|
||||||
m_aircraft->mrStatusLabel->setText("Error: Assign a Yaw channel");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS";
|
|
||||||
setupMotors(motorList);
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
|
||||||
Q_ASSERT(obj);
|
|
||||||
field = obj->getField("FixedWingYaw1");
|
|
||||||
field->setValue(m_aircraft->triYawChannel->currentText());
|
|
||||||
|
|
||||||
// Motor 1 to 6, Y6 Layout:
|
|
||||||
// pitch roll yaw
|
|
||||||
double mixer [8][3] = {
|
|
||||||
{ 0.5, 1, 0},
|
|
||||||
{ 0.5, -1, 0},
|
|
||||||
{ -1, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0},
|
|
||||||
{ 0, 0, 0}
|
|
||||||
};
|
|
||||||
setupMixer(mixer);
|
|
||||||
|
|
||||||
int eng = m_aircraft->triYawChannel->currentIndex()-1;
|
|
||||||
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
field = obj->getField(mixerTypes.at(eng));
|
|
||||||
field->setValue("Servo");
|
|
||||||
field = obj->getField(mixerVectors.at(eng));
|
|
||||||
resetField(field);
|
|
||||||
int ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(127,ti);
|
|
||||||
|
|
||||||
m_aircraft->mrStatusLabel->setText("SUCCESS: Mixer Saved OK");
|
|
||||||
|
|
||||||
}
|
|
||||||
// Now reflect those settings in the "Custom" panel as well
|
|
||||||
updateCustomAirframeUI();
|
|
||||||
|
|
||||||
} else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
|
|
||||||
airframeType = "HeliCP";
|
|
||||||
m_aircraft->widget_3->sendccpmUpdate();
|
|
||||||
} else {
|
|
||||||
airframeType = "Custom";
|
|
||||||
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
|
||||||
|
|
||||||
// Curve is also common to all quads:
|
|
||||||
field = obj->getField("ThrottleCurve1");
|
|
||||||
QList<double> curve = m_aircraft->customThrottle1Curve->getCurve();
|
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
field = obj->getField("ThrottleCurve2");
|
|
||||||
curve.clear();
|
|
||||||
curve = m_aircraft->customThrottle2Curve->getCurve();
|
|
||||||
for (int i=0;i<curve.length();i++) {
|
|
||||||
field->setValue(curve.at(i),i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update the table:
|
|
||||||
for (int i=0; i<8; i++) {
|
|
||||||
field = obj->getField(mixerTypes.at(i));
|
|
||||||
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
|
||||||
field->setValue(q->currentText());
|
|
||||||
field = obj->getField(mixerVectors.at(i));
|
|
||||||
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
|
||||||
field->setValue(m_aircraft->customMixerTable->item(1,i)->text(),ti);
|
|
||||||
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
|
||||||
field->setValue(m_aircraft->customMixerTable->item(2,i)->text(),ti);
|
|
||||||
ti = field->getElementNames().indexOf("Roll");
|
|
||||||
field->setValue(m_aircraft->customMixerTable->item(3,i)->text(),ti);
|
|
||||||
ti = field->getElementNames().indexOf("Pitch");
|
|
||||||
field->setValue(m_aircraft->customMixerTable->item(4,i)->text(),ti);
|
|
||||||
ti = field->getElementNames().indexOf("Yaw");
|
|
||||||
field->setValue(m_aircraft->customMixerTable->item(5,i)->text(),ti);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
|
||||||
UAVObjectField* field = obj->getField(QString("AirframeType"));
|
|
||||||
field->setValue(airframeType);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::openHelp()
|
|
||||||
{
|
|
||||||
|
|
||||||
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Airframe+configuration", QUrl::StrictMode) );
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigAirframeWidget::addToDirtyMonitor()
|
|
||||||
{
|
|
||||||
addWidget(m_aircraft->customMixerTable);
|
|
||||||
addWidget(m_aircraft->customThrottle2Curve);
|
|
||||||
addWidget(m_aircraft->customThrottle1Curve);
|
|
||||||
addWidget(m_aircraft->multiThrottleCurve);
|
|
||||||
addWidget(m_aircraft->fixedWingThrottle);
|
|
||||||
addWidget(m_aircraft->fixedWingType);
|
|
||||||
addWidget(m_aircraft->feedForwardSlider);
|
|
||||||
addWidget(m_aircraft->accelTime);
|
|
||||||
addWidget(m_aircraft->decelTime);
|
|
||||||
addWidget(m_aircraft->maxAccelSlider);
|
|
||||||
addWidget(m_aircraft->multirotorFrameType);
|
|
||||||
addWidget(m_aircraft->multiMotor1);
|
|
||||||
addWidget(m_aircraft->multiMotor2);
|
|
||||||
addWidget(m_aircraft->multiMotor3);
|
|
||||||
addWidget(m_aircraft->multiMotor4);
|
|
||||||
addWidget(m_aircraft->multiMotor5);
|
|
||||||
addWidget(m_aircraft->multiMotor6);
|
|
||||||
addWidget(m_aircraft->multiMotor7);
|
|
||||||
addWidget(m_aircraft->multiMotor8);
|
|
||||||
addWidget(m_aircraft->triYawChannel);
|
|
||||||
addWidget(m_aircraft->aircraftType);
|
|
||||||
addWidget(m_aircraft->fwEngineChannel);
|
|
||||||
addWidget(m_aircraft->fwAileron1Channel);
|
|
||||||
addWidget(m_aircraft->fwAileron2Channel);
|
|
||||||
addWidget(m_aircraft->fwElevator1Channel);
|
|
||||||
addWidget(m_aircraft->fwElevator2Channel);
|
|
||||||
addWidget(m_aircraft->fwRudder1Channel);
|
|
||||||
addWidget(m_aircraft->fwRudder2Channel);
|
|
||||||
addWidget(m_aircraft->elevonSlider1);
|
|
||||||
addWidget(m_aircraft->elevonSlider2);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmType);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmTailChannel);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmEngineChannel);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoWChannel);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoXChannel);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoYChannel);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmSingleServo);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoZChannel);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleW);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleX);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCorrectionAngle);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleZ);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleY);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivePassthrough);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkRoll);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkCyclic);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRevoSlider);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmREVOspinBox);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveSlider);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivespinBox);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScale);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScaleBox);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCyclicScale);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScale);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScaleBox);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScale);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScaleBox);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSlider);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSpinBox);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveType);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->NumCurvePoints);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue1);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue2);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue3);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveToGenerate);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->CurveSettings);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ThrottleCurve);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->PitchCurve);
|
|
||||||
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAdvancedSettingsTable);
|
|
||||||
}
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
|||||||
#include "configahrswidget.h"
|
#include "configahrswidget.h"
|
||||||
#include "configgadgetwidget.h"
|
#include "configgadgetwidget.h"
|
||||||
|
|
||||||
#include "configairframewidget.h"
|
#include "configvehicletypewidget.h"
|
||||||
#include "configccattitudewidget.h"
|
#include "configccattitudewidget.h"
|
||||||
#include "configinputwidget.h"
|
#include "configinputwidget.h"
|
||||||
#include "configoutputwidget.h"
|
#include "configoutputwidget.h"
|
||||||
@ -68,7 +68,7 @@ ConfigGadgetWidget::ConfigGadgetWidget(QWidget *parent) : QWidget(parent)
|
|||||||
qwd = new DefaultHwSettingsWidget(this);
|
qwd = new DefaultHwSettingsWidget(this);
|
||||||
ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.png"), QString("HW Settings"));
|
ftw->insertTab(ConfigGadgetWidget::hardware, qwd, QIcon(":/configgadget/images/hw_config.png"), QString("HW Settings"));
|
||||||
|
|
||||||
qwd = new ConfigAirframeWidget(this);
|
qwd = new ConfigVehicleTypeWidget(this);
|
||||||
ftw->insertTab(ConfigGadgetWidget::aircraft, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft"));
|
ftw->insertTab(ConfigGadgetWidget::aircraft, qwd, QIcon(":/configgadget/images/Airframe.png"), QString("Aircraft"));
|
||||||
|
|
||||||
qwd = new ConfigInputWidget(this);
|
qwd = new ConfigInputWidget(this);
|
||||||
|
@ -56,18 +56,19 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
|||||||
|
|
||||||
addApplySaveButtons(m_config->saveRCInputToRAM,m_config->saveRCInputToSD);
|
addApplySaveButtons(m_config->saveRCInputToRAM,m_config->saveRCInputToSD);
|
||||||
|
|
||||||
|
//Generate the rows of buttons in the input channel form GUI
|
||||||
unsigned int index=0;
|
unsigned int index=0;
|
||||||
foreach (QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames())
|
foreach (QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames())
|
||||||
{
|
{
|
||||||
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
||||||
inputChannelForm * inp=new inputChannelForm(this,index==0);
|
inputChannelForm * inpForm=new inputChannelForm(this,index==0);
|
||||||
m_config->channelSettings->layout()->addWidget(inp);
|
m_config->channelSettings->layout()->addWidget(inpForm); //Add the row to the UI
|
||||||
inp->setName(name);
|
inpForm->setName(name);
|
||||||
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelGroups",inp->ui->channelGroup,index);
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelGroups",inpForm->ui->channelGroup,index);
|
||||||
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNumber",inp->ui->channelNumber,index);
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNumber",inpForm->ui->channelNumber,index);
|
||||||
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMin",inp->ui->channelMin,index);
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMin",inpForm->ui->channelMin,index);
|
||||||
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNeutral",inp->ui->channelNeutral,index);
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelNeutral",inpForm->ui->channelNeutral,index);
|
||||||
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inp->ui->channelMax,index);
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inpForm->ui->channelMax,index);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,926 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file configvehicletypewidget.cpp
|
||||||
|
* @author E. Lafargue, K. Sebesta & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012
|
||||||
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
|
* @{
|
||||||
|
* @addtogroup ConfigPlugin Config Plugin
|
||||||
|
* @{
|
||||||
|
* @brief Airframe configuration panel
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||||
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
#include "configvehicletypewidget.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QtGui/QWidget>
|
||||||
|
#include <QtGui/QTextEdit>
|
||||||
|
#include <QtGui/QVBoxLayout>
|
||||||
|
#include <QtGui/QPushButton>
|
||||||
|
#include <math.h>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
#include <QUrl>
|
||||||
|
#include "systemsettings.h"
|
||||||
|
#include "mixersettings.h"
|
||||||
|
#include "actuatorsettings.h"
|
||||||
|
#include <QEventLoop>
|
||||||
|
|
||||||
|
/**
|
||||||
|
Helper delegate for the custom mixer editor table.
|
||||||
|
Taken straight from Qt examples, thanks!
|
||||||
|
*/
|
||||||
|
SpinBoxDelegate::SpinBoxDelegate(QObject *parent)
|
||||||
|
: QItemDelegate(parent)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *SpinBoxDelegate::createEditor(QWidget *parent,
|
||||||
|
const QStyleOptionViewItem &/* option */,
|
||||||
|
const QModelIndex &/* index */) const
|
||||||
|
{
|
||||||
|
QSpinBox *editor = new QSpinBox(parent);
|
||||||
|
editor->setMinimum(-127);
|
||||||
|
editor->setMaximum(127);
|
||||||
|
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinBoxDelegate::setEditorData(QWidget *editor,
|
||||||
|
const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
int value = index.model()->data(index, Qt::EditRole).toInt();
|
||||||
|
|
||||||
|
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||||
|
spinBox->setValue(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
|
||||||
|
const QModelIndex &index) const
|
||||||
|
{
|
||||||
|
QSpinBox *spinBox = static_cast<QSpinBox*>(editor);
|
||||||
|
spinBox->interpretText();
|
||||||
|
int value = spinBox->value();
|
||||||
|
|
||||||
|
model->setData(index, value, Qt::EditRole);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SpinBoxDelegate::updateEditorGeometry(QWidget *editor,
|
||||||
|
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
|
||||||
|
{
|
||||||
|
editor->setGeometry(option.rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Constructor
|
||||||
|
*/
|
||||||
|
ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
||||||
|
{
|
||||||
|
m_aircraft = new Ui_AircraftWidget();
|
||||||
|
m_aircraft->setupUi(this);
|
||||||
|
|
||||||
|
addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD);
|
||||||
|
|
||||||
|
addUAVObject("SystemSettings");
|
||||||
|
addUAVObject("MixerSettings");
|
||||||
|
addUAVObject("ActuatorSettings");
|
||||||
|
|
||||||
|
|
||||||
|
ffTuningInProgress = false;
|
||||||
|
ffTuningPhase = false;
|
||||||
|
|
||||||
|
//Generate list of channels
|
||||||
|
QStringList channels;
|
||||||
|
channels << "None";
|
||||||
|
for (int i = 0; i < ActuatorSettings::CHANNELADDR_NUMELEM; i++) {
|
||||||
|
mixerTypes << QString("Mixer%1Type").arg(i+1);
|
||||||
|
mixerVectors << QString("Mixer%1Vector").arg(i+1);
|
||||||
|
channels << QString("Channel%1").arg(i+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList airframeTypes;
|
||||||
|
airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom";
|
||||||
|
m_aircraft->aircraftType->addItems(airframeTypes);
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(1);
|
||||||
|
|
||||||
|
QStringList fixedWingTypes;
|
||||||
|
fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail";
|
||||||
|
m_aircraft->fixedWingType->addItems(fixedWingTypes);
|
||||||
|
m_aircraft->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder"
|
||||||
|
|
||||||
|
QStringList groundVehicleTypes;
|
||||||
|
groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle";
|
||||||
|
m_aircraft->groundVehicleType->addItems(groundVehicleTypes);
|
||||||
|
m_aircraft->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)"
|
||||||
|
|
||||||
|
QStringList multiRotorTypes;
|
||||||
|
multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" <<
|
||||||
|
"Hexacopter" << "Hexacopter X" << "Hexacopter Y6" <<
|
||||||
|
"Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ;
|
||||||
|
m_aircraft->multirotorFrameType->addItems(multiRotorTypes);
|
||||||
|
m_aircraft->multirotorFrameType->setCurrentIndex(1); //Set default model to "Quad +"
|
||||||
|
|
||||||
|
// Now load all the channel assignements
|
||||||
|
//OLD STYLE: DO IT MANUALLY
|
||||||
|
// m_aircraft->triYawChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->gvMotor1ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->gvMotor2ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->gvSteering1ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->gvSteering2ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwElevator1ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwElevator2ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwEngineChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwRudder1ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwRudder2ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwAileron1ChannelBox->addItems(channels);
|
||||||
|
// m_aircraft->fwAileron2ChannelBox->addItems(channels);
|
||||||
|
|
||||||
|
//NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name
|
||||||
|
// The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name
|
||||||
|
foreach(QComboBox *combobox, this->findChildren<QComboBox*>(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate
|
||||||
|
{
|
||||||
|
combobox->addItems(channels);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup the Multirotor picture in the Quad settings interface
|
||||||
|
m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
QSvgRenderer *renderer = new QSvgRenderer();
|
||||||
|
renderer->load(QString(":/configgadget/images/quad-shapes.svg"));
|
||||||
|
quad = new QGraphicsSvgItem();
|
||||||
|
quad->setSharedRenderer(renderer);
|
||||||
|
quad->setElementId("quad-plus");
|
||||||
|
QGraphicsScene *scene = new QGraphicsScene(this);
|
||||||
|
scene->addItem(quad);
|
||||||
|
scene->setSceneRect(quad->boundingRect());
|
||||||
|
m_aircraft->quadShape->setScene(scene);
|
||||||
|
|
||||||
|
// Put combo boxes in line one of the custom mixer table:
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("Mixer1Type"));
|
||||||
|
QStringList list = field->getOptions();
|
||||||
|
for (int i=0;i<8;i++) {
|
||||||
|
QComboBox* qb = new QComboBox(m_aircraft->customMixerTable);
|
||||||
|
qb->addItems(list);
|
||||||
|
m_aircraft->customMixerTable->setCellWidget(0,i,qb);
|
||||||
|
}
|
||||||
|
|
||||||
|
SpinBoxDelegate *sbd = new SpinBoxDelegate();
|
||||||
|
for (int i=1;i<8; i++) {
|
||||||
|
m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Connect aircraft type selection dropbox to callback function
|
||||||
|
connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int)));
|
||||||
|
|
||||||
|
//Connect airframe selection dropbox to callback functions
|
||||||
|
connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||||
|
connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||||
|
connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString)));
|
||||||
|
|
||||||
|
//Connect throttle curve reset pushbuttons to reset functions
|
||||||
|
connect(m_aircraft->fwThrottleReset, SIGNAL(clicked()), this, SLOT(resetFwMixer()));
|
||||||
|
connect(m_aircraft->mrThrottleCurveReset, SIGNAL(clicked()), this, SLOT(resetMrMixer()));
|
||||||
|
connect(m_aircraft->gvThrottleCurve1Reset, SIGNAL(clicked()), this, SLOT(resetGvFrontMixer()));
|
||||||
|
connect(m_aircraft->gvThrottleCurve2Reset, SIGNAL(clicked()), this, SLOT(resetGvRearMixer()));
|
||||||
|
connect(m_aircraft->customReset1, SIGNAL(clicked()), this, SLOT(resetCt1Mixer()));
|
||||||
|
connect(m_aircraft->customReset2, SIGNAL(clicked()), this, SLOT(resetCt2Mixer()));
|
||||||
|
|
||||||
|
//Connect throttle curve manipulation points to output text
|
||||||
|
connect(m_aircraft->fixedWingThrottle, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateFwThrottleCurveValue(QList<double>,double)));
|
||||||
|
connect(m_aircraft->multiThrottleCurve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateMrThrottleCurveValue(QList<double>,double)));
|
||||||
|
connect(m_aircraft->groundVehicleThrottle1, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateGvThrottle1CurveValue(QList<double>,double)));
|
||||||
|
connect(m_aircraft->groundVehicleThrottle2, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateGvThrottle2CurveValue(QList<double>,double)));
|
||||||
|
connect(m_aircraft->customThrottle1Curve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateCustomThrottle1CurveValue(QList<double>,double)));
|
||||||
|
connect(m_aircraft->customThrottle2Curve, SIGNAL(curveUpdated(QList<double>,double)), this, SLOT(updateCustomThrottle2CurveValue(QList<double>,double)));
|
||||||
|
|
||||||
|
// connect(m_aircraft->fwAileron1Channel, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleAileron2(int)));
|
||||||
|
// connect(m_aircraft->fwElevator1Channel, SIGNAL(currentIndexChanged(int)), this, SLOT(toggleElevator2(int)));
|
||||||
|
|
||||||
|
//Connect the three feed forward test checkboxes
|
||||||
|
connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||||
|
connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||||
|
connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest()));
|
||||||
|
|
||||||
|
//WHAT DOES THIS DO?
|
||||||
|
enableControls(false);
|
||||||
|
refreshWidgetsValues();
|
||||||
|
|
||||||
|
// Connect the help pushbutton
|
||||||
|
connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp()));
|
||||||
|
addToDirtyMonitor();
|
||||||
|
|
||||||
|
//Initialize GUI tabs //MOVING THIS FROM THE END OF THIS FUNCTION CAN CAUSE RUNTIME ERRORS DUE TO setupMultiRotorUI. WHY?
|
||||||
|
setupMultiRotorUI( m_aircraft->multirotorFrameType->currentText() );
|
||||||
|
setupGroundVehicleUI( m_aircraft->groundVehicleType->currentText() );
|
||||||
|
setupFixedWingUI( m_aircraft->fixedWingType->currentText() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Destructor
|
||||||
|
*/
|
||||||
|
ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget()
|
||||||
|
{
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Slot for switching the airframe type. We do it explicitely
|
||||||
|
rather than a signal in the UI, because we want to force a fitInView of the quad shapes.
|
||||||
|
This is because this method (fitinview) only works when the widget is shown.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::switchAirframeType(int index){
|
||||||
|
m_aircraft->airframesWidget->setCurrentIndex(index);
|
||||||
|
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||||
|
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||||
|
if (m_aircraft->aircraftType->findText("Custom")) {
|
||||||
|
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||||
|
for (int i=0;i<8;i++) {
|
||||||
|
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
||||||
|
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
WHAT DOES THIS DO???
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::showEvent(QShowEvent *event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event)
|
||||||
|
// Thit fitInView method should only be called now, once the
|
||||||
|
// widget is shown, otherwise it cannot compute its values and
|
||||||
|
// the result is usually a ahrsbargraph that is way too small.
|
||||||
|
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||||
|
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||||
|
for (int i=0;i<8;i++) {
|
||||||
|
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
||||||
|
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resize the GUI contents when the user changes the window size
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
Q_UNUSED(event);
|
||||||
|
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||||
|
// Make the custom table columns autostretch:
|
||||||
|
m_aircraft->customMixerTable->resizeColumnsToContents();
|
||||||
|
for (int i=0;i<8;i++) {
|
||||||
|
m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()-
|
||||||
|
m_aircraft->customMixerTable->verticalHeader()->width())/8);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ConfigVehicleTypeWidget::toggleAileron2(int index)
|
||||||
|
{
|
||||||
|
if (index) {
|
||||||
|
m_aircraft->fwAileron2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwAileron2Label->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
m_aircraft->fwAileron2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwAileron2Label->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigVehicleTypeWidget::toggleElevator2(int index)
|
||||||
|
{
|
||||||
|
if (index) {
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwElevator2Label->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
m_aircraft->fwElevator2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwElevator2Label->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfigVehicleTypeWidget::toggleRudder2(int index)
|
||||||
|
{
|
||||||
|
if (index) {
|
||||||
|
m_aircraft->fwRudder2ChannelBox->setEnabled(true);
|
||||||
|
m_aircraft->fwRudder2Label->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
m_aircraft->fwRudder2ChannelBox->setEnabled(false);
|
||||||
|
m_aircraft->fwRudder2Label->setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
/// Feed Forward Testing
|
||||||
|
/////////////////////////////////////////////////////////
|
||||||
|
/**
|
||||||
|
Enables and runs feed forward testing
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::enableFFTest()
|
||||||
|
{
|
||||||
|
// Role:
|
||||||
|
// - Check if all three checkboxes are checked
|
||||||
|
// - Every other timer event: toggle engine from 45% to 55%
|
||||||
|
// - Every other time event: send FF settings to flight FW
|
||||||
|
if (m_aircraft->ffTestBox1->isChecked() &&
|
||||||
|
m_aircraft->ffTestBox2->isChecked() &&
|
||||||
|
m_aircraft->ffTestBox3->isChecked()) {
|
||||||
|
if (!ffTuningInProgress)
|
||||||
|
{
|
||||||
|
// Initiate tuning:
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
||||||
|
UAVObject::Metadata mdata = obj->getMetadata();
|
||||||
|
accInitialData = mdata;
|
||||||
|
mdata.flightAccess = UAVObject::ACCESS_READONLY;
|
||||||
|
obj->setMetadata(mdata);
|
||||||
|
}
|
||||||
|
// Depending on phase, either move actuator or send FF settings:
|
||||||
|
if (ffTuningPhase) {
|
||||||
|
// Send FF settings to the board
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
||||||
|
field->setDouble((double)m_aircraft->feedForwardSlider->value()/100);
|
||||||
|
field = obj->getField(QString("AccelTime"));
|
||||||
|
field->setDouble(m_aircraft->accelTime->value());
|
||||||
|
field = obj->getField(QString("DecelTime"));
|
||||||
|
field->setDouble(m_aircraft->decelTime->value());
|
||||||
|
field = obj->getField(QString("MaxAccel"));
|
||||||
|
field->setDouble(m_aircraft->maxAccelSlider->value());
|
||||||
|
obj->updated();
|
||||||
|
} else {
|
||||||
|
// Toggle motor state
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
||||||
|
double value = obj->getField("Throttle")->getDouble();
|
||||||
|
double target = (value < 0.5) ? 0.55 : 0.45;
|
||||||
|
obj->getField("Throttle")->setValue(target);
|
||||||
|
obj->updated();
|
||||||
|
}
|
||||||
|
ffTuningPhase = !ffTuningPhase;
|
||||||
|
ffTuningInProgress = true;
|
||||||
|
QTimer::singleShot(1000, this, SLOT(enableFFTest()));
|
||||||
|
} else {
|
||||||
|
// - If no: disarm timer, restore actuatorcommand metadata
|
||||||
|
// Disarm!
|
||||||
|
if (ffTuningInProgress) {
|
||||||
|
ffTuningInProgress = false;
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ManualControlCommand")));
|
||||||
|
UAVObject::Metadata mdata = obj->getMetadata();
|
||||||
|
mdata = accInitialData; // Restore metadata
|
||||||
|
obj->setMetadata(mdata);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets Fixed wing throttle mixer
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetFwMixer()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||||
|
resetMixer(m_aircraft->fixedWingThrottle, field->getNumElements(),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets Multirotor throttle mixer
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetMrMixer()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||||
|
resetMixer(m_aircraft->multiThrottleCurve, field->getNumElements(),0.9);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets Ground vehicle front throttle mixer
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetGvFrontMixer()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||||
|
resetMixer(m_aircraft->groundVehicleThrottle1, field->getNumElements(),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets Ground vehicle rear throttle mixer
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetGvRearMixer()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve2"));
|
||||||
|
resetMixer(m_aircraft->groundVehicleThrottle2, field->getNumElements(),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets Custom throttle 1 mixer
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetCt1Mixer()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||||
|
resetMixer(m_aircraft->customThrottle1Curve, field->getNumElements(),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets Custom throttle 2 mixer
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetCt2Mixer()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve2"));
|
||||||
|
resetMixer(m_aircraft->customThrottle2Curve, field->getNumElements(),1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Resets a mixer curve
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetMixer(MixerCurveWidget *mixer, int numElements, double maxvalue)
|
||||||
|
{
|
||||||
|
// Setup all Throttle1 curves for all types of airframes
|
||||||
|
mixer->initLinearCurve((quint32)numElements,maxvalue);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the currently moved fixed wing throttle curve item value
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateFwThrottleCurveValue(QList<double> list, double value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(list);
|
||||||
|
m_aircraft->fwThrottleCurveItemValue->setText(QString().sprintf("Val: %.2f",value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the currently moved multi-rotor throttle curve item value
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateMrThrottleCurveValue(QList<double> list, double value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(list);
|
||||||
|
m_aircraft->mrThrottleCurveItemValue->setText(QString().sprintf("Val: %.2f",value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the moved ground vehicle front throttle curve item value
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateGvThrottle1CurveValue(QList<double> list, double value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(list);
|
||||||
|
m_aircraft->gvThrottleCurve1ItemValue->setText(QString().sprintf("Val: %.2f",value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the moved ground vehicle rear throttle curve item value
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateGvThrottle2CurveValue(QList<double> list, double value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(list);
|
||||||
|
m_aircraft->gvThrottleCurve2ItemValue->setText(QString().sprintf("Val: %.2f",value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the currently moved custom throttle curve item value (Custom throttle 1)
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateCustomThrottle1CurveValue(QList<double> list, double value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(list);
|
||||||
|
m_aircraft->customThrottleCurve1Value->setText(QString().sprintf("Val: %.2f",value));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the currently moved custom throttle curve item value (Custom throttle 2)
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateCustomThrottle2CurveValue(QList<double> list, double value)
|
||||||
|
{
|
||||||
|
Q_UNUSED(list);
|
||||||
|
m_aircraft->customThrottleCurve2Value->setText(QString().sprintf("Val: %.2f",value));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**************************
|
||||||
|
* Aircraft settings
|
||||||
|
**************************/
|
||||||
|
/**
|
||||||
|
Refreshes the current value of the SystemSettings which holds the aircraft type
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::refreshWidgetsValues()
|
||||||
|
{
|
||||||
|
if(!allObjectsUpdated())
|
||||||
|
return;
|
||||||
|
|
||||||
|
//WHAT DOES THIS DO?
|
||||||
|
bool dirty=isDirty(); //WHY IS THIS CALLED HERE AND THEN AGAIN SEVERAL LINES LATER IN setupAirframeUI()
|
||||||
|
|
||||||
|
// Get the Airframe type from the system settings:
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
UAVObjectField *field = obj->getField(QString("AirframeType"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
// At this stage, we will need to have some hardcoded settings in this code, this
|
||||||
|
// is not ideal, but here you go.
|
||||||
|
QString frameType = field->getValue().toString();
|
||||||
|
setupAirframeUI(frameType);
|
||||||
|
|
||||||
|
obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
field = obj->getField(QString("ThrottleCurve1"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
QList<double> curveValues;
|
||||||
|
// If the 1st element of the curve is <= -10, then the curve
|
||||||
|
// is a straight line (that's how the mixer works on the mainboard):
|
||||||
|
if (field->getValue(0).toInt() <= -10) {
|
||||||
|
m_aircraft->multiThrottleCurve->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
m_aircraft->fixedWingThrottle->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
m_aircraft->groundVehicleThrottle1->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
double temp=0;
|
||||||
|
double value;
|
||||||
|
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||||
|
value=field->getValue(i).toDouble();
|
||||||
|
temp+=value;
|
||||||
|
curveValues.append(value);
|
||||||
|
}
|
||||||
|
if(temp==0)
|
||||||
|
{
|
||||||
|
m_aircraft->multiThrottleCurve->initLinearCurve(field->getNumElements(),0.9);
|
||||||
|
m_aircraft->fixedWingThrottle->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
m_aircraft->groundVehicleThrottle1->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_aircraft->multiThrottleCurve->initCurve(curveValues);
|
||||||
|
m_aircraft->fixedWingThrottle->initCurve(curveValues);
|
||||||
|
m_aircraft->groundVehicleThrottle1->initCurve(curveValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Setup all Throttle2 curves for all types of airframes //AT THIS MOMENT, THAT MEANS ONLY GROUND VEHICLES
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
field = obj->getField(QString("ThrottleCurve2"));
|
||||||
|
Q_ASSERT(field);
|
||||||
|
curveValues.clear();
|
||||||
|
// If the 1st element of the curve is <= -10, then the curve
|
||||||
|
// is a straight line (that's how the mixer works on the mainboard):
|
||||||
|
if (field->getValue(0).toInt() <= -10) {
|
||||||
|
m_aircraft->groundVehicleThrottle2->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
double temp=0;
|
||||||
|
double value;
|
||||||
|
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||||
|
value=field->getValue(i).toDouble();
|
||||||
|
temp+=value;
|
||||||
|
curveValues.append(value);
|
||||||
|
}
|
||||||
|
if(temp==0)
|
||||||
|
{
|
||||||
|
m_aircraft->groundVehicleThrottle2->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_aircraft->groundVehicleThrottle2->initCurve(curveValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the Settings for fixed wing frames:
|
||||||
|
if (frameType.startsWith("FixedWing")) {
|
||||||
|
|
||||||
|
// Retrieve fixed wing settings
|
||||||
|
refreshFixedWingWidgetsValues(frameType);
|
||||||
|
|
||||||
|
} else if (frameType == "Tri" ||
|
||||||
|
frameType == "QuadX" || frameType == "QuadP" ||
|
||||||
|
frameType == "Hexa" || frameType == "HexaCoax" || frameType == "HexaX" ||
|
||||||
|
frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP" || frameType == "OctoCoaxX" ) {
|
||||||
|
|
||||||
|
// Retrieve multirotor settings
|
||||||
|
refreshMultiRotorWidgetsValues(frameType);
|
||||||
|
} else if (frameType == "HeliCP") {
|
||||||
|
m_aircraft->widget_3->requestccpmUpdate();
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Helicopter"));//"Helicopter"
|
||||||
|
} else if (frameType.startsWith("GroundVehicle")) {
|
||||||
|
|
||||||
|
// Retrieve ground vehicle settings
|
||||||
|
refreshGroundVehicleWidgetsValues(frameType);
|
||||||
|
|
||||||
|
} else if (frameType == "Custom") {
|
||||||
|
m_aircraft->aircraftType->setCurrentIndex(m_aircraft->aircraftType->findText("Custom"));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
updateCustomAirframeUI();
|
||||||
|
setDirty(dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
\brief Sets up the mixer depending on Airframe type. Accepts either system settings or
|
||||||
|
combo box entry from airframe type, as those do not overlap.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType)
|
||||||
|
{
|
||||||
|
|
||||||
|
bool dirty=isDirty();
|
||||||
|
if(frameType == "FixedWing" || frameType == "Elevator aileron rudder" ||
|
||||||
|
frameType == "FixedWingElevon" || frameType == "Elevon" ||
|
||||||
|
frameType == "FixedWingVtail" || frameType == "Vtail"){
|
||||||
|
setupFixedWingUI(frameType);
|
||||||
|
} else if (frameType == "Tri" || frameType == "Tricopter Y" ||
|
||||||
|
frameType == "QuadX" || frameType == "Quad X" ||
|
||||||
|
frameType == "QuadP" || frameType == "Quad +" ||
|
||||||
|
frameType == "Hexa" || frameType == "Hexacopter" ||
|
||||||
|
frameType == "HexaX" || frameType == "Hexacopter X" ||
|
||||||
|
frameType == "HexaCoax" || frameType == "Hexacopter Y6" ||
|
||||||
|
frameType == "Octo" || frameType == "Octocopter" ||
|
||||||
|
frameType == "OctoV" || frameType == "Octocopter V" ||
|
||||||
|
frameType == "OctoCoaxP" || frameType == "Octo Coax +" ) {
|
||||||
|
|
||||||
|
//Call multi-rotor setup UI
|
||||||
|
setupMultiRotorUI(frameType);
|
||||||
|
}
|
||||||
|
else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" ||
|
||||||
|
frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" ||
|
||||||
|
frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") {
|
||||||
|
setupGroundVehicleUI(frameType);
|
||||||
|
}
|
||||||
|
|
||||||
|
//SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST???
|
||||||
|
m_aircraft->quadShape->setSceneRect(quad->boundingRect());
|
||||||
|
m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio);
|
||||||
|
|
||||||
|
setDirty(dirty);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset the contents of a field
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetField(UAVObjectField * field)
|
||||||
|
{
|
||||||
|
for (unsigned int i=0;i<field->getNumElements();i++) {
|
||||||
|
field->setValue(0,i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Reset actuator values
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::resetActuators()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("ActuatorSettings")));
|
||||||
|
Q_ASSERT(obj);
|
||||||
|
QList<UAVObjectField*> fieldList = obj->getFields();
|
||||||
|
// Reset all assignements first:
|
||||||
|
foreach (UAVObjectField* field, fieldList) {
|
||||||
|
// NOTE: we assume that all options in ActuatorSettings are a channel assignement
|
||||||
|
// except for the options called "ChannelBoxXXX"
|
||||||
|
if (field->getUnits().contains("channel")) {
|
||||||
|
field->setValue(field->getOptions().last());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Updates the custom airframe settings based on the current airframe.
|
||||||
|
|
||||||
|
Note: does NOT ask for an object refresh itself!
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateCustomAirframeUI()
|
||||||
|
{
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("ThrottleCurve1"));
|
||||||
|
QList<double> curveValues;
|
||||||
|
// If the 1st element of the curve is <= -10, then the curve
|
||||||
|
// is a straight line (that's how the mixer works on the mainboard):
|
||||||
|
if (field->getValue(0).toInt() <= -10) {
|
||||||
|
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
} else {
|
||||||
|
double temp=0;
|
||||||
|
double value;
|
||||||
|
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||||
|
value=field->getValue(i).toDouble();
|
||||||
|
temp+=value;
|
||||||
|
curveValues.append(value);
|
||||||
|
}
|
||||||
|
if(temp==0)
|
||||||
|
m_aircraft->customThrottle1Curve->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
else
|
||||||
|
m_aircraft->customThrottle1Curve->initCurve(curveValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
field = obj->getField(QString("ThrottleCurve2"));
|
||||||
|
curveValues.clear();
|
||||||
|
// If the 1st element of the curve is <= -10, then the curve
|
||||||
|
// is a straight line (that's how the mixer works on the mainboard):
|
||||||
|
if (field->getValue(0).toInt() <= -10) {
|
||||||
|
m_aircraft->customThrottle2Curve->initLinearCurve(field->getNumElements(),(double)1);
|
||||||
|
} else {
|
||||||
|
for (unsigned int i=0; i < field->getNumElements(); i++) {
|
||||||
|
curveValues.append(field->getValue(i).toDouble());
|
||||||
|
}
|
||||||
|
m_aircraft->customThrottle2Curve->initCurve(curveValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the table:
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
field = obj->getField(mixerTypes.at(i));
|
||||||
|
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
||||||
|
QString s = field->getValue().toString();
|
||||||
|
q->setCurrentIndex(q->findText(s));
|
||||||
|
//bool en = (s != "Disabled");
|
||||||
|
field = obj->getField(mixerVectors.at(i));
|
||||||
|
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
m_aircraft->customMixerTable->item(1,i)->setText(field->getValue(ti).toString());
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||||
|
m_aircraft->customMixerTable->item(2,i)->setText(field->getValue(ti).toString());
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
m_aircraft->customMixerTable->item(3,i)->setText(field->getValue(ti).toString());
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
m_aircraft->customMixerTable->item(4,i)->setText(field->getValue(ti).toString());
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
m_aircraft->customMixerTable->item(5,i)->setText(field->getValue(ti).toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
Sends the config to the board (airframe type)
|
||||||
|
|
||||||
|
We do all the tasks common to all airframes, or family of airframes, and
|
||||||
|
we call additional methods for specific frames, so that we do not have a code
|
||||||
|
that is too heavy.
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::updateObjectsFromWidgets()
|
||||||
|
{
|
||||||
|
qDebug()<<"updateObjectsFromWidgets";
|
||||||
|
QString airframeType = "Custom"; //Sets airframe type default to "Custom"
|
||||||
|
if (m_aircraft->aircraftType->currentText() == "Fixed Wing") {
|
||||||
|
airframeType = updateFixedWingObjectsFromWidgets();
|
||||||
|
} else if (m_aircraft->aircraftType->currentText() == "Multirotor") {
|
||||||
|
//update the mixer
|
||||||
|
airframeType = updateMultiRotorObjectsFromWidgets();
|
||||||
|
} else if (m_aircraft->aircraftType->currentText() == "Helicopter") {
|
||||||
|
airframeType = "HeliCP";
|
||||||
|
m_aircraft->widget_3->sendccpmUpdate();
|
||||||
|
} else if (m_aircraft->aircraftType->currentText() == "Ground") {
|
||||||
|
airframeType = updateGroundVehicleObjectsFromWidgets();
|
||||||
|
} else {
|
||||||
|
airframeType = "Custom";
|
||||||
|
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("MixerSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("FeedForward"));
|
||||||
|
|
||||||
|
// Curve is also common to all quads:
|
||||||
|
field = obj->getField("ThrottleCurve1");
|
||||||
|
QList<double> curve = m_aircraft->customThrottle1Curve->getCurve();
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
|
||||||
|
field = obj->getField("ThrottleCurve2");
|
||||||
|
curve.clear();
|
||||||
|
curve = m_aircraft->customThrottle2Curve->getCurve();
|
||||||
|
for (int i=0;i<curve.length();i++) {
|
||||||
|
field->setValue(curve.at(i),i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the table:
|
||||||
|
for (int i=0; i<8; i++) {
|
||||||
|
field = obj->getField(mixerTypes.at(i));
|
||||||
|
QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,i);
|
||||||
|
field->setValue(q->currentText());
|
||||||
|
field = obj->getField(mixerVectors.at(i));
|
||||||
|
int ti = field->getElementNames().indexOf("ThrottleCurve1");
|
||||||
|
field->setValue(m_aircraft->customMixerTable->item(1,i)->text(),ti);
|
||||||
|
ti = field->getElementNames().indexOf("ThrottleCurve2");
|
||||||
|
field->setValue(m_aircraft->customMixerTable->item(2,i)->text(),ti);
|
||||||
|
ti = field->getElementNames().indexOf("Roll");
|
||||||
|
field->setValue(m_aircraft->customMixerTable->item(3,i)->text(),ti);
|
||||||
|
ti = field->getElementNames().indexOf("Pitch");
|
||||||
|
field->setValue(m_aircraft->customMixerTable->item(4,i)->text(),ti);
|
||||||
|
ti = field->getElementNames().indexOf("Yaw");
|
||||||
|
field->setValue(m_aircraft->customMixerTable->item(5,i)->text(),ti);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//WHAT DOES THIS DO?
|
||||||
|
UAVDataObject* obj = dynamic_cast<UAVDataObject*>(getObjectManager()->getObject(QString("SystemSettings")));
|
||||||
|
UAVObjectField* field = obj->getField(QString("AirframeType"));
|
||||||
|
field->setValue(airframeType);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Opens the wiki from the user's default browser
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::openHelp()
|
||||||
|
{
|
||||||
|
|
||||||
|
QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/display/Doc/Airframe+configuration", QUrl::StrictMode) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
WHAT DOES THIS DO???
|
||||||
|
*/
|
||||||
|
void ConfigVehicleTypeWidget::addToDirtyMonitor()
|
||||||
|
{
|
||||||
|
addWidget(m_aircraft->customMixerTable);
|
||||||
|
addWidget(m_aircraft->customThrottle1Curve);
|
||||||
|
addWidget(m_aircraft->customThrottle2Curve);
|
||||||
|
addWidget(m_aircraft->multiThrottleCurve);
|
||||||
|
addWidget(m_aircraft->fixedWingThrottle);
|
||||||
|
addWidget(m_aircraft->fixedWingType);
|
||||||
|
addWidget(m_aircraft->groundVehicleThrottle1);
|
||||||
|
addWidget(m_aircraft->groundVehicleThrottle2);
|
||||||
|
addWidget(m_aircraft->groundVehicleType);
|
||||||
|
addWidget(m_aircraft->feedForwardSlider);
|
||||||
|
addWidget(m_aircraft->accelTime);
|
||||||
|
addWidget(m_aircraft->decelTime);
|
||||||
|
addWidget(m_aircraft->maxAccelSlider);
|
||||||
|
addWidget(m_aircraft->multirotorFrameType);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox1);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox2);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox3);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox4);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox5);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox6);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox7);
|
||||||
|
addWidget(m_aircraft->multiMotorChannelBox8);
|
||||||
|
addWidget(m_aircraft->triYawChannelBox);
|
||||||
|
addWidget(m_aircraft->aircraftType);
|
||||||
|
addWidget(m_aircraft->fwEngineChannelBox);
|
||||||
|
addWidget(m_aircraft->fwAileron1ChannelBox);
|
||||||
|
addWidget(m_aircraft->fwAileron2ChannelBox);
|
||||||
|
addWidget(m_aircraft->fwElevator1ChannelBox);
|
||||||
|
addWidget(m_aircraft->fwElevator2ChannelBox);
|
||||||
|
addWidget(m_aircraft->fwRudder1ChannelBox);
|
||||||
|
addWidget(m_aircraft->fwRudder2ChannelBox);
|
||||||
|
addWidget(m_aircraft->elevonSlider1);
|
||||||
|
addWidget(m_aircraft->elevonSlider2);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmType);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmTailChannel);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmEngineChannel);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoWChannel);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoXChannel);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoYChannel);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmSingleServo);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmServoZChannel);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleW);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleX);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCorrectionAngle);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleZ);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAngleY);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivePassthrough);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkRoll);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmLinkCyclic);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRevoSlider);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmREVOspinBox);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveSlider);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectivespinBox);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScale);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCollectiveScaleBox);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmCyclicScale);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScale);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmPitchScaleBox);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScale);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmRollScaleBox);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSlider);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->SwashLvlPositionSpinBox);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->CurveType);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->NumCurvePoints);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue1);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue2);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->CurveValue3);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->CurveToGenerate);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->CurveSettings);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ThrottleCurve);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->PitchCurve);
|
||||||
|
addWidget(m_aircraft->widget_3->m_ccpm->ccpmAdvancedSettingsTable);
|
||||||
|
}
|
||||||
|
|
@ -2,7 +2,7 @@
|
|||||||
******************************************************************************
|
******************************************************************************
|
||||||
*
|
*
|
||||||
* @file configairframetwidget.h
|
* @file configairframetwidget.h
|
||||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
|
||||||
* @addtogroup GCSPlugins GCS Plugins
|
* @addtogroup GCSPlugins GCS Plugins
|
||||||
* @{
|
* @{
|
||||||
* @addtogroup ConfigPlugin Config Plugin
|
* @addtogroup ConfigPlugin Config Plugin
|
||||||
@ -24,8 +24,8 @@
|
|||||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
#ifndef CONFIGAIRFRAMEWIDGET_H
|
#ifndef CONFIGVEHICLETYPEWIDGET_H
|
||||||
#define CONFIGAIRFRAMEWIDGET_H
|
#define CONFIGVEHICLETYPEWIDGET_H
|
||||||
|
|
||||||
#include "ui_airframe.h"
|
#include "ui_airframe.h"
|
||||||
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
#include "../uavobjectwidgetutils/configtaskwidget.h"
|
||||||
@ -39,24 +39,27 @@
|
|||||||
|
|
||||||
class Ui_Widget;
|
class Ui_Widget;
|
||||||
|
|
||||||
class ConfigAirframeWidget: public ConfigTaskWidget
|
class ConfigVehicleTypeWidget: public ConfigTaskWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ConfigAirframeWidget(QWidget *parent = 0);
|
ConfigVehicleTypeWidget(QWidget *parent = 0);
|
||||||
~ConfigAirframeWidget();
|
~ConfigVehicleTypeWidget();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_AircraftWidget *m_aircraft;
|
Ui_AircraftWidget *m_aircraft;
|
||||||
bool setupFrameFixedWing();
|
bool setupFrameFixedWing(QString airframeType);
|
||||||
bool setupFrameElevon();
|
bool setupFrameElevon(QString airframeType);
|
||||||
bool setupFrameVtail();
|
bool setupFrameVtail(QString airframeType);
|
||||||
bool setupQuad(bool pLayout);
|
bool setupQuad(bool pLayout);
|
||||||
bool setupHexa(bool pLayout);
|
bool setupHexa(bool pLayout);
|
||||||
bool setupOcto();
|
bool setupOcto();
|
||||||
|
bool setupGroundVehicleCar(QString airframeType);
|
||||||
|
bool setupGroundVehicleDifferential(QString airframeType);
|
||||||
|
bool setupGroundVehicleMotorcycle(QString airframeType);
|
||||||
void updateCustomAirframeUI();
|
void updateCustomAirframeUI();
|
||||||
bool setupMixer(double mixerFactors[8][3]);
|
bool setupMultiRotorMixer(double mixerFactors[8][3]);
|
||||||
void setupMotors(QList<QString> motorList);
|
void setupMotors(QList<QString> motorList);
|
||||||
void addToDirtyMonitor();
|
void addToDirtyMonitor();
|
||||||
void resetField(UAVObjectField * field);
|
void resetField(UAVObjectField * field);
|
||||||
@ -74,19 +77,39 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
virtual void refreshWidgetsValues();
|
virtual void refreshWidgetsValues();
|
||||||
|
void refreshFixedWingWidgetsValues(QString frameType);
|
||||||
|
void refreshMultiRotorWidgetsValues(QString frameType);
|
||||||
|
void refreshGroundVehicleWidgetsValues(QString frameType);
|
||||||
|
|
||||||
void updateObjectsFromWidgets();
|
void updateObjectsFromWidgets();
|
||||||
|
QString updateFixedWingObjectsFromWidgets();
|
||||||
|
QString updateMultiRotorObjectsFromWidgets();
|
||||||
|
QString updateGroundVehicleObjectsFromWidgets();
|
||||||
// void saveAircraftUpdate();
|
// void saveAircraftUpdate();
|
||||||
|
|
||||||
void setupAirframeUI(QString type);
|
void setupAirframeUI(QString type);
|
||||||
|
void setupFixedWingUI(QString frameType);
|
||||||
|
void setupMultiRotorUI(QString frameType);
|
||||||
|
void setupGroundVehicleUI(QString frameType);
|
||||||
|
|
||||||
|
void throwMultiRotorChannelConfigError(int numMotors);
|
||||||
|
void throwFixedWingChannelConfigError(QString airframeType);
|
||||||
|
void throwGroundVehicleChannelConfigError(QString airframeType);
|
||||||
|
|
||||||
void toggleAileron2(int index);
|
void toggleAileron2(int index);
|
||||||
void toggleElevator2(int index);
|
void toggleElevator2(int index);
|
||||||
void toggleRudder2(int index);
|
void toggleRudder2(int index);
|
||||||
void switchAirframeType(int index);
|
void switchAirframeType(int index);
|
||||||
void resetFwMixer();
|
void resetFwMixer();
|
||||||
void resetMrMixer();
|
void resetMrMixer();
|
||||||
|
void resetGvFrontMixer();
|
||||||
|
void resetGvRearMixer();
|
||||||
void resetCt1Mixer();
|
void resetCt1Mixer();
|
||||||
void resetCt2Mixer();
|
void resetCt2Mixer();
|
||||||
void updateFwThrottleCurveValue(QList<double> list, double value);
|
void updateFwThrottleCurveValue(QList<double> list, double value);
|
||||||
void updateMrThrottleCurveValue(QList<double> list, double value);
|
void updateMrThrottleCurveValue(QList<double> list, double value);
|
||||||
|
void updateGvThrottle1CurveValue(QList<double> list, double value);
|
||||||
|
void updateGvThrottle2CurveValue(QList<double> list, double value);
|
||||||
void updateCustomThrottle1CurveValue(QList<double> list, double value);
|
void updateCustomThrottle1CurveValue(QList<double> list, double value);
|
||||||
void updateCustomThrottle2CurveValue(QList<double> list, double value);
|
void updateCustomThrottle2CurveValue(QList<double> list, double value);
|
||||||
void enableFFTest();
|
void enableFFTest();
|
||||||
@ -117,4 +140,4 @@ public:
|
|||||||
const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONFIGAIRFRAMEWIDGET_H
|
#endif // CONFIGVEHICLETYPEWIDGET_H
|
@ -8,6 +8,8 @@ inputChannelForm::inputChannelForm(QWidget *parent,bool showlegend) :
|
|||||||
ui(new Ui::inputChannelForm)
|
ui(new Ui::inputChannelForm)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
|
//The first time through the loop, keep the legend. All other times, delete it.
|
||||||
if(!showlegend)
|
if(!showlegend)
|
||||||
{
|
{
|
||||||
layout()->removeWidget(ui->legend0);
|
layout()->removeWidget(ui->legend0);
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>80</width>
|
<width>80</width>
|
||||||
<height>0</height>
|
<height>25</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -53,6 +53,12 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>100</width>
|
<width>100</width>
|
||||||
@ -63,6 +69,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="4">
|
<item row="2" column="4">
|
||||||
<widget class="QSpinBox" name="channelMin">
|
<widget class="QSpinBox" name="channelMin">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="buttonSymbols">
|
<property name="buttonSymbols">
|
||||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -76,6 +88,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="2" column="8">
|
<item row="2" column="8">
|
||||||
<widget class="QSpinBox" name="channelMax">
|
<widget class="QSpinBox" name="channelMax">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="buttonSymbols">
|
<property name="buttonSymbols">
|
||||||
<enum>QAbstractSpinBox::NoButtons</enum>
|
<enum>QAbstractSpinBox::NoButtons</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -93,11 +111,17 @@
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -126,11 +150,17 @@ font:bold;</string>
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -159,11 +189,17 @@ font:bold;</string>
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -192,11 +228,17 @@ font:bold;</string>
|
|||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -227,6 +269,12 @@ font:bold;</string>
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>22</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -240,6 +288,12 @@ font:bold;</string>
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>25</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="maximumSize">
|
<property name="maximumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>80</width>
|
<width>80</width>
|
||||||
@ -269,6 +323,12 @@ font:bold;</string>
|
|||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Rev</string>
|
<string>Rev</string>
|
||||||
</property>
|
</property>
|
||||||
@ -277,14 +337,14 @@ font:bold;</string>
|
|||||||
<item row="2" column="9">
|
<item row="2" column="9">
|
||||||
<widget class="QLabel" name="neutral">
|
<widget class="QLabel" name="neutral">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>30</width>
|
<width>35</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@ -331,50 +391,23 @@ font:bold;</string>
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="3">
|
|
||||||
<widget class="QLabel" name="legend2">
|
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="font">
|
|
||||||
<font>
|
|
||||||
<weight>75</weight>
|
|
||||||
<italic>false</italic>
|
|
||||||
<bold>true</bold>
|
|
||||||
</font>
|
|
||||||
</property>
|
|
||||||
<property name="styleSheet">
|
|
||||||
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
border-radius: 5;
|
|
||||||
margin:5px;
|
|
||||||
font:bold;</string>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Number</string>
|
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignCenter</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="2">
|
<item row="0" column="2">
|
||||||
<widget class="QLabel" name="legend1">
|
<widget class="QLabel" name="legend1">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@ -397,6 +430,45 @@ font:bold;</string>
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QLabel" name="legend2">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>26</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<weight>75</weight>
|
||||||
|
<italic>false</italic>
|
||||||
|
<bold>true</bold>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255));
|
||||||
|
color: rgb(255, 255, 255);
|
||||||
|
border-radius: 5;
|
||||||
|
margin:5px;
|
||||||
|
font:bold;</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Number</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
@ -16,6 +16,10 @@
|
|||||||
<field name="VTOLMotorSW" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
<field name="VTOLMotorSW" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
<field name="VTOLMotorW" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
<field name="VTOLMotorW" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
<field name="VTOLMotorNW" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
<field name="VTOLMotorNW" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
|
<field name="GroundVehicleThrottle1" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
|
<field name="GroundVehicleThrottle2" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
|
<field name="GroundVehicleSteering1" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
|
<field name="GroundVehicleSteering2" units="channel" type="enum" elements="1" options="Channel1,Channel2,Channel3,Channel4,Channel5,Channel6,Channel7,Channel8,Channel9,Channel10,None" defaultvalue="None"/>
|
||||||
<field name="ChannelUpdateFreq" units="Hz" type="uint16" elements="4" defaultvalue="50"/>
|
<field name="ChannelUpdateFreq" units="Hz" type="uint16" elements="4" defaultvalue="50"/>
|
||||||
<field name="ChannelMax" units="us" type="int16" elements="10" defaultvalue="1000"/>
|
<field name="ChannelMax" units="us" type="int16" elements="10" defaultvalue="1000"/>
|
||||||
<field name="ChannelNeutral" units="us" type="int16" elements="10" defaultvalue="1000"/>
|
<field name="ChannelNeutral" units="us" type="int16" elements="10" defaultvalue="1000"/>
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
<field name="Mixer6" units="" type="float" elements="1"/>
|
<field name="Mixer6" units="" type="float" elements="1"/>
|
||||||
<field name="Mixer7" units="" type="float" elements="1"/>
|
<field name="Mixer7" units="" type="float" elements="1"/>
|
||||||
<field name="Mixer8" units="" type="float" elements="1"/>
|
<field name="Mixer8" units="" type="float" elements="1"/>
|
||||||
|
<field name="Mixer9" units="" type="float" elements="1"/>
|
||||||
|
<field name="Mixer10" units="" type="float" elements="1"/>
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<xml>
|
<xml>
|
||||||
<object name="SystemSettings" singleinstance="true" settings="true">
|
<object name="SystemSettings" singleinstance="true" settings="true">
|
||||||
<description>Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand</description>
|
<description>Select airframe type. Currently used by @ref ActuatorModule to choose mixing from @ref ActuatorDesired to @ref ActuatorCommand</description>
|
||||||
<field name="AirframeType" units="" type="enum" elements="1" options="FixedWing,FixedWingElevon,FixedWingVtail,VTOL,HeliCP,QuadX,QuadP,Hexa,Octo,Custom,HexaX,OctoV,OctoCoaxP,OctoCoaxX,HexaCoax,Tri" defaultvalue="FixedWing"/>
|
<field name="AirframeType" units="" type="enum" elements="1" options="FixedWing,FixedWingElevon,FixedWingVtail,VTOL,HeliCP,QuadX,QuadP,Hexa,Octo,Custom,HexaX,OctoV,OctoCoaxP,OctoCoaxX,HexaCoax,Tri,GroundVehicleCar,GroundVehicleDifferential,GroundVehicleMotorcycle" defaultvalue="FixedWing"/>
|
||||||
<field name="GUIConfigData" units="bits" type="uint32" elements="2" defaultvalue="0"/>
|
<field name="GUIConfigData" units="bits" type="uint32" elements="2" defaultvalue="0"/>
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user