Commit acbacef3 authored by Lorenz Meier's avatar Lorenz Meier

Autopilot plugin and airframe loader: Move to new-style map approach

parent 2b83ce66
...@@ -26,86 +26,99 @@ ...@@ -26,86 +26,99 @@
#include "AirframeComponentAirframes.h" #include "AirframeComponentAirframes.h"
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoStandardPlane[] = { QMap<QString, AirframeComponentAirframes::AirframeType_t> AirframeComponentAirframes::rgAirframeTypes;
{ "Multiplex Easystar 1/2", 2100 },
{ "Generic AERT", 2101 }, AirframeComponentAirframes::AirframeComponentAirframes() {
{ "3DR Skywalker", 2102 },
{ "Skyhunter (1800 mm)", 2103 }, // Standard planes
{ "Generic AETR", 2104 }, AirframeType_t standardPlane = { "Standard Airplane", "qrc:/qmlimages/AirframeStandardPlane.png", };
{ NULL, 0 } AirframeInfo_t easystar = {"Multiplex Easystar 1/2", 2100};
}; standardPlane.rgAirframeInfo.append(easystar);
rgAirframeTypes.insert("StandardPlane", standardPlane);
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoSimulation[] = {
{ "Plane (HilStar, X-Plane)", 1000 }, // Flying wings
{ "Plane (Rascal, FlightGear)", 1004 }, }
{ "Quad X HIL", 1001 },
{ "Quad + HIL", 1003 }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoStandardPlane[] = {
{ NULL, 0 } // { "Multiplex Easystar 1/2", 2100 },
}; // { "Generic AERT", 2101 },
// { "3DR Skywalker", 2102 },
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoFlyingWing[] = { // { "Skyhunter (1800 mm)", 2103 },
{ "Z-84 Wing Wing (845 mm)", 3033 }, // { "Generic AETR", 2104 },
{ "TBS Caipirinha (850 mm)", 3100 }, // { NULL, 0 }
{ "Bormatec Camflyer Q (800 mm)", 3030 }, //};
{ "FX-61 Phantom FPV (1550 mm)", 3031 },
{ "FX-79 Buffalo (2000 mm)", 3034 }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoSimulation[] = {
{ "Skywalker X5 (1180 mm)", 3032 }, // { "Plane (HilStar, X-Plane)", 1000 },
{ "Viper v2 (3000 mm)", 3035 }, // { "Plane (Rascal, FlightGear)", 1004 },
{ NULL, 0 } // { "Quad X HIL", 1001 },
}; // { "Quad + HIL", 1003 },
// { NULL, 0 }
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorX[] = { //};
{ "DJI F330 8\" Quad", 4010 },
{ "DJI F450 10\" Quad", 4011 }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoFlyingWing[] = {
{ "X frame Quad UAVCAN", 4012 }, // { "Z-84 Wing Wing (845 mm)", 3033 },
{ "AR.Drone Frame Quad", 4008 }, // { "TBS Caipirinha (850 mm)", 3100 },
{ NULL, 0 } // { "Bormatec Camflyer Q (800 mm)", 3030 },
}; // { "FX-61 Phantom FPV (1550 mm)", 3031 },
// { "FX-79 Buffalo (2000 mm)", 3034 },
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorPlus[] = { // { "Skywalker X5 (1180 mm)", 3032 },
{ "Generic 10\" Quad +", 5001 }, // { "Viper v2 (3000 mm)", 3035 },
{ NULL, 0 } // { NULL, 0 }
}; //};
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoHexaRotorX[] = { //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorX[] = {
{ "Standard 10\" Hexa X", 6001 }, // { "DJI F330 8\" Quad", 4010 },
{ "Coaxial 10\" Hexa X", 11001 }, // { "DJI F450 10\" Quad", 4011 },
{ NULL, 0 } // { "X frame Quad UAVCAN", 4012 },
}; // { "AR.Drone Frame Quad", 4008 },
// { NULL, 0 }
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoHexaRotorPlus[] = { //};
{ "Standard 10\" Hexa", 7001 },
{ NULL, 0 } //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorPlus[] = {
}; // { "Generic 10\" Quad +", 5001 },
// { NULL, 0 }
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoOctoRotorX[] = { //};
{ "Standard 10\" Octo", 8001 },
{ "Coaxial 10\" Octo", 12001 }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoHexaRotorX[] = {
{ NULL, 0 } // { "Standard 10\" Hexa X", 6001 },
}; // { "Coaxial 10\" Hexa X", 11001 },
// { NULL, 0 }
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoOctoRotorPlus[] = { //};
{ "Standard 10\" Octo", 9001 },
{ NULL, 0 } //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoHexaRotorPlus[] = {
}; // { "Standard 10\" Hexa", 7001 },
// { NULL, 0 }
const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorH[] = { //};
{ "3DR Iris", 10016 },
{ "TBS Discovery", 10015 }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoOctoRotorX[] = {
{ "SteadiDrone QU4D", 10017 }, // { "Standard 10\" Octo", 8001 },
{ NULL, 0 } // { "Coaxial 10\" Octo", 12001 },
}; // { NULL, 0 }
//};
const AirframeComponentAirframes::AirframeType_t AirframeComponentAirframes::rgAirframeTypes[] = {
{ "Standard Airplane", "qrc:/qmlimages/AirframeStandardPlane.png", AirframeComponentAirframes::_rgAirframeInfoStandardPlane }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoOctoRotorPlus[] = {
{ "Flying Wing", "qrc:/qmlimages/AirframeFlyingWing.png", AirframeComponentAirframes::_rgAirframeInfoFlyingWing }, // { "Standard 10\" Octo", 9001 },
{ "QuadRotor X", "qrc:/qmlimages/AirframeQuadRotorX.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorX }, // { NULL, 0 }
{ "QuadRotor +", "qrc:/qmlimages/AirframeQuadRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorPlus }, //};
{ "HexaRotor X", "qrc:/qmlimages/AirframeHexaRotorX.png", AirframeComponentAirframes::_rgAirframeInfoHexaRotorX },
{ "HexaRotor +", "qrc:/qmlimages/AirframeHexaRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoHexaRotorPlus }, //const AirframeComponentAirframes::AirframeInfo_t AirframeComponentAirframes::_rgAirframeInfoQuadRotorH[] = {
{ "OctoRotor X", "qrc:/qmlimages/AirframeOctoRotorX.png", AirframeComponentAirframes::_rgAirframeInfoOctoRotorX }, // { "3DR Iris", 10016 },
{ "OctoRotor +", "qrc:/qmlimages/AirframeOctoRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoOctoRotorPlus }, // { "TBS Discovery", 10015 },
{ "QuadRotor H", "qrc:/qmlimages/AirframeQuadRotorH.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorH }, // { "SteadiDrone QU4D", 10017 },
{ "Simulation", "qrc:/qmlimages/AirframeSimulation.png", AirframeComponentAirframes::_rgAirframeInfoSimulation }, // { NULL, 0 }
{ NULL, NULL, NULL } //};
};
//const AirframeComponentAirframes::AirframeType_t AirframeComponentAirframes::rgAirframeTypes[] = {
// { "Standard Airplane", "qrc:/qmlimages/AirframeStandardPlane.png", AirframeComponentAirframes::_rgAirframeInfoStandardPlane },
// { "Flying Wing", "qrc:/qmlimages/AirframeFlyingWing.png", AirframeComponentAirframes::_rgAirframeInfoFlyingWing },
// { "QuadRotor X", "qrc:/qmlimages/AirframeQuadRotorX.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorX },
// { "QuadRotor +", "qrc:/qmlimages/AirframeQuadRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorPlus },
// { "HexaRotor X", "qrc:/qmlimages/AirframeHexaRotorX.png", AirframeComponentAirframes::_rgAirframeInfoHexaRotorX },
// { "HexaRotor +", "qrc:/qmlimages/AirframeHexaRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoHexaRotorPlus },
// { "OctoRotor X", "qrc:/qmlimages/AirframeOctoRotorX.png", AirframeComponentAirframes::_rgAirframeInfoOctoRotorX },
// { "OctoRotor +", "qrc:/qmlimages/AirframeOctoRotorPlus.png", AirframeComponentAirframes::_rgAirframeInfoOctoRotorPlus },
// { "QuadRotor H", "qrc:/qmlimages/AirframeQuadRotorH.png", AirframeComponentAirframes::_rgAirframeInfoQuadRotorH },
// { "Simulation", "qrc:/qmlimages/AirframeSimulation.png", AirframeComponentAirframes::_rgAirframeInfoSimulation },
// { NULL, NULL, NULL }
//};
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
#include <QObject> #include <QObject>
#include <QQuickItem> #include <QQuickItem>
#include <QList> #include <QList>
#include <QMap>
#include "UASInterface.h" #include "UASInterface.h"
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
...@@ -38,6 +39,8 @@ ...@@ -38,6 +39,8 @@
class AirframeComponentAirframes class AirframeComponentAirframes
{ {
public: public:
AirframeComponentAirframes();
typedef struct { typedef struct {
const char* name; const char* name;
int autostartId; int autostartId;
...@@ -46,23 +49,13 @@ public: ...@@ -46,23 +49,13 @@ public:
typedef struct { typedef struct {
const char* name; const char* name;
const char* imageResource; const char* imageResource;
const AirframeInfo_t* rgAirframeInfo; QList<AirframeInfo_t> rgAirframeInfo;
} AirframeType_t; } AirframeType_t;
public: public:
static const AirframeType_t rgAirframeTypes[]; static QMap<QString, AirframeType_t> rgAirframeTypes;
private: private:
static const AirframeInfo_t _rgAirframeInfoStandardPlane[];
static const AirframeInfo_t _rgAirframeInfoFlyingWing[];
static const AirframeInfo_t _rgAirframeInfoQuadRotorX[];
static const AirframeInfo_t _rgAirframeInfoQuadRotorPlus[];
static const AirframeInfo_t _rgAirframeInfoOctoRotorX[];
static const AirframeInfo_t _rgAirframeInfoOctoRotorPlus[];
static const AirframeInfo_t _rgAirframeInfoHexaRotorX[];
static const AirframeInfo_t _rgAirframeInfoHexaRotorPlus[];
static const AirframeInfo_t _rgAirframeInfoQuadRotorH[];
static const AirframeInfo_t _rgAirframeInfoSimulation[];
}; };
#endif #endif
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include "UASManager.h" #include "UASManager.h"
#include "PX4ParameterLoader.h" #include "PX4ParameterLoader.h"
#include "PX4AirframeLoader.h"
#include "FlightModesComponentController.h" #include "FlightModesComponentController.h"
#include "AirframeComponentController.h" #include "AirframeComponentController.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
...@@ -81,13 +82,18 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) : ...@@ -81,13 +82,18 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(UASInterface* uas, QObject* parent) :
connect(_parameterFacts, &PX4ParameterLoader::parametersReady, this, &PX4AutoPilotPlugin::_pluginReadyPreChecks); connect(_parameterFacts, &PX4ParameterLoader::parametersReady, this, &PX4AutoPilotPlugin::_pluginReadyPreChecks);
connect(_parameterFacts, &PX4ParameterLoader::parameterListProgress, this, &PX4AutoPilotPlugin::parameterListProgress); connect(_parameterFacts, &PX4ParameterLoader::parameterListProgress, this, &PX4AutoPilotPlugin::parameterListProgress);
_airframeFacts = new PX4AirframeLoader(this, uas, this);
Q_CHECK_PTR(_airframeFacts);
PX4ParameterLoader::loadParameterFactMetaData(); PX4ParameterLoader::loadParameterFactMetaData();
PX4AirframeLoader::loadAirframeFactMetaData();
} }
PX4AutoPilotPlugin::~PX4AutoPilotPlugin() PX4AutoPilotPlugin::~PX4AutoPilotPlugin()
{ {
delete _parameterFacts; delete _parameterFacts;
delete _airframeFacts;
} }
QList<AutoPilotPluginManager::FullMode_t> PX4AutoPilotPlugin::getModes(void) QList<AutoPilotPluginManager::FullMode_t> PX4AutoPilotPlugin::getModes(void)
...@@ -259,6 +265,7 @@ QString PX4AutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMo ...@@ -259,6 +265,7 @@ QString PX4AutoPilotPlugin::getShortModeText(uint8_t baseMode, uint32_t customMo
void PX4AutoPilotPlugin::clearStaticData(void) void PX4AutoPilotPlugin::clearStaticData(void)
{ {
PX4ParameterLoader::clearStaticData(); PX4ParameterLoader::clearStaticData();
PX4AirframeLoader::clearStaticData();
} }
const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void) const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "PX4ParameterLoader.h" #include "PX4ParameterLoader.h"
#include "PX4AirframeLoader.h"
#include "AirframeComponent.h" #include "AirframeComponent.h"
#include "RadioComponent.h" #include "RadioComponent.h"
#include "FlightModesComponent.h" #include "FlightModesComponent.h"
...@@ -72,7 +73,8 @@ private: ...@@ -72,7 +73,8 @@ private:
// Overrides from AutoPilotPlugin // Overrides from AutoPilotPlugin
virtual ParameterLoader* _getParameterLoader(void) { return _parameterFacts; } virtual ParameterLoader* _getParameterLoader(void) { return _parameterFacts; }
PX4ParameterLoader* _parameterFacts; PX4ParameterLoader* _parameterFacts;
PX4AirframeLoader* _airframeFacts;
QVariantList _components; QVariantList _components;
AirframeComponent* _airframeComponent; AirframeComponent* _airframeComponent;
RadioComponent* _radioComponent; RadioComponent* _radioComponent;
......
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