From d24d0a054be371cb2ca7942838cd3213ae49590c Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 29 Oct 2015 13:40:24 -0700 Subject: [PATCH] Empty APM Airframe vehicle component --- QGCApplication.pro | 4 + qgroundcontrol.qrc | 4 + .../APM/APMAirframeComponent.cc | 116 ++++++++++++++++++ .../APM/APMAirframeComponent.h | 56 +++++++++ .../APM/APMAirframeComponent.qml | 51 ++++++++ .../APM/APMAirframeComponentSummary.qml | 45 +++++++ .../APM/APMAutoPilotPlugin.cc | 22 +++- src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h | 5 +- src/AutoPilotPlugins/APM/APMComponent.cc | 53 ++++++++ src/AutoPilotPlugins/APM/APMComponent.h | 54 ++++++++ 10 files changed, 404 insertions(+), 6 deletions(-) create mode 100644 src/AutoPilotPlugins/APM/APMAirframeComponent.cc create mode 100644 src/AutoPilotPlugins/APM/APMAirframeComponent.h create mode 100644 src/AutoPilotPlugins/APM/APMAirframeComponent.qml create mode 100644 src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml create mode 100644 src/AutoPilotPlugins/APM/APMComponent.cc create mode 100644 src/AutoPilotPlugins/APM/APMComponent.h diff --git a/QGCApplication.pro b/QGCApplication.pro index a89c6d8af..724ae8030 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -509,6 +509,8 @@ HEADERS+= \ src/AutoPilotPlugins/AutoPilotPlugin.h \ src/AutoPilotPlugins/AutoPilotPluginManager.h \ src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h \ + src/AutoPilotPlugins/APM/APMAirframeComponent.h \ + src/AutoPilotPlugins/APM/APMComponent.h \ src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \ src/AutoPilotPlugins/PX4/AirframeComponent.h \ src/AutoPilotPlugins/PX4/AirframeComponentAirframes.h \ @@ -551,6 +553,8 @@ SOURCES += \ src/AutoPilotPlugins/AutoPilotPlugin.cc \ src/AutoPilotPlugins/AutoPilotPluginManager.cc \ src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc \ + src/AutoPilotPlugins/APM/APMAirframeComponent.cc \ + src/AutoPilotPlugins/APM/APMComponent.cc \ src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \ src/AutoPilotPlugins/PX4/AirframeComponent.cc \ src/AutoPilotPlugins/PX4/AirframeComponentAirframes.cc \ diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index 33fba8e4a..81ced86ff 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -81,6 +81,10 @@ src/MissionEditor/MissionEditor.qml src/MissionEditor/MissionEditorHelp.qml + src/AutoPilotPlugins/APM/APMAirframeComponent.qml + src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml + + src/FlightDisplay/qmldir src/FlightDisplay/FlightDisplayView.qml diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.cc b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc new file mode 100644 index 000000000..7519398a7 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.cc @@ -0,0 +1,116 @@ +/*===================================================================== + + 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 . + + ======================================================================*/ + +/// @file +/// @author Don Gagne + +#include "APMAirframeComponent.h" +#include "QGCQmlWidgetHolder.h" + +APMAirframeComponent::APMAirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + APMComponent(uas, autopilot, parent), + _name(tr("Airframe")) +{ + +} + +QString APMAirframeComponent::name(void) const +{ + return _name; +} + +QString APMAirframeComponent::description(void) const +{ + return tr("The Airframe Component is used to select the airframe which matches your vehicle. " + "This will in turn set up the various tuning values for flight paramters."); +} + +QString APMAirframeComponent::iconResource(void) const +{ + return "/qmlimages/AirframeComponentIcon.png"; +} + +bool APMAirframeComponent::requiresSetup(void) const +{ + return true; +} + +bool APMAirframeComponent::setupComplete(void) const +{ + // You'll need to figure out which parameters trigger setup complete +#if 0 + return _autopilot->getParameterFact(FactSystem::defaultComponentId, "SYS_AUTOSTART")->value().toInt() != 0; +#else + return true; +#endif +} + +QString APMAirframeComponent::setupStateDescription(void) const +{ + const char* stateDescription; + + if (requiresSetup()) { + stateDescription = "Requires calibration"; + } else { + stateDescription = "Calibrated"; + } + return QString(stateDescription); +} + +QStringList APMAirframeComponent::setupCompleteChangedTriggerList(void) const +{ + // You'll need to figure out which parameters trigger setup complete +#if 0 + return QStringList("SYS_AUTOSTART"); +#else + return QStringList(); +#endif +} + +QStringList APMAirframeComponent::paramFilterList(void) const +{ +#if 0 + QStringList list; + + list << "SYS_AUTOSTART"; + + return list; +#else + return QStringList(); +#endif +} + +QUrl APMAirframeComponent::setupSource(void) const +{ + return QUrl::fromUserInput("qrc:/qml/APMAirframeComponent.qml"); +} + +QUrl APMAirframeComponent::summaryQmlSource(void) const +{ + return QUrl::fromUserInput("qrc:/qml/APMAirframeComponentSummary.qml"); +} + +QString APMAirframeComponent::prerequisiteSetup(void) const +{ + return QString(); +} diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.h b/src/AutoPilotPlugins/APM/APMAirframeComponent.h new file mode 100644 index 000000000..4a763c66e --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.h @@ -0,0 +1,56 @@ +/*===================================================================== + + 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 APMAirframeComponent_H +#define APMAirframeComponent_H + +#include "APMComponent.h" + +class APMAirframeComponent : public APMComponent +{ + Q_OBJECT + +public: + APMAirframeComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); + + // Virtuals from APMComponent + 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 QString setupStateDescription(void) const; + virtual QUrl setupSource(void) const; + virtual QStringList paramFilterList(void) const; + virtual QUrl summaryQmlSource(void) const; + virtual QString prerequisiteSetup(void) const; + +private: + const QString _name; + QVariantList _summaryItems; +}; + +#endif diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponent.qml b/src/AutoPilotPlugins/APM/APMAirframeComponent.qml new file mode 100644 index 000000000..e03e3e950 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMAirframeComponent.qml @@ -0,0 +1,51 @@ +/*===================================================================== + + 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.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 +import QtQuick.Dialogs 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Palette 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Controllers 1.0 +import QGroundControl.ScreenTools 1.0 + +QGCView { + id: qgcView + viewPanel: panel + + QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } + + QGCViewPanel { + id: panel + anchors.fill: parent + + QGCLabel { + text: "Work in progress"; + } + + } // QGCViewPanel +} // QGCView diff --git a/src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml b/src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml new file mode 100644 index 000000000..975a6f825 --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMAirframeComponentSummary.qml @@ -0,0 +1,45 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.FactControls 1.0 +import QGroundControl.Controls 1.0 +import QGroundControl.Controllers 1.0 +import QGroundControl.Palette 1.0 + +FactPanel { + id: panel + anchors.fill: parent + color: qgcPal.windowShadeDark + + QGCPalette { id: qgcPal; colorGroupEnabled: enabled } + +/* + property Fact sysIdFact: controller.getParameterFact(-1, "MAV_SYS_ID") + property Fact sysAutoStartFact: controller.getParameterFact(-1, "SYS_AUTOSTART") + + property bool autoStartSet: sysAutoStartFact.value != 0 +*/ + + Column { + anchors.fill: parent + anchors.margins: 8 + +/* + VehicleSummaryRow { + labelText: "System ID:" + valueText: sysIdFact.valueString + } + + VehicleSummaryRow { + labelText: "Airframe type:" + valueText: autoStartSet ? controller.currentAirframeType : "Setup required" + } + + VehicleSummaryRow { + labelText: "Vehicle:" + valueText: autoStartSet ? controller.currentVehicleName : "Setup required" + } +*/ + } +} diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc index 09e5e1c8a..ad623ca5b 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc @@ -29,9 +29,10 @@ #include "FirmwarePlugin/APM/APMFirmwarePlugin.h" // FIXME: Hack /// This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_ARDUPILOT type. -APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent) : - AutoPilotPlugin(vehicle, parent), - _incorrectParameterVersion(false) +APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent) + : AutoPilotPlugin(vehicle, parent) + , _incorrectParameterVersion(false) + , _airframeComponent(NULL) { Q_ASSERT(vehicle); } @@ -43,9 +44,20 @@ APMAutoPilotPlugin::~APMAutoPilotPlugin() const QVariantList& APMAutoPilotPlugin::vehicleComponents(void) { - static const QVariantList emptyList; + if (_components.count() == 0 && !_incorrectParameterVersion) { + Q_ASSERT(_vehicle); - return emptyList; + if (parametersReady()) { + _airframeComponent = new APMAirframeComponent(_vehicle->uas(), this); + Q_CHECK_PTR(_airframeComponent); + _airframeComponent->setupTriggerSignals(); + _components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent)); + } else { + qWarning() << "Call to vehicleCompenents prior to parametersReady"; + } + } + + return _components; } /// This will perform various checks prior to signalling that the plug in ready diff --git a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h index 3864d2c2b..43c639736 100644 --- a/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h +++ b/src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h @@ -26,6 +26,7 @@ #include "AutoPilotPlugin.h" #include "Vehicle.h" +#include "APMAirframeComponent.h" /// This is the APM specific implementation of the AutoPilot class. class APMAutoPilotPlugin : public AutoPilotPlugin @@ -44,7 +45,9 @@ public slots: void _parametersReadyPreChecks(bool missingParameters); private: - bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed + bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed + QVariantList _components; + APMAirframeComponent* _airframeComponent; }; #endif diff --git a/src/AutoPilotPlugins/APM/APMComponent.cc b/src/AutoPilotPlugins/APM/APMComponent.cc new file mode 100644 index 000000000..2a0b652fe --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMComponent.cc @@ -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 . + + ======================================================================*/ + +/// @file +/// @author Don Gagne + +#include "APMComponent.h" +#include "Fact.h" +#include "AutoPilotPlugin.h" + +APMComponent::APMComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : + VehicleComponent(uas, autopilot, parent) +{ + Q_ASSERT(uas); + Q_ASSERT(autopilot); +} + +void APMComponent::setupTriggerSignals(void) +{ + // Watch for changed on trigger list params + foreach (QString paramName, setupCompleteChangedTriggerList()) { + Fact* fact = _autopilot->getParameterFact(FactSystem::defaultComponentId, paramName); + + connect(fact, &Fact::valueChanged, this, &APMComponent::_triggerUpdated); + } +} + + +void APMComponent::_triggerUpdated(QVariant value) +{ + Q_UNUSED(value); + emit setupCompleteChanged(setupComplete()); +} diff --git a/src/AutoPilotPlugins/APM/APMComponent.h b/src/AutoPilotPlugins/APM/APMComponent.h new file mode 100644 index 000000000..88097c18a --- /dev/null +++ b/src/AutoPilotPlugins/APM/APMComponent.h @@ -0,0 +1,54 @@ +/*===================================================================== + + 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 APMComponent_H +#define APMComponent_H + +#include "VehicleComponent.h" + +#include + +/// @file +/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects. +/// @author Don Gagne + +class APMComponent : public VehicleComponent +{ + Q_OBJECT + +public: + APMComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent = NULL); + + /// @brief Returns an list of parameter names for which a change should cause the setupCompleteChanged + /// signal to be emitted. Last element is signalled by NULL. + virtual QStringList setupCompleteChangedTriggerList(void) const = 0; + + /// Should be called after the component is created (but not in constructor) to setup the + /// signals which are used to track parameter changes which affect setupComplete state. + void setupTriggerSignals(void); + +private slots: + void _triggerUpdated(QVariant value); +}; + +#endif -- 2.22.0