diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/UAVObjectUtil.pluginspec b/ground/openpilotgcs/src/plugins/uavobjectutil/UAVObjectUtil.pluginspec
index 8f2a24d0b..af65371e7 100644
--- a/ground/openpilotgcs/src/plugins/uavobjectutil/UAVObjectUtil.pluginspec
+++ b/ground/openpilotgcs/src/plugins/uavobjectutil/UAVObjectUtil.pluginspec
@@ -6,5 +6,6 @@
http://www.openpilot.org
-
+
+
diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp
index 63e6f64dd..8c31d0309 100644
--- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp
+++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.cpp
@@ -193,3 +193,40 @@ int UAVObjectUtilManager::getHomeLocation(bool &set, double LLA[3], double ECEF[
}
// ******************************
+// GPS
+
+int UAVObjectUtilManager::getGPSPosition(double LLA[3])
+{
+ QMutexLocker locker(mutex);
+
+ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
+ if (!pm) return -1;
+
+ UAVObjectManager *obm = pm->getObject();
+ if (!obm) return -2;
+
+ UAVDataObject *obj = dynamic_cast(obm->getObject(QString("GPSPosition")));
+ if (!obj) return -3;
+
+ LLA[0] = obj->getField(QString("Latitude"))->getDouble() * 1E-7;
+ LLA[1] = obj->getField(QString("Longitude"))->getDouble() * 1E-7;
+ LLA[2] = obj->getField(QString("Altitude"))->getDouble();
+
+ if (LLA[0] != LLA[0]) LLA[0] = 0; // nan detection
+ else
+ if (LLA[0] > 90) LLA[0] = 90;
+ else
+ if (LLA[0] < -90) LLA[0] = -90;
+
+ if (LLA[1] != LLA[1]) LLA[1] = 0; // nan detection
+ else
+ if (LLA[1] > 180) LLA[1] = 180;
+ else
+ if (LLA[1] < -180) LLA[1] = -180;
+
+ if (LLA[2] != LLA[2]) LLA[2] = 0; // nan detection
+
+ return 0; // OK
+}
+
+// ******************************
diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h
index abea4aa14..3dafea601 100644
--- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h
+++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilmanager.h
@@ -25,6 +25,7 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+
#ifndef UAVOBJECTUTILMANAGER_H
#define UAVOBJECTUTILMANAGER_H
@@ -46,6 +47,8 @@ public:
int getHomeLocation(bool &set, double LLA[3]);
int getHomeLocation(bool &set, double LLA[3], double ECEF[3], double RNE[9], double Be[3]);
+ int getGPSPosition(double LLA[3]);
+
private:
QMutex *mutex;
diff --git a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilplugin.cpp b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilplugin.cpp
index cf557644f..ad7f55ad8 100644
--- a/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilplugin.cpp
+++ b/ground/openpilotgcs/src/plugins/uavobjectutil/uavobjectutilplugin.cpp
@@ -30,17 +30,14 @@
UAVObjectUtilPlugin::UAVObjectUtilPlugin()
{
-
}
UAVObjectUtilPlugin::~UAVObjectUtilPlugin()
{
-
}
void UAVObjectUtilPlugin::extensionsInitialized()
{
-
}
bool UAVObjectUtilPlugin::initialize(const QStringList & arguments, QString * errorString)
@@ -48,20 +45,15 @@ bool UAVObjectUtilPlugin::initialize(const QStringList & arguments, QString * er
Q_UNUSED(arguments)
Q_UNUSED(errorString)
- // Create object manager and expose object
+ // Create manager and expose object
UAVObjectUtilManager *objUtilMngr = new UAVObjectUtilManager();
addAutoReleasedObject(objUtilMngr);
- // Initialize UAVObjects
-// UAVObjectUtilInitialize(objMngr);
-
-
return true;
}
void UAVObjectUtilPlugin::shutdown()
{
-
}
Q_EXPORT_PLUGIN(UAVObjectUtilPlugin)