1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

GCS/GPS Renamed GPSObject to PositionActual and added field for GPS status (NoGPS, NoFix, Fix2D and Fix3D)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@733 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
vassilis 2010-06-10 01:27:19 +00:00 committed by vassilis
parent 5472d531e7
commit 6844743050
13 changed files with 91 additions and 97 deletions

View File

@ -45,7 +45,7 @@ FlightGearBridge::FlightGearBridge()
actDesired = ActuatorDesired::GetInstance(objManager);
altActual = AltitudeActual::GetInstance(objManager);
attActual = AttitudeActual::GetInstance(objManager);
gps = GpsObject::GetInstance(objManager);
posActual = PositionActual::GetInstance(objManager);
telStats = GCSTelemetryStats::GetInstance(objManager);
// Listen to autopilot connection events
@ -152,7 +152,7 @@ void FlightGearBridge::setupObjects()
setupInputObject(actDesired, 50);
setupOutputObject(altActual, 250);
setupOutputObject(attActual, 50);
setupOutputObject(gps, 250);
setupOutputObject(posActual, 250);
}
void FlightGearBridge::setupInputObject(UAVObject* obj, int updatePeriod)
@ -270,15 +270,15 @@ void FlightGearBridge::processUpdate(QString& data)
attActual->setData(attActualData);
// Update gps objects
GpsObject::DataFields gpsData;
PositionActual::DataFields gpsData;
gpsData.Altitude = altitude;
gpsData.Heading = heading;
gpsData.GroundSpeed = groundspeed;
gpsData.Groundspeed = groundspeed;
gpsData.Latitude = latitude;
gpsData.Longitude = longitude;
gpsData.Satellites = 10;
gpsData.Updates = 0;
gps->setData(gpsData);
gpsData.Status = PositionActual::STATUS_FIX3D;
posActual->setData(gpsData);
}
void FlightGearBridge::telStatsUpdated(UAVObject* obj)

View File

@ -37,7 +37,7 @@
#include "uavobjects/actuatordesired.h"
#include "uavobjects/altitudeactual.h"
#include "uavobjects/attitudeactual.h"
#include "uavobjects/gpsobject.h"
#include "uavobjects/positionactual.h"
#include "uavobjects/gcstelemetrystats.h"
class FlightGearBridge: public QObject
@ -75,7 +75,7 @@ private:
ActuatorDesired* actDesired;
AltitudeActual* altActual;
AttitudeActual* attActual;
GpsObject* gps;
PositionActual* posActual;
GCSTelemetryStats* telStats;
QHostAddress fgHost;
int inPort;

View File

@ -68,7 +68,7 @@ MapGadgetWidget::MapGadgetWidget(QWidget *parent) : QWidget(parent)
// Get required UAVObjects
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
m_gpsObj = GpsObject::GetInstance(objManager);
m_positionActual = PositionActual::GetInstance(objManager);
m_updateTimer = new QTimer();
m_updateTimer->setInterval(250);
@ -94,7 +94,7 @@ void MapGadgetWidget::setPosition(QPointF pos)
void MapGadgetWidget::updatePosition()
{
GpsObject::DataFields data = m_gpsObj->getData();
PositionActual::DataFields data = m_positionActual->getData();
setPosition(QPointF(data.Longitude, data.Latitude));
}

View File

@ -31,7 +31,7 @@
#include "qmapcontrol/qmapcontrol.h"
#include <QtGui/QWidget>
#include "uavobjects/uavobjectmanager.h"
#include "uavobjects/gpsobject.h"
#include "uavobjects/positionactual.h"
using namespace qmapcontrol;
@ -66,7 +66,7 @@ private:
Layer *m_googleSatLayer;
Layer *m_yahooLayer;
QTimer *m_updateTimer;
GpsObject *m_gpsObj;
PositionActual *m_positionActual;
};
#endif /* MAPGADGETWIDGET_H_ */

View File

@ -30,7 +30,7 @@
#include "uavobjects/uavobject.h"
#include "uavobjects/altitudeactual.h"
#include "uavobjects/gpsobject.h"
#include "uavobjects/positionactual.h"
#include "qwt/src/qwt.h"

View File

