Commit e79dd41d authored by Don Gagne's avatar Don Gagne

UASManager -> HomePositionManager

parent f10e77cb
...@@ -240,6 +240,7 @@ HEADERS += \ ...@@ -240,6 +240,7 @@ HEADERS += \
src/comm/TCPLink.h \ src/comm/TCPLink.h \
src/comm/UDPLink.h \ src/comm/UDPLink.h \
src/GAudioOutput.h \ src/GAudioOutput.h \
src/HomePositionManager.h \
src/LogCompressor.h \ src/LogCompressor.h \
src/MG.h \ src/MG.h \
src/QGC.h \ src/QGC.h \
...@@ -263,8 +264,6 @@ HEADERS += \ ...@@ -263,8 +264,6 @@ HEADERS += \
src/uas/FileManager.h \ src/uas/FileManager.h \
src/uas/UAS.h \ src/uas/UAS.h \
src/uas/UASInterface.h \ src/uas/UASInterface.h \
src/uas/UASManager.h \
src/uas/UASManagerInterface.h \
src/uas/UASMessageHandler.h \ src/uas/UASMessageHandler.h \
src/uas/UASWaypointManager.h \ src/uas/UASWaypointManager.h \
src/ui/flightdisplay/FlightDisplay.h \ src/ui/flightdisplay/FlightDisplay.h \
...@@ -377,6 +376,7 @@ SOURCES += \ ...@@ -377,6 +376,7 @@ SOURCES += \
src/comm/TCPLink.cc \ src/comm/TCPLink.cc \
src/comm/UDPLink.cc \ src/comm/UDPLink.cc \
src/GAudioOutput.cc \ src/GAudioOutput.cc \
src/HomePositionManager.cc \
src/LogCompressor.cc \ src/LogCompressor.cc \
src/main.cc \ src/main.cc \
src/QGC.cc \ src/QGC.cc \
...@@ -395,7 +395,6 @@ SOURCES += \ ...@@ -395,7 +395,6 @@ SOURCES += \
src/QmlControls/ScreenToolsController.cc \ src/QmlControls/ScreenToolsController.cc \
src/uas/FileManager.cc \ src/uas/FileManager.cc \
src/uas/UAS.cc \ src/uas/UAS.cc \
src/uas/UASManager.cc \
src/uas/UASMessageHandler.cc \ src/uas/UASMessageHandler.cc \
src/uas/UASWaypointManager.cc \ src/uas/UASWaypointManager.cc \
src/ui/flightdisplay/FlightDisplay.cc \ src/ui/flightdisplay/FlightDisplay.cc \
......
/*================================================================== /*=====================================================================
======================================================================*/
/** QGroundControl Open Source Ground Control Station
* @file
* @brief Implementation of class UASManager (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
* @author Lorenz Meier <mavteam@student.ethz.ch>
* 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 <QList> #include <QList>
#include <QApplication> #include <QApplication>
...@@ -15,7 +28,7 @@ ...@@ -15,7 +28,7 @@
#include "UAS.h" #include "UAS.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "UASManager.h" #include "HomePositionManager.h"
#include "QGC.h" #include "QGC.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "QGCApplication.h" #include "QGCApplication.h"
...@@ -25,26 +38,24 @@ ...@@ -25,26 +38,24 @@
#define MEAN_EARTH_DIAMETER 12756274.0 #define MEAN_EARTH_DIAMETER 12756274.0
#define UMR 0.017453292519943295769236907684886 #define UMR 0.017453292519943295769236907684886
IMPLEMENT_QGC_SINGLETON(UASManager, UASManagerInterface) IMPLEMENT_QGC_SINGLETON(HomePositionManager, HomePositionManager)
UASManager::UASManager(QObject* parent) : HomePositionManager::HomePositionManager(QObject* parent) :
UASManagerInterface(parent), QObject(parent),
offlineUASWaypointManager(NULL),
homeLat(47.3769), homeLat(47.3769),
homeLon(8.549444), homeLon(8.549444),
homeAlt(470.0), homeAlt(470.0),
homeFrame(MAV_FRAME_GLOBAL) homeFrame(MAV_FRAME_GLOBAL)
{ {
loadSettings(); loadSettings();
setLocalNEDSafetyBorders(1, -1, 0, -1, 1, -1);
} }
UASManager::~UASManager() HomePositionManager::~HomePositionManager()
{ {
storeSettings(); storeSettings();
} }
void UASManager::storeSettings() void HomePositionManager::storeSettings()
{ {
QSettings settings; QSettings settings;
settings.beginGroup("QGC_UASMANAGER"); settings.beginGroup("QGC_UASMANAGER");
...@@ -54,7 +65,7 @@ void UASManager::storeSettings() ...@@ -54,7 +65,7 @@ void UASManager::storeSettings()
settings.endGroup(); settings.endGroup();
} }
void UASManager::loadSettings() void HomePositionManager::loadSettings()
{ {
QSettings settings; QSettings settings;
settings.beginGroup("QGC_UASMANAGER"); settings.beginGroup("QGC_UASMANAGER");
...@@ -72,7 +83,7 @@ void UASManager::loadSettings() ...@@ -72,7 +83,7 @@ void UASManager::loadSettings()
settings.endGroup(); settings.endGroup();
} }
bool UASManager::setHomePosition(double lat, double lon, double alt) bool HomePositionManager::setHomePosition(double lat, double lon, double alt)
{ {
// Checking for NaN and infitiny // Checking for NaN and infitiny
// and checking for borders // and checking for borders
...@@ -101,7 +112,7 @@ bool UASManager::setHomePosition(double lat, double lon, double alt) ...@@ -101,7 +112,7 @@ bool UASManager::setHomePosition(double lat, double lon, double alt)
return changed; return changed;
} }
bool UASManager::setHomePositionAndNotify(double lat, double lon, double alt) bool HomePositionManager::setHomePositionAndNotify(double lat, double lon, double alt)
{ {
// Checking for NaN and infitiny // Checking for NaN and infitiny
// and checking for borders // and checking for borders
...@@ -114,28 +125,7 @@ bool UASManager::setHomePositionAndNotify(double lat, double lon, double alt) ...@@ -114,28 +125,7 @@ bool UASManager::setHomePositionAndNotify(double lat, double lon, double alt)
return changed; return changed;
} }
/** void HomePositionManager::initReference(const double & latitude, const double & longitude, const double & altitude)
* @param x1 Point 1 coordinate in x dimension
* @param y1 Point 1 coordinate in y dimension
* @param z1 Point 1 coordinate in z dimension
*
* @param x2 Point 2 coordinate in x dimension
* @param y2 Point 2 coordinate in y dimension
* @param z2 Point 2 coordinate in z dimension
*/
void UASManager::setLocalNEDSafetyBorders(double x1, double y1, double z1, double x2, double y2, double z2)
{
nedSafetyLimitPosition1.x() = x1;
nedSafetyLimitPosition1.y() = y1;
nedSafetyLimitPosition1.z() = z1;
nedSafetyLimitPosition2.x() = x2;
nedSafetyLimitPosition2.y() = y2;
nedSafetyLimitPosition2.z() = z2;
}
void UASManager::initReference(const double & latitude, const double & longitude, const double & altitude)
{ {
Eigen::Matrix3d R; Eigen::Matrix3d R;
double s_long, s_lat, c_long, c_lat; double s_long, s_lat, c_long, c_lat;
...@@ -159,7 +149,7 @@ void UASManager::initReference(const double & latitude, const double & longitude ...@@ -159,7 +149,7 @@ void UASManager::initReference(const double & latitude, const double & longitude
ecef_ref_point_ = wgs84ToEcef(latitude, longitude, altitude); ecef_ref_point_ = wgs84ToEcef(latitude, longitude, altitude);
} }
Eigen::Vector3d UASManager::wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude) Eigen::Vector3d HomePositionManager::wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude)
{ {
const double a = 6378137.0; // semi-major axis const double a = 6378137.0; // semi-major axis
const double e_sq = 6.69437999014e-3; // first eccentricity squared const double e_sq = 6.69437999014e-3; // first eccentricity squared
...@@ -179,12 +169,12 @@ Eigen::Vector3d UASManager::wgs84ToEcef(const double & latitude, const double & ...@@ -179,12 +169,12 @@ Eigen::Vector3d UASManager::wgs84ToEcef(const double & latitude, const double &
return ecef; return ecef;
} }
Eigen::Vector3d UASManager::ecefToEnu(const Eigen::Vector3d & ecef) Eigen::Vector3d HomePositionManager::ecefToEnu(const Eigen::Vector3d & ecef)
{ {
return ecef_ref_orientation_ * (ecef - ecef_ref_point_); return ecef_ref_orientation_ * (ecef - ecef_ref_point_);
} }
void UASManager::wgs84ToEnu(const double& lat, const double& lon, const double& alt, double* east, double* north, double* up) void HomePositionManager::wgs84ToEnu(const double& lat, const double& lon, const double& alt, double* east, double* north, double* up)
{ {
Eigen::Vector3d ecef = wgs84ToEcef(lat, lon, alt); Eigen::Vector3d ecef = wgs84ToEcef(lat, lon, alt);
Eigen::Vector3d enu = ecefToEnu(ecef); Eigen::Vector3d enu = ecefToEnu(ecef);
...@@ -193,49 +183,17 @@ void UASManager::wgs84ToEnu(const double& lat, const double& lon, const double& ...@@ -193,49 +183,17 @@ void UASManager::wgs84ToEnu(const double& lat, const double& lon, const double&
*up = enu.z(); *up = enu.z();
} }
//void UASManager::wgs84ToNed(const double& lat, const double& lon, const double& alt, double* north, double* east, double* down) void HomePositionManager::enuToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt)
//{
//}
void UASManager::enuToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt)
{ {
*lat=homeLat+y/MEAN_EARTH_DIAMETER*360./PI; *lat=homeLat+y/MEAN_EARTH_DIAMETER*360./PI;
*lon=homeLon+x/MEAN_EARTH_DIAMETER*360./PI/cos(homeLat*UMR); *lon=homeLon+x/MEAN_EARTH_DIAMETER*360./PI/cos(homeLat*UMR);
*alt=homeAlt+z; *alt=homeAlt+z;
} }
void UASManager::nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) void HomePositionManager::nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt)
{ {
*lat=homeLat+x/MEAN_EARTH_DIAMETER*360./PI; *lat=homeLat+x/MEAN_EARTH_DIAMETER*360./PI;
*lon=homeLon+y/MEAN_EARTH_DIAMETER*360./PI/cos(homeLat*UMR); *lon=homeLon+y/MEAN_EARTH_DIAMETER*360./PI/cos(homeLat*UMR);
*alt=homeAlt-z; *alt=homeAlt-z;
} }
/**
* This function will change QGC's home position on a number of conditions only
*/
void UASManager::uavChangedHomePosition(int uav, double lat, double lon, double alt)
{
// Accept home position changes from the active UAS
if (uav == MultiVehicleManager::instance()->activeVehicle()->id())
{
if (setHomePosition(lat, lon, alt))
{
// XXX DO NOT UPDATE THE WHOLE FLEET
// foreach (UASInterface* mav, systems)
// {
// // Only update the other systems, not the original source
// if (mav->getUASID() != uav)
// {
// mav->setHomePosition(homeLat, homeLon, homeAlt);
// }
// }
}
}
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
QGroundControl Open Source Ground Control Station QGroundControl Open Source Ground Control Station
(c) 2009 - 2011 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> (c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project This file is part of the QGROUNDCONTROL project
...@@ -21,17 +21,9 @@ This file is part of the QGROUNDCONTROL project ...@@ -21,17 +21,9 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/ ======================================================================*/
/**
* @file
* @brief Definition of class UASManager
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _UASMANAGER_H_ #ifndef _UASMANAGER_H_
#define _UASMANAGER_H_ #define _UASMANAGER_H_
#include "UASManagerInterface.h"
#include "UASInterface.h" #include "UASInterface.h"
#include <QList> #include <QList>
...@@ -42,17 +34,13 @@ This file is part of the QGROUNDCONTROL project ...@@ -42,17 +34,13 @@ This file is part of the QGROUNDCONTROL project
#include "QGCGeo.h" #include "QGCGeo.h"
#include "QGCSingleton.h" #include "QGCSingleton.h"
/** /// Manages an offline home position as well as performance coordinate transformations
* @brief Central manager for all connected aerial vehicles /// around a home position.
* class HomePositionManager : public QObject
* This class keeps a list of all connected / configured UASs. It also stores which
* UAS is currently select with respect to user input or manual controls.
**/
class UASManager : public UASManagerInterface
{ {
Q_OBJECT Q_OBJECT
DECLARE_QGC_SINGLETON(UASManager, UASManagerInterface) DECLARE_QGC_SINGLETON(HomePositionManager, HomePositionManager)
public: public:
/** @brief Get home position latitude */ /** @brief Get home position latitude */
...@@ -85,40 +73,6 @@ public: ...@@ -85,40 +73,6 @@ public:
/** @brief Convert x,y,z coordinates to lat / lon / alt coordinates in north-east-down frame */ /** @brief Convert x,y,z coordinates to lat / lon / alt coordinates in north-east-down frame */
void nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt); void nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt);
void getLocalNEDSafetyLimits(double* x1, double* y1, double* z1, double* x2, double* y2, double* z2)
{
*x1 = nedSafetyLimitPosition1.x();
*y1 = nedSafetyLimitPosition1.y();
*z1 = nedSafetyLimitPosition1.z();
*x2 = nedSafetyLimitPosition2.x();
*y2 = nedSafetyLimitPosition2.y();
*z2 = nedSafetyLimitPosition2.z();
}
/** @brief Check if a position is in the local NED safety limits */
bool isInLocalNEDSafetyLimits(double x, double y, double z)
{
if (x < nedSafetyLimitPosition1.x() &&
y > nedSafetyLimitPosition1.y() &&
z < nedSafetyLimitPosition1.z() &&
x > nedSafetyLimitPosition2.x() &&
y < nedSafetyLimitPosition2.y() &&
z > nedSafetyLimitPosition2.z())
{
// Within limits
return true;
}
else
{
// Not within limits
return false;
}
}
// void wgs84ToNed(const double& lat, const double& lon, const double& alt, double* north, double* east, double* down);
public slots: public slots:
/** @brief Set the current home position, but do not change it on the UAVs */ /** @brief Set the current home position, but do not change it on the UAVs */
bool setHomePosition(double lat, double lon, double alt); bool setHomePosition(double lat, double lon, double alt);
...@@ -126,35 +80,30 @@ public slots: ...@@ -126,35 +80,30 @@ public slots:
/** @brief Set the current home position on all UAVs*/ /** @brief Set the current home position on all UAVs*/
bool setHomePositionAndNotify(double lat, double lon, double alt); bool setHomePositionAndNotify(double lat, double lon, double alt);
/** @brief Set the safety limits in local position frame */
void setLocalNEDSafetyBorders(double x1, double y1, double z1, double x2, double y2, double z2);
/** @brief Update home position based on the position from one of the UAVs */
void uavChangedHomePosition(int uav, double lat, double lon, double alt);
/** @brief Load settings */ /** @brief Load settings */
void loadSettings(); void loadSettings();
/** @brief Store settings */ /** @brief Store settings */
void storeSettings(); void storeSettings();
signals:
/** @brief Current home position changed */
void homePositionChanged(double lat, double lon, double alt);
protected: protected:
UASWaypointManager *offlineUASWaypointManager;
double homeLat; double homeLat;
double homeLon; double homeLon;
double homeAlt; double homeAlt;
int homeFrame; int homeFrame;
Eigen::Quaterniond ecef_ref_orientation_; Eigen::Quaterniond ecef_ref_orientation_;
Eigen::Vector3d ecef_ref_point_; Eigen::Vector3d ecef_ref_point_;
Eigen::Vector3d nedSafetyLimitPosition1;
Eigen::Vector3d nedSafetyLimitPosition2;
void initReference(const double & latitude, const double & longitude, const double & altitude); void initReference(const double & latitude, const double & longitude, const double & altitude);
private: private:
/// @brief All access to UASManager singleton is through UASManager::instance /// @brief All access to HomePositionManager singleton is through HomePositionManager::instance
UASManager(QObject* parent = NULL); HomePositionManager(QObject* parent = NULL);
~UASManager(); ~HomePositionManager();
public: public:
/* Need to align struct pointer to prevent a memory assertion: /* Need to align struct pointer to prevent a memory assertion:
......
...@@ -63,7 +63,7 @@ G_END_DECLS ...@@ -63,7 +63,7 @@ G_END_DECLS
#endif #endif
#include "QGCSingleton.h" #include "QGCSingleton.h"
#include "LinkManager.h" #include "LinkManager.h"
#include "UASManager.h" #include "HomePositionManager.h"
#include "UASMessageHandler.h" #include "UASMessageHandler.h"
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include "QGCTemporaryFile.h" #include "QGCTemporaryFile.h"
...@@ -602,21 +602,21 @@ void QGCApplication::_createSingletons(void) ...@@ -602,21 +602,21 @@ void QGCApplication::_createSingletons(void)
Q_ASSERT(linkManager); Q_ASSERT(linkManager);
// Needs LinkManager // Needs LinkManager
UASManagerInterface* uasManager = UASManager::_createSingleton(); HomePositionManager* uasManager = HomePositionManager::_createSingleton();
Q_UNUSED(uasManager); Q_UNUSED(uasManager);
Q_ASSERT(uasManager); Q_ASSERT(uasManager);
// Need UASManager // Need HomePositionManager
AutoPilotPluginManager* pluginManager = AutoPilotPluginManager::_createSingleton(); AutoPilotPluginManager* pluginManager = AutoPilotPluginManager::_createSingleton();
Q_UNUSED(pluginManager); Q_UNUSED(pluginManager);
Q_ASSERT(pluginManager); Q_ASSERT(pluginManager);
// Need UASManager // Need HomePositionManager
UASMessageHandler* messageHandler = UASMessageHandler::_createSingleton(); UASMessageHandler* messageHandler = UASMessageHandler::_createSingleton();
Q_UNUSED(messageHandler); Q_UNUSED(messageHandler);
Q_ASSERT(messageHandler); Q_ASSERT(messageHandler);
// Needs UASManager // Needs HomePositionManager
FactSystem* factSystem = FactSystem::_createSingleton(); FactSystem* factSystem = FactSystem::_createSingleton();
Q_UNUSED(factSystem); Q_UNUSED(factSystem);
Q_ASSERT(factSystem); Q_ASSERT(factSystem);
...@@ -648,7 +648,7 @@ void QGCApplication::_destroySingletons(void) ...@@ -648,7 +648,7 @@ void QGCApplication::_destroySingletons(void)
FactSystem::_deleteSingleton(); FactSystem::_deleteSingleton();
UASMessageHandler::_deleteSingleton(); UASMessageHandler::_deleteSingleton();
AutoPilotPluginManager::_deleteSingleton(); AutoPilotPluginManager::_deleteSingleton();
UASManager::_deleteSingleton(); HomePositionManager::_deleteSingleton();
LinkManager::_deleteSingleton(); LinkManager::_deleteSingleton();
GAudioOutput::_deleteSingleton(); GAudioOutput::_deleteSingleton();
MultiVehicleManager::_deleteSingleton(); MultiVehicleManager::_deleteSingleton();
......
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
/// Include this macro in your Derived Class definition /// Include this macro in your Derived Class definition
/// @param className Derived Class name /// @param className Derived Class name
/// @param interfaceName If your class is accessed through an interface specify that, if not specify Derived class name. /// @param interfaceName If your class is accessed through an interface specify that, if not specify Derived class name.
/// For example DECLARE_QGC_SINGLETON(UASManager, UASManagerInterface)
#define DECLARE_QGC_SINGLETON(className, interfaceName) \ #define DECLARE_QGC_SINGLETON(className, interfaceName) \
public: \ public: \
static interfaceName* instance(bool nullOk = false); \ static interfaceName* instance(bool nullOk = false); \
...@@ -54,7 +53,6 @@ ...@@ -54,7 +53,6 @@
/// Include this macro in your Derived Class implementation /// Include this macro in your Derived Class implementation
/// @param className Derived Class name /// @param className Derived Class name
/// @param interfaceName If your class is accessed through an interface specify that, if not specify Derived class name. /// @param interfaceName If your class is accessed through an interface specify that, if not specify Derived class name.
/// For example DECLARE_QGC_SINGLETON(UASManager, UASManagerInterface)
#define IMPLEMENT_QGC_SINGLETON(className, interfaceName) \ #define IMPLEMENT_QGC_SINGLETON(className, interfaceName) \
interfaceName* className::_instance = NULL; \ interfaceName* className::_instance = NULL; \
interfaceName* className::_mockInstance = NULL; \ interfaceName* className::_mockInstance = NULL; \
...@@ -114,7 +112,7 @@ class UnitTest; ...@@ -114,7 +112,7 @@ class UnitTest;
/// This is done in order to make sure they are all created on the main thread. As such no other code other than Unit Test /// This is done in order to make sure they are all created on the main thread. As such no other code other than Unit Test
/// code has access to the constructor/destructor. QGCSingleton supports replacing singletons with a mock implementation. /// code has access to the constructor/destructor. QGCSingleton supports replacing singletons with a mock implementation.
/// In this case your object must derive from an interface which in turn derives from QGCSingleton. Youu can then use /// In this case your object must derive from an interface which in turn derives from QGCSingleton. Youu can then use
/// the setMock method to add and remove you mock implementation. See UASManager example usage. In order to provide the /// the setMock method to add and remove you mock implementation. See HomePositionManager example usage. In order to provide the
/// appropriate methods to make all this work you need to use the DECLARE_QGC_SINGLETON and IMPLEMENT_QGC_SINGLETON /// appropriate methods to make all this work you need to use the DECLARE_QGC_SINGLETON and IMPLEMENT_QGC_SINGLETON
/// macros as follows: /// macros as follows:
/// @code{.unparsed} /// @code{.unparsed}
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include "SetupView.h" #include "SetupView.h"
#include "UASManager.h"
#include "AutoPilotPluginManager.h" #include "AutoPilotPluginManager.h"
#include "VehicleComponent.h" #include "VehicleComponent.h"
#include "QGCQmlWidgetHolder.h" #include "QGCQmlWidgetHolder.h"
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "MockLink.h" #include "MockLink.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "SetupView.h" #include "SetupView.h"
#include "UASManager.h"
#include "MultiVehicleManager.h" #include "MultiVehicleManager.h"
UT_REGISTER_TEST(SetupViewTest) UT_REGISTER_TEST(SetupViewTest)
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "UASInterface.h" #include "UASInterface.h"
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
#include "UASManagerInterface.h"
#include "FactPanelController.h" #include "FactPanelController.h"
class CustomCommandWidgetController : public FactPanelController class CustomCommandWidgetController : public FactPanelController
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
======================================================================*/ ======================================================================*/
#include "ViewWidgetController.h" #include "ViewWidgetController.h"
#include "UASManager.h"
#include "MultiVehicleManager.h" #include "MultiVehicleManager.h"
ViewWidgetController::ViewWidgetController(void) : ViewWidgetController::ViewWidgetController(void) :
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include "UASInterface.h" #include "UASInterface.h"
#include "AutoPilotPlugin.h" #include "AutoPilotPlugin.h"
#include "UASManagerInterface.h"
#include "Vehicle.h" #include "Vehicle.h"
class ViewWidgetController : public QObject class ViewWidgetController : public QObject
......
...@@ -43,6 +43,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -43,6 +43,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGC.h" #include "QGC.h"
#include "QGCFileDialog.h" #include "QGCFileDialog.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "HomePositionManager.h"
// FlightGear _fgProcess start and connection is quite fragile. Uncomment the define below to get higher level of debug output // FlightGear _fgProcess start and connection is quite fragile. Uncomment the define below to get higher level of debug output
// for tracking down problems. // for tracking down problems.
...@@ -954,11 +955,11 @@ bool QGCFlightGearLink::connectSimulation() ...@@ -954,11 +955,11 @@ bool QGCFlightGearLink::connectSimulation()
} }
// We start out at our home position // We start out at our home position
_fgArgList << QString("--lat=%1").arg(UASManager::instance()->getHomeLatitude()); _fgArgList << QString("--lat=%1").arg(HomePositionManager::instance()->getHomeLatitude());
_fgArgList << QString("--lon=%1").arg(UASManager::instance()->getHomeLongitude()); _fgArgList << QString("--lon=%1").arg(HomePositionManager::instance()->getHomeLongitude());
// The altitude is not set because an altitude not equal to the ground altitude leads to a non-zero default throttle in flightgear // The altitude is not set because an altitude not equal to the ground altitude leads to a non-zero default throttle in flightgear
// Without the altitude-setting the aircraft is positioned on the ground // Without the altitude-setting the aircraft is positioned on the ground
//_fgArgList << QString("--altitude=%1").arg(UASManager::instance()->getHomeAltitude()); //_fgArgList << QString("--altitude=%1").arg(HomePositionManager::instance()->getHomeAltitude());
#ifdef DEBUG_FLIGHTGEAR_CONNECT #ifdef DEBUG_FLIGHTGEAR_CONNECT
// This tell FlightGear to output highest debug level of log output. Handy for debuggin failures by looking at the FG // This tell FlightGear to output highest debug level of log output. Handy for debuggin failures by looking at the FG
......
...@@ -40,6 +40,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -40,6 +40,7 @@ This file is part of the QGROUNDCONTROL project
#include "UAS.h" #include "UAS.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "HomePositionManager.h"
QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress localHost, quint16 localPort) : QGCXPlaneLink::QGCXPlaneLink(UASInterface* mav, QString remoteHost, QHostAddress localHost, quint16 localPort) :
mav(mav), mav(mav),
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include "UAS.h" #include "UAS.h"
#include "LinkInterface.h" #include "LinkInterface.h"
#include "UASManager.h" #include "HomePositionManager.h"
#include "QGC.h" #include "QGC.h"
#include "GAudioOutput.h" #include "GAudioOutput.h"
#include "MAVLinkProtocol.h" #include "MAVLinkProtocol.h"
...@@ -2672,10 +2672,10 @@ void UAS::home() ...@@ -2672,10 +2672,10 @@ void UAS::home()
{ {
mavlink_message_t msg; mavlink_message_t msg;
double latitude = UASManager::instance()->getHomeLatitude(); double latitude = HomePositionManager::instance()->getHomeLatitude();
double longitude = UASManager::instance()->getHomeLongitude(); double longitude = HomePositionManager::instance()->getHomeLongitude();
double altitude = UASManager::instance()->getHomeAltitude(); double altitude = HomePositionManager::instance()->getHomeAltitude();
int frame = UASManager::instance()->getHomeFrame(); int frame = HomePositionManager::instance()->getHomeFrame();
mavlink_msg_command_long_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, uasId, MAV_COMP_ID_ALL, MAV_CMD_OVERRIDE_GOTO, 1, MAV_GOTO_DO_CONTINUE, MAV_GOTO_HOLD_AT_CURRENT_POSITION, frame, 0, latitude, longitude, altitude); mavlink_msg_command_long_pack(mavlink->getSystemId(), mavlink->getComponentId(), &msg, uasId, MAV_COMP_ID_ALL, MAV_CMD_OVERRIDE_GOTO, 1, MAV_GOTO_DO_CONTINUE, MAV_GOTO_HOLD_AT_CURRENT_POSITION, frame, 0, latitude, longitude, altitude);
_vehicle->sendMessage(msg); _vehicle->sendMessage(msg);
......
/*=====================================================================
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
* @brief Definition of class UASManager
* @author Lorenz Meier <mavteam@student.ethz.ch>
*
*/
#ifndef _UASMANAGERINTERFACE_H_
#define _UASMANAGERINTERFACE_H_
#include <QList>
#include <QMutex>
#include <Eigen/Eigen>
#include "UASInterface.h"
#include "QGCGeo.h"
#include "QGCSingleton.h"
/**
* @brief Central manager for all connected aerial vehicles
*
* This class keeps a list of all connected / configured UASs. It also stores which
* UAS is currently select with respect to user input or manual controls.
*
* This is the abstract base class for UASManager. Although there is normally only
* a single UASManger we still use a abstract base interface since this allows us
* to create mock versions of the UASManager for testing purposes.
*
* See UASManager.h for method documentation
**/
class UASManagerInterface : public QGCSingleton
{
Q_OBJECT
public:
virtual double getHomeLatitude() const = 0;
virtual double getHomeLongitude() const = 0;
virtual double getHomeAltitude() const = 0;
virtual int getHomeFrame() const = 0;
virtual Eigen::Vector3d wgs84ToEcef(const double & latitude, const double & longitude, const double & altitude) = 0;
virtual Eigen::Vector3d ecefToEnu(const Eigen::Vector3d & ecef) = 0;
virtual void wgs84ToEnu(const double& lat, const double& lon, const double& alt, double* east, double* north, double* up) = 0;
virtual void enuToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) = 0;
virtual void nedToWgs84(const double& x, const double& y, const double& z, double* lat, double* lon, double* alt) = 0;
virtual void getLocalNEDSafetyLimits(double* x1, double* y1, double* z1, double* x2, double* y2, double* z2) = 0;
virtual bool isInLocalNEDSafetyLimits(double x, double y, double z) = 0;
public slots:
virtual bool setHomePosition(double lat, double lon, double alt) = 0;
virtual bool setHomePositionAndNotify(double lat, double lon, double alt) = 0;
virtual void setLocalNEDSafetyBorders(double x1, double y1, double z1, double x2, double y2, double z2) = 0;
virtual void uavChangedHomePosition(int uav, double lat, double lon, double alt) = 0;
virtual void loadSettings() = 0;
virtual void storeSettings() = 0;
signals:
/** @brief Current home position changed */
void homePositionChanged(double lat, double lon, double alt);
protected:
UASManagerInterface(QObject* parent = NULL) :
QGCSingleton(parent) { }
};
#endif // _UASMANAGERINTERFACE_H_
...@@ -32,7 +32,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -32,7 +32,7 @@ This file is part of the QGROUNDCONTROL project
#include "UASWaypointManager.h" #include "UASWaypointManager.h"
#include "UAS.h" #include "UAS.h"
#include "mavlink_types.h" #include "mavlink_types.h"
#include "UASManager.h" #include "HomePositionManager.h"
#include "QGCMessageBox.h" #include "QGCMessageBox.h"
#include "Vehicle.h" #include "Vehicle.h"
...@@ -1164,7 +1164,7 @@ float UASWaypointManager::getAltitudeRecommendation() ...@@ -1164,7 +1164,7 @@ float UASWaypointManager::getAltitudeRecommendation()
if (waypointsEditable.count() > 0) { if (waypointsEditable.count() > 0) {
return waypointsEditable.last()->getAltitude(); return waypointsEditable.last()->getAltitude();
} else { } else {
return UASManager::instance()->getHomeAltitude() + getHomeAltitudeOffsetDefault(); return HomePositionManager::instance()->getHomeAltitude() + getHomeAltitudeOffsetDefault();
} }
} }
......
...@@ -38,7 +38,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -38,7 +38,7 @@ This file is part of the QGROUNDCONTROL project
#include <QDebug> #include <QDebug>
#include "MultiVehicleManager.h" #include "MultiVehicleManager.h"
#include "UASManager.h" #include "HomePositionManager.h"
#include "HSIDisplay.h" #include "HSIDisplay.h"
#include "QGC.h" #include "QGC.h"
#include "Waypoint.h" #include "Waypoint.h"
...@@ -435,11 +435,6 @@ void HSIDisplay::renderOverlay() ...@@ -435,11 +435,6 @@ void HSIDisplay::renderOverlay()
paintText(str, valueColor, 2.6f, 10, vheight - 4.0f, &painter); paintText(str, valueColor, 2.6f, 10, vheight - 4.0f, &painter);
} }
// Draw Safety
double x1, y1, z1, x2, y2, z2;
UASManager::instance()->getLocalNEDSafetyLimits(&x1, &y1, &z1, &x2, &y2, &z2);
// drawSafetyArea(QPointF(x1, y1), QPointF(x2, y2), QGC::colorYellow, painter);
// Draw status message // Draw status message
paintText(statusMessage, statusColor, 2.8f, 8, 15, &painter); paintText(statusMessage, statusColor, 2.8f, 8, 15, &painter);
...@@ -1372,7 +1367,7 @@ void HSIDisplay::drawWaypoints(QPainter& painter) ...@@ -1372,7 +1367,7 @@ void HSIDisplay::drawWaypoints(QPainter& painter)
// Transform the lat/lon for this waypoint into the local frame // Transform the lat/lon for this waypoint into the local frame
double e, n, u; double e, n, u;
UASManager::instance()->wgs84ToEnu(w->getX(), w->getY(),w->getZ(), &e, &n, &u); HomePositionManager::instance()->wgs84ToEnu(w->getX(), w->getY(),w->getZ(), &e, &n, &u);
in = QPointF(n, e); in = QPointF(n, e);
} }
// Otherwise we don't process this waypoint. // Otherwise we don't process this waypoint.
......
#include "MAVLinkDecoder.h" #include "MAVLinkDecoder.h"
#include "UASManager.h"
#include <QDebug> #include <QDebug>
......
...@@ -73,6 +73,7 @@ This file is part of the QGROUNDCONTROL project ...@@ -73,6 +73,7 @@ This file is part of the QGROUNDCONTROL project
#include "QGCDockWidget.h" #include "QGCDockWidget.h"
#include "MultiVehicleManager.h" #include "MultiVehicleManager.h"
#include "CustomCommandWidget.h" #include "CustomCommandWidget.h"
#include "HomePositionManager.h"
#ifdef UNITTEST_BUILD #ifdef UNITTEST_BUILD
#include "QmlControls/QmlTestWidget.h" #include "QmlControls/QmlTestWidget.h"
...@@ -655,7 +656,7 @@ void MainWindow::closeEvent(QCloseEvent *event) ...@@ -655,7 +656,7 @@ void MainWindow::closeEvent(QCloseEvent *event)
_storeCurrentViewState(); _storeCurrentViewState();
storeSettings(); storeSettings();
UASManager::instance()->storeSettings(); HomePositionManager::instance()->storeSettings();
event->accept(); event->accept();
} }
......
...@@ -41,7 +41,6 @@ This file is part of the QGROUNDCONTROL project ...@@ -41,7 +41,6 @@ This file is part of the QGROUNDCONTROL project
#include "LinkManager.h" #include "LinkManager.h"
#include "LinkInterface.h" #include "LinkInterface.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "UASManager.h"
#include "UASControlWidget.h" #include "UASControlWidget.h"
#include "UASInfoWidget.h" #include "UASInfoWidget.h"
#include "WaypointList.h" #include "WaypointList.h"
......
...@@ -37,7 +37,7 @@ This file is part of the PIXHAWK project ...@@ -37,7 +37,7 @@ This file is part of the PIXHAWK project
#include <UASInterface.h> #include <UASInterface.h>
#include <UAS.h> #include <UAS.h>
#include <UASManager.h> #include <HomePositionManager.h>
#include <QDebug> #include <QDebug>
#include <QMouseEvent> #include <QMouseEvent>
#include <QTextEdit> #include <QTextEdit>
...@@ -314,8 +314,8 @@ void WaypointList::addEditable(bool onCurrentPosition) ...@@ -314,8 +314,8 @@ void WaypointList::addEditable(bool onCurrentPosition)
} else { } else {
updateStatusLabel(tr("Added default GLOBAL (Relative alt.) waypoint.")); updateStatusLabel(tr("Added default GLOBAL (Relative alt.) waypoint."));
} }
wp = new Waypoint(0, UASManager::instance()->getHomeLatitude(), wp = new Waypoint(0, HomePositionManager::instance()->getHomeLatitude(),
UASManager::instance()->getHomeLongitude(), HomePositionManager::instance()->getHomeLongitude(),
WPM->getAltitudeRecommendation(), 0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT); WPM->getAltitudeRecommendation(), 0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
WPM->addWaypointEditable(wp); WPM->addWaypointEditable(wp);
} }
...@@ -337,8 +337,8 @@ void WaypointList::addEditable(bool onCurrentPosition) ...@@ -337,8 +337,8 @@ void WaypointList::addEditable(bool onCurrentPosition)
{ {
// MAV connected, but position unknown, add default waypoint // MAV connected, but position unknown, add default waypoint
updateStatusLabel(tr("WARNING: No position known. Adding default LOCAL (NED) waypoint")); updateStatusLabel(tr("WARNING: No position known. Adding default LOCAL (NED) waypoint"));
wp = new Waypoint(0, UASManager::instance()->getHomeLatitude(), wp = new Waypoint(0, HomePositionManager::instance()->getHomeLatitude(),
UASManager::instance()->getHomeLongitude(), HomePositionManager::instance()->getHomeLongitude(),
WPM->getAltitudeRecommendation(), 0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT); WPM->getAltitudeRecommendation(), 0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
WPM->addWaypointEditable(wp); WPM->addWaypointEditable(wp);
} }
...@@ -347,8 +347,8 @@ void WaypointList::addEditable(bool onCurrentPosition) ...@@ -347,8 +347,8 @@ void WaypointList::addEditable(bool onCurrentPosition)
{ {
//Since no UAV available, create first default waypoint. //Since no UAV available, create first default waypoint.
updateStatusLabel(tr("No UAV connected. Adding default GLOBAL (NED) waypoint")); updateStatusLabel(tr("No UAV connected. Adding default GLOBAL (NED) waypoint"));
wp = new Waypoint(0, UASManager::instance()->getHomeLatitude(), wp = new Waypoint(0, HomePositionManager::instance()->getHomeLatitude(),
UASManager::instance()->getHomeLongitude(), HomePositionManager::instance()->getHomeLongitude(),
WPM->getAltitudeRecommendation(), 0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT); WPM->getAltitudeRecommendation(), 0, WPM->getAcceptanceRadiusRecommendation(), 0, 0,true, true, (MAV_FRAME)WPM->getFrameRecommendation(), MAV_CMD_NAV_WAYPOINT);
WPM->addWaypointEditable(wp); WPM->addWaypointEditable(wp);
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
#include "QGCMapWidget.h" #include "QGCMapWidget.h"
#include "QGCMapToolBar.h" #include "QGCMapToolBar.h"
#include "UASInterface.h" #include "UASInterface.h"
#include "UASManager.h" #include "HomePositionManager.h"
#include "MAV2DIcon.h" #include "MAV2DIcon.h"
#include "Waypoint2DIcon.h" #include "Waypoint2DIcon.h"
#include "UASWaypointManager.h" #include "UASWaypointManager.h"
...@@ -123,7 +123,7 @@ bool QGCMapWidget::setHomeActionTriggered() ...@@ -123,7 +123,7 @@ bool QGCMapWidget::setHomeActionTriggered()
QGCMessageBox::information(tr("Error"), tr("Please connect first")); QGCMessageBox::information(tr("Error"), tr("Please connect first"));
return false; return false;
} }
UASManagerInterface *uasManager = UASManager::instance(); HomePositionManager *uasManager = HomePositionManager::instance();
if (!uasManager) { return false; } if (!uasManager) { return false; }
// Enter an altitude // Enter an altitude
...@@ -187,7 +187,7 @@ void QGCMapWidget::showEvent(QShowEvent* event) ...@@ -187,7 +187,7 @@ void QGCMapWidget::showEvent(QShowEvent* event)
connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleAdded, this, &QGCMapWidget::_vehicleAdded); connect(MultiVehicleManager::instance(), &MultiVehicleManager::vehicleAdded, this, &QGCMapWidget::_vehicleAdded);
connect(MultiVehicleManager::instance(), &MultiVehicleManager::activeVehicleChanged, this, &QGCMapWidget::_activeVehicleChanged); connect(MultiVehicleManager::instance(), &MultiVehicleManager::activeVehicleChanged, this, &QGCMapWidget::_activeVehicleChanged);
connect(UASManager::instance(), SIGNAL(homePositionChanged(double,double,double)), this, SLOT(updateHomePosition(double,double,double)), Qt::UniqueConnection); connect(HomePositionManager::instance(), SIGNAL(homePositionChanged(double,double,double)), this, SLOT(updateHomePosition(double,double,double)), Qt::UniqueConnection);
foreach (Vehicle* vehicle, MultiVehicleManager::instance()->vehicles()) { foreach (Vehicle* vehicle, MultiVehicleManager::instance()->vehicles()) {
_vehicleAdded(vehicle); _vehicleAdded(vehicle);
...@@ -213,7 +213,7 @@ void QGCMapWidget::showEvent(QShowEvent* event) ...@@ -213,7 +213,7 @@ void QGCMapWidget::showEvent(QShowEvent* event)
} }
// Set home // Set home
updateHomePosition(UASManager::instance()->getHomeLatitude(), UASManager::instance()->getHomeLongitude(), UASManager::instance()->getHomeAltitude()); updateHomePosition(HomePositionManager::instance()->getHomeLatitude(), HomePositionManager::instance()->getHomeLongitude(), HomePositionManager::instance()->getHomeAltitude());
// Set currently selected system // Set currently selected system
_activeVehicleChanged(MultiVehicleManager::instance()->activeVehicle()); _activeVehicleChanged(MultiVehicleManager::instance()->activeVehicle());
......
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