diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 76b97c5b93e3abb750ab9fc9f565b397cd9fe213..2174a90cbca104795d9d5ead7645e20e90612192 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -586,6 +586,7 @@ HEADERS+= \ src/AutoPilotPlugins/PX4/SafetyComponent.h \ src/AutoPilotPlugins/PX4/SensorsComponent.h \ src/AutoPilotPlugins/PX4/SensorsComponentController.h \ + src/AutoPilotPlugins/PX4/PX4TuningComponent.h \ src/FirmwarePlugin/FirmwarePluginManager.h \ src/FirmwarePlugin/FirmwarePlugin.h \ src/FirmwarePlugin/APM/APMFirmwarePlugin.h \ @@ -642,6 +643,7 @@ SOURCES += \ src/AutoPilotPlugins/PX4/SafetyComponent.cc \ src/AutoPilotPlugins/PX4/SensorsComponent.cc \ src/AutoPilotPlugins/PX4/SensorsComponentController.cc \ + src/AutoPilotPlugins/PX4/PX4TuningComponent.cc \ src/FirmwarePlugin/APM/APMFirmwarePlugin.cc \ src/FirmwarePlugin/APM/APMParameterMetaData.cc \ src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 07ac0d0eb5a01070a3500bc45604c60bc0329ba6..cc590f610596fc0775227b213747a3b92459f5c4 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -75,6 +75,7 @@ src/QmlControls/VehicleRotationCal.qml src/QmlControls/VehicleSummaryRow.qml src/ViewWidgets/ViewWidget.qml + src/QmlControls/FactSliderPanel.qml src/FactSystem/FactControls/FactCheckBox.qml src/FactSystem/FactControls/FactComboBox.qml src/FactSystem/FactControls/FactLabel.qml @@ -105,6 +106,8 @@ src/QmlControls/QmlTest.qml src/AutoPilotPlugins/Common/RadioComponent.qml src/AutoPilotPlugins/PX4/PX4RadioComponentSummary.qml + src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml + src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml src/AutoPilotPlugins/APM/APMNotSupported.qml src/AutoPilotPlugins/APM/APMCameraComponent.qml src/AutoPilotPlugins/APM/APMCameraComponentSummary.qml @@ -118,8 +121,6 @@ src/AutoPilotPlugins/APM/APMSafetyComponentSummaryPlane.qml src/AutoPilotPlugins/APM/APMSafetyComponentSummaryRover.qml src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml - src/AutoPilotPlugins/APM/APMTuningComponentPlane.qml - src/AutoPilotPlugins/APM/APMTuningComponentRover.qml src/AutoPilotPlugins/PX4/SafetyComponent.qml src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml src/AutoPilotPlugins/PX4/SensorsComponent.qml diff --git a/src/AutoPilotPlugins/APM/APMTuningComponent.cc b/src/AutoPilotPlugins/APM/APMTuningComponent.cc index e8dfdcd6bae48c6f6519649b64ff5c0e2a4a0df0..5ee5f04594f146fe37db9ee07da46e0a39f93712 100644 --- a/src/AutoPilotPlugins/APM/APMTuningComponent.cc +++ b/src/AutoPilotPlugins/APM/APMTuningComponent.cc @@ -66,9 +66,6 @@ QUrl APMTuningComponent::setupSource(void) const QString qmlFile; switch (_vehicle->vehicleType()) { - case MAV_TYPE_FIXED_WING: - qmlFile = "qrc:/qml/APMTuningComponentPlane.qml"; - break; case MAV_TYPE_QUADROTOR: case MAV_TYPE_COAXIAL: case MAV_TYPE_HELICOPTER: @@ -77,11 +74,8 @@ QUrl APMTuningComponent::setupSource(void) const case MAV_TYPE_TRICOPTER: qmlFile = "qrc:/qml/APMTuningComponentCopter.qml"; break; - case MAV_TYPE_GROUND_ROVER: - qmlFile = "qrc:/qml/APMTuningComponentRover.qml"; - break; default: - qmlFile = "qrc:/qml/APMNotSupported.qml"; + // No tuning panel break; } diff --git a/src/AutoPilotPlugins/APM/APMTuningComponentPlane.qml b/src/AutoPilotPlugins/APM/APMTuningComponentPlane.qml deleted file mode 100644 index ace3b3a1d446a0f7f015bec81cb86672bca4e9aa..0000000000000000000000000000000000000000 --- a/src/AutoPilotPlugins/APM/APMTuningComponentPlane.qml +++ /dev/null @@ -1,33 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2015 QGROUNDCONTROL PROJECT - - This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL 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. - - QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . - - ======================================================================*/ - -import QtQuick 2.5 - -import QGroundControl.Controls 1.0 - -QGCLabel { - anchors.fill: parent - text: "Not supported" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter -} diff --git a/src/AutoPilotPlugins/APM/APMTuningComponentRover.qml b/src/AutoPilotPlugins/APM/APMTuningComponentRover.qml deleted file mode 100644 index ace3b3a1d446a0f7f015bec81cb86672bca4e9aa..0000000000000000000000000000000000000000 --- a/src/AutoPilotPlugins/APM/APMTuningComponentRover.qml +++ /dev/null @@ -1,33 +0,0 @@ -/*===================================================================== - - QGroundControl Open Source Ground Control Station - - (c) 2009 - 2015 QGROUNDCONTROL PROJECT - - This file is part of the QGROUNDCONTROL project - - QGROUNDCONTROL 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. - - QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . - - ======================================================================*/ - -import QtQuick 2.5 - -import QGroundControl.Controls 1.0 - -QGCLabel { - anchors.fill: parent - text: "Not supported" - horizontalAlignment: Text.AlignHCenter - verticalAlignment: Text.AlignVCenter -} diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc index 24bd16d6f7418ef2e8c1665dda16ca3ed71e75ab..10027db2c85ada20470ea3f2397224af02ac10c7 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc @@ -95,34 +95,32 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) if (parametersReady()) { _airframeComponent = new AirframeComponent(_vehicle, this); - Q_CHECK_PTR(_airframeComponent); _airframeComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); _radioComponent = new PX4RadioComponent(_vehicle, this); - Q_CHECK_PTR(_radioComponent); _radioComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_radioComponent)); _flightModesComponent = new FlightModesComponent(_vehicle, this); - Q_CHECK_PTR(_flightModesComponent); _flightModesComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent)); _sensorsComponent = new SensorsComponent(_vehicle, this); - Q_CHECK_PTR(_sensorsComponent); _sensorsComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent)); _powerComponent = new PowerComponent(_vehicle, this); - Q_CHECK_PTR(_powerComponent); _powerComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_powerComponent)); _safetyComponent = new SafetyComponent(_vehicle, this); - Q_CHECK_PTR(_safetyComponent); _safetyComponent->setupTriggerSignals(); _components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent)); + + _tuningComponent = new PX4TuningComponent(_vehicle, this); + _tuningComponent->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_tuningComponent)); } else { qWarning() << "Call to vehicleCompenents prior to parametersReady"; } diff --git a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h index ebc559fdd9f43c5e772bf057503c47567d125aac..db0b2d1129e06c989440c740ff1378a229b0ce0c 100644 --- a/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h +++ b/src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h @@ -32,6 +32,7 @@ #include "SensorsComponent.h" #include "SafetyComponent.h" #include "PowerComponent.h" +#include "PX4TuningComponent.h" #include "Vehicle.h" #include @@ -58,6 +59,7 @@ public: SensorsComponent* sensorsComponent(void) { return _sensorsComponent; } SafetyComponent* safetyComponent(void) { return _safetyComponent; } PowerComponent* powerComponent(void) { return _powerComponent; } + PX4TuningComponent* tuningComponent(void) { return _tuningComponent; } public slots: // FIXME: This is public until we restructure AutoPilotPlugin/FirmwarePlugin/Vehicle @@ -72,6 +74,7 @@ private: SensorsComponent* _sensorsComponent; SafetyComponent* _safetyComponent; PowerComponent* _powerComponent; + PX4TuningComponent* _tuningComponent; bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed }; diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc new file mode 100644 index 0000000000000000000000000000000000000000..36a2a60d95117d1207c0d376214d35f25b034d7e --- /dev/null +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponent.cc @@ -0,0 +1,103 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL 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. + + QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +#include "PX4TuningComponent.h" +#include "PX4AutoPilotPlugin.h" +#include "AirframeComponent.h" + +PX4TuningComponent::PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) + : PX4Component(vehicle, autopilot, parent) + , _name("Tuning") +{ +} + +QString PX4TuningComponent::name(void) const +{ + return _name; +} + +QString PX4TuningComponent::description(void) const +{ + return tr("The Tuning Component is used to tune the flight characteristics of the Vehicle."); +} + +QString PX4TuningComponent::iconResource(void) const +{ + return "/qmlimages/TuningComponentIcon.png"; +} + +bool PX4TuningComponent::requiresSetup(void) const +{ + return false; +} + +bool PX4TuningComponent::setupComplete(void) const +{ + return true; +} + +QStringList PX4TuningComponent::setupCompleteChangedTriggerList(void) const +{ + return QStringList(); +} + +QUrl PX4TuningComponent::setupSource(void) const +{ + QString qmlFile; + + switch (_vehicle->vehicleType()) { + case MAV_TYPE_FIXED_WING: + qmlFile = "qrc:/qml/PX4TuningComponentPlane.qml"; + break; + case MAV_TYPE_QUADROTOR: + case MAV_TYPE_COAXIAL: + case MAV_TYPE_HELICOPTER: + case MAV_TYPE_HEXAROTOR: + case MAV_TYPE_OCTOROTOR: + case MAV_TYPE_TRICOPTER: + qmlFile = "qrc:/qml/PX4TuningComponentCopter.qml"; + break; + default: + break; + } + + return QUrl::fromUserInput(qmlFile); +} + +QUrl PX4TuningComponent::summaryQmlSource(void) const +{ + return QUrl(); +} + +QString PX4TuningComponent::prerequisiteSetup(void) const +{ + PX4AutoPilotPlugin* plugin = dynamic_cast(_autopilot); + if (plugin) { + if (!plugin->airframeComponent()->setupComplete()) { + return plugin->airframeComponent()->name(); + } + } + + qWarning() << "Internal error: plugin cast failed"; + return QString(); +} diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponent.h b/src/AutoPilotPlugins/PX4/PX4TuningComponent.h new file mode 100644 index 0000000000000000000000000000000000000000..a86a65abe6c149f0575696452f1e9febe51c2e93 --- /dev/null +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponent.h @@ -0,0 +1,53 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2014 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL 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. + + QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +#ifndef PX4TuningComponent_H +#define PX4TuningComponent_H + +#include "PX4Component.h" + +class PX4TuningComponent : public PX4Component +{ + Q_OBJECT + +public: + PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL); + + // Virtuals from PX4Component + virtual QStringList setupCompleteChangedTriggerList(void) const; + + // Virtuals from VehicleComponent + virtual QString name(void) const; + virtual QString description(void) const; + virtual QString iconResource(void) const; + virtual bool requiresSetup(void) const; + virtual bool setupComplete(void) const; + virtual QUrl setupSource(void) const; + virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; + +private: + const QString _name; +}; + +#endif diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml new file mode 100644 index 0000000000000000000000000000000000000000..12d1422a485d250426802ff624e8a0d7bd2230ac --- /dev/null +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml @@ -0,0 +1,69 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2015 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL 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. + + QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import QGroundControl.Controls 1.0 + +FactSliderPanel { + anchors.fill: parent + + sliderModel: ListModel { + ListElement { + title: "Roll sensitivity" + description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy." + param: "MC_ROLL_TC" + min: 0 + max: 100 + step: 1 + } + + ListElement { + title: "Pitch sensitivity" + description: "Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy." + param: "MC_PITCH_TC" + min: 0 + max: 100 + step: 1 + } + + ListElement { + title: "Altitude control sensitivity" + description: "Slide to the left to make altitude control smoother and less twitchy. Slide to the right to make altitude control more accurate and more aggressive." + param: "MPC_Z_FF" + min: 0 + max: 100 + step: 1 + } + + ListElement { + title: "Position control sensitivity" + description: "Slide to the left to make flight in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive." + param: "MPC_XY_FF" + min: 0 + max: 100 + step: 1 + } + } +} diff --git a/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml new file mode 100644 index 0000000000000000000000000000000000000000..9c291d21d5d1bfd878c32fc933d4420cd6af48a3 --- /dev/null +++ b/src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml @@ -0,0 +1,69 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2015 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL 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. + + QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import QGroundControl.Controls 1.0 + +FactSliderPanel { + anchors.fill: parent + + sliderModel: ListModel { + ListElement { + title: "Roll sensitivity" + description: "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 + max: 100 + step: 1 + } + + ListElement { + title: "Pitch sensitivity" + description: "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 + max: 100 + step: 1 + } + + ListElement { + title: "Cruise throttle" + description: "This is the throttle setting required to achieve the desired cruise speed." + param: "FW_THR_CRUISE" + min: 0 + max: 100 + step: 1 + } + + ListElement { + title: "Position control sensitivity" + description: "Slide to the left to make flight in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive." + param: "FW_L1_PERIOD" + min: 0 + max: 100 + step: 1 + } + } +} diff --git a/src/QmlControls/FactSliderPanel.qml b/src/QmlControls/FactSliderPanel.qml new file mode 100644 index 0000000000000000000000000000000000000000..90fdf78ca2e83039fec1b7aba66fefea5cd5929c --- /dev/null +++ b/src/QmlControls/FactSliderPanel.qml @@ -0,0 +1,143 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2015 QGROUNDCONTROL PROJECT + + This file is part of the QGROUNDCONTROL project + + QGROUNDCONTROL 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. + + QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see . + + ======================================================================*/ + +import QtQuick 2.5 +import QtQuick.Controls 1.4 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.ScreenTools 1.0 + +QGCView { + viewPanel: panel + + property string panelTitle: "Title" ///< Title for panel + + /// ListModel must contains elements which look like this: + /// ListElement { + /// title: "Roll sensitivity" + /// description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy." + /// param: "MC_ROLL_TC" + /// min: 0 + /// max: 100 + /// step: 1 + /// } + property ListModel sliderModel + + FactPanelController { id: controller; factPanel: panel } + + QGCPalette { id: palette; colorGroupEnabled: enabled } + property real _margins: ScreenTools.defaultFontPixelHeight + + property bool _loadComplete: false + + Component.onCompleted: { + // Qml Sliders have a strange behavior in which they first set Slider::value to some internal + // setting and then set Slider::value to the bound properties value. If you have an onValueChanged + // handler which updates your property with the new value, this first value change will trash + // your bound values. In order to work around this we don't set the values into the Sliders until + // after Qml load is done. We also don't track value changes until Qml load completes. + for (var i=0; i