1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

Foolishly forgot object like I always do

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1529 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-09-04 22:01:11 +00:00 committed by peabody124
parent a378621666
commit f9a0b799a2
6 changed files with 526 additions and 0 deletions

View File

@ -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;
}
/**
* @}
*/

View File

@ -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
/**
* @}
* @}
*/

View File

@ -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<UAVObjectField*> 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<AttitudeSettings*>(objMngr->getObject(AttitudeSettings::OBJID, instID));
}

View File

@ -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

View File

@ -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()

View File

@ -0,0 +1,11 @@
<xml>
<object name="AttitudeSettings" singleinstance="true" settings="true">
<description>Sets correction between airframe attitude and AHRS attitude</description>
<field name="PitchBias" units="" type="float" elements="1" defaultvalue="0"/>
<field name="RollBias" units="" type="float" elements="1" defaultvalue="0"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="onchange" period="0"/>
<logging updatemode="never" period="0"/>
</object>
</xml>