Commit 0f3a51fc authored by Don Gagne's avatar Don Gagne

New AutoPilotPlugin and VehicleSetup

parent e56080f8
......@@ -408,9 +408,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;
......
......@@ -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)
#
......@@ -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 \
......@@ -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 \
......@@ -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 \
......@@ -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 \
......@@ -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 \
......@@ -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 \
......@@ -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 \
......@@ -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
/*=====================================================================
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 <don@thegagnes.com>
#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;
}
}
/*=====================================================================
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 <don@thegagnes.com>
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
/*=====================================================================
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 <don@thegagnes.com>
#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;
}
/*=====================================================================
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 <don@thegagnes.com>
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
/*=====================================================================
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 <don@thegagnes.com>
#include "AirframeComponent.h"
#include "QGCPX4AirframeConfig.h"
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "SYS_AUTOSTART", NULL };
struct mavType {
int type;
const char* description;
};
/// @brief Used to translate from MAV_TYPE_* id to user string
static const struct mavType mavTypeInfo[] = {
{ MAV_TYPE_GENERIC, "Generic" },
{ MAV_TYPE_FIXED_WING, "Fixed Wing" },
{ MAV_TYPE_QUADROTOR, "Quadrotor" },
{ MAV_TYPE_COAXIAL, "Coaxial" },
{ MAV_TYPE_HELICOPTER, "Helicopter"},
{ MAV_TYPE_ANTENNA_TRACKER, "Antenna Tracker" },
{ MAV_TYPE_GCS, "Ground Control Station" },
{ MAV_TYPE_AIRSHIP, "Airship" },
{ MAV_TYPE_FREE_BALLOON, "Free Balloon" },
{ MAV_TYPE_ROCKET, "Rocket" },
{ MAV_TYPE_GROUND_ROVER, "Ground Rover" },
{ MAV_TYPE_SURFACE_BOAT, "Boat" },
{ MAV_TYPE_SUBMARINE, "Submarine" },
{ MAV_TYPE_HEXAROTOR, "Hexarotor" },
{ MAV_TYPE_OCTOROTOR, "Octorotor" },
{ MAV_TYPE_TRICOPTER, "Tricopter" },
{ MAV_TYPE_FLAPPING_WING, "Flapping Wing" },
{ MAV_TYPE_KITE, "Kite" },
{ MAV_TYPE_ONBOARD_CONTROLLER, "Onbard companion controller" },
{ MAV_TYPE_VTOL_DUOROTOR, "Two-rotor VTOL" },
{ MAV_TYPE_VTOL_QUADROTOR, "Quad-rotor VTOL" },
};
static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
AirframeComponent::AirframeComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
_name(tr("Airframe"))
{
// Validate that our mavTypeInfo array hasn't gotten out of sync
Q_ASSERT(cMavTypes == MAV_TYPE_ENUM_END);
static const int mavTypes[] = {
MAV_TYPE_GENERIC,
MAV_TYPE_FIXED_WING,
MAV_TYPE_QUADROTOR,
MAV_TYPE_COAXIAL,
MAV_TYPE_HELICOPTER,
MAV_TYPE_ANTENNA_TRACKER,
MAV_TYPE_GCS,
MAV_TYPE_AIRSHIP,
MAV_TYPE_FREE_BALLOON,
MAV_TYPE_ROCKET,
MAV_TYPE_GROUND_ROVER,
MAV_TYPE_SURFACE_BOAT,
MAV_TYPE_SUBMARINE,
MAV_TYPE_HEXAROTOR,
MAV_TYPE_OCTOROTOR,
MAV_TYPE_TRICOPTER,
MAV_TYPE_FLAPPING_WING,
MAV_TYPE_KITE,
MAV_TYPE_ONBOARD_CONTROLLER,
MAV_TYPE_VTOL_DUOROTOR,
MAV_TYPE_VTOL_QUADROTOR
};
for (size_t i=0; i<sizeof(mavTypes)/sizeof(mavTypes[0]); i++) {
Q_ASSERT(mavTypeInfo[i].type == mavTypes[i]);
}
}
QString AirframeComponent::name(void) const
{
return _name;
}
QString AirframeComponent::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 AirframeComponent::icon(void) const
{
return ":/files/images/px4/menu/plane.png";
}
bool AirframeComponent::requiresSetup(void) const
{
return true;
}
bool AirframeComponent::setupComplete(void) const
{
QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) {
return value.toInt() != 0;
} else {
Q_ASSERT(false);
return false;
}
}
QString AirframeComponent::setupStateDescription(void) const
{
const char* stateDescription;
if (requiresSetup()) {
stateDescription = "Requires calibration";
} else {
stateDescription = "Calibrated";
}
return QString(stateDescription);
}
const char** AirframeComponent::setupCompleteChangedTriggerList(void) const
{
return triggerParams;
}
QStringList AirframeComponent::paramFilterList(void) const
{
QStringList list;
list << "SYS_AUTOSTART";
return list;
}
QWidget* AirframeComponent::setupWidget(void) const
{
return new QGCPX4AirframeConfig;
}
QList<QStringList> AirframeComponent::summaryItems(void) const
{
QVariant value;
QStringList row;
QList<QStringList> items;
row << "System ID:";
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "MAV_SYS_ID", value)) {
if (value.toInt() == 0) {
row << "Setup required";
} else {
row << value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
}
items << row;
row.clear();
row << "Airframe:";
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SYS_AUTOSTART", value)) {
if (value.toInt() == 0) {
row << "Setup required";
} else {
row << value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
}
items << row;
row.clear();
row << "Type:";
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "MAV_TYPE", value)) {
int index = value.toInt();
if (index < 0 || index >= (int)cMavTypes) {
row << "Unknown";
} else {
row << mavTypeInfo[index].description;
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
row << "Unknown";
}
items << row;
return items;
}
/*=====================================================================
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 AIRFRAMECOMPONENT_H
#define AIRFRAMECOMPONENT_H
#include "PX4Component.h"
/// @file
/// @brief The Airframe VehicleComponent is used to set the SYS_AUTOSTART airframe id.
/// @author Don Gagne <don@thegagnes.com>
class AirframeComponent : public PX4Component
{
Q_OBJECT
public:
AirframeComponent(UASInterface* uas, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name(void) const;
virtual QString description(void) const;
virtual QString icon(void) const;
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual QList<QStringList> summaryItems(void) const;
private:
const QString _name;
};
#endif
/*=====================================================================
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 <don@thegagnes.com>
#include "FlightModesComponent.h"
#include <QVBoxLayout>
#include <QLabel>
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL };
struct SwitchListItem {
const char* param;
const char* name;
};
/// @brief Used to translate from RC_MAP_* parameters name to user string
static const SwitchListItem switchList[] = {
{ "RC_MAP_MODE_SW", "Mode Switch:" }, // First entry must be mode switch
{ "RC_MAP_POSCTL_SW", "Position Control Switch:" },
{ "RC_MAP_LOITER_SW", "Loiter Switch:" },
{ "RC_MAP_RETURN_SW", "Return Switch:" }
};
static const size_t cSwitchList = sizeof(switchList) / sizeof(switchList[0]);
FlightModesComponent::FlightModesComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
_name(tr("Flight Modes"))
{
}
QString FlightModesComponent::name(void) const
{
return _name;
}
QString FlightModesComponent::description(void) const
{
// FIXME: Better text
return tr("The Flight Modes Component is used to set the switches associated with Flight Modes. "
"At a minimum the Main Mode Switch must be assigned prior to flight.");
}
QString FlightModesComponent::icon(void) const
{
return ":/files/images/px4/menu/toggle_switch.png";
}
bool FlightModesComponent::requiresSetup(void) const
{
return true;
}
bool FlightModesComponent::setupComplete(void) const
{
QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) {
return value.toInt() != 0;
} else {
Q_ASSERT(false);
return false;
}
}
QString FlightModesComponent::setupStateDescription(void) const
{
const char* stateDescription;
if (requiresSetup()) {
stateDescription = "Requires calibration";
} else {
stateDescription = "Calibrated";
}
return QString(stateDescription);
}
const char** FlightModesComponent::setupCompleteChangedTriggerList(void) const
{
return triggerParams;
}
QStringList FlightModesComponent::paramFilterList(void) const
{
QStringList list;
for (size_t i=0; i<cSwitchList; i++) {
list << switchList[i].param;
}
return list;
}
QWidget* FlightModesComponent::setupWidget(void) const
{
QWidget* widget = new QWidget;
QVBoxLayout* layout = new QVBoxLayout(widget);
QLabel* label = new QLabel("Coming Soon\nUse Radio setup for Main Mode Switch setup\n(Use Flight Modes Parameters for everything else)", widget);
label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
layout->addWidget(label);
return widget;
}
QList<QStringList> FlightModesComponent::summaryItems(void) const
{
QList<QStringList> items;
// Create summary items for each mode switch
for (size_t i=0; i<cSwitchList; i++) {
QVariant value;
QStringList row;
row << switchList[i].name;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), switchList[i].param, value)) {
int chan = value.toInt();
if (chan == 0) {
// Switch is not mapped
if (i == 0) {
// Mode switch is required
Q_ASSERT(switchList[0].param == "RC_MAP_MODE_SW");
row << "Setup required";
} else {
row << "None";
}
} else {
row << tr("Chan %1").arg(chan);
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
row << "Unknown";
}
items << row;
}
return items;
}
/*=====================================================================
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 FLIGHTMODESCOMPONENT_H
#define FLIGHTMODESCOMPONENT_H
#include "PX4Component.h"
/// @file
/// @brief The FlightModes VehicleComponent is used to set the associated Flight Mode switches.
/// @author Don Gagne <don@thegagnes.com>
class FlightModesComponent : public PX4Component
{
Q_OBJECT
public:
FlightModesComponent(UASInterface* uas, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name(void) const;
virtual QString description(void) const;
virtual QString icon(void) const;
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual QList<QStringList> summaryItems(void) const;
private:
const QString _name;
};
#endif
/*=====================================================================
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 "PX4AutoPilotPlugin.h"
#include "AirframeComponent.h"
#include "RadioComponent.h"
#include "SensorsComponent.h"
#include "FlightModesComponent.h"
/// @file
/// @brief This is the AutoPilotPlugin implementatin for the MAV_AUTOPILOT_PX4 type.
/// @author Don Gagne <don@thegagnes.com>
enum PX4_CUSTOM_MAIN_MODE {
PX4_CUSTOM_MAIN_MODE_MANUAL = 1,
PX4_CUSTOM_MAIN_MODE_ALTCTL,
PX4_CUSTOM_MAIN_MODE_POSCTL,
PX4_CUSTOM_MAIN_MODE_AUTO,
PX4_CUSTOM_MAIN_MODE_ACRO,
PX4_CUSTOM_MAIN_MODE_OFFBOARD,
};
enum PX4_CUSTOM_SUB_MODE_AUTO {
PX4_CUSTOM_SUB_MODE_AUTO_READY = 1,
PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF,
PX4_CUSTOM_SUB_MODE_AUTO_LOITER,
PX4_CUSTOM_SUB_MODE_AUTO_MISSION,
PX4_CUSTOM_SUB_MODE_AUTO_RTL,
PX4_CUSTOM_SUB_MODE_AUTO_LAND,
PX4_CUSTOM_SUB_MODE_AUTO_RTGS
};
union px4_custom_mode {
struct {
uint16_t reserved;
uint8_t main_mode;
uint8_t sub_mode;
};
uint32_t data;
float data_float;
};
PX4AutoPilotPlugin::PX4AutoPilotPlugin(void)
{
}
QList<VehicleComponent*> PX4AutoPilotPlugin::getVehicleComponents(UASInterface* uas) const
{
QList<VehicleComponent*> components;
VehicleComponent* component;
component = new AirframeComponent(uas);
Q_CHECK_PTR(component);
components.append(component);
component = new RadioComponent(uas);
Q_CHECK_PTR(component);
components.append(component);
component = new FlightModesComponent(uas);
Q_CHECK_PTR(component);
components.append(component);
component = new SensorsComponent(uas);
Q_CHECK_PTR(component);
components.append(component);
return components;
}
QList<AutoPilotPlugin::FullMode_t> PX4AutoPilotPlugin::getModes(void) const
{
QList<FullMode_t> modeList;
FullMode_t fullMode;
union px4_custom_mode px4_cm;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_MANUAL;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_ALTCTL;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_POSCTL;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_MANUAL_INPUT_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_AUTO;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_AUTO_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
px4_cm.data = 0;
px4_cm.main_mode = PX4_CUSTOM_MAIN_MODE_OFFBOARD;
fullMode.baseMode = MAV_MODE_FLAG_CUSTOM_MODE_ENABLED | MAV_MODE_FLAG_AUTO_ENABLED | MAV_MODE_FLAG_STABILIZE_ENABLED | MAV_MODE_FLAG_GUIDED_ENABLED;
fullMode.customMode = px4_cm.data;
modeList << fullMode;
return modeList;
}
QString PX4AutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMode) const
{
QString mode;
Q_ASSERT(baseMode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED);
if (baseMode & MAV_MODE_FLAG_CUSTOM_MODE_ENABLED) {
union px4_custom_mode px4_mode;
px4_mode.data = customMode;
if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_MANUAL) {
mode = "|MANUAL";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_ALTCTL) {
mode = "|ALTCTL";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_POSCTL) {
mode = "|POSCTL";
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_AUTO) {
mode = "|AUTO";
if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_READY) {
mode += "|READY";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_TAKEOFF) {
mode += "|TAKEOFF";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_LOITER) {
mode += "|LOITER";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_MISSION) {
mode += "|MISSION";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_RTL) {
mode += "|RTL";
} else if (px4_mode.sub_mode == PX4_CUSTOM_SUB_MODE_AUTO_LAND) {
mode += "|LAND";
}
} else if (px4_mode.main_mode == PX4_CUSTOM_MAIN_MODE_OFFBOARD) {
mode = "|OFFBOARD";
}
} else {
mode = AutoPilotPlugin::getInstanceForAutoPilotPlugin(MAV_AUTOPILOT_GENERIC)->getShortModeText(baseMode, customMode);
}
return mode;
}
/*=====================================================================
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 PX4AUTOPILOT_H
#define PX4AUTOPILOT_H
#include "AutoPilotPlugin.h"
/// @file
/// @brief This is the PX4 specific implementation of the AutoPilot class.
/// @author Don Gagne <don@thegagnes.com>
class PX4AutoPilotPlugin : public AutoPilotPlugin
{
Q_OBJECT
public:
PX4AutoPilotPlugin(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
/*=====================================================================
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 <don@thegagnes.com>
#include "PX4Component.h"
PX4Component::PX4Component(UASInterface* uas, QObject* parent) :
VehicleComponent(uas, parent)
{
bool fSuccess = connect(_paramMgr, SIGNAL(parameterUpdated(int, QString, QVariant)), this, SLOT(_parameterUpdated(int, QString, QVariant)));
Q_ASSERT(fSuccess);
Q_UNUSED(fSuccess);
}
void PX4Component::_parameterUpdated(int compId, QString paramName, QVariant value)
{
Q_UNUSED(value);
if (compId == _paramMgr->getDefaultComponentId()) {
const char** prgTriggers = setupCompleteChangedTriggerList();
Q_ASSERT(prgTriggers);
while (*prgTriggers != NULL) {
if (paramName == *prgTriggers) {
emit setupCompleteChanged();
return;
}
prgTriggers++;
}
}
}
/*=====================================================================
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 PX4COMPONENT_H
#define PX4COMPONENT_H
#include "VehicleComponent.h"
/// @file
/// @brief This class is used as an abstract base class for all PX4 VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com>
class PX4Component : public VehicleComponent
{
Q_OBJECT
public:
PX4Component(UASInterface* uas, QObject* parent = NULL);
/// @brief Returns an array of parameter names for which a change should cause the setupCompleteChanged
/// signal to be emitted. Last element is signalled by NULL. Must be implemented by upper level class.
virtual const char** setupCompleteChangedTriggerList(void) const = 0;
private slots:
/// @brief Connected to QGCUASParamManagerInterface::parameterUpdated signal in order to signal
/// setupCompleteChanged at appropriate times.
void _parameterUpdated(int compId, QString paramName, QVariant value);
};
#endif
/*=====================================================================
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 <don@thegagnes.com>
#include "RadioComponent.h"
#include "PX4RCCalibration.h"
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "RC_MAP_MODE_SW", NULL };
RadioComponent::RadioComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
_name(tr("Radio"))
{
}
QString RadioComponent::name(void) const
{
return _name;
}
QString RadioComponent::description(void) const
{
return tr("The Radio Component is used to setup which channels on your RC Transmitter you will use for each vehicle control such as Roll, Pitch, Yaw and Throttle. "
"It also allows you to assign switches and dials to the various flight modes. "
"Prior to flight you must also calibrate the extents for all of your channels.");
}
QString RadioComponent::icon(void) const
{
return ":/files/images/px4/menu/remote.png";
}
bool RadioComponent::requiresSetup(void) const
{
return true;
}
bool RadioComponent::setupComplete(void) const
{
QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[0], value)) {
return value.toInt() != 0;
} else {
Q_ASSERT(false);
return false;
}
}
QString RadioComponent::setupStateDescription(void) const
{
const char* stateDescription;
if (requiresSetup()) {
stateDescription = "Requires calibration";
} else {
stateDescription = "Calibrated";
}
return QString(stateDescription);
}
const char** RadioComponent::setupCompleteChangedTriggerList(void) const
{
return triggerParams;
}
QStringList RadioComponent::paramFilterList(void) const
{
QStringList list;
list << "RC*";
return list;
}
QWidget* RadioComponent::setupWidget(void) const
{
return new PX4RCCalibration;
}
QList<QStringList> RadioComponent::summaryItems(void) const
{
QList<QStringList> items;
QStringList row;
// FIXME: Need to pull receiver type from RSSI value
row << "Receiver type:" << "n/a";
items << row;
static const char* stickParams[] = { "RC_MAP_ROLL", "RC_MAP_PITCH", "RC_MAP_YAW", "RC_MAP_THROTTLE" };
QString summary("Chan ");
bool allSticksMapped = true;
for (size_t i=0; i<sizeof(stickParams)/sizeof(stickParams[0]); i++) {
QVariant value;
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), stickParams[i], value)) {
if (value.toInt() == 0) {
allSticksMapped = false;
break;
} else {
if (i != 0) {
summary += ",";
}
summary += value.toString();
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
summary += "?";
}
}
if (!allSticksMapped) {
summary = "Not mapped";
}
row.clear();
row << "Ail, Ele, Rud, Throt:" << summary;
items << row;
return items;
}
/*=====================================================================
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 RADIOCOMPONENT_H
#define RADIOCOMPONENT_H
#include "PX4Component.h"
/// @file
/// @brief The Radio VehicleComponent is used to calibrate the trasmitter and assign function mapping
/// to channels.
/// @author Don Gagne <don@thegagnes.com>
class RadioComponent : public PX4Component
{
Q_OBJECT
public:
RadioComponent(UASInterface* uas, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name(void) const;
virtual QString description(void) const;
virtual QString icon(void) const;
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual QList<QStringList> summaryItems(void) const;
private:
const QString _name;
};
#endif
/*=====================================================================
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 <don@thegagnes.com>
#include "SensorsComponent.h"
#include "QGCPX4SensorCalibration.h"
// These two list must be kept in sync
/// @brief Parameters which signal a change in setupComplete state
static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL };
/// @brief Used to translate from parameter name to user string
static const char* triggerSensors[] = { "Compass", "Gyro", "Acceleromter", "Airspeed", NULL };
SensorsComponent::SensorsComponent(UASInterface* uas, QObject* parent) :
PX4Component(uas, parent),
_name(tr("Sensors"))
{
}
QString SensorsComponent::name(void) const
{
return _name;
}
QString SensorsComponent::description(void) const
{
return tr("The Sensors Component allows you to calibrate the sensors within your vehicle. "
"Prior to flight you must calibrate the Magnetometer, Gyroscope and Accelerometer.");
}
QString SensorsComponent::icon(void) const
{
return ":/files/images/px4/menu/sensors.png";
}
bool SensorsComponent::requiresSetup(void) const
{
return true;
}
bool SensorsComponent::setupComplete(void) const
{
const char** prgTriggers = setupCompleteChangedTriggerList();
Q_ASSERT(prgTriggers);
while (*prgTriggers != NULL) {
QVariant value;
if (!_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), *prgTriggers, value)) {
Q_ASSERT(false);
return false;
}
if (value.toFloat() == 0.0f) {
return false;
}
prgTriggers++;
}
return true;
}
QString SensorsComponent::setupStateDescription(void) const
{
const char* stateDescription;
if (requiresSetup()) {
stateDescription = "Requires calibration";
} else {
stateDescription = "Calibrated";
}
return QString(stateDescription);
}
const char** SensorsComponent::setupCompleteChangedTriggerList(void) const
{
return triggerParams;
}
QStringList SensorsComponent::paramFilterList(void) const
{
QStringList list;
list << "SENS_*";
return list;
}
QWidget* SensorsComponent::setupWidget(void) const
{
return new QGCPX4SensorCalibration;
}
QList<QStringList> SensorsComponent::summaryItems(void) const
{
QList<QStringList> items;
// Summary item for each Sensor
int i = 0;
while (triggerParams[i] != NULL) {
QVariant value;
QStringList row;
row << tr("%1:").arg(triggerSensors[i]);
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), triggerParams[i], value)) {
if (value.toFloat() == 0.0f) {
row << "Setup required";
} else {
row << "Ready";
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
}
items << row;
i++;
}
// Summary item for each orientation param
static const char* orientationSensors[] = { "Autopilot orientation:", "Compass orientation:" };
static const char* orientationParams[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT" };
static const size_t cOrientationSensors = sizeof(orientationSensors)/sizeof(orientationSensors[0]);
static const char* orientationValues[] = {
"Line of flight",
"Yaw:45",
"Yaw:90",
"Yaw:135",
"Yaw:180",
"Yaw:225",
"Yaw:270",
"Yaw:315",
"Roll:180",
"Roll:180 Yaw:45",
"Roll:180 Yaw:90",
"Roll:180 Yaw:135",
"Pitch:180",
"Roll:180 Yaw:225",
"Roll:180 Yaw:270",
"Roll:180 Yaw:315",
"Roll:90",
"Roll:90 Yaw:45",
"Roll:90 Yaw:90",
"Roll:90 Yaw:135",
"Roll:270",
"Roll:270 Yaw:45",
"Roll:270 Yaw:90",
"Roll:270 Yaw:135",
"Pitch:90",
"Pitch:270",
"Pitch:180",
"Pitch:180 Yaw:90",
"Pitch:180 Yaw:270",
"Roll:90 Pitch:90",
"Roll:180 Pitch:90",
"Roll:270 Pitch:90",
"Roll:90 Pitch:180",
"Roll:270 Pitch:180",
"Roll:90 Pitch:270",
"Roll:180 Pitch:270",
"Roll:270 Pitch:270",
"Roll:90 Pitch:180 Yaw:90",
"Roll:90 Yaw:270"
};
static const size_t cOrientationValues = sizeof(orientationValues)/sizeof(orientationValues[0]);
for (size_t i=0; i<cOrientationSensors; i++) {
QVariant value;
QStringList row;
row.clear();
row << orientationSensors[i];
if (_paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), orientationParams[i], value)) {
int index = value.toInt();
if (index < 0 || index >= (int)cOrientationValues) {
row << "Setup required";
} else {
row << orientationValues[index];
}
} else {
// Why is the parameter missing?
Q_ASSERT(false);
row << "Unknown";
}
items << row;
}
return items;
}
/*=====================================================================
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 SENSORSCOMPONENT_H
#define SENSORSCOMPONENT_H
#include "PX4Component.h"
/// @file
/// @brief The Sensors VehicleComponent is used to calibrate the the various sensors associated with the board.
/// @author Don Gagne <don@thegagnes.com>
class SensorsComponent : public PX4Component
{
Q_OBJECT
public:
SensorsComponent(UASInterface* uas, QObject* parent = NULL);
// Virtuals from PX4Component
virtual const char** setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name(void) const;
virtual QString description(void) const;
virtual QString icon(void) const;
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QString setupStateDescription(void) const;
virtual QWidget* setupWidget(void) const;
virtual QStringList paramFilterList(void) const;
virtual QList<QStringList> summaryItems(void) const;
private:
const QString _name;
};
#endif
/*=====================================================================
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 <don@thegagnes.com>
#include "ParameterEditor.h"
#include "ui_ParameterEditor.h"
ParameterEditor::ParameterEditor(UASInterface* uas, const QStringList& filterList, QWidget* parent) :
QWidget(parent),
_ui(new Ui::ParameterEditor)
{
_ui->setupUi(this);
_ui->paramTreeWidget->setFilterList(filterList);
_ui->paramTreeWidget->setUAS(uas);
_ui->paramTreeWidget->handleOnboardParameterListUpToDate();
_ui->pendingCommitsWidget->setUAS(uas);
_ui->pendingCommitsWidget->update();
}
ParameterEditor::~ParameterEditor()
{
delete _ui;
}
/*=====================================================================
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 PARAMETEREDITOR_H
#define PARAMETEREDITOR_H
#include <QWidget>
#include "UASInterface.h"
/// @file
/// @brief This is the Parameter Editor widget which is used in the Parameters tab of Vehicle Setup.
/// @author Don Gagne <don@thegagnes.com>
namespace Ui {
class ParameterEditor;
}
class ParameterEditor : public QWidget
{
Q_OBJECT
public:
explicit ParameterEditor(UASInterface* uas, const QStringList& filterList, QWidget* parent = 0);
~ParameterEditor();
private:
Ui::ParameterEditor* _ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>ParameterEditor</class>
<widget class="QWidget" name="ParameterEditor">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>600</width>
<height>600</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QGroupBox" name="advancedConfigurationGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>3</horstretch>
<verstretch>1</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Onboard Configuration</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="verticalLayout_7">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="advancedColumnLayout">
<item>
<widget class="QGCParamWidget" name="paramTreeWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QGroupBox" name="pendingChangesGroupBox">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>2</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>329</width>
<height>400</height>
</size>
</property>
<property name="title">
<string>Changes Pending</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_8">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0">
<property name="spacing">
<number>-1</number>
</property>
<item>
<widget class="QGCPendingParamWidget" name="pendingCommitsWidget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_13">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>10</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="advancedStatusLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Status</string>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QGCPendingParamWidget</class>
<extends>QWidget</extends>
<header>ui/QGCPendingParamWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>QGCParamWidget</class>
<extends>QWidget</extends>
<header>ui/QGCParamWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>
/*=====================================================================
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 <don@thegagnes.com>
#include "SetupView.h"
#include "ui_SetupView.h"
#include "UASManager.h"
#include "AutoPilotPlugin.h"
#include "VehicleComponent.h"
#include "VehicleComponentButton.h"
#include "SummaryPage.h"
#include "PX4FirmwareUpgrade.h"
#
#include <QQmlError>
#include <QQmlContext>
#include <QDebug>
SetupView::SetupView(QWidget* parent) :
QWidget(parent),
_uasCurrent(NULL),
_setupWidget(NULL),
_parameterWidget(NULL),
_initComplete(false),
_ui(new Ui::SetupView)
{
_ui->setupUi(this);
bool fSucceeded = connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this, SLOT(_setActiveUAS(UASInterface*)));
Q_UNUSED(fSucceeded);
Q_ASSERT(fSucceeded);
connect(_ui->firmwareButton, &QPushButton::clicked, this, &SetupView::_firmwareButtonClicked);
connect(_ui->summaryButton, &QPushButton::clicked, this, &SetupView::_summaryButtonClicked);
// Summary button is not shown until we have parameters ready
_ui->summaryButton->setVisible(false);
// We show firmware upgrade until we get parameters
_firmwareButtonClicked();
}
SetupView::~SetupView()
{
delete _ui;
}
void SetupView::_setActiveUAS(UASInterface* uas)
{
if (_uasCurrent) {
disconnect(_uasCurrent->getParamManager(), SIGNAL(parameterListUpToDate()), this, SLOT(_parametersReady()));
}
// Clear all UI and fall back to Firmware ui since that is the only thing available when no UAS
_clearWidgets();
_clearComponentButtons();
_ui->summaryButton->setVisible(false);
_components.clear();
_firmwareButtonClicked();
_uasCurrent = uas;
if (_uasCurrent) {
connect(_uasCurrent, &UASInterface::connected, this, &SetupView::_uasConnected);
connect(_uasCurrent, &UASInterface::disconnected, this, &SetupView::_uasDisconnected);
bool fSucceeded = connect(_uasCurrent->getParamManager(), SIGNAL(parameterListUpToDate()), this, SLOT(_parametersReady()));
Q_ASSERT(fSucceeded);
Q_UNUSED(fSucceeded);
if (_uasCurrent->getParamManager()->parametersReady()) {
_parametersReady();
}
}
}
/// @brief Removes and deletes both the setup and parameter widgets from the tab view.
void SetupView::_clearWidgets(void)
{
if (_setupWidget) {
_ui->setupLayout->removeWidget(_setupWidget);
delete _setupWidget;
_setupWidget = NULL;
}
if (_parameterWidget) {
_ui->setupLayout->removeWidget(_parameterWidget);
delete _parameterWidget;
_parameterWidget = NULL;
}
}
/// @brief Removes and deletes all vehicle component setup buttons from the view.
void SetupView::_clearComponentButtons(void)
{
QLayoutItem* item;
while ((item = _ui->componentButtonLayout->itemAt(0))) {
VehicleComponentButton* componentButton = dynamic_cast<VehicleComponentButton*>(item->widget());
Q_ASSERT(componentButton);
_ui->componentButtonLayout->removeWidget(item->widget());
}
}
void SetupView::_summaryButtonClicked(void)
{
// Clear previous tab widgets
_clearWidgets();
// Create new tab widgets
_setupWidget = new SummaryPage(_components);
Q_CHECK_PTR(_setupWidget);
_ui->setupLayout->addWidget(_setupWidget);
_parameterWidget = new ParameterEditor(_uasCurrent, QStringList(), this);
_ui->parameterLayout->addWidget(_parameterWidget);
_showBothTabs();
_ui->tabWidget->setTabText(0, tr("Vehicle Summary"));
_ui->tabWidget->setTabText(1, tr("All Parameters"));
_uncheckAllButtons();
_ui->summaryButton->setChecked(true);
}
void SetupView::_firmwareButtonClicked(void)
{
// Clear previous tab widgets
_clearWidgets();
// Create new tab widgets
_setupWidget = new PX4FirmwareUpgrade(this);
Q_CHECK_PTR(_setupWidget);
_ui->setupLayout->addWidget(_setupWidget);
_showOnlySetupTab();
_ui->tabWidget->setTabEnabled(1, false);
_ui->tabWidget->setTabText(0, tr("Firmware Upgrade"));
_uncheckAllButtons();
_ui->firmwareButton->setChecked(true);
}
void SetupView::_componentButtonClicked(void)
{
// Clear previous tab widgets
_clearWidgets();
// Create new tab widgets
VehicleComponentButton* componentButton = dynamic_cast<VehicleComponentButton*>(sender());
Q_ASSERT(componentButton);
VehicleComponent* component = componentButton->component();
Q_ASSERT(component);
_setupWidget = component->setupWidget();
Q_ASSERT(_setupWidget);
_ui->setupLayout->addWidget(_setupWidget);
_parameterWidget = new ParameterEditor(_uasCurrent, component->paramFilterList(), this);
_ui->parameterLayout->addWidget(_parameterWidget);
_showBothTabs();
_ui->tabWidget->setTabText(0, tr("%1 Setup").arg(component->name()));
_ui->tabWidget->setTabText(1, tr("%1 Parameters").arg(component->name()));
_uncheckAllButtons();
componentButton->setChecked(true);
}
void SetupView::_parametersReady(void)
{
// When parameters become ready for the first time, setup the rest of the ui.
if (_initComplete) {
return;
}
_initComplete = true;
disconnect(_uasCurrent->getParamManager(), SIGNAL(parameterListUpToDate()), this, SLOT(_parametersReady()));
_ui->summaryButton->setVisible(true);
_components = AutoPilotPlugin::getInstanceForAutoPilotPlugin(_uasCurrent->getAutopilotType())->getVehicleComponents(_uasCurrent);
foreach(VehicleComponent* component, _components) {
VehicleComponentButton* button = new VehicleComponentButton(component, _ui->navBarWidget);
button->setCheckable(true);
button->setObjectName(component->name() + "Button");
button->setText(component->name());
QIcon icon;
icon.addFile(component->icon());
button->setIcon(icon);
button->setIconSize(_ui->firmwareButton->iconSize());
connect(button, &VehicleComponentButton::clicked, this, &SetupView::_componentButtonClicked);
_ui->componentButtonLayout->addWidget(button);
}
_summaryButtonClicked();
}
void SetupView::_showOnlySetupTab(void)
{
_ui->tabWidget->setCurrentIndex(0);
_ui->tabWidget->removeTab(1);
}
void SetupView::_showBothTabs(void)
{
_ui->tabWidget->setCurrentIndex(0);
if (_ui->tabWidget->count() == 1) {
_ui->tabWidget->insertTab(1, _ui->parameterTab, QString());
}
}
void SetupView::_uncheckAllButtons(void)
{
_ui->firmwareButton->setChecked(false);
_ui->summaryButton->setChecked(false);
int i = 0;
QLayoutItem* item;
while ((item = _ui->componentButtonLayout->itemAt(i++))) {
VehicleComponentButton* componentButton = dynamic_cast<VehicleComponentButton*>(item->widget());
if (componentButton != NULL) {
componentButton->setChecked(false);
}
}
}
void SetupView::_uasConnected(void)
{
qDebug() << "UAS connected";
// FIXME: We should re-connect the UI
}
void SetupView::_uasDisconnected(void)
{
qDebug() << "UAS disconnected";
// FIXME: We should disconnect the UI
}
/*=====================================================================
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 SETUPVIEW_H
#define SETUPVIEW_H
#include <QWidget>
#include "UASInterface.h"
#include "ParameterEditor.h"
#include "VehicleComponent.h"
/// @file
/// @brief This class is used to display the UI for the VehicleComponent objects.
/// @author Don Gagne <don@thegagnes.com>
namespace Ui {
class SetupView;
}
class SetupView : public QWidget
{
Q_OBJECT
public:
explicit SetupView(QWidget* parent = 0);
~SetupView();
private slots:
void _setActiveUAS(UASInterface* uas);
void _summaryButtonClicked(void);
void _firmwareButtonClicked(void);
void _componentButtonClicked(void);
void _parametersReady(void);
void _uasConnected(void);
void _uasDisconnected(void);
private:
void _clearWidgets(void);
void _clearComponentButtons(void);
void _showOnlySetupTab(void);
void _showBothTabs(void);
void _uncheckAllButtons(void);
UASInterface* _uasCurrent; ///< Currently active UAS
QList<VehicleComponent*> _components; ///< VehicleComponents for active UAS
QWidget* _setupWidget; ///< Currently active setup widget
ParameterEditor* _parameterWidget; ///< Currently active parameter editor wdiget
bool _initComplete; ///< true: parameters are ready and ui has been setup
Ui::SetupView* _ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SetupView</class>
<widget class="QWidget" name="SetupView">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>493</width>
<height>419</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QWidget" name="navBarWidget" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<layout class="QVBoxLayout" name="navBarLayout">
<property name="sizeConstraint">
<enum>QLayout::SetMinAndMaxSize</enum>
</property>
<property name="leftMargin">
<number>12</number>
</property>
<property name="topMargin">
<number>12</number>
</property>
<property name="rightMargin">
<number>24</number>
</property>
<property name="bottomMargin">
<number>12</number>
</property>
<item>
<widget class="VehicleSetupButton" name="firmwareButton">
<property name="text">
<string>Firmware
Upgrade</string>
</property>
<property name="icon">
<iconset resource="../../qgroundcontrol.qrc">
<normaloff>:/files/images/px4/menu/firmware_upgrade.png</normaloff>:/files/images/px4/menu/firmware_upgrade.png</iconset>
</property>
<property name="iconSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="VehicleSetupButton" name="summaryButton">
<property name="text">
<string>Vehicle
Summary</string>
</property>
<property name="icon">
<iconset resource="../../qgroundcontrol.qrc">
<normaloff>:/files/images/px4/menu/plane.png</normaloff>:/files/images/px4/menu/plane.png</iconset>
</property>
<property name="iconSize">
<size>
<width>60</width>
<height>60</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="componentButtonLayout"/>
</item>
<item>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="setupTab">
<attribute name="title">
<string>Setup</string>
</attribute>
<layout class="QVBoxLayout" name="setupLayout"/>
</widget>
<widget class="QWidget" name="parameterTab">
<attribute name="title">
<string>Parameters</string>
</attribute>
<layout class="QVBoxLayout" name="parameterLayout"/>
</widget>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>VehicleSetupButton</class>
<extends>QPushButton</extends>
<header>VehicleSetupButton.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="../../qgroundcontrol.qrc"/>
</resources>
<connections/>
</ui>
/*=====================================================================
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 <don@thegagnes.com>
#include "SummaryPage.h"
#include "ui_SummaryPage.h"
#include <QGroupBox>
#include <QTableWidget>
#include <QSpacerItem>
#include <QDebug>
SummaryPage::SummaryPage(QList<VehicleComponent*>& components, QWidget* parent) :
QWidget(parent),
_components(components),
_ui(new Ui::SummaryPage)
{
_ui->setupUi(this);
// Loop over all components, creating summary widgets
int row = 0;
int col = 0;
foreach(VehicleComponent* component, _components) {
QList<QStringList> summaryItems = component->summaryItems();
if (summaryItems.count()) {
// Rows without columns, bad
Q_ASSERT(summaryItems[0].count());
QGroupBox* box = new QGroupBox(component->name(), this);
QVBoxLayout* layout = new QVBoxLayout(box);
QTableWidget* table = new QTableWidget(summaryItems.count(), summaryItems[0].count(), box);
table->setShowGrid(false);
table->horizontalHeader()->setVisible(false);
table->verticalHeader()->setVisible(false);
QTableWidgetItem* item;
for (int tRow=0; tRow<summaryItems.count(); tRow++) {
for (int tCol=0; tCol<summaryItems[tRow].count(); tCol++) {
item = new QTableWidgetItem(summaryItems[tRow][tCol]);
table->setItem(tRow, tCol, item);
}
}
table->resizeColumnsToContents();
layout->addWidget(table);
_ui->gridLayout->addWidget(box, row, col++, Qt::AlignLeft | Qt::AlignTop);
}
if (col == 2) {
row++;
col = 0;
}
}
// Add spacers to force the grid to collapse to it's smallest size
QSpacerItem* spacer = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
_ui->gridLayout->addItem(spacer, 0, 2, 1, 1);
spacer = new QSpacerItem(20, 40, QSizePolicy::Minimum, QSizePolicy::Expanding);
_ui->gridLayout->addItem(spacer, row, 0, 1, 1);
}
SummaryPage::~SummaryPage()
{
delete _ui;
}
/*=====================================================================
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 SUMMARYPAGE_H
#define SUMMARYPAGE_H
#include <QWidget>
#include <QList>
#include "VehicleComponent.h"
/// @file
/// @brief This class is used to display the Summary Page portion of the Vehicle Setup UI.
/// @author Don Gagne <don@thegagnes.com>
namespace Ui {
class SummaryPage;
}
class SummaryPage : public QWidget
{
Q_OBJECT
public:
explicit SummaryPage(QList<VehicleComponent*>& components, QWidget* parent = 0);
~SummaryPage();
private:
QList<VehicleComponent*> _components; ///< VehicleComponents for active UAS
Ui::SummaryPage* _ui;
};
#endif
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SummaryPage</class>
<widget class="QWidget" name="SummaryPage">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1537</width>
<height>1100</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout"/>
</widget>
<resources/>
<connections/>
</ui>
/*=====================================================================
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 <don@thegagnes.com>
#include "VehicleComponent.h"
VehicleComponent::VehicleComponent(UASInterface* uas, QObject* parent) :
QObject(parent),
_uas(uas),
_paramMgr(_uas->getParamManager())
{
}
VehicleComponent::~VehicleComponent()
{
}
/*=====================================================================
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 VEHICLECOMPONENT_H
#define VEHICLECOMPONENT_H
#include <QObject>
#include "UASInterface.h"
/// @file
/// @brief Vehicle Component class. A vehicle component is an object which
/// abstracts the physical portion of a vehicle into a set of
/// configurable values and user interface.
/// @author Don Gagne <don@thegagnes.com>
class VehicleComponent : public QObject
{
Q_OBJECT
Q_PROPERTY(QString name READ name CONSTANT)
Q_PROPERTY(QString description READ description CONSTANT)
Q_PROPERTY(bool requiresSetup READ requiresSetup CONSTANT)
Q_PROPERTY(bool setupComplete READ setupComplete STORED false NOTIFY setupCompleteChanged)
Q_PROPERTY(QString setupStateDescription READ setupStateDescription STORED false)
Q_PROPERTY(QString icon READ icon CONSTANT)
Q_PROPERTY(QWidget* setupWidget READ setupWidget STORED false)
public:
VehicleComponent(UASInterface* uas, QObject* parent = NULL);
~VehicleComponent();
virtual QString name(void) const = 0;
virtual QString description(void) const = 0;
virtual QString icon(void) const = 0;
virtual bool requiresSetup(void) const = 0;
virtual bool setupComplete(void) const = 0;
virtual QString setupStateDescription(void) const = 0;
virtual QWidget* setupWidget(void) const = 0;
virtual QStringList paramFilterList(void) const = 0;
virtual QList<QStringList> summaryItems(void) const = 0;
signals:
void setupCompleteChanged(void);
protected:
UASInterface* _uas;
QGCUASParamManagerInterface* _paramMgr;
};
#endif
/*=====================================================================
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 VEHICLECOMPONENTBUTTON_H
#define VEHICLECOMPONENTBUTTON_H
#include "VehicleSetupButton.h"
#include "VehicleComponent.h"
/// @file
/// @brief This class is used for the push buttons in the Vehicle Setup display.
/// @author Don Gagne <don@thegagnes.com>
class VehicleComponentButton : public VehicleSetupButton
{
Q_OBJECT
public:
/// @param component VehicleComponent associated witht this button
VehicleComponentButton(VehicleComponent* component, QWidget* parent = NULL) :
VehicleSetupButton(parent),
_component(component)
{
Q_ASSERT(component);
}
/// @brief Returns the component associated with the button
VehicleComponent* component(void) { return _component; }
private:
VehicleComponent* _component;
};
#endif
/*=====================================================================
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 VEHICLESETUPBUTTON_H
#define VEHICLESETUPBUTTON_H
#include <QPushButton>
/// @file
/// @brief This class is used for the push button in the Vehicle Setup display. We use a seperate class
/// so we can assign a seperate style for them.
/// @author Don Gagne <don@thegagnes.com>
class VehicleSetupButton : public QPushButton
{
Q_OBJECT
public:
VehicleSetupButton(QWidget* parent = NULL) : QPushButton(parent) { }
};
#endif
// Currently unused but leaving here for future conversion to QML
import QtQuick 2.0
import QtQuick.Controls 1.2
Rectangle {
SystemPalette { id: myPalette; colorGroup: SystemPalette.Active }
color: myPalette.dark
anchors.fill: parent
id: buttonParent
signal componentButtonClicked(variant varComponent)
Button {
id: summaryButton
objectName: "summaryButton"
height: 50
width: 150
text: "Summary"
}
Button {
id: firmwareButton
objectName: "firmwareButton"
height: 50
width: 150
anchors.top: summaryButton.bottom
text: "Firmware"
}
ListModel {
id: vehicleComponentModelTest
ListElement {
name: "Radio"
setupComplete: true
icon: "/Users/Don/repos/qgroundcontrol/files/images/px4/menu/remote.png"
}
ListElement {
name: "Gyroscope"
setupCompleted: false
icon: "qrc:/files/images/px4/menu/remote.png"
}
ListElement {
name: "Magnetometer"
icon: "qrc:/files/images/px4/menu/remote.png"
}
}
ListView {
id: componentList
width: 200; height: contentItem.childrenRect.height
snapMode: ListView.NoSnap
anchors.top: firmwareButton.bottom
model: vehicleComponentModel
delegate: Button {
objectName: name + "SetupButton"
height: 50
width: 150
text: name
iconSource: icon
onClicked: {
console.log("Setup button clicked")
buttonParent.componentButtonClicked(modelData)
}
Rectangle {
width: 10
height: 10
color: setupComplete ? "green" : "red"
border.color: "black"
}
}
}
}
// Currently unused but leaving here for future conversion to QML
import QtQuick 2.0
import QtQuick.Controls 1.2
Item {
width: parent.width
height: parent.height
ListModel {
id: vehicleComponentModelTest
ListElement {
name: "Gyroscope"
description: "Long description"
setupComplete: false
}
ListElement {
name: "Magnetometer"
description: "Long description"
setupComplete: false
}
ListElement {
name: "Radio"
description: "Long description"
setupComplete: true
}
}
ListView {
id: componentList
anchors.fill: parent
model: vehicleComponentModel
section.property: "setupComplete"
section.criteria: ViewSection.FullString
section.delegate: Text { text: section == "true" ? "Setup complete" : "Requires setup" }
delegate: Item {
width: 180; height: 40
Column {
Text { text: "Component:" + model.name }
Text { text: model.description }
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment