From f9a0b799a28fa215107ef28cbf486248cc6d56b1 Mon Sep 17 00:00:00 2001 From: peabody124 Date: Sat, 4 Sep 2010 22:01:11 +0000 Subject: [PATCH] Foolishly forgot object like I always do git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1529 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../OpenPilot/UAVObjects/attitudesettings.c | 113 +++++++++++++++ .../UAVObjects/inc/attitudesettings.h | 93 ++++++++++++ .../plugins/uavobjects/attitudesettings.cpp | 133 ++++++++++++++++++ .../src/plugins/uavobjects/attitudesettings.h | 80 +++++++++++ .../plugins/uavobjects/attitudesettings.py | 96 +++++++++++++ .../uavobjectdefinition/attitudesettings.xml | 11 ++ 6 files changed, 526 insertions(+) create mode 100644 flight/OpenPilot/UAVObjects/attitudesettings.c create mode 100644 flight/OpenPilot/UAVObjects/inc/attitudesettings.h create mode 100644 ground/src/plugins/uavobjects/attitudesettings.cpp create mode 100644 ground/src/plugins/uavobjects/attitudesettings.h create mode 100644 ground/src/plugins/uavobjects/attitudesettings.py create mode 100644 ground/src/shared/uavobjectdefinition/attitudesettings.xml diff --git a/flight/OpenPilot/UAVObjects/attitudesettings.c b/flight/OpenPilot/UAVObjects/attitudesettings.c new file mode 100644 index 000000000..5314397a1 --- /dev/null +++ b/flight/OpenPilot/UAVObjects/attitudesettings.c @@ -0,0 +1,113 @@ +/** + ****************************************************************************** + * @addtogroup UAVObjects OpenPilot UAVObjects + * @{ + * @addtogroup AttitudeSettings AttitudeSettings + * @brief Sets correction between airframe attitude and AHRS attitude + * + * Autogenerated files and functions for AttitudeSettings Object + * @{ + * + * @file attitudesettings.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the AttitudeSettings object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: attitudesettings.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 "attitudesettings.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 AttitudeSettingsInitialize() +{ + // Register object with the object manager + handle = UAVObjRegister(ATTITUDESETTINGS_OBJID, ATTITUDESETTINGS_NAME, ATTITUDESETTINGS_METANAME, 0, + ATTITUDESETTINGS_ISSINGLEINST, ATTITUDESETTINGS_ISSETTINGS, ATTITUDESETTINGS_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) +{ + AttitudeSettingsData data; + UAVObjMetadata metadata; + + // Initialize object fields to their default values + UAVObjGetInstanceData(obj, instId, &data); + memset(&data, 0, sizeof(AttitudeSettingsData)); + data.PitchBias = 0; + data.RollBias = 0; + + UAVObjSetInstanceData(obj, instId, &data); + + // Initialize object metadata to their default values + metadata.access = ACCESS_READWRITE; + metadata.gcsAccess = ACCESS_READWRITE; + metadata.telemetryAcked = 1; + metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE; + metadata.telemetryUpdatePeriod = 0; + metadata.gcsTelemetryAcked = 1; + metadata.gcsTelemetryUpdateMode = UPDATEMODE_ONCHANGE; + metadata.gcsTelemetryUpdatePeriod = 0; + metadata.loggingUpdateMode = UPDATEMODE_NEVER; + metadata.loggingUpdatePeriod = 0; + UAVObjSetMetadata(obj, &metadata); +} + +/** + * Get object handle + */ +UAVObjHandle AttitudeSettingsHandle() +{ + return handle; +} + +/** + * @} + */ + diff --git a/flight/OpenPilot/UAVObjects/inc/attitudesettings.h b/flight/OpenPilot/UAVObjects/inc/attitudesettings.h new file mode 100644 index 000000000..6294ef29a --- /dev/null +++ b/flight/OpenPilot/UAVObjects/inc/attitudesettings.h @@ -0,0 +1,93 @@ +/** + ****************************************************************************** + * @addtogroup UAVObjects OpenPilot UAVObjects + * @{ + * @addtogroup AttitudeSettings AttitudeSettings + * @brief Sets correction between airframe attitude and AHRS attitude + * + * Autogenerated files and functions for AttitudeSettings Object + + * @{ + * + * @file attitudesettings.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the AttitudeSettings object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: attitudesettings.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 ATTITUDESETTINGS_H +#define ATTITUDESETTINGS_H + +// Object constants +#define ATTITUDESETTINGS_OBJID 1065705802U +#define ATTITUDESETTINGS_NAME "AttitudeSettings" +#define ATTITUDESETTINGS_METANAME "AttitudeSettingsMeta" +#define ATTITUDESETTINGS_ISSINGLEINST 1 +#define ATTITUDESETTINGS_ISSETTINGS 1 +#define ATTITUDESETTINGS_NUMBYTES sizeof(AttitudeSettingsData) + +// Object access macros +/** + * @function AttitudeSettingsGet(dataOut) + * @brief Populate a AttitudeSettingsData object + * @param[out] dataOut + */ +#define AttitudeSettingsGet(dataOut) UAVObjGetData(AttitudeSettingsHandle(), dataOut) +#define AttitudeSettingsSet(dataIn) UAVObjSetData(AttitudeSettingsHandle(), dataIn) +#define AttitudeSettingsInstGet(instId, dataOut) UAVObjGetInstanceData(AttitudeSettingsHandle(), instId, dataOut) +#define AttitudeSettingsInstSet(instId, dataIn) UAVObjSetInstanceData(AttitudeSettingsHandle(), instId, dataIn) +#define AttitudeSettingsConnectQueue(queue) UAVObjConnectQueue(AttitudeSettingsHandle(), queue, EV_MASK_ALL_UPDATES) +#define AttitudeSettingsConnectCallback(cb) UAVObjConnectCallback(AttitudeSettingsHandle(), cb, EV_MASK_ALL_UPDATES) +#define AttitudeSettingsCreateInstance() UAVObjCreateInstance(AttitudeSettingsHandle()) +#define AttitudeSettingsRequestUpdate() UAVObjRequestUpdate(AttitudeSettingsHandle()) +#define AttitudeSettingsRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(AttitudeSettingsHandle(), instId) +#define AttitudeSettingsUpdated() UAVObjUpdated(AttitudeSettingsHandle()) +#define AttitudeSettingsInstUpdated(instId) UAVObjUpdated(AttitudeSettingsHandle(), instId) +#define AttitudeSettingsGetMetadata(dataOut) UAVObjGetMetadata(AttitudeSettingsHandle(), dataOut) +#define AttitudeSettingsSetMetadata(dataIn) UAVObjSetMetadata(AttitudeSettingsHandle(), dataIn) +#define AttitudeSettingsReadOnly(dataIn) UAVObjReadOnly(AttitudeSettingsHandle()) + +// Object data +typedef struct { + float PitchBias; + float RollBias; + +} __attribute__((packed)) AttitudeSettingsData; + +// Field information +// Field PitchBias information +// Field RollBias information + + +// Generic interface functions +int32_t AttitudeSettingsInitialize(); +UAVObjHandle AttitudeSettingsHandle(); + +#endif // ATTITUDESETTINGS_H + +/** + * @} + * @} + */ diff --git a/ground/src/plugins/uavobjects/attitudesettings.cpp b/ground/src/plugins/uavobjects/attitudesettings.cpp new file mode 100644 index 000000000..3ec3a71e3 --- /dev/null +++ b/ground/src/plugins/uavobjects/attitudesettings.cpp @@ -0,0 +1,133 @@ +/** + ****************************************************************************** + * + * @file attitudesettings.cpp + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @see The GNU Public License (GPL) Version 3 + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup UAVObjectsPlugin UAVObjects Plugin + * @{ + * + * @note Object definition file: attitudesettings.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @brief The UAVUObjects GCS plugin + *****************************************************************************/ +/* + * 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 "attitudesettings.h" +#include "uavobjectfield.h" + +const QString AttitudeSettings::NAME = QString("AttitudeSettings"); + +/** + * Constructor + */ +AttitudeSettings::AttitudeSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) +{ + // Create fields + QList fields; + QStringList PitchBiasElemNames; + PitchBiasElemNames.append("0"); + fields.append( new UAVObjectField(QString("PitchBias"), QString(""), UAVObjectField::FLOAT32, PitchBiasElemNames, QStringList()) ); + QStringList RollBiasElemNames; + RollBiasElemNames.append("0"); + fields.append( new UAVObjectField(QString("RollBias"), QString(""), UAVObjectField::FLOAT32, RollBiasElemNames, QStringList()) ); + + // Initialize object + initializeFields(fields, (quint8*)&data, NUMBYTES); + // Set the default field values + setDefaultFieldValues(); +} + +/** + * Get the default metadata for this object + */ +UAVObject::Metadata AttitudeSettings::getDefaultMetadata() +{ + UAVObject::Metadata metadata; + metadata.flightAccess = ACCESS_READWRITE; + metadata.gcsAccess = ACCESS_READWRITE; + metadata.gcsTelemetryAcked = 1; + metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE; + metadata.gcsTelemetryUpdatePeriod = 0; + metadata.flightTelemetryAcked = 1; + metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_ONCHANGE; + metadata.flightTelemetryUpdatePeriod = 0; + metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER; + metadata.loggingUpdatePeriod = 0; + 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 AttitudeSettings::setDefaultFieldValues() +{ + data.PitchBias = 0; + data.RollBias = 0; + +} + +/** + * Get the object data fields + */ +AttitudeSettings::DataFields AttitudeSettings::getData() +{ + QMutexLocker locker(mutex); + return data; +} + +/** + * Set the object data fields + */ +void AttitudeSettings::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* AttitudeSettings::clone(quint32 instID) +{ + AttitudeSettings* obj = new AttitudeSettings(); + obj->initialize(instID, this->getMetaObject()); + return obj; +} + +/** + * Static function to retrieve an instance of the object. + */ +AttitudeSettings* AttitudeSettings::GetInstance(UAVObjectManager* objMngr, quint32 instID) +{ + return dynamic_cast(objMngr->getObject(AttitudeSettings::OBJID, instID)); +} diff --git a/ground/src/plugins/uavobjects/attitudesettings.h b/ground/src/plugins/uavobjects/attitudesettings.h new file mode 100644 index 000000000..d0327d391 --- /dev/null +++ b/ground/src/plugins/uavobjects/attitudesettings.h @@ -0,0 +1,80 @@ +/** + ****************************************************************************** + * + * @file attitudesettings.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @see The GNU Public License (GPL) Version 3 + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup UAVObjectsPlugin UAVObjects Plugin + * @{ + * + * @note Object definition file: attitudesettings.xml. + * This is an automatically generated file. + * DO NOT modify manually. + * + * @brief The UAVUObjects GCS plugin + *****************************************************************************/ +/* + * 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 ATTITUDESETTINGS_H +#define ATTITUDESETTINGS_H + +#include "uavdataobject.h" +#include "uavobjectmanager.h" + +class UAVOBJECTS_EXPORT AttitudeSettings: public UAVDataObject +{ + Q_OBJECT + +public: + // Field structure + typedef struct { + float PitchBias; + float RollBias; + + } __attribute__((packed)) DataFields; + + // Field information + // Field PitchBias information + // Field RollBias information + + + // Constants + static const quint32 OBJID = 1065705802U; + static const QString NAME; + static const bool ISSINGLEINST = 1; + static const bool ISSETTINGS = 1; + static const quint32 NUMBYTES = sizeof(DataFields); + + // Functions + AttitudeSettings(); + + DataFields getData(); + void setData(const DataFields& data); + Metadata getDefaultMetadata(); + UAVDataObject* clone(quint32 instID); + + static AttitudeSettings* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0); + +private: + DataFields data; + + void setDefaultFieldValues(); + +}; + +#endif // ATTITUDESETTINGS_H diff --git a/ground/src/plugins/uavobjects/attitudesettings.py b/ground/src/plugins/uavobjects/attitudesettings.py new file mode 100644 index 000000000..0a59845a6 --- /dev/null +++ b/ground/src/plugins/uavobjects/attitudesettings.py @@ -0,0 +1,96 @@ +## +############################################################################## +# +# @file attitudesettings.py +# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. +# @brief Implementation of the AttitudeSettings object. This file has been +# automatically generated by the UAVObjectGenerator. +# +# @note Object definition file: attitudesettings.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( + 'PitchBias', + 'f', + 1, + [ + '0', + ], + { + } + ), + uavobject.UAVObjectField( + 'RollBias', + 'f', + 1, + [ + '0', + ], + { + } + ), +] + + +class AttitudeSettings(uavobject.UAVObject): + ## Object constants + OBJID = 1065705802 + NAME = "AttitudeSettings" + METANAME = "AttitudeSettingsMeta" + ISSINGLEINST = 1 + ISSETTINGS = 1 + + 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 = AttitudeSettings() + print (x) + +if __name__ == "__main__": + #import pdb ; pdb.run('main()') + main() diff --git a/ground/src/shared/uavobjectdefinition/attitudesettings.xml b/ground/src/shared/uavobjectdefinition/attitudesettings.xml new file mode 100644 index 000000000..88bcf5e1f --- /dev/null +++ b/ground/src/shared/uavobjectdefinition/attitudesettings.xml @@ -0,0 +1,11 @@ + + + Sets correction between airframe attitude and AHRS attitude + + + + + + + +