Commit 1f2214d3 authored by pixhawk's avatar pixhawk

Redesigned MAVLink folder structure, suits now better multiple projects

parent 017b5ae1
...@@ -24,3 +24,4 @@ doc/doxy.log ...@@ -24,3 +24,4 @@ doc/doxy.log
deploy/mac deploy/mac
deploy/linux deploy/linux
controller_log* controller_log*
user_config.pri
#------------------------------------------------- #-------------------------------------------------
# #
# MAVGround - Micro Air Vehicle Groundstation # QGroundControl - Micro Air Vehicle Groundstation
# #
# Please see our website at <http://qgroundcontrol.org> # Please see our website at <http://qgroundcontrol.org>
# #
# Original Author: # Author:
# Lorenz Meier <mavteam@student.ethz.ch> # Lorenz Meier <mavteam@student.ethz.ch>
# #
# Contributing Authors (in alphabetical order): # (c) 2009-2010 PIXHAWK Team
#
# (c) 2009 PIXHAWK Team
# #
# This file is part of the mav groundstation project # This file is part of the mav groundstation project
# MAVGround is free software: you can redistribute it and/or modify # QGroundControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or # the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version. # (at your option) any later version.
# MAVGround is distributed in the hope that it will be useful, # QGroundControl is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with MAVGround. If not, see <http://www.gnu.org/licenses/>. # along with QGroundControl. If not, see <http://www.gnu.org/licenses/>.
# #
#------------------------------------------------- #-------------------------------------------------
......
#-------------------------------------------------
#
# QGroundControl - Micro Air Vehicle Groundstation
#
# Please see our website at <http://qgroundcontrol.org>
#
# Author:
# Lorenz Meier <mavteam@student.ethz.ch>
#
# (c) 2009-2010 PIXHAWK Team
#
# This file is part of the mav groundstation 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 QMapControl map library # Include QMapControl map library
# prefer version from external directory / # prefer version from external directory /
# from http://github.com/pixhawk/qmapcontrol/ # from http://github.com/pixhawk/qmapcontrol/
...@@ -5,6 +31,7 @@ ...@@ -5,6 +31,7 @@
# Version from GIT repository is preferred # Version from GIT repository is preferred
# include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{ # include ( "../qmapcontrol/QMapControl/QMapControl.pri" ) #{
# Include bundled version if necessary # Include bundled version if necessary
include(lib/QMapControl/QMapControl.pri) include(lib/QMapControl/QMapControl.pri)
# message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows") # message("Including bundled QMapControl version as FALLBACK. This is fine on Linux and MacOS, but not the best choice in Windows")
...@@ -24,6 +51,12 @@ OBJECTS_DIR = $$BUILDDIR/obj ...@@ -24,6 +51,12 @@ OBJECTS_DIR = $$BUILDDIR/obj
MOC_DIR = $$BUILDDIR/moc MOC_DIR = $$BUILDDIR/moc
UI_HEADERS_DIR = src/ui/generated UI_HEADERS_DIR = src/ui/generated
exists(user_config.pri) {
message("----- USING USER QGROUNDCONTROL CONFIG FROM user_config.pri -----")
include(user_config.pri)
}
# } # }
# Include general settings for MAVGround # Include general settings for MAVGround
# necessary as last include to override any non-acceptable settings # necessary as last include to override any non-acceptable settings
...@@ -42,8 +75,7 @@ DEPENDPATH += . \ ...@@ -42,8 +75,7 @@ DEPENDPATH += . \
plugins plugins
INCLUDEPATH += . \ INCLUDEPATH += . \
lib/QMapControl \ lib/QMapControl \
$$BASEDIR/../mavlink/contrib/slugs/include \ $$BASEDIR/../mavlink/include/common
$$BASEDIR/../mavlink/include
# ../mavlink/include \ # ../mavlink/include \
# MAVLink/include \ # MAVLink/include \
......
...@@ -71,7 +71,13 @@ bool MAVLinkXMLParser::generate() ...@@ -71,7 +71,13 @@ bool MAVLinkXMLParser::generate()
bool success = true; bool success = true;
// Only generate if output dir is correctly set // Only generate if output dir is correctly set
if (outputDirName == "") return false; if (outputDirName == "")
{
emit parseState(tr("<font color=\"red\">ERROR: No output directory given.\nAbort.</font>"));
return false;
}
QString topLevelOutputDirName = outputDirName;
// print out the element names of all elements that are direct children // print out the element names of all elements that are direct children
// of the outermost element. // of the outermost element.
...@@ -87,6 +93,31 @@ bool MAVLinkXMLParser::generate() ...@@ -87,6 +93,31 @@ bool MAVLinkXMLParser::generate()
QString lcmStructDefs = ""; QString lcmStructDefs = "";
QString pureFileName; QString pureFileName;
QString pureIncludeFileName;
QFileInfo fInfo(this->fileName);
pureFileName = fInfo.baseName().split(".", QString::SkipEmptyParts).first();
// XML parsed and converted to C code. Now generating the files
outputDirName += QDir::separator() + pureFileName;
QDateTime now = QDateTime::currentDateTime().toUTC();
QLocale loc(QLocale::English);
QString dateFormat = "dddd, MMMM d yyyy, hh:mm UTC";
QString date = loc.toString(now, dateFormat);
QString includeLine = "#include \"%1\"\n";
QString mainHeaderName = pureFileName + ".h";
QString messagesDirName = ".";//"generated";
QDir dir(outputDirName + "/" + messagesDirName);
// Start main header
QString mainHeader = QString("/** @file\n *\t@brief MAVLink comm protocol.\n *\t@see http://pixhawk.ethz.ch/software/mavlink\n *\t Generated on %1\n */\n#ifndef " + pureFileName.toUpper() + "_H\n#define " + pureFileName.toUpper() + "_H\n\n").arg(date); // The main header includes all messages
// Mark all code as C code
mainHeader += "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n";
mainHeader += "\n#include \"../protocol.h\"\n";
mainHeader += "\n#define MAVLINK_ENABLED_" + pureFileName.toUpper() + "\n\n";
// Run through root children // Run through root children
while(!n.isNull()) while(!n.isNull())
...@@ -107,47 +138,55 @@ bool MAVLinkXMLParser::generate() ...@@ -107,47 +138,55 @@ bool MAVLinkXMLParser::generate()
// Handle all include tags // Handle all include tags
if (e.tagName() == "include") if (e.tagName() == "include")
{ {
QString fileName = e.text(); QString incFileName = e.text();
// Load file // Load file
QDomDocument includeDoc = QDomDocument(); //QDomDocument includeDoc = QDomDocument();
// Prepend file path if it is a relative path and // Prepend file path if it is a relative path and
// make it relative to opened file // make it relative to opened file
QFileInfo fInfo(fileName); QFileInfo fInfo(incFileName);
QString incFilePath;
if (fInfo.isRelative()) if (fInfo.isRelative())
{ {
QFileInfo rInfo(this->fileName); QFileInfo rInfo(this->fileName);
fileName = rInfo.absoluteDir().canonicalPath() + "/" + fileName; incFilePath = rInfo.absoluteDir().canonicalPath() + "/" + incFileName;
pureFileName = rInfo.baseName().split(".").first(); pureIncludeFileName = fInfo.baseName().split(".", QString::SkipEmptyParts).first();
} }
QFile file(fileName); QFile file(incFilePath);
if (file.open(QIODevice::ReadOnly | QIODevice::Text)) if (file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
const QString instanceText(QString::fromUtf8(file.readAll())); emit parseState(QString("<font color=\"green\">Included messages from file: %1</font>").arg(incFileName));
includeDoc.setContent(instanceText); // NEW MODE: CREATE INDIVIDUAL FOLDERS
// Create new output directory, parse included XML and generate C-code
// Get all messages MAVLinkXMLParser includeParser(incFilePath, topLevelOutputDirName, this);
QDomNode in = includeDoc.documentElement().firstChild(); connect(&includeParser, SIGNAL(parseState(QString)), this, SIGNAL(parseState(QString)));
//while (!in.isNull()) // Generate and write
//{ includeParser.generate();
QDomElement ie = in.toElement(); mainHeader += "\n#include \"../" + pureIncludeFileName + "/" + pureIncludeFileName + ".h\"\n";
if (!ie.isNull())
{
if (ie.tagName() == "messages" || ie.tagName() == "include") // OLD MODE: MERGE BOTH FILES
{ // const QString instanceText(QString::fromUtf8(file.readAll()));
QDomNode ref = n.parentNode().insertAfter(in, n); // includeDoc.setContent(instanceText);
if (ref.isNull()) // // Get all messages
{ // QDomNode in = includeDoc.documentElement().firstChild();
emit parseState(QString("<font color=\"red\">ERROR: Inclusion failed: XML syntax error in file %1. Wrong/misspelled XML?\nAbort.</font>").arg(fileName)); // QDomElement ie = in.toElement();
return false; // if (!ie.isNull())
} // {
} // if (ie.tagName() == "messages" || ie.tagName() == "include")
} // {
//in = in.nextSibling(); // QDomNode ref = n.parentNode().insertAfter(in, n);
//} // if (ref.isNull())
// {
emit parseState(QString("<font color=\"green\">Included messages from file: %1</font>").arg(fileName)); // emit parseState(QString("<font color=\"red\">ERROR: Inclusion failed: XML syntax error in file %1. Wrong/misspelled XML?\nAbort.</font>").arg(fileName));
// return false;
// }
// }
// }
emit parseState(QString("<font color=\"green\">End of inclusion from file: %1</font>").arg(incFileName));
} }
else else
{ {
...@@ -406,20 +445,7 @@ bool MAVLinkXMLParser::generate() ...@@ -406,20 +445,7 @@ bool MAVLinkXMLParser::generate()
n = n.nextSibling(); n = n.nextSibling();
} // While through root children } // While through root children
// XML parsed and converted to C code. Now generating the files
QDateTime now = QDateTime::currentDateTime().toUTC();
QLocale loc(QLocale::English);
QString dateFormat = "dddd, MMMM d yyyy, hh:mm UTC";
QString date = loc.toString(now, dateFormat);
QString mainHeader = QString("/** @file\n *\t@brief MAVLink comm protocol.\n *\t@see http://pixhawk.ethz.ch/software/mavlink\n *\t Generated on %1\n */\n#ifndef MAVLINK_H\n#define MAVLINK_H\n\n").arg(date); // The main header includes all messages
// Mark all code as C code
mainHeader += "#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n";
mainHeader += "\n#include \"protocol.h\"\n";
mainHeader += "\n#define MAVLINK_ENABLED_" + pureFileName.toUpper() + "\n\n";
QString includeLine = "#include \"%1\"\n";
QString mainHeaderName = "mavlink.h";
QString messagesDirName = "generated";
QDir dir(outputDirName + "/" + messagesDirName);
// Create directory if it doesn't exist, report result in success // Create directory if it doesn't exist, report result in success
if (!dir.exists()) success = success && dir.mkpath(outputDirName + "/" + messagesDirName); if (!dir.exists()) success = success && dir.mkpath(outputDirName + "/" + messagesDirName);
for (int i = 0; i < cFiles.size(); i++) for (int i = 0; i < cFiles.size(); i++)
...@@ -428,6 +454,7 @@ bool MAVLinkXMLParser::generate() ...@@ -428,6 +454,7 @@ bool MAVLinkXMLParser::generate()
bool ok = rawFile.open(QIODevice::WriteOnly | QIODevice::Text); bool ok = rawFile.open(QIODevice::WriteOnly | QIODevice::Text);
success = success && ok; success = success && ok;
rawFile.write(cFiles.at(i).second.toLatin1()); rawFile.write(cFiles.at(i).second.toLatin1());
rawFile.close();
mainHeader += includeLine.arg(messagesDirName + "/" + cFiles.at(i).first); mainHeader += includeLine.arg(messagesDirName + "/" + cFiles.at(i).first);
} }
...@@ -441,6 +468,18 @@ bool MAVLinkXMLParser::generate() ...@@ -441,6 +468,18 @@ bool MAVLinkXMLParser::generate()
bool ok = rawHeader.open(QIODevice::WriteOnly | QIODevice::Text); bool ok = rawHeader.open(QIODevice::WriteOnly | QIODevice::Text);
success = success && ok; success = success && ok;
rawHeader.write(mainHeader.toLatin1()); rawHeader.write(mainHeader.toLatin1());
rawHeader.close();
// Write alias mavlink header
QFile mavlinkHeader(outputDirName + "/mavlink.h");
ok = mavlinkHeader.open(QIODevice::WriteOnly | QIODevice::Text);
success = success && ok;
QString mHeader = QString("/** @file\n *\t@brief MAVLink comm protocol.\n *\t@see http://pixhawk.ethz.ch/software/mavlink\n *\t Generated on %1\n */\n#ifndef MAVLINK_H\n#define MAVLINK_H\n\n").arg(date); // The main header includes all messages
// Mark all code as C code
mHeader += "#include \"" + mainHeaderName + "\"\n\n";
mHeader += "#endif\n";
mavlinkHeader.write(mHeader.toLatin1());
mavlinkHeader.close();
// Write C structs / lcm definitions // Write C structs / lcm definitions
// QFile lcmStructs(outputDirName + "/mavlink.lcm"); // QFile lcmStructs(outputDirName + "/mavlink.lcm");
......
...@@ -142,6 +142,13 @@ QMap3DWidget::display(void* clientData) ...@@ -142,6 +142,13 @@ QMap3DWidget::display(void* clientData)
map3d->displayHandler(); map3d->displayHandler();
} }
//void QMap3DWidget::paintEvent(QPaintEvent *event)
//{
// Q_UNUSED(event);
//}
void void
QMap3DWidget::displayHandler(void) QMap3DWidget::displayHandler(void)
{ {
...@@ -184,6 +191,7 @@ QMap3DWidget::displayHandler(void) ...@@ -184,6 +191,7 @@ QMap3DWidget::displayHandler(void)
} }
// turn on smooth lines // turn on smooth lines
makeCurrent();
glEnable(GL_LINE_SMOOTH); glEnable(GL_LINE_SMOOTH);
glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);
glEnable(GL_BLEND); glEnable(GL_BLEND);
...@@ -247,6 +255,8 @@ QMap3DWidget::displayHandler(void) ...@@ -247,6 +255,8 @@ QMap3DWidget::displayHandler(void)
glVertex2f(getWindowWidth(), getWindowHeight()); glVertex2f(getWindowWidth(), getWindowHeight());
glEnd(); glEnd();
glFlush();
std::pair<float,float> mouseWorldCoords = std::pair<float,float> mouseWorldCoords =
getPositionIn3DMode(getMouseX(), getMouseY()); getPositionIn3DMode(getMouseX(), getMouseY());
...@@ -262,6 +272,8 @@ QMap3DWidget::displayHandler(void) ...@@ -262,6 +272,8 @@ QMap3DWidget::displayHandler(void)
5, 5,
5, 5,
&painter); &painter);
painter.end();
repaint();
} }
void QMap3DWidget::drawWaypoints(void) const void QMap3DWidget::drawWaypoints(void) const
...@@ -310,25 +322,10 @@ void QMap3DWidget::drawWaypoints(void) const ...@@ -310,25 +322,10 @@ void QMap3DWidget::drawWaypoints(void) const
glColor3f(1.0f, 0.3f, 0.3f); glColor3f(1.0f, 0.3f, 0.3f);
glLineWidth(1.0f); glLineWidth(1.0f);
// // Make sure quad object exists
// static GLUquadricObj* quadObj2;
// if(!quadObj2) quadObj2 = gluNewQuadric();
// gluQuadricDrawStyle(quadObj2, GLU_LINE);
// gluQuadricNormals(quadObj2, GLU_SMOOTH);
// /* If we ever changed/used the texture or orientation state
// of quadObj, we'd need to change it to the defaults here
// with gluQuadricTexture and/or gluQuadricOrientation. */
// gluSphere(quadObj2, radius, 10, 10);
wireSphere(radius, 10, 10); wireSphere(radius, 10, 10);
glPopMatrix(); glPopMatrix();
// DRAW CONNECTING LINE // DRAW CONNECTING LINE
// Draw line from last waypoint to this one // Draw line from last waypoint to this one
if (!lastWaypoint.isNull()) if (!lastWaypoint.isNull())
...@@ -387,6 +384,7 @@ QMap3DWidget::drawLegend(void) ...@@ -387,6 +384,7 @@ QMap3DWidget::drawLegend(void)
25, 25,
getWindowHeight() - 65, getWindowHeight() - 65,
&painter); &painter);
painter.end();
} }
void void
......
...@@ -55,6 +55,7 @@ public: ...@@ -55,6 +55,7 @@ public:
static void display(void* clientData); static void display(void* clientData);
void displayHandler(void); void displayHandler(void);
// void paintEvent(QPaintEvent *event);
static void mouse(Qt::MouseButton button, MouseState state, static void mouse(Qt::MouseButton button, MouseState state,
int32_t x, int32_t y, void* clientData); int32_t x, int32_t y, void* clientData);
......
#-------------------------------------------------
#
# QGroundControl - Micro Air Vehicle Groundstation
#
# Please see our website at <http://qgroundcontrol.org>
#
# Author:
# Lorenz Meier <mavteam@student.ethz.ch>
#
# (c) 2009-2010 PIXHAWK Team
#
# This file is part of the mav groundstation 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/>.
#
#-------------------------------------------------
# Uncomment ONE of these lines to enable the special message set of a project.
# Several message sets can be also enabled in parallel, as long as function names
# and message ids do not conflict.
INCLUDEPATH += $$BASEDIR/../mavlink/include/pixhawk
#INCLUDEPATH += $$BASEDIR/../mavlink/include/slugs
#INCLUDEPATH += $$BASEDIR/../mavlink/include/ualberta
INCLUDEPATH -= $$BASEDIR/../mavlink/include/common
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