diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 4ae67dd94..4d22e3683 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -159,6 +159,7 @@ SRC += $(OPUAVOBJ)/manualcontrolcommand.c SRC += $(OPUAVOBJ)/manualcontrolsettings.c SRC += $(OPUAVOBJ)/attitudedesired.c SRC += $(OPUAVOBJ)/stabilizationsettings.c +SRC += $(OPUAVOBJ)/ahrsstatus.c SRC += $(OPUAVOBJ)/altitudeactual.c SRC += $(OPUAVOBJ)/attitudeactual.c SRC += $(OPUAVOBJ)/attitudesettings.c diff --git a/flight/OpenPilot/UAVObjects/ahrsstatus.c b/flight/OpenPilot/UAVObjects/ahrsstatus.c new file mode 100644 index 000000000..d66117e98 --- /dev/null +++ b/flight/OpenPilot/UAVObjects/ahrsstatus.c @@ -0,0 +1,102 @@ +/** + ****************************************************************************** + * + * @file ahrsstatus.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the AhrsStatus object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: ahrsstatus.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "openpilot.h" +#include "ahrsstatus.h" + +// Private variables +static UAVObjHandle handle; + +// Private functions +static void setDefaults(UAVObjHandle obj, uint16_t instId); + +/** + * Initialize object. + * \return 0 Success + * \return -1 Failure + */ +int32_t AhrsStatusInitialize() +{ + // Register object with the object manager + handle = UAVObjRegister(AHRSSTATUS_OBJID, AHRSSTATUS_NAME, AHRSSTATUS_METANAME, 0, + AHRSSTATUS_ISSINGLEINST, AHRSSTATUS_ISSETTINGS, AHRSSTATUS_NUMBYTES, &setDefaults); + + // Done + if (handle != 0) + { + return 0; + } + else + { + return -1; + } +} + +/** + * Initialize object fields and metadata with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +static void setDefaults(UAVObjHandle obj, uint16_t instId) +{ + AhrsStatusData data; + UAVObjMetadata metadata; + + // Initialize object fields to their default values + UAVObjGetInstanceData(obj, instId, &data); + memset(&data, 0, sizeof(AhrsStatusData)); + + UAVObjSetInstanceData(obj, instId, &data); + + // Initialize object metadata to their default values + metadata.access = ACCESS_READWRITE; + metadata.gcsAccess = ACCESS_READWRITE; + metadata.telemetryAcked = 0; + metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC; + metadata.telemetryUpdatePeriod = 1000; + metadata.gcsTelemetryAcked = 0; + metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL; + metadata.gcsTelemetryUpdatePeriod = 0; + metadata.loggingUpdateMode = UPDATEMODE_PERIODIC; + metadata.loggingUpdatePeriod = 1000; + UAVObjSetMetadata(obj, &metadata); +} + +/** + * Get object handle + */ +UAVObjHandle AhrsStatusHandle() +{ + return handle; +} + + + diff --git a/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h b/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h new file mode 100644 index 000000000..b33ed495a --- /dev/null +++ b/flight/OpenPilot/UAVObjects/inc/ahrsstatus.h @@ -0,0 +1,74 @@ +/** + ****************************************************************************** + * + * @file ahrsstatus.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the AhrsStatus object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: ahrsstatus.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef AHRSSTATUS_H +#define AHRSSTATUS_H + +// Object constants +#define AHRSSTATUS_OBJID 3344048156U +#define AHRSSTATUS_NAME "AhrsStatus" +#define AHRSSTATUS_METANAME "AhrsStatusMeta" +#define AHRSSTATUS_ISSINGLEINST 1 +#define AHRSSTATUS_ISSETTINGS 0 +#define AHRSSTATUS_NUMBYTES sizeof(AhrsStatusData) + +// Object access macros +#define AhrsStatusGet(dataOut) UAVObjGetData(AhrsStatusHandle(), dataOut) +#define AhrsStatusSet(dataIn) UAVObjSetData(AhrsStatusHandle(), dataIn) +#define AhrsStatusInstGet(instId, dataOut) UAVObjGetInstanceData(AhrsStatusHandle(), instId, dataOut) +#define AhrsStatusInstSet(instId, dataIn) UAVObjSetInstanceData(AhrsStatusHandle(), instId, dataIn) +#define AhrsStatusConnectQueue(queue) UAVObjConnectQueue(AhrsStatusHandle(), queue, EV_MASK_ALL_UPDATES) +#define AhrsStatusConnectCallback(cb) UAVObjConnectCallback(AhrsStatusHandle(), cb, EV_MASK_ALL_UPDATES) +#define AhrsStatusCreateInstance() UAVObjCreateInstance(AhrsStatusHandle()) +#define AhrsStatusRequestUpdate() UAVObjRequestUpdate(AhrsStatusHandle()) +#define AhrsStatusRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(AhrsStatusHandle(), instId) +#define AhrsStatusUpdated() UAVObjUpdated(AhrsStatusHandle()) +#define AhrsStatusInstUpdated(instId) UAVObjUpdated(AhrsStatusHandle(), instId) +#define AhrsStatusGetMetadata(dataOut) UAVObjGetMetadata(AhrsStatusHandle(), dataOut) +#define AhrsStatusSetMetadata(dataIn) UAVObjSetMetadata(AhrsStatusHandle(), dataIn) + +// Object data +typedef struct { + uint8_t SerialNumber[25]; + +} __attribute__((packed)) AhrsStatusData; + +// Field information +// Field SerialNumber information +/* Number of elements for field SerialNumber */ +#define AHRSSTATUS_SERIALNUMBER_NUMELEM 25 + + +// Generic interface functions +int32_t AhrsStatusInitialize(); +UAVObjHandle AhrsStatusHandle(); + +#endif // AHRSSTATUS_H diff --git a/flight/OpenPilot/UAVObjects/uavobjectsinit.c b/flight/OpenPilot/UAVObjects/uavobjectsinit.c index 10a19770d..eb3525e2b 100644 --- a/flight/OpenPilot/UAVObjects/uavobjectsinit.c +++ b/flight/OpenPilot/UAVObjects/uavobjectsinit.c @@ -31,6 +31,7 @@ #include "actuatorcommand.h" #include "actuatordesired.h" #include "actuatorsettings.h" +#include "ahrsstatus.h" #include "altitudeactual.h" #include "attitudeactual.h" #include "attitudedesired.h" @@ -62,6 +63,7 @@ void UAVObjectsInitializeAll() ActuatorCommandInitialize(); ActuatorDesiredInitialize(); ActuatorSettingsInitialize(); + AhrsStatusInitialize(); AltitudeActualInitialize(); AttitudeActualInitialize(); AttitudeDesiredInitialize(); diff --git a/ground/src/plugins/uavobjects/ahrsstatus.cpp b/ground/src/plugins/uavobjects/ahrsstatus.cpp new file mode 100644 index 000000000..5aff20f6c --- /dev/null +++ b/ground/src/plugins/uavobjects/ahrsstatus.cpp @@ -0,0 +1,150 @@ +/** + ****************************************************************************** + * + * @file ahrsstatus.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the AhrsStatus object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: ahrsstatus.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "ahrsstatus.h" +#include "uavobjectfield.h" + +const QString AhrsStatus::NAME = QString("AhrsStatus"); + +/** + * Constructor + */ +AhrsStatus::AhrsStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) +{ + // Create fields + QList fields; + QStringList SerialNumberElemNames; + SerialNumberElemNames.append("0"); + SerialNumberElemNames.append("1"); + SerialNumberElemNames.append("2"); + SerialNumberElemNames.append("3"); + SerialNumberElemNames.append("4"); + SerialNumberElemNames.append("5"); + SerialNumberElemNames.append("6"); + SerialNumberElemNames.append("7"); + SerialNumberElemNames.append("8"); + SerialNumberElemNames.append("9"); + SerialNumberElemNames.append("10"); + SerialNumberElemNames.append("11"); + SerialNumberElemNames.append("12"); + SerialNumberElemNames.append("13"); + SerialNumberElemNames.append("14"); + SerialNumberElemNames.append("15"); + SerialNumberElemNames.append("16"); + SerialNumberElemNames.append("17"); + SerialNumberElemNames.append("18"); + SerialNumberElemNames.append("19"); + SerialNumberElemNames.append("20"); + SerialNumberElemNames.append("21"); + SerialNumberElemNames.append("22"); + SerialNumberElemNames.append("23"); + SerialNumberElemNames.append("24"); + fields.append( new UAVObjectField(QString("SerialNumber"), QString("n/a"), UAVObjectField::UINT8, SerialNumberElemNames, QStringList()) ); + + // Initialize object + initializeFields(fields, (quint8*)&data, NUMBYTES); + // Set the default field values + setDefaultFieldValues(); +} + +/** + * Get the default metadata for this object + */ +UAVObject::Metadata AhrsStatus::getDefaultMetadata() +{ + UAVObject::Metadata metadata; + metadata.flightAccess = ACCESS_READWRITE; + metadata.gcsAccess = ACCESS_READWRITE; + metadata.gcsTelemetryAcked = 0; + metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL; + metadata.gcsTelemetryUpdatePeriod = 0; + metadata.flightTelemetryAcked = 0; + metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; + metadata.flightTelemetryUpdatePeriod = 1000; + metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC; + metadata.loggingUpdatePeriod = 1000; + return metadata; +} + +/** + * Initialize object fields with the default values. + * If a default value is not specified the object fields + * will be initialized to zero. + */ +void AhrsStatus::setDefaultFieldValues() +{ + +} + +/** + * Get the object data fields + */ +AhrsStatus::DataFields AhrsStatus::getData() +{ + QMutexLocker locker(mutex); + return data; +} + +/** + * Set the object data fields + */ +void AhrsStatus::setData(const DataFields& data) +{ + QMutexLocker locker(mutex); + // Get metadata + Metadata mdata = getMetadata(); + // Update object if the access mode permits + if ( mdata.gcsAccess == ACCESS_READWRITE ) + { + this->data = data; + emit objectUpdatedAuto(this); // trigger object updated event + emit objectUpdated(this); + } +} + +/** + * Create a clone of this object, a new instance ID must be specified. + * Do not use this function directly to create new instances, the + * UAVObjectManager should be used instead. + */ +UAVDataObject* AhrsStatus::clone(quint32 instID) +{ + AhrsStatus* obj = new AhrsStatus(); + obj->initialize(instID, this->getMetaObject()); + return obj; +} + +/** + * Static function to retrieve an instance of the object. + */ +AhrsStatus* AhrsStatus::GetInstance(UAVObjectManager* objMngr, quint32 instID) +{ + return dynamic_cast(objMngr->getObject(AhrsStatus::OBJID, instID)); +} diff --git a/ground/src/plugins/uavobjects/ahrsstatus.h b/ground/src/plugins/uavobjects/ahrsstatus.h new file mode 100644 index 000000000..e7181d2be --- /dev/null +++ b/ground/src/plugins/uavobjects/ahrsstatus.h @@ -0,0 +1,78 @@ +/** + ****************************************************************************** + * + * @file ahrsstatus.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the AhrsStatus object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: ahrsstatus.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program 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. + * + * This program 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 this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef AHRSSTATUS_H +#define AHRSSTATUS_H + +#include "uavdataobject.h" +#include "uavobjectmanager.h" + +class UAVOBJECTS_EXPORT AhrsStatus: public UAVDataObject +{ + Q_OBJECT + +public: + // Field structure + typedef struct { + quint8 SerialNumber[25]; + + } __attribute__((packed)) DataFields; + + // Field information + // Field SerialNumber information + /* Number of elements for field SerialNumber */ + static const quint32 SERIALNUMBER_NUMELEM = 25; + + + // Constants + static const quint32 OBJID = 3344048156U; + static const QString NAME; + static const bool ISSINGLEINST = 1; + static const bool ISSETTINGS = 0; + static const quint32 NUMBYTES = sizeof(DataFields); + + // Functions + AhrsStatus(); + + DataFields getData(); + void setData(const DataFields& data); + Metadata getDefaultMetadata(); + UAVDataObject* clone(quint32 instID); + + static AhrsStatus* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0); + +private: + DataFields data; + + void setDefaultFieldValues(); + +}; + +#endif // AHRSSTATUS_H diff --git a/ground/src/plugins/uavobjects/ahrsstatus.py b/ground/src/plugins/uavobjects/ahrsstatus.py new file mode 100644 index 000000000..b55e20c5e --- /dev/null +++ b/ground/src/plugins/uavobjects/ahrsstatus.py @@ -0,0 +1,110 @@ +## +############################################################################## +# +# @file ahrsstatus.py +# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. +# @brief Implementation of the AhrsStatus object. This file has been +# automatically generated by the UAVObjectGenerator. +# +# @note Object definition file: ahrsstatus.xml. +# This is an automatically generated file. +# DO NOT modify manually. +# +# @see The GNU Public License (GPL) Version 3 +# +#############################################################################/ +# +# This program 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. +# +# This program 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 this program; if not, write to the Free Software Foundation, Inc., +# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + + +import uavobject + +import struct +from collections import namedtuple + +# This is a list of instances of the data fields contained in this object +_fields = [ \ + uavobject.UAVObjectField( + 'SerialNumber', + 'B', + 25, + [ + '0', + '1', + '2', + '3', + '4', + '5', + '6', + '7', + '8', + '9', + '10', + '11', + '12', + '13', + '14', + '15', + '16', + '17', + '18', + '19', + '20', + '21', + '22', + '23', + '24', + ], + { + } + ), +] + + +class AhrsStatus(uavobject.UAVObject): + ## Object constants + OBJID = 3344048156 + NAME = "AhrsStatus" + METANAME = "AhrsStatusMeta" + ISSINGLEINST = 1 + ISSETTINGS = 0 + + def __init__(self): + uavobject.UAVObject.__init__(self, + self.OBJID, + self.NAME, + self.METANAME, + 0, + self.ISSINGLEINST) + + for f in _fields: + self.add_field(f) + + def __str__(self): + s = ("0x%08X (%10u) %-30s %3u bytes format '%s'\n" + % (self.OBJID, self.OBJID, self.NAME, self.get_struct().size, self.get_struct().format)) + for f in self.get_tuple()._fields: + s += ("\t%s\n" % f) + return (s) + +def main(): + # Instantiate the object and dump out some interesting info + x = AhrsStatus() + print (x) + +if __name__ == "__main__": + #import pdb ; pdb.run('main()') + main() diff --git a/ground/src/plugins/uavobjects/uavobjects.pro b/ground/src/plugins/uavobjects/uavobjects.pro index 84d4cca56..7552d2c8e 100644 --- a/ground/src/plugins/uavobjects/uavobjects.pro +++ b/ground/src/plugins/uavobjects/uavobjects.pro @@ -12,6 +12,7 @@ HEADERS += uavobjects_global.h \ uavobjectsinit.h \ uavobjectsplugin.h \ examplesettings.h \ + ahrsstatus.h \ altitudeactual.h \ attitudeactual.h \ attitudesettings.h \ @@ -41,6 +42,7 @@ SOURCES += uavobject.cpp \ uavobjectfield.cpp \ uavobjectsinit.cpp \ uavobjectsplugin.cpp \ + ahrsstatus.cpp \ altitudeactual.cpp \ attitudeactual.cpp \ attitudesettings.cpp \ diff --git a/ground/src/plugins/uavobjects/uavobjectsinit.cpp b/ground/src/plugins/uavobjects/uavobjectsinit.cpp index f29646a96..dfec56d42 100644 --- a/ground/src/plugins/uavobjects/uavobjectsinit.cpp +++ b/ground/src/plugins/uavobjects/uavobjectsinit.cpp @@ -32,6 +32,7 @@ #include "actuatorcommand.h" #include "actuatordesired.h" #include "actuatorsettings.h" +#include "ahrsstatus.h" #include "altitudeactual.h" #include "attitudeactual.h" #include "attitudedesired.h" @@ -63,6 +64,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr) objMngr->registerObject( new ActuatorCommand() ); objMngr->registerObject( new ActuatorDesired() ); objMngr->registerObject( new ActuatorSettings() ); + objMngr->registerObject( new AhrsStatus() ); objMngr->registerObject( new AltitudeActual() ); objMngr->registerObject( new AttitudeActual() ); objMngr->registerObject( new AttitudeDesired() ); diff --git a/ground/src/shared/uavobjectdefinition/ahrsstatus.xml b/ground/src/shared/uavobjectdefinition/ahrsstatus.xml new file mode 100644 index 000000000..ea28f77e1 --- /dev/null +++ b/ground/src/shared/uavobjectdefinition/ahrsstatus.xml @@ -0,0 +1,9 @@ + + + + + + + + +