mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-30 08:24:11 +01:00
Added getGPSPosition() function to the UAVObject utility
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2830 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
d666a61bf5
commit
a5f17b148b
@ -6,5 +6,6 @@
|
||||
<url>http://www.openpilot.org</url>
|
||||
<dependencyList>
|
||||
<dependency name="Core" version="1.0.0"/>
|
||||
</dependencyList>
|
||||
<dependency name="UAVObjects" version="1.0.0"/>
|
||||
</dependencyList>
|
||||
</plugin>
|
||||
|
@ -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<UAVObjectManager>();
|
||||
if (!obm) return -2;
|
||||
|
||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(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
|
||||
}
|
||||
|
||||
// ******************************
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user