mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Added a home location utility
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2825 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
5f2c502172
commit
7a34e25956
60
ground/openpilotgcs/src/libs/utils/homelocationutil.cpp
Normal file
60
ground/openpilotgcs/src/libs/utils/homelocationutil.cpp
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file homelocationutil.cpp
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* @brief Utilities to find the location of openpilot GCS files:
|
||||||
|
* - Plugins Share directory path
|
||||||
|
*
|
||||||
|
* @brief Home location utility functions
|
||||||
|
*
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "homelocationutil.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
#include "coordinateconversions.h"
|
||||||
|
#include "worldmagmodel.h"
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
HomeLocationUtil::HomeLocationUtil()
|
||||||
|
{
|
||||||
|
// Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
int HomeLocationUtil::getDetails(double LLA[3], double ECEF[3], double RNE[9], double Be[3])
|
||||||
|
{
|
||||||
|
QDateTime dt = QDateTime::currentDateTime().toUTC();
|
||||||
|
|
||||||
|
// double current_altitude = obj->getField("Altitude")->getDouble();
|
||||||
|
|
||||||
|
CoordinateConversions().LLA2ECEF(LLA, ECEF);
|
||||||
|
CoordinateConversions().RneFromLLA(LLA, (double (*)[3])RNE);
|
||||||
|
if (WorldMagModel().GetMagVector(LLA, dt.date().month(), dt.date().day(), dt.date().year(), Be) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
ground/openpilotgcs/src/libs/utils/homelocationutil.h
Normal file
53
ground/openpilotgcs/src/libs/utils/homelocationutil.h
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
/**
|
||||||
|
******************************************************************************
|
||||||
|
*
|
||||||
|
* @file homelocationutil.h
|
||||||
|
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||||
|
* Parts by Nokia Corporation (qt-info@nokia.com) Copyright (C) 2009.
|
||||||
|
* @brief
|
||||||
|
* @see The GNU Public License (GPL) Version 3
|
||||||
|
* @defgroup
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
/*
|
||||||
|
* This program 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.
|
||||||
|
*
|
||||||
|
* This program 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 this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef HOMELOCATIONUTIL_H
|
||||||
|
#define HOMELOCATIONUTIL_H
|
||||||
|
|
||||||
|
#include "utils_global.h"
|
||||||
|
|
||||||
|
// ******************************
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
class QTCREATOR_UTILS_EXPORT HomeLocationUtil
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HomeLocationUtil();
|
||||||
|
|
||||||
|
int getDetails(double LLA[3], double ECEF[3], double RNE[9], double Be[3]);
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******************************
|
||||||
|
|
||||||
|
#endif
|
@ -1,9 +1,13 @@
|
|||||||
TEMPLATE = lib
|
TEMPLATE = lib
|
||||||
TARGET = Utils
|
TARGET = Utils
|
||||||
|
|
||||||
QT += gui \
|
QT += gui \
|
||||||
network
|
network
|
||||||
|
|
||||||
DEFINES += QTCREATOR_UTILS_LIB
|
DEFINES += QTCREATOR_UTILS_LIB
|
||||||
|
|
||||||
include(../../openpilotgcslibrary.pri)
|
include(../../openpilotgcslibrary.pri)
|
||||||
|
|
||||||
SOURCES += reloadpromptutils.cpp \
|
SOURCES += reloadpromptutils.cpp \
|
||||||
settingsutils.cpp \
|
settingsutils.cpp \
|
||||||
filesearch.cpp \
|
filesearch.cpp \
|
||||||
@ -39,14 +43,17 @@ SOURCES += reloadpromptutils.cpp \
|
|||||||
detailswidget.cpp \
|
detailswidget.cpp \
|
||||||
coordinateconversions.cpp \
|
coordinateconversions.cpp \
|
||||||
pathutils.cpp \
|
pathutils.cpp \
|
||||||
worldmagmodel.cpp
|
worldmagmodel.cpp \
|
||||||
win32 {
|
homelocationutil.cpp
|
||||||
|
|
||||||
|
win32 {
|
||||||
SOURCES += abstractprocess_win.cpp \
|
SOURCES += abstractprocess_win.cpp \
|
||||||
consoleprocess_win.cpp \
|
consoleprocess_win.cpp \
|
||||||
winutils.cpp
|
winutils.cpp
|
||||||
HEADERS += winutils.h
|
HEADERS += winutils.h
|
||||||
}
|
}
|
||||||
else:SOURCES += consoleprocess_unix.cpp
|
else:SOURCES += consoleprocess_unix.cpp
|
||||||
|
|
||||||
HEADERS += utils_global.h \
|
HEADERS += utils_global.h \
|
||||||
reloadpromptutils.h \
|
reloadpromptutils.h \
|
||||||
settingsutils.h \
|
settingsutils.h \
|
||||||
@ -86,10 +93,13 @@ HEADERS += utils_global.h \
|
|||||||
detailswidget.h \
|
detailswidget.h \
|
||||||
coordinateconversions.h \
|
coordinateconversions.h \
|
||||||
pathutils.h \
|
pathutils.h \
|
||||||
worldmagmodel.h
|
worldmagmodel.h \
|
||||||
|
homelocationutil.h
|
||||||
|
|
||||||
FORMS += filewizardpage.ui \
|
FORMS += filewizardpage.ui \
|
||||||
projectintropage.ui \
|
projectintropage.ui \
|
||||||
newclasswidget.ui \
|
newclasswidget.ui \
|
||||||
submiteditorwidget.ui \
|
submiteditorwidget.ui \
|
||||||
checkablemessagebox.ui
|
checkablemessagebox.ui
|
||||||
|
|
||||||
RESOURCES += utils.qrc
|
RESOURCES += utils.qrc
|
||||||
|
Loading…
x
Reference in New Issue
Block a user