11 changed files with 746 additions and 110 deletions
@ -0,0 +1,288 @@
@@ -0,0 +1,288 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?> |
||||
<airframes> |
||||
<version>1</version> |
||||
<airframe_group image="AirframeFlyingWing.png" name="Flying Wing"> |
||||
<airframe id="3030" maintainer="Simon Wilks <simon@px4.io>" name="IO Camflyer"> |
||||
<maintainer>Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
<url>https://pixhawk.org/platforms/planes/bormatec_camflyer_q</url> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">left aileron</output> |
||||
<output name="MAIN2">right aileron</output> |
||||
<output name="MAIN4">throttle</output> |
||||
</airframe> |
||||
<airframe id="3031" maintainer="Simon Wilks <simon@px4.io>" name="Phantom FPV Flying Wing"> |
||||
<maintainer>Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
<url>https://pixhawk.org/platforms/planes/z-84_wing_wing</url> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">left aileron</output> |
||||
<output name="MAIN2">right aileron</output> |
||||
<output name="MAIN4">throttle</output> |
||||
</airframe> |
||||
<airframe id="3032" maintainer="Thomas Gubler <thomas@px4.io>, Julian Oes <julian@px4.io>" name="Skywalker X5 Flying Wing"> |
||||
<maintainer>Thomas Gubler <thomas@px4.io>, Julian Oes <julian@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
<url>https://pixhawk.org/platforms/planes/skywalker_x5</url> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">left aileron</output> |
||||
<output name="MAIN2">right aileron</output> |
||||
<output name="MAIN4">throttle</output> |
||||
</airframe> |
||||
<airframe id="3033" maintainer="Simon Wilks <simon@px4.io>" name="Wing Wing (aka Z-84) Flying Wing"> |
||||
<maintainer>Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
<url>https://pixhawk.org/platforms/planes/z-84_wing_wing</url> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">left aileron</output> |
||||
<output name="MAIN2">right aileron</output> |
||||
<output name="MAIN4">throttle</output> |
||||
</airframe> |
||||
<airframe id="3034" maintainer="Simon Wilks <simon@px4.io>" name="FX-79 Buffalo Flying Wing"> |
||||
<maintainer>Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
</airframe> |
||||
<airframe id="3035" maintainer="Simon Wilks <simon@px4.io>" name="Viper"> |
||||
<maintainer>Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
</airframe> |
||||
<airframe id="3100" maintainer="Lorenz Meier <lorenz@px4.io>" name="TBS Caipirinha"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Flying Wing</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeHexaRotorPlus.png" name="Hexarotor +"> |
||||
<airframe id="7001" maintainer="Anton Babushkin <anton@px4.io>" name="Generic Hexarotor + geometry"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Hexarotor +</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="Hexarotor Coaxial"> |
||||
<airframe id="11001" maintainer="Lorenz Meier <lorenz@px4.io>" name="Generic Hexa coaxial geometry"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Hexarotor Coaxial</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeHexaRotorX.png" name="Hexarotor x"> |
||||
<airframe id="6001" maintainer="Anton Babushkin <anton@px4.io>" name="Generic Hexarotor x geometry"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Hexarotor x</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeOctoRotorPlus.png" name="Octorotor +"> |
||||
<airframe id="9001" maintainer="Anton Babushkin <anton@px4.io>" name="Generic Octocopter + geometry"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Octorotor +</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="Octorotor Coaxial"> |
||||
<airframe id="12001" maintainer="Lorenz Meier <lorenz@px4.io>" name="Generic 10" Octo coaxial geometry"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Octorotor Coaxial</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeOctoRotorX.png" name="Octorotor x"> |
||||
<airframe id="8001" maintainer="Anton Babushkin <anton@px4.io>" name="Generic Octocopter X geometry"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Octorotor x</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeQuadRotorPlus.png" name="Quadrotor +"> |
||||
<airframe id="5001" maintainer="Anton Babushkin <anton@px4.io>" name="Generic 10" Quad + geometry"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Quadrotor +</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeQuadRotorH.png" name="Quadrotor Wide"> |
||||
<airframe id="10015" maintainer="Anton Babushkin <anton@px4.io>, Simon Wilks <simon@px4.io>" name="Team Blacksheep Discovery"> |
||||
<maintainer>Anton Babushkin <anton@px4.io>, Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Quadrotor Wide</type> |
||||
</airframe> |
||||
<airframe id="10016" maintainer="Anton Babushkin <anton@px4.io>" name="3DR Iris Quadrotor"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Quadrotor Wide</type> |
||||
</airframe> |
||||
<airframe id="10017" maintainer="Thomas Gubler <thomas@px4.io>" name="Steadidrone QU4D"> |
||||
<maintainer>Thomas Gubler <thomas@px4.io></maintainer> |
||||
<type>Quadrotor Wide</type> |
||||
</airframe> |
||||
<airframe id="10018" maintainer="Simon Wilks <simon@px4.io>" name="Team Blacksheep Discovery Endurance"> |
||||
<maintainer>Simon Wilks <simon@px4.io></maintainer> |
||||
<type>Quadrotor Wide</type> |
||||
</airframe> |
||||
<airframe id="10019" maintainer="Anton Matosov <anton.matosov@gmail.com>" name="HobbyKing SK450 DeadCat modification"> |
||||
<maintainer>Anton Matosov <anton.matosov@gmail.com></maintainer> |
||||
<type>Quadrotor Wide</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeQuadRotorX.png" name="Quadrotor x"> |
||||
<airframe id="4001" maintainer="Lorenz Meier <lorenz@px4.io>" name="Generic Quadrotor X config"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Quadrotor x</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
<airframe id="4008" maintainer="Lorenz Meier <lorenz@px4.io>" name="AR.Drone Frame"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Quadrotor x</type> |
||||
</airframe> |
||||
<airframe id="4010" maintainer="Lorenz Meier <lorenz@px4.io>" name="DJI Flame Wheel F330"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Quadrotor x</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
<airframe id="4011" maintainer="Lorenz Meier <lorenz@px4.io>" name="DJI Flame Wheel F450"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Quadrotor x</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
</airframe> |
||||
<airframe id="4012" maintainer="Pavel Kirienko <pavel@px4.io>" name="F450-sized quadrotor with CAN"> |
||||
<maintainer>Pavel Kirienko <pavel@px4.io></maintainer> |
||||
<type>Quadrotor x</type> |
||||
</airframe> |
||||
<airframe id="4020" maintainer="Thomas Gubler <thomas@px4.io>" name="Hobbyking Micro PCB"> |
||||
<maintainer>Thomas Gubler <thomas@px4.io></maintainer> |
||||
<type>Quadrotor x</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="Rover"> |
||||
<airframe id="50001" maintainer="John Doe <john@example.com>" name="Axial Racing AX10"> |
||||
<type>Rover</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeSimulation.png" name="Simulation"> |
||||
<airframe id="1000" maintainer="Lorenz Meier <lorenz@px4.io>" name="HILStar (XPlane)"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Simulation</type> |
||||
<output name="MAIN1">aileron</output> |
||||
<output name="MAIN2">elevator</output> |
||||
<output name="MAIN3">rudder</output> |
||||
<output name="MAIN4">throttle</output> |
||||
</airframe> |
||||
<airframe id="1001" maintainer="Anton Babushkin <anton@px4.io>" name="HIL Quadcopter X"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Simulation</type> |
||||
</airframe> |
||||
<airframe id="1003" maintainer="Anton Babushkin <anton@px4.io>" name="HIL Quadcopter +"> |
||||
<maintainer>Anton Babushkin <anton@px4.io></maintainer> |
||||
<type>Simulation</type> |
||||
</airframe> |
||||
<airframe id="1004" maintainer="Thomas Gubler <thomas@px4.io>" name="HIL Rascal 110 (Flightgear)"> |
||||
<maintainer>Thomas Gubler <thomas@px4.io></maintainer> |
||||
<type>Simulation</type> |
||||
</airframe> |
||||
<airframe id="1005" maintainer="Thomas Gubler <thomas@px4.io>" name="HIL Malolo 1 (Flightgear)"> |
||||
<maintainer>Thomas Gubler <thomas@px4.io></maintainer> |
||||
<type>Simulation</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="AirframeStandardPlane.png" name="Standard Plane"> |
||||
<airframe id="2100" maintainer="Lorenz Meier <lorenz@px4.io>" name="Multiplex Easystar"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Standard Plane</type> |
||||
</airframe> |
||||
<airframe id="2101" maintainer="Lorenz Meier <lorenz@px4.io>" name="Standard AERT Plane"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Standard Plane</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">aileron</output> |
||||
<output name="MAIN2">elevator</output> |
||||
<output name="MAIN3">throttle</output> |
||||
<output name="MAIN4">rudder</output> |
||||
<output name="MAIN5">flaps</output> |
||||
</airframe> |
||||
<airframe id="2102" maintainer="Lorenz Meier <lorenz@px4.io>" name="Skywalker (3DR Aero)"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Standard Plane</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">aileron</output> |
||||
<output name="MAIN2">elevator</output> |
||||
<output name="MAIN3">throttle</output> |
||||
<output name="MAIN4">rudder</output> |
||||
<output name="MAIN5">flaps</output> |
||||
</airframe> |
||||
<airframe id="2103" maintainer="Lorenz Meier <lorenz@px4.io>" name="Skyhunter 1800"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Standard Plane</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">aileron</output> |
||||
<output name="MAIN2">elevator</output> |
||||
<output name="MAIN4">throttle</output> |
||||
</airframe> |
||||
<airframe id="2104" maintainer="Lorenz Meier <lorenz@px4.io>" name="Standard AETR Plane"> |
||||
<maintainer>Lorenz Meier <lorenz@px4.io></maintainer> |
||||
<type>Standard Plane</type> |
||||
<output name="AUX1">feed-through of RC AUX1 channel</output> |
||||
<output name="AUX2">feed-through of RC AUX2 channel</output> |
||||
<output name="AUX3">feed-through of RC AUX3 channel</output> |
||||
<output name="MAIN1">aileron</output> |
||||
<output name="MAIN2">elevator</output> |
||||
<output name="MAIN3">throttle</output> |
||||
<output name="MAIN4">rudder</output> |
||||
<output name="MAIN5">flaps</output> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="Tricopter Y+"> |
||||
<airframe id="14001" maintainer="Trent Lukaczyk <aerialhedgehog@gmail.com>" name="Generic Tricopter Y+ Geometry"> |
||||
<maintainer>Trent Lukaczyk <aerialhedgehog@gmail.com></maintainer> |
||||
<type>Tricopter Y+</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="Tricopter Y-"> |
||||
<airframe id="14002" maintainer="Trent Lukaczyk <aerialhedgehog@gmail.com>" name="Generic Tricopter Y- Geometry"> |
||||
<maintainer>Trent Lukaczyk <aerialhedgehog@gmail.com></maintainer> |
||||
<type>Tricopter Y-</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="VTOL Tailsitter"> |
||||
<airframe id="13001" maintainer="Roman Bapst <roman@px4.io>" name="Duorotor Tailsitter"> |
||||
<maintainer>Roman Bapst <roman@px4.io></maintainer> |
||||
<type>VTOL Tailsitter</type> |
||||
</airframe> |
||||
<airframe id="13003" maintainer="Roman Bapst <roman@px4.io>" name="Quadrotor X Tailsitter"> |
||||
<maintainer>Roman Bapst <roman@px4.io></maintainer> |
||||
<type>VTOL Tailsitter</type> |
||||
</airframe> |
||||
<airframe id="13004" maintainer="Roman Bapst <roman@px4.io>" name="Quadrotor + Tailsitter"> |
||||
<maintainer>Roman Bapst <roman@px4.io></maintainer> |
||||
<type>VTOL Tailsitter</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
<airframe_group image="" name="VTOL Tiltrotor"> |
||||
<airframe id="13002" maintainer="Roman Bapst <roman@px4.io>" name="BirdsEyeView Aerobotics FireFly6"> |
||||
<maintainer>Roman Bapst <roman@px4.io></maintainer> |
||||
<type>VTOL Tiltrotor</type> |
||||
</airframe> |
||||
</airframe_group> |
||||
</airframes> |
@ -0,0 +1,255 @@
@@ -0,0 +1,255 @@
|
||||
/*=====================================================================
|
||||
|
||||
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 "PX4AirframeLoader.h" |
||||
#include "QGCApplication.h" |
||||
#include "QGCLoggingCategory.h" |
||||
#include "AirframeComponentAirframes.h" |
||||
|
||||
#include <QFile> |
||||
#include <QFileInfo> |
||||
#include <QDir> |
||||
#include <QDebug> |
||||
|
||||
QGC_LOGGING_CATEGORY(PX4AirframeLoaderLog, "PX4AirframeLoaderLog") |
||||
|
||||
bool PX4AirframeLoader::_airframeMetaDataLoaded = false; |
||||
|
||||
PX4AirframeLoader::PX4AirframeLoader(AutoPilotPlugin* autopilot, UASInterface* uas, QObject* parent) |
||||
{ |
||||
Q_UNUSED(autopilot); |
||||
Q_UNUSED(uas); |
||||
Q_UNUSED(parent); |
||||
Q_ASSERT(uas); |
||||
} |
||||
|
||||
/// Load Airframe Fact meta data
|
||||
///
|
||||
/// The meta data comes from firmware airframes.xml file.
|
||||
void PX4AirframeLoader::loadAirframeFactMetaData(void) |
||||
{ |
||||
if (_airframeMetaDataLoaded) { |
||||
return; |
||||
} |
||||
|
||||
qCDebug(PX4AirframeLoaderLog) << "Loading PX4 airframe fact meta data"; |
||||
qDebug() << "LOADING META DATA"; |
||||
|
||||
Q_ASSERT(AirframeComponentAirframes::get().count() == 0); |
||||
|
||||
QString airframeFilename; |
||||
|
||||
// We want unit test builds to always use the resource based meta data to provide repeatable results
|
||||
if (!qgcApp()->runningUnitTests()) { |
||||
// First look for meta data that comes from a firmware download. Fall back to resource if not there.
|
||||
QSettings settings; |
||||
QDir parameterDir = QFileInfo(settings.fileName()).dir(); |
||||
airframeFilename = parameterDir.filePath("PX4AirframeFactMetaData.xml"); |
||||
} |
||||
if (airframeFilename.isEmpty() || !QFile(airframeFilename).exists()) { |
||||
airframeFilename = ":/AutoPilotPlugins/PX4/AirframeFactMetaData.xml"; |
||||
} |
||||
|
||||
qCDebug(PX4AirframeLoaderLog) << "Loading meta data file:" << airframeFilename; |
||||
|
||||
QFile xmlFile(airframeFilename); |
||||
Q_ASSERT(xmlFile.exists()); |
||||
|
||||
bool success = xmlFile.open(QIODevice::ReadOnly); |
||||
Q_UNUSED(success); |
||||
Q_ASSERT(success); |
||||
|
||||
if (!success) { |
||||
qWarning() << "Failed opening airframe XML"; |
||||
return; |
||||
} |
||||
|
||||
QXmlStreamReader xml(xmlFile.readAll()); |
||||
xmlFile.close(); |
||||
if (xml.hasError()) { |
||||
qWarning() << "Badly formed XML" << xml.errorString(); |
||||
return; |
||||
} |
||||
|
||||
QString airframeGroup; |
||||
QString image; |
||||
QString errorString; |
||||
int xmlState = XmlStateNone; |
||||
bool badMetaData = true; |
||||
|
||||
while (!xml.atEnd()) { |
||||
if (xml.isStartElement()) { |
||||
QString elementName = xml.name().toString(); |
||||
|
||||
if (elementName == "airframes") { |
||||
if (xmlState != XmlStateNone) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
xmlState = XmlStateFoundAirframes; |
||||
|
||||
} else if (elementName == "version") { |
||||
if (xmlState != XmlStateFoundAirframes) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
xmlState = XmlStateFoundVersion; |
||||
|
||||
bool convertOk; |
||||
QString strVersion = xml.readElementText(); |
||||
int intVersion = strVersion.toInt(&convertOk); |
||||
if (!convertOk) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
if (intVersion < 1) { |
||||
// We can't read these old files
|
||||
qDebug() << "Airframe version stamp too old, skipping load. Found:" << intVersion << "Want: 3 File:" << airframeFilename; |
||||
return; |
||||
} |
||||
|
||||
|
||||
} else if (elementName == "airframe_group") { |
||||
if (xmlState != XmlStateFoundVersion) { |
||||
// We didn't get a version stamp, assume older version we can't read
|
||||
qDebug() << "Parameter version stamp not found, skipping load" << airframeFilename; |
||||
return; |
||||
} |
||||
xmlState = XmlStateFoundGroup; |
||||
|
||||
if (!xml.attributes().hasAttribute("name") || !xml.attributes().hasAttribute("image")) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
airframeGroup = xml.attributes().value("name").toString(); |
||||
image = xml.attributes().value("image").toString(); |
||||
qCDebug(PX4AirframeLoaderLog) << "Found group: " << airframeGroup; |
||||
|
||||
} else if (elementName == "airframe") { |
||||
if (xmlState != XmlStateFoundGroup) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
xmlState = XmlStateFoundAirframe; |
||||
|
||||
if (!xml.attributes().hasAttribute("name") || !xml.attributes().hasAttribute("id")) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
|
||||
QString name = xml.attributes().value("name").toString(); |
||||
QString id = xml.attributes().value("id").toString(); |
||||
|
||||
qCDebug(PX4AirframeLoaderLog) << "Found airframe name:" << name << " type:" << airframeGroup << " id:" << id; |
||||
|
||||
// Now that we know type we can airframe meta data object and add it to the system
|
||||
AirframeComponentAirframes::insert(airframeGroup, image, name, id.toInt()); |
||||
|
||||
} else { |
||||
// We should be getting meta data now
|
||||
if (xmlState != XmlStateFoundAirframe) { |
||||
qWarning() << "Badly formed XML"; |
||||
return; |
||||
} |
||||
|
||||
if (!badMetaData) { |
||||
|
||||
// We eventually want this, just not yet now
|
||||
// if (elementName == "short_desc") {
|
||||
// Q_ASSERT(metaData);
|
||||
// QString text = xml.readElementText();
|
||||
// text = text.replace("\n", " ");
|
||||
// qCDebug(PX4AirframeLoaderLog) << "Short description:" << text;
|
||||
// metaData->setShortDescription(text);
|
||||
|
||||
// } else if (elementName == "long_desc") {
|
||||
// Q_ASSERT(metaData);
|
||||
// QString text = xml.readElementText();
|
||||
// text = text.replace("\n", " ");
|
||||
// qCDebug(PX4AirframeLoaderLog) << "Long description:" << text;
|
||||
// metaData->setLongDescription(text);
|
||||
|
||||
// } else if (elementName == "min") {
|
||||
// Q_ASSERT(metaData);
|
||||
// QString text = xml.readElementText();
|
||||
// qCDebug(PX4AirframeLoaderLog) << "Min:" << text;
|
||||
|
||||
// QVariant varMin;
|
||||
// if (metaData->convertAndValidate(text, true /* convertOnly */, varMin, errorString)) {
|
||||
// metaData->setMin(varMin);
|
||||
// } else {
|
||||
// qCWarning(PX4AirframeLoaderLog) << "Invalid min value, name:" << metaData->name() << " type:" << metaData->type() << " min:" << text << " error:" << errorString;
|
||||
// }
|
||||
|
||||
// } else if (elementName == "max") {
|
||||
// Q_ASSERT(metaData);
|
||||
// QString text = xml.readElementText();
|
||||
// qCDebug(PX4AirframeLoaderLog) << "Max:" << text;
|
||||
|
||||
// QVariant varMax;
|
||||
// if (metaData->convertAndValidate(text, true /* convertOnly */, varMax, errorString)) {
|
||||
// metaData->setMax(varMax);
|
||||
// } else {
|
||||
// qCWarning(PX4AirframeLoaderLog) << "Invalid max value, name:" << metaData->name() << " type:" << metaData->type() << " max:" << text << " error:" << errorString;
|
||||
// }
|
||||
|
||||
// } else if (elementName == "unit") {
|
||||
// Q_ASSERT(metaData);
|
||||
// QString text = xml.readElementText();
|
||||
// qCDebug(PX4AirframeLoaderLog) << "Unit:" << text;
|
||||
// metaData->setUnits(text);
|
||||
|
||||
// } else {
|
||||
qDebug() << "Unknown element in XML: " << elementName; |
||||
// }
|
||||
} |
||||
} |
||||
} else if (xml.isEndElement()) { |
||||
QString elementName = xml.name().toString(); |
||||
|
||||
if (elementName == "airframe") { |
||||
// Done loading this airframe, validate
|
||||
|
||||
// Reset for next airframe
|
||||
badMetaData = false; |
||||
xmlState = XmlStateFoundGroup; |
||||
} else if (elementName == "airframe_group") { |
||||
xmlState = XmlStateFoundVersion; |
||||
} else if (elementName == "airframes") { |
||||
xmlState = XmlStateFoundAirframes; |
||||
} |
||||
} |
||||
xml.readNext(); |
||||
} |
||||
|
||||
_airframeMetaDataLoaded = true; |
||||
} |
||||
|
||||
void PX4AirframeLoader::clearStaticData(void) |
||||
{ |
||||
AirframeComponentAirframes::clear(); |
||||
_airframeMetaDataLoaded = false; |
||||
} |
@ -0,0 +1,69 @@
@@ -0,0 +1,69 @@
|
||||
/*=====================================================================
|
||||
|
||||
QGroundControl Open Source Ground Control Station |
||||
|
||||
(c) 2009 - 2015 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 PX4AIRFRAMELOADER_H |
||||
#define PX4AIRFRAMELOADER_H |
||||
|
||||
#include <QObject> |
||||
#include <QMap> |
||||
#include <QXmlStreamReader> |
||||
#include <QLoggingCategory> |
||||
|
||||
#include "ParameterLoader.h" |
||||
#include "FactSystem.h" |
||||
#include "UASInterface.h" |
||||
#include "AutoPilotPlugin.h" |
||||
|
||||
/// @file PX4AirframeLoader.h
|
||||
/// @author Lorenz Meier <lm@qgroundcontrol.org>
|
||||
|
||||
Q_DECLARE_LOGGING_CATEGORY(PX4AirframeLoaderLog) |
||||
|
||||
/// Collection of Parameter Facts for PX4 AutoPilot
|
||||
|
||||
class PX4AirframeLoader : QObject |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
/// @param uas Uas which this set of facts is associated with
|
||||
PX4AirframeLoader(AutoPilotPlugin* autpilot,UASInterface* uas, QObject* parent = NULL); |
||||
|
||||
static void loadAirframeFactMetaData(void); |
||||
static void clearStaticData(void); |
||||
|
||||
private: |
||||
enum { |
||||
XmlStateNone, |
||||
XmlStateFoundAirframes, |
||||
XmlStateFoundVersion, |
||||
XmlStateFoundGroup, |
||||
XmlStateFoundAirframe, |
||||
XmlStateDone |
||||
}; |
||||
|
||||
static bool _airframeMetaDataLoaded; ///< true: parameter meta data already loaded
|
||||
static QMap<QString, FactMetaData*> _mapParameterName2FactMetaData; ///< Maps from a parameter name to FactMetaData
|
||||
}; |
||||
|
||||
#endif // PX4AIRFRAMELOADER_H
|
Loading…
Reference in new issue