Skip to content

Commit

Permalink
New AutoPilotPlugin and VehicleSetup
Browse files Browse the repository at this point in the history
  • Loading branch information
DonLakeFlyer committed Nov 21, 2014
1 parent c9a43c9 commit 006b4d3
Show file tree
Hide file tree
Showing 33 changed files with 2,880 additions and 10 deletions.
4 changes: 1 addition & 3 deletions files/styles/style-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,7 @@ QPushButton, QToolButton {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #777, stop: 1 #333);
}

QPushButton#advancedMenuButton, QPushButton#airframeMenuButton, QPushButton#firmwareMenuButton,
QPushButton#tuningMenuButton, QPushButton#rcMenuButton, QPushButton#sensorMenuButton,
QPushButton#flightModeMenuButton, QPushButton#safetyConfigButton {
VehicleSetupButton, VehicleComponentButton {
background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #333, stop: 1 #111);
border-radius: 5px;
min-height: 64px;
Expand Down
51 changes: 44 additions & 7 deletions qgroundcontrol.pro
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,8 @@ ReleaseBuild {
}
}

# qextserialport should not be used by general QGroundControl code. Use QSerialPort instead. This is only
# here to support special case Firmware Upgrade code.
include(libs/qextserialport/src/qextserialport.pri)

#
Expand Down Expand Up @@ -249,7 +251,9 @@ INCLUDEPATH += \
src/ui/designer \
src/ui/configuration \
src/ui/px4_configuration \
src/ui/main
src/ui/main \
src/VehicleSetup \
src/AutoPilotPlugins

FORMS += \
src/ui/MainWindow.ui \
Expand Down Expand Up @@ -312,7 +316,6 @@ FORMS += \
src/ui/mission/QGCMissionNavSweep.ui \
src/ui/mission/QGCMissionDoStartSearch.ui \
src/ui/mission/QGCMissionDoFinishSearch.ui \
src/ui/QGCPX4VehicleConfig.ui \
src/ui/QGCHilConfiguration.ui \
src/ui/QGCHilFlightGearConfiguration.ui \
src/ui/QGCHilJSBSimConfiguration.ui \
Expand All @@ -325,7 +328,6 @@ FORMS += \
src/ui/uas/QGCMessageView.ui \
src/ui/JoystickButton.ui \
src/ui/JoystickAxis.ui \
src/ui/QGCConfigView.ui \
src/ui/configuration/terminalconsole.ui \
src/ui/configuration/SerialSettingsDialog.ui \
src/ui/px4_configuration/QGCPX4AirframeConfig.ui \
Expand Down Expand Up @@ -452,7 +454,6 @@ HEADERS += \
src/ui/mission/QGCMissionNavSweep.h \
src/ui/mission/QGCMissionDoStartSearch.h \
src/ui/mission/QGCMissionDoFinishSearch.h \
src/ui/QGCPX4VehicleConfig.h \
src/comm/QGCHilLink.h \
src/ui/QGCHilConfiguration.h \
src/ui/QGCHilFlightGearConfiguration.h \
Expand All @@ -472,7 +473,6 @@ HEADERS += \
src/ui/uas/QGCMessageView.h \
src/ui/JoystickButton.h \
src/ui/JoystickAxis.h \
src/ui/QGCConfigView.h \
src/ui/configuration/console.h \
src/ui/configuration/SerialSettingsDialog.h \
src/ui/configuration/terminalconsole.h \
Expand Down Expand Up @@ -608,7 +608,6 @@ SOURCES += \
src/ui/mission/QGCMissionNavSweep.cc \
src/ui/mission/QGCMissionDoStartSearch.cc \
src/ui/mission/QGCMissionDoFinishSearch.cc \
src/ui/QGCPX4VehicleConfig.cc \
src/ui/QGCHilConfiguration.cc \
src/ui/QGCHilFlightGearConfiguration.cc \
src/ui/QGCHilJSBSimConfiguration.cc \
Expand All @@ -627,7 +626,6 @@ SOURCES += \
src/ui/JoystickButton.cc \
src/ui/JoystickAxis.cc \
src/ui/uas/QGCMessageView.cc \
src/ui/QGCConfigView.cc \
src/ui/configuration/terminalconsole.cpp \
src/ui/configuration/console.cpp \
src/ui/configuration/SerialSettingsDialog.cc \
Expand Down Expand Up @@ -700,3 +698,42 @@ SOURCES += \
src/qgcunittest/PX4RCCalibrationTest.cc

}