@ -273,7 +273,7 @@ TestDataGen::TestDataGen()
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
altActual = AltitudeActual::GetInstance(objManager);
gps = GpsObject::GetInstance(objManager);
gps = PositionActual::GetInstance(objManager);
//Setup timer
timer = new QTimer(this);
@ -292,14 +292,13 @@ void TestDataGen::genTestData()
// Update gps objects
GpsObject::DataFields gpsData;
PositionActual::DataFields gpsData;
gpsData.Altitude = 0;
gpsData.Heading = 0;
gpsData.GroundSpeed = 0;
gpsData.Groundspeed = 0;
gpsData.Latitude = 0;
gpsData.Longitude = 0;
gpsData.Satellites = 10;
gpsData.Updates = 0;
gps->setData(gpsData);
testTime++;

View File

@ -31,7 +31,7 @@
#include "plotdata.h"
#include "uavobjects/uavobject.h"
#include "uavobjects/altitudeactual.h"
#include "uavobjects/gpsobject.h"
#include "uavobjects/positionactual.h"
#include "qwt/src/qwt.h"
@ -69,7 +69,7 @@ public:
private:
AltitudeActual* altActual;
GpsObject* gps;
PositionActual* gps;
QTimer *timer;
double testTime;

View File

@ -1,12 +1,12 @@
/**
******************************************************************************
*
* @file gpsobject.cpp
* @file positionactual.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GpsObject object. This file has been
* @brief Implementation of the PositionActual object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: gpsobject.xml.
* @note Object definition file: positionactual.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
@ -28,18 +28,26 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "gpsobject.h"
#include "positionactual.h"
#include "uavobjectfield.h"
const QString GpsObject::NAME = QString("GpsObject");
const QString PositionActual::NAME = QString("PositionActual");
/**
* Constructor
*/
GpsObject::GpsObject(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
PositionActual::PositionActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList StatusElemNames;
StatusElemNames.append("0");
QStringList StatusEnumOptions;
StatusEnumOptions.append("NoGPS");
StatusEnumOptions.append("NoFix");
StatusEnumOptions.append("Fix2D");
StatusEnumOptions.append("Fix3D");
fields.append( new UAVObjectField(QString("Status"), QString(""), UAVObjectField::ENUM, StatusElemNames, StatusEnumOptions) );
QStringList LatitudeElemNames;
LatitudeElemNames.append("0");
fields.append( new UAVObjectField(QString("Latitude"), QString("degrees"), UAVObjectField::FLOAT32, LatitudeElemNames, QStringList()) );
@ -52,18 +60,12 @@ GpsObject::GpsObject(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
QStringList HeadingElemNames;
HeadingElemNames.append("0");
fields.append( new UAVObjectField(QString("Heading"), QString("degrees"), UAVObjectField::FLOAT32, HeadingElemNames, QStringList()) );
QStringList GroundSpeedElemNames;
GroundSpeedElemNames.append("0");
fields.append( new UAVObjectField(QString("GroundSpeed"), QString("m/s"), UAVObjectField::FLOAT32, GroundSpeedElemNames, QStringList()) );
QStringList GroundspeedElemNames;
GroundspeedElemNames.append("0");
fields.append( new UAVObjectField(QString("Groundspeed"), QString("m/s"), UAVObjectField::FLOAT32, GroundspeedElemNames, QStringList()) );
QStringList SatellitesElemNames;
SatellitesElemNames.append("0");
fields.append( new UAVObjectField(QString("Satellites"), QString(""), UAVObjectField::INT8, SatellitesElemNames, QStringList()) );
QStringList UpdatesElemNames;
UpdatesElemNames.append("0");
fields.append( new UAVObjectField(QString("Updates"), QString(""), UAVObjectField::UINT16, UpdatesElemNames, QStringList()) );
QStringList FailuresElemNames;
FailuresElemNames.append("0");
fields.append( new UAVObjectField(QString("Failures"), QString(""), UAVObjectField::UINT16, FailuresElemNames, QStringList()) );
QStringList PDOPElemNames;
PDOPElemNames.append("0");
fields.append( new UAVObjectField(QString("PDOP"), QString(""), UAVObjectField::FLOAT32, PDOPElemNames, QStringList()) );
@ -83,7 +85,7 @@ GpsObject::GpsObject(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
/**
* Get the default metadata for this object
*/
UAVObject::Metadata GpsObject::getDefaultMetadata()
UAVObject::Metadata PositionActual::getDefaultMetadata()
{
UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE;
@ -104,7 +106,7 @@ UAVObject::Metadata GpsObject::getDefaultMetadata()
* If a default value is not specified the object fields
* will be initialized to zero.
*/
void GpsObject::setDefaultFieldValues()
void PositionActual::setDefaultFieldValues()
{
}
@ -112,7 +114,7 @@ void GpsObject::setDefaultFieldValues()
/**
* Get the object data fields
*/
GpsObject::DataFields GpsObject::getData()
PositionActual::DataFields PositionActual::getData()
{
QMutexLocker locker(mutex);
return data;
@ -121,7 +123,7 @@ GpsObject::DataFields GpsObject::getData()
/**
* Set the object data fields
*/
void GpsObject::setData(const DataFields& data)
void PositionActual::setData(const DataFields& data)
{
QMutexLocker locker(mutex);
// Get metadata
@ -140,9 +142,9 @@ void GpsObject::setData(const DataFields& data)
* Do not use this function directly to create new instances, the
* UAVObjectManager should be used instead.
*/
UAVDataObject* GpsObject::clone(quint32 instID)
UAVDataObject* PositionActual::clone(quint32 instID)
{
GpsObject* obj = new GpsObject();
PositionActual* obj = new PositionActual();
obj->initialize(instID, this->getMetaObject());
return obj;
}
@ -150,7 +152,7 @@ UAVDataObject* GpsObject::clone(quint32 instID)
/**
* Static function to retrieve an instance of the object.
*/
GpsObject* GpsObject::GetInstance(UAVObjectManager* objMngr, quint32 instID)
PositionActual* PositionActual::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<GpsObject*>(objMngr->getObject(GpsObject::OBJID, instID));
return dynamic_cast<PositionActual*>(objMngr->getObject(PositionActual::OBJID, instID));
}

View File

@ -1,12 +1,12 @@
/**
******************************************************************************
*
* @file gpsobject.h
* @file positionactual.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GpsObject object. This file has been
* @brief Implementation of the PositionActual object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: gpsobject.xml.
* @note Object definition file: positionactual.xml.
* This is an automatically generated file.
* DO NOT modify manually.
*
@ -28,27 +28,26 @@
* with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef GPSOBJECT_H
#define GPSOBJECT_H
#ifndef POSITIONACTUAL_H
#define POSITIONACTUAL_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT GpsObject: public UAVDataObject
class UAVOBJECTS_EXPORT PositionActual: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
quint8 Status;
float Latitude;
float Longitude;
float Altitude;
float Heading;
float GroundSpeed;
float Groundspeed;
qint8 Satellites;
quint16 Updates;
quint16 Failures;
float PDOP;
float HDOP;
float VDOP;
@ -56,35 +55,36 @@ public:
} __attribute__((packed)) DataFields;
// Field information
// Field Status information
/* Enumeration options for field Status */
typedef enum { STATUS_NOGPS=0, STATUS_NOFIX=1, STATUS_FIX2D=2, STATUS_FIX3D=3, } StatusOptions;
// Field Latitude information
// Field Longitude information
// Field Altitude information
// Field Heading information
// Field GroundSpeed information
// Field Groundspeed information
// Field Satellites information
// Field Updates information
// Field Failures information
// Field PDOP information
// Field HDOP information
// Field VDOP information
// Constants
static const quint32 OBJID = 3887395742U;
static const quint32 OBJID = 981132812U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
GpsObject();
PositionActual();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static GpsObject* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
static PositionActual* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
@ -93,4 +93,4 @@ private:
};
#endif // GPSOBJECT_H
#endif // POSITIONACTUAL_H

View File

@ -1,12 +1,12 @@
##
##############################################################################
#
# @file gpsobject.py
# @file positionactual.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the GpsObject object. This file has been
# @brief Implementation of the PositionActual object. This file has been
# automatically generated by the UAVObjectGenerator.
#
# @note Object definition file: gpsobject.xml.
# @note Object definition file: positionactual.xml.
# This is an automatically generated file.
# DO NOT modify manually.
#
@ -37,6 +37,20 @@ from collections import namedtuple
# This is a list of instances of the data fields contained in this object
_fields = [ \
uavobject.UAVObjectField(
'Status',
'b',
1,
[
'0',
],
{
'0' : 'NoGPS',
'1' : 'NoFix',
'2' : 'Fix2D',
'3' : 'Fix3D',
}
),
uavobject.UAVObjectField(
'Latitude',
'f',
@ -78,7 +92,7 @@ _fields = [ \
}
),
uavobject.UAVObjectField(
'GroundSpeed',
'Groundspeed',
'f',
1,
[
@ -97,26 +111,6 @@ _fields = [ \
{
}
),
uavobject.UAVObjectField(
'Updates',
'H',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'Failures',
'H',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'PDOP',
'f',
@ -150,11 +144,11 @@ _fields = [ \
]
class GpsObject(uavobject.UAVObject):
class PositionActual(uavobject.UAVObject):
## Object constants
OBJID = 3887395742
NAME = "GpsObject"
METANAME = "GpsObjectMeta"
OBJID = 981132812
NAME = "PositionActual"
METANAME = "PositionActualMeta"
ISSINGLEINST = 1
ISSETTINGS = 0
@ -178,7 +172,7 @@ class GpsObject(uavobject.UAVObject):
def main():
# Instantiate the object and dump out some interesting info
x = GpsObject()
x = PositionActual()
print (x)
if __name__ == "__main__":

View File

@ -16,7 +16,6 @@ HEADERS += uavobjects_global.h \
attitudesettings.h \
exampleobject2.h \
exampleobject1.h \
gpsobject.h \
gcstelemetrystats.h \
flighttelemetrystats.h \
systemstats.h \
@ -30,7 +29,8 @@ HEADERS += uavobjects_global.h \
attitudedesired.h \
actuatorsettings.h \
actuatordesired.h \
actuatorcommand.h
actuatorcommand.h \
positionactual.h
SOURCES += uavobject.cpp \
uavmetaobject.cpp \
uavobjectmanager.cpp \
@ -44,7 +44,6 @@ SOURCES += uavobject.cpp \
examplesettings.cpp \
exampleobject2.cpp \
exampleobject1.cpp \
gpsobject.cpp \
gcstelemetrystats.cpp \
flighttelemetrystats.cpp \
systemstats.cpp \
@ -58,6 +57,7 @@ SOURCES += uavobject.cpp \
attitudedesired.cpp \
actuatorsettings.cpp \
actuatordesired.cpp \
actuatorcommand.cpp
actuatorcommand.cpp \
positionactual.cpp
DEFINES += UAVOBJECTS_LIBRARY
OTHER_FILES += UAVObjects.pluginspec

View File

@ -42,10 +42,10 @@
#include "examplesettings.h"
#include "flighttelemetrystats.h"
#include "gcstelemetrystats.h"
#include "gpsobject.h"
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
#include "objectpersistence.h"
#include "positionactual.h"
#include "stabilizationsettings.h"
#include "systemalarms.h"
#include "systemsettings.h"
@ -71,10 +71,10 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new ExampleSettings() );
objMngr->registerObject( new FlightTelemetryStats() );
objMngr->registerObject( new GCSTelemetryStats() );
objMngr->registerObject( new GpsObject() );
objMngr->registerObject( new ManualControlCommand() );
objMngr->registerObject( new ManualControlSettings() );
objMngr->registerObject( new ObjectPersistence() );
objMngr->registerObject( new PositionActual() );
objMngr->registerObject( new StabilizationSettings() );
objMngr->registerObject( new SystemAlarms() );
objMngr->registerObject( new SystemSettings() );

View File

@ -1,13 +1,12 @@
<xml>
<object name="GpsObject" singleinstance="true" settings="false">
<object name="PositionActual" singleinstance="true" settings="false">
<field name="Status" units="" type="enum" elements="1" options="NoGPS,NoFix,Fix2D,Fix3D"/>
<field name="Latitude" units="degrees" type="float" elements="1"/>
<field name="Longitude" units="degrees" type="float" elements="1"/>
<field name="Altitude" units="meters" type="float" elements="1"/>
<field name="Heading" units="degrees" type="float" elements="1"/>
<field name="GroundSpeed" units="m/s" type="float" elements="1"/>
<field name="Groundspeed" units="m/s" type="float" elements="1"/>
<field name="Satellites" units="" type="int8" elements="1"/>
<field name="Updates" units="" type="uint16" elements="1"/>
<field name="Failures" units="" type="uint16" elements="1"/>
<field name="PDOP" units="" type="float" elements="1"/>
<field name="HDOP" units="" type="float" elements="1"/>
<field name="VDOP" units="" type="float" elements="1"/>