From dcd64a5c4551048299f9f226dfcafe67d3ceb07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Thu, 28 Jan 2021 14:23:02 +0100 Subject: [PATCH] pid tuning: add vtol --- src/AutoPilotPlugins/PX4/PX4TuningComponent.cc | 18 +---- .../PX4/PX4TuningComponentCopter.qml | 42 +----------- .../PX4/PX4TuningComponentCopterAll.qml | 57 ++++++++++++++++ .../PX4/PX4TuningComponentPlane.qml | 30 +------- .../PX4/PX4TuningComponentPlaneAll.qml | 45 ++++++++++++ .../PX4/PX4TuningComponentVTOL.qml | 79 ++++++++-------------- src/FirmwarePlugin/PX4/PX4Resources.qrc | 2 + 7 files changed, 134 insertions(+), 139 deletions(-) create mode 100644 src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml create mode 100644 src/AutoPilotPlugins/PX4/PX4TuningComponentPlaneAll.qml diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc index 70329c7..1bc63b5 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc @@ -12,25 +12,9 @@ #include "PX4AutoPilotPlugin.h" #include "AirframeComponent.h" -static bool isCopterOrFW(MAV_TYPE type) { - switch (type) { - case MAV_TYPE_FIXED_WING: - case MAV_TYPE_QUADROTOR: - case MAV_TYPE_COAXIAL: - case MAV_TYPE_HELICOPTER: - case MAV_TYPE_HEXAROTOR: - case MAV_TYPE_OCTOROTOR: - case MAV_TYPE_TRICOPTER: - return true; - default: - break; - } - return false; -} - PX4TuningComponent::PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : VehicleComponent(vehicle, autopilot, parent) - , _name(isCopterOrFW(vehicle->vehicleType()) ? tr("PID Tuning") : tr("Tuning")) + , _name(tr("PID Tuning")) { } diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml index 4dcb842..dfa8ae0 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml @@ -9,14 +9,10 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 -import QtCharts 2.2 import QtQuick.Layouts 1.2 import QGroundControl 1.0 import QGroundControl.Controls 1.0 -import QGroundControl.FactSystem 1.0 -import QGroundControl.FactControls 1.0 -import QGroundControl.ScreenTools 1.0 SetupPage { id: tuningPage @@ -25,43 +21,7 @@ SetupPage { Component { id: pageComponent - Item { - width: availableWidth - - FactPanelController { - id: controller - } - - QGCTabBar { - id: bar - width: parent.width - anchors.top: parent.top - QGCTabButton { - text: qsTr("Rate Controller") - } - QGCTabButton { - text: qsTr("Attitude Controller") - } - QGCTabButton { - text: qsTr("Velocity Controller") - } - QGCTabButton { - text: qsTr("Position Controller") - } - } - - property var pages: [ - "PX4TuningComponentCopterRate.qml", - "PX4TuningComponentCopterAttitude.qml", - "PX4TuningComponentCopterVelocity.qml", - "PX4TuningComponentCopterPosition.qml" - ] - - Loader { - source: pages[bar.currentIndex] - width: parent.width - anchors.top: bar.bottom - } + PX4TuningComponentCopterAll { } } // Component - pageComponent } // SetupPage diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml new file mode 100644 index 0000000..bb6ef3e --- /dev/null +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml @@ -0,0 +1,57 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.ScreenTools 1.0 + +Item { + width: availableWidth + + FactPanelController { + id: controller + } + + QGCTabBar { + id: bar + width: parent.width + anchors.top: parent.top + QGCTabButton { + text: qsTr("Rate Controller") + } + QGCTabButton { + text: qsTr("Attitude Controller") + } + QGCTabButton { + text: qsTr("Velocity Controller") + } + QGCTabButton { + text: qsTr("Position Controller") + } + } + + property var pages: [ + "PX4TuningComponentCopterRate.qml", + "PX4TuningComponentCopterAttitude.qml", + "PX4TuningComponentCopterVelocity.qml", + "PX4TuningComponentCopterPosition.qml" + ] + + Loader { + source: pages[bar.currentIndex] + width: parent.width + anchors.top: bar.bottom + anchors.topMargin: ScreenTools.defaultFontPixelWidth + } +} diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml index 3f5af2b..8b57ec4 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml @@ -9,14 +9,10 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 -import QtCharts 2.2 import QtQuick.Layouts 1.2 import QGroundControl 1.0 import QGroundControl.Controls 1.0 -import QGroundControl.FactSystem 1.0 -import QGroundControl.FactControls 1.0 -import QGroundControl.ScreenTools 1.0 SetupPage { id: tuningPage @@ -25,31 +21,7 @@ SetupPage { Component { id: pageComponent - Item { - width: availableWidth - - FactPanelController { - id: controller - } - - QGCTabBar { - id: bar - width: parent.width - anchors.top: parent.top - QGCTabButton { - text: qsTr("TECS") - } - } - - property var pages: [ - "PX4TuningComponentPlaneTECS.qml", - ] - - Loader { - source: pages[bar.currentIndex] - width: parent.width - anchors.top: bar.bottom - } + PX4TuningComponentPlaneAll { } } // Component - pageComponent } // SetupPage diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlaneAll.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlaneAll.qml new file mode 100644 index 0000000..3cc9e4f --- /dev/null +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlaneAll.qml @@ -0,0 +1,45 @@ +/**************************************************************************** + * + * (c) 2009-2020 QGROUNDCONTROL PROJECT + * + * QGroundControl is licensed according to the terms in the file + * COPYING.md in the root of the source code directory. + * + ****************************************************************************/ + +import QtQuick 2.3 +import QtQuick.Controls 1.2 +import QtQuick.Layouts 1.2 + +import QGroundControl 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.ScreenTools 1.0 + +Item { + width: availableWidth + + FactPanelController { + id: controller + } + + QGCTabBar { + id: bar + width: parent.width + anchors.top: parent.top + QGCTabButton { + text: qsTr("TECS") + } + } + + property var pages: [ + "PX4TuningComponentPlaneTECS.qml", + ] + + Loader { + source: pages[bar.currentIndex] + width: parent.width + anchors.top: bar.bottom + anchors.topMargin: ScreenTools.defaultFontPixelWidth + } +} diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml index 51dd03a..4e65646 100644 --- a/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml @@ -11,7 +11,9 @@ import QtQuick 2.3 import QtQuick.Controls 1.2 -import QGroundControl.Controls 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.FactSystem 1.0 +import QGroundControl.ScreenTools 1.0 SetupPage { id: tuningPage @@ -20,64 +22,37 @@ SetupPage { Component { id: pageComponent - FactSliderPanel { - width: availableWidth - sliderModel: ListModel { + Item { + width: availableWidth - ListElement { - title: qsTr("Plane Roll sensitivity") - description: qsTr("Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy.") - param: "FW_R_TC" - min: 0.2 - max: 0.8 - step: 0.01 - } + FactPanelController { + id: controller + } - ListElement { - title: qsTr("Plane Pitch sensitivity") - description: qsTr("Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy.") - param: "FW_P_TC" - min: 0.2 - max: 0.8 - step: 0.01 - } + QGCTabBar { + id: bar + width: parent.width + anchors.top: parent.top - ListElement { - title: qsTr("Plane Cruise throttle") - description: qsTr("This is the throttle setting required to achieve the desired cruise speed. Most planes need 50-60%.") - param: "FW_THR_CRUISE" - min: 20 - max: 80 - step: 1 + QGCTabButton { + text: qsTr("Multirotor") } - - ListElement { - title: qsTr("Hover Throttle") - description: qsTr("Adjust throttle so hover is at mid-throttle. Slide to the left if hover is lower than throttle center. Slide to the right if hover is higher than throttle center.") - param: "MPC_THR_HOVER" - min: 20 - max: 80 - step: 1 + QGCTabButton { + text: qsTr("Fixedwing") } + } - ListElement { - title: qsTr("Hover manual minimum throttle") - description: qsTr("Slide to the left to start the motors with less idle power. Slide to the right if descending in manual flight becomes unstable.") - param: "MPC_MANTHR_MIN" - min: 0 - max: 15 - step: 1 - } + property var pages: [ + "PX4TuningComponentCopterAll.qml", + "PX4TuningComponentPlaneAll.qml" + ] - ListElement { - title: qsTr("Plane Mission mode sensitivity") - description: qsTr("Slide to the left to make position control more accurate and more aggressive. Slide to the right to make flight in mission mode smoother and less twitchy.") - param: "FW_L1_PERIOD" - min: 12 - max: 50 - step: 0.5 - } + Loader { + source: pages[bar.currentIndex] + width: parent.width + anchors.top: bar.bottom + anchors.topMargin: ScreenTools.defaultFontPixelWidth } } - } + } // Component - pageComponent } diff --git a/src/FirmwarePlugin/PX4/PX4Resources.qrc b/src/FirmwarePlugin/PX4/PX4Resources.qrc index e556ba9..e83713a 100644 --- a/src/FirmwarePlugin/PX4/PX4Resources.qrc +++ b/src/FirmwarePlugin/PX4/PX4Resources.qrc @@ -13,11 +13,13 @@ ../../AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml ../../AutoPilotPlugins/PX4/PX4FlightBehaviorCopter.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml + ../../AutoPilotPlugins/PX4/PX4TuningComponentCopterAll.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentCopterAttitude.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentCopterRate.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentCopterVelocity.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentCopterPosition.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml + ../../AutoPilotPlugins/PX4/PX4TuningComponentPlaneAll.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentPlaneTECS.qml ../../AutoPilotPlugins/PX4/PX4TuningComponentVTOL.qml ../../AutoPilotPlugins/PX4/SafetyComponent.qml