#
# AutoPilot Plugin Support
#
FORMS += \
src/VehicleSetup/SetupView.ui \
src/VehicleSetup/SummaryPage.ui \
src/VehicleSetup/ParameterEditor.ui \
src/ui/QGCPX4VehicleConfig.ui

HEADERS+= \
src/VehicleSetup/SetupView.h \
src/VehicleSetup/SummaryPage.h \
src/VehicleSetup/ParameterEditor.h \
src/VehicleSetup/VehicleSetupButton.h \
src/VehicleSetup/VehicleComponentButton.h \
src/VehicleSetup/VehicleComponent.h \
src/AutoPilotPlugins/AutoPilotPlugin.h \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.h \
src/AutoPilotPlugins/PX4/PX4Component.h \
src/AutoPilotPlugins/PX4/RadioComponent.h \
src/AutoPilotPlugins/PX4/FlightModesComponent.h \
src/AutoPilotPlugins/PX4/AirframeComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h

SOURCES += \
src/VehicleSetup/SetupView.cc \
src/VehicleSetup/SummaryPage.cc \
src/VehicleSetup/ParameterEditor.cc \
src/VehicleSetup/VehicleComponent.cc \
src/AutoPilotPlugins/AutoPilotPlugin.cc \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/PX4AutoPilotPlugin.cc \
src/AutoPilotPlugins/PX4/PX4Component.cc \
src/AutoPilotPlugins/PX4/RadioComponent.cc \
src/AutoPilotPlugins/PX4/FlightModesComponent.cc \
src/AutoPilotPlugins/PX4/AirframeComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc
56 changes: 56 additions & 0 deletions src/AutoPilotPlugins/AutoPilotPlugin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*=====================================================================
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/>.
======================================================================*/

/// @file
/// @author Don Gagne <[email protected]>

#include "AutoPilotPlugin.h"
#include "PX4/PX4AutoPilotPlugin.h"
#include "Generic/GenericAutoPilotPlugin.h"

static AutoPilotPlugin* PX4_AutoPilot = NULL; ///< Singleton plugin for MAV_AUTOPILOT_PX4
static AutoPilotPlugin* Generic_AutoPilot = NULL; ///< Singleton plugin for AutoPilots which do not have a specifically implemented plugin

AutoPilotPlugin::AutoPilotPlugin(void)
{

}

AutoPilotPlugin* AutoPilotPlugin::getInstanceForAutoPilotPlugin(int autopilotType)
{
switch (autopilotType) {
case MAV_AUTOPILOT_PX4:
if (PX4_AutoPilot == NULL) {
PX4_AutoPilot = new PX4AutoPilotPlugin;
}
Q_ASSERT(PX4_AutoPilot);
return PX4_AutoPilot;

default:
if (Generic_AutoPilot == NULL) {
Generic_AutoPilot = new GenericAutoPilotPlugin;
}
Q_ASSERT(Generic_AutoPilot);
return Generic_AutoPilot;
}
}
69 changes: 69 additions & 0 deletions src/AutoPilotPlugins/AutoPilotPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*=====================================================================
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 AUTOPILOTPLUGIN_H
#define AUTOPILOTPLUGIN_H

#include <QObject>
#include <QList>
#include <QString>

#include "UASInterface.h"
#include "VehicleComponent.h"

/// @file
/// @brief The AutoPilotPlugin class is an abstract base class which represent the methods and objects
/// which are specific to a certain AutoPilot. This is the only place where AutoPilot specific
/// code should reside in QGroundControl. The remainder of the QGroundControl source is
/// generic to a common mavlink implementation.
/// @author Don Gagne <[email protected]>

class AutoPilotPlugin : public QObject
{
Q_OBJECT

public:
/// @brief Returns the singleton AutoPilot instance for the specified auto pilot type.
/// @param autopilotType Specified using the MAV_AUTOPILOT_* values.
static AutoPilotPlugin* getInstanceForAutoPilotPlugin(int autopilotType);

/// @brief Returns the list of VehicleComponent objects associated with the AutoPilot.
virtual QList<VehicleComponent*> getVehicleComponents(UASInterface* uas) const = 0;

typedef struct {
uint8_t baseMode;
uint32_t customMode;
} FullMode_t;

/// @brief Returns the list of modes which are available for this AutoPilot.
virtual QList<FullMode_t> getModes(void) const = 0;

/// @brief Returns a human readable short description for the specified mode.
virtual QString getShortModeText(uint8_t baseMode, uint32_t customMode) const = 0;

protected:
// All access to AutoPilotPugin objects is through getInstanceForAutoPilotPlugin
AutoPilotPlugin(void);
};

#endif
86 changes: 86 additions & 0 deletions src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*=====================================================================
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/>.
======================================================================*/

/// @file
/// @author Don Gagne <[email protected]>

#include "GenericAutoPilotPlugin.h"

GenericAutoPilotPlugin::GenericAutoPilotPlugin(void)
{

}

QList<VehicleComponent*> GenericAutoPilotPlugin::getVehicleComponents(UASInterface* uas) const
{
Q_UNUSED(uas);

// Generic autopilot has no configurable components
return QList<VehicleComponent*>();
}

QList<AutoPilotPlugin::FullMode_t> GenericAutoPilotPlugin::getModes(void) const
{
QList<FullMode_t> modeList;
FullMode_t fullMode;

fullMode.customMode = 0;

fullMode.baseMode = MAV_MODE_FLAG_MANUAL_INPUT_ENABLED;
modeList << fullMode;

fullMode.baseMode = MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED;
modeList << fullMode;

fullMode.baseMode = MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
modeList << fullMode;

fullMode.baseMode = MAV_MODE_FLAG_AUTO_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
modeList << fullMode;

return modeList;
}

QString GenericAutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMode) const
{
Q_UNUSED(customMode);

QString mode;

// use base_mode - not autopilot-specific
if (baseMode == 0) {
mode = "|PREFLIGHT";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_AUTO) {
mode = "|AUTO";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_MANUAL) {
mode = "|MANUAL";
if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_GUIDED) {
mode += "|GUIDED";
} else if (baseMode & MAV_MODE_FLAG_DECODE_POSITION_STABILIZE) {
mode += "|STABILIZED";
}
}

return mode;
}

46 changes: 46 additions & 0 deletions src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*=====================================================================
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 GENERICAUTOPILOT_H
#define GENERICAUTOPILOT_H

#include "AutoPilotPlugin.h"

/// @file
/// @brief This is the generic implementation of the AutoPilotPlugin class for mavs
/// we do not have a specific AutoPilotPlugin implementation.
/// @author Don Gagne <[email protected]>

class GenericAutoPilotPlugin : public AutoPilotPlugin
{
Q_OBJECT

public:
GenericAutoPilotPlugin(void);

virtual QList<VehicleComponent*> getVehicleComponents(UASInterface* uas) const ;
virtual QList<FullMode_t> getModes(void) const;
virtual QString getShortModeText(uint8_t baseMode, uint32_t customMode) const;
};

#endif
Loading

0 comments on commit 006b4d3

Please sign in to comment.