mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-03 11:24:10 +01:00
Added telemetry functions.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2834 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
1bb5ed54ff
commit
3dcd93e66b
@ -40,6 +40,12 @@ UAVObjectUtilManager::UAVObjectUtilManager()
|
|||||||
|
|
||||||
UAVObjectUtilManager::~UAVObjectUtilManager()
|
UAVObjectUtilManager::~UAVObjectUtilManager()
|
||||||
{
|
{
|
||||||
|
// while (!queue.isEmpty())
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
disconnect();
|
||||||
|
|
||||||
if (mutex)
|
if (mutex)
|
||||||
{
|
{
|
||||||
delete mutex;
|
delete mutex;
|
||||||
@ -120,7 +126,7 @@ int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool save_to_sdcard)
|
|||||||
return -1; // error
|
return -1; // error
|
||||||
|
|
||||||
// ******************
|
// ******************
|
||||||
// save the new home location details
|
// save the new settings
|
||||||
|
|
||||||
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
if (!pm) return -2;
|
if (!pm) return -2;
|
||||||
@ -158,7 +164,7 @@ int UAVObjectUtilManager::setHomeLocation(double LLA[3], bool save_to_sdcard)
|
|||||||
obj->updated();
|
obj->updated();
|
||||||
|
|
||||||
// ******************
|
// ******************
|
||||||
// save the new location to SD card
|
// save the new setting to SD card
|
||||||
|
|
||||||
if (save_to_sdcard)
|
if (save_to_sdcard)
|
||||||
saveObjectToSD(obj);
|
saveObjectToSD(obj);
|
||||||
@ -195,12 +201,28 @@ int UAVObjectUtilManager::getHomeLocation(bool &set, double LLA[3])
|
|||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("HomeLocation")));
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("HomeLocation")));
|
||||||
if (!obj) return -3;
|
if (!obj) return -3;
|
||||||
|
|
||||||
|
// obj->requestUpdate();
|
||||||
|
|
||||||
set = obj->getField("Set")->getValue().toBool();
|
set = obj->getField("Set")->getValue().toBool();
|
||||||
|
|
||||||
LLA[0] = obj->getField("Latitude")->getDouble() * 1e-7;
|
LLA[0] = obj->getField("Latitude")->getDouble() * 1e-7;
|
||||||
LLA[1] = obj->getField("Longitude")->getDouble() * 1e-7;
|
LLA[1] = obj->getField("Longitude")->getDouble() * 1e-7;
|
||||||
LLA[2] = obj->getField("Altitude")->getDouble();
|
LLA[2] = obj->getField("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
|
return 0; // OK
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,6 +239,8 @@ int UAVObjectUtilManager::getHomeLocation(bool &set, double LLA[3], double ECEF[
|
|||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("HomeLocation")));
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("HomeLocation")));
|
||||||
if (!obj) return -3;
|
if (!obj) return -3;
|
||||||
|
|
||||||
|
// obj->requestUpdate();
|
||||||
|
|
||||||
UAVObjectField *ECEF_field = obj->getField(QString("ECEF"));
|
UAVObjectField *ECEF_field = obj->getField(QString("ECEF"));
|
||||||
if (!ECEF_field) return -4;
|
if (!ECEF_field) return -4;
|
||||||
|
|
||||||
@ -260,6 +284,8 @@ int UAVObjectUtilManager::getGPSPosition(double LLA[3])
|
|||||||
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("GPSPosition")));
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("GPSPosition")));
|
||||||
if (!obj) return -3;
|
if (!obj) return -3;
|
||||||
|
|
||||||
|
// obj->requestUpdate();
|
||||||
|
|
||||||
LLA[0] = obj->getField(QString("Latitude"))->getDouble() * 1e-7;
|
LLA[0] = obj->getField(QString("Latitude"))->getDouble() * 1e-7;
|
||||||
LLA[1] = obj->getField(QString("Longitude"))->getDouble() * 1e-7;
|
LLA[1] = obj->getField(QString("Longitude"))->getDouble() * 1e-7;
|
||||||
LLA[2] = obj->getField(QString("Altitude"))->getDouble();
|
LLA[2] = obj->getField(QString("Altitude"))->getDouble();
|
||||||
@ -282,3 +308,88 @@ int UAVObjectUtilManager::getGPSPosition(double LLA[3])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ******************************
|
// ******************************
|
||||||
|
// telemetry port
|
||||||
|
|
||||||
|
int UAVObjectUtilManager::setTelemetrySerialPortSpeed(QString speed, bool save_to_sdcard)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(mutex);
|
||||||
|
|
||||||
|
// ******************
|
||||||
|
// save the new settings
|
||||||
|
|
||||||
|
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("/*TelemetrySettings*/")));
|
||||||
|
if (!obj) return -3;
|
||||||
|
|
||||||
|
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||||
|
if (!field) return -4;
|
||||||
|
|
||||||
|
field->setValue(speed);
|
||||||
|
|
||||||
|
obj->updated();
|
||||||
|
|
||||||
|
// ******************
|
||||||
|
// save the new setting to SD card
|
||||||
|
|
||||||
|
if (save_to_sdcard)
|
||||||
|
saveObjectToSD(obj);
|
||||||
|
|
||||||
|
// ******************
|
||||||
|
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
|
||||||
|
int UAVObjectUtilManager::getTelemetrySerialPortSpeed(QString &speed)
|
||||||
|
{
|
||||||
|
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("TelemetrySettings")));
|
||||||
|
if (!obj) return -3;
|
||||||
|
|
||||||
|
// obj->requestUpdate();
|
||||||
|
|
||||||
|
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||||
|
if (!field) return -4;
|
||||||
|
|
||||||
|
speed = field->getValue().toString();
|
||||||
|
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
|
||||||
|
int UAVObjectUtilManager::getTelemetrySerialPortSpeeds(QComboBox *comboBox)
|
||||||
|
{
|
||||||
|
QMutexLocker locker(mutex);
|
||||||
|
|
||||||
|
if (!comboBox) return -1;
|
||||||
|
|
||||||
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
||||||
|
if (!pm) return -2;
|
||||||
|
|
||||||
|
UAVObjectManager *obm = pm->getObject<UAVObjectManager>();
|
||||||
|
if (!obm) return -3;
|
||||||
|
|
||||||
|
UAVDataObject *obj = dynamic_cast<UAVDataObject*>(obm->getObject(QString("TelemetrySettings")));
|
||||||
|
if (!obj) return -4;
|
||||||
|
|
||||||
|
// obj->requestUpdate();
|
||||||
|
|
||||||
|
UAVObjectField *field = obj->getField(QString("Speed"));
|
||||||
|
if (!field) return -5;
|
||||||
|
|
||||||
|
comboBox->addItems(field->getOptions());
|
||||||
|
|
||||||
|
return 0; // OK
|
||||||
|
}
|
||||||
|
|
||||||
|
// ******************************
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QQueue>
|
#include <QQueue>
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
class UAVOBJECTUTIL_EXPORT UAVObjectUtilManager: public QObject
|
class UAVOBJECTUTIL_EXPORT UAVObjectUtilManager: public QObject
|
||||||
{
|
{
|
||||||
@ -55,6 +56,10 @@ public:
|
|||||||
|
|
||||||
int getGPSPosition(double LLA[3]);
|
int getGPSPosition(double LLA[3]);
|
||||||
|
|
||||||
|
int setTelemetrySerialPortSpeed(QString speed, bool save_to_sdcard);
|
||||||
|
int getTelemetrySerialPortSpeed(QString &speed);
|
||||||
|
int getTelemetrySerialPortSpeeds(QComboBox *comboBox);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QMutex *mutex;
|
QMutex *mutex;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user