Skip to content

Commit

Permalink
Merge pull request mavlink#2359 from DonLakeFlyer/APMFlightMode
Browse files Browse the repository at this point in the history
Apm flight mode config
  • Loading branch information
DonLakeFlyer committed Dec 6, 2015
2 parents 745fff0 + 690ae21 commit cfd84bd
Show file tree
Hide file tree
Showing 13 changed files with 661 additions and 16 deletions.
5 changes: 5 additions & 0 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ SOURCES += \
INCLUDEPATH += \
src/AutoPilotPlugins/Common \
src/AutoPilotPlugins/PX4 \
src/AutoPilotPlugins/APM \
src/FirmwarePlugin \
src/Vehicle \
src/VehicleSetup \
Expand All @@ -564,6 +565,8 @@ HEADERS+= \
src/AutoPilotPlugins/APM/APMAirframeComponent.h \
src/AutoPilotPlugins/APM/APMComponent.h \
src/AutoPilotPlugins/APM/APMRadioComponent.h \
src/AutoPilotPlugins/APM/APMFlightModesComponent.h \
src/AutoPilotPlugins/APM/APMFlightModesComponentController.h \
src/AutoPilotPlugins/Common/RadioComponentController.h \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
Expand Down Expand Up @@ -609,6 +612,8 @@ SOURCES += \
src/AutoPilotPlugins/APM/APMAirframeComponent.cc \
src/AutoPilotPlugins/APM/APMComponent.cc \
src/AutoPilotPlugins/APM/APMRadioComponent.cc \
src/AutoPilotPlugins/APM/APMFlightModesComponent.cc \
src/AutoPilotPlugins/APM/APMFlightModesComponentController.cc \
src/AutoPilotPlugins/Common/RadioComponentController.cc \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
Expand Down
2 changes: 2 additions & 0 deletions qgroundcontrol.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<file alias="FlightDisplayView.qml">src/FlightDisplay/FlightDisplayView.qml</file>
<file alias="FlightModesComponent.qml">src/AutoPilotPlugins/PX4/FlightModesComponent.qml</file>
<file alias="FlightModesComponentSummary.qml">src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml</file>
<file alias="APMFlightModesComponent.qml">src/AutoPilotPlugins/APM/APMFlightModesComponent.qml</file>
<file alias="APMFlightModesComponentSummary.qml">src/AutoPilotPlugins/APM/APMFlightModesComponentSummary.qml</file>

<file alias="BluetoothSettings.qml">src/ui/preferences/BluetoothSettings.qml</file>
<file alias="DebugWindow.qml">src/ui/preferences/DebugWindow.qml</file>
Expand Down
7 changes: 7 additions & 0 deletions src/AutoPilotPlugins/APM/APMAutoPilotPlugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ APMAutoPilotPlugin::APMAutoPilotPlugin(Vehicle* vehicle, QObject* parent)
: AutoPilotPlugin(vehicle, parent)
, _incorrectParameterVersion(false)
, _airframeComponent(NULL)
, _flightModesComponent(NULL)
, _radioComponent(NULL)
{
Q_ASSERT(vehicle);
}
Expand All @@ -53,6 +55,11 @@ const QVariantList& APMAutoPilotPlugin::vehicleComponents(void)
_airframeComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));

_flightModesComponent = new APMFlightModesComponent(_vehicle, this);
Q_CHECK_PTR(_flightModesComponent);
_flightModesComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent));

_radioComponent = new APMRadioComponent(_vehicle, this);
Q_CHECK_PTR(_radioComponent);
_radioComponent->setupTriggerSignals();
Expand Down
12 changes: 8 additions & 4 deletions src/AutoPilotPlugins/APM/APMAutoPilotPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "Vehicle.h"
#include "APMAirframeComponent.h"
#include "APMRadioComponent.h"
#include "APMFlightModesComponent.h"

/// This is the APM specific implementation of the AutoPilot class.
class APMAutoPilotPlugin : public AutoPilotPlugin
Expand All @@ -41,8 +42,9 @@ class APMAutoPilotPlugin : public AutoPilotPlugin
// Overrides from AutoPilotPlugin
virtual const QVariantList& vehicleComponents(void);

APMAirframeComponent* airframeComponent(void) { return _airframeComponent; }
APMRadioComponent* radioComponent(void) { return _radioComponent; }
APMAirframeComponent* airframeComponent (void) { return _airframeComponent; }
APMFlightModesComponent* flightModesComponent(void) { return _flightModesComponent; }
APMRadioComponent* radioComponent (void) { return _radioComponent; }

public slots:
// FIXME: This is public until we restructure AutoPilotPlugin/FirmwarePlugin/Vehicle
Expand All @@ -51,8 +53,10 @@ public slots:
private:
bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed
QVariantList _components;
APMAirframeComponent* _airframeComponent;
APMRadioComponent* _radioComponent;

APMAirframeComponent* _airframeComponent;
APMFlightModesComponent* _flightModesComponent;
APMRadioComponent* _radioComponent;
};

#endif
102 changes: 102 additions & 0 deletions src/AutoPilotPlugins/APM/APMFlightModesComponent.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/

#include "APMFlightModesComponent.h"
#include "APMAutoPilotPlugin.h"

APMFlightModesComponent::APMFlightModesComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
APMComponent(vehicle, autopilot, parent),
_name(tr("Flight Modes"))
{
}

QString APMFlightModesComponent::name(void) const
{
return _name;
}

QString APMFlightModesComponent::description(void) const
{
return QString("The Flight Modes Component is used to assign FLight Modes to Channel 5.");
}

QString APMFlightModesComponent::iconResource(void) const
{
return "/qmlimages/FlightModesComponentIcon.png";
}

bool APMFlightModesComponent::requiresSetup(void) const
{
return true;
}

bool APMFlightModesComponent::setupComplete(void) const
{
return true;
}

QString APMFlightModesComponent::setupStateDescription(void) const
{
const char* stateDescription;

if (requiresSetup()) {
stateDescription = "Requires calibration";
} else {
stateDescription = "Calibrated";
}
return QString(stateDescription);
}

QStringList APMFlightModesComponent::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}

QStringList APMFlightModesComponent::paramFilterList(void) const
{
return QStringList();
}

QUrl APMFlightModesComponent::setupSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/APMFlightModesComponent.qml");
}

QUrl APMFlightModesComponent::summaryQmlSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/APMFlightModesComponentSummary.qml");
}

QString APMFlightModesComponent::prerequisiteSetup(void) const
{
APMAutoPilotPlugin* plugin = dynamic_cast<APMAutoPilotPlugin*>(_autopilot);
Q_ASSERT(plugin);

if (!plugin->airframeComponent()->setupComplete()) {
return plugin->airframeComponent()->name();
} else if (!plugin->radioComponent()->setupComplete()) {
return plugin->radioComponent()->name();
}

return QString();
}
55 changes: 55 additions & 0 deletions src/AutoPilotPlugins/APM/APMFlightModesComponent.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
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 <http://www.gnu.org/licenses/>.
======================================================================*/

#ifndef APMFlightModesComponent_H
#define APMFlightModesComponent_H

#include "APMComponent.h"

class APMFlightModesComponent : public APMComponent
{
Q_OBJECT

public:
APMFlightModesComponent(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 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;
};

#endif
Loading

0 comments on commit cfd84bd

Please sign in to comment.