mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-17 02:52:12 +01:00
altitude: Add altitude module which reads BMP085
This module reads from the BMP085 pressure sensor. It periodically updates the pressure (kPa) and temperature (C) as well as the calculated altitude (m). git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@640 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
b7601c9765
commit
d02a3325d9
@ -85,6 +85,8 @@ MODMANUALCONTROL = $(OPMODULEDIR)/ManualControl
|
||||
MODMANUALCONTROLINC = $(MODMANUALCONTROL)/inc
|
||||
MODACTUATOR = $(OPMODULEDIR)/Actuator
|
||||
MODACTUATORINC = $(MODACTUATOR)/inc
|
||||
MODALTITUDE = $(OPMODULEDIR)/Altitude
|
||||
MODALTITUDEINC = $(MODALTITUDE)/inc
|
||||
PIOS = ../PiOS
|
||||
PIOSINC = $(PIOS)/inc
|
||||
PIOSSTM32F10X = $(PIOS)/STM32F10x
|
||||
@ -117,6 +119,7 @@ SRC += $(MODTELEMETRY)/telemetry.c
|
||||
SRC += $(MODGPS)/GPS.c $(MODGPS)/buffer.c
|
||||
SRC += $(MODMANUALCONTROL)/manualcontrol.c
|
||||
SRC += $(MODACTUATOR)/actuator.c
|
||||
SRC += $(MODALTITUDE)/altitude.c
|
||||
|
||||
## OPENPILOT:
|
||||
SRC += $(OPSYSTEM)/openpilot.c
|
||||
@ -155,6 +158,7 @@ SRC += $(OPUAVOBJ)/manualcontrolcommand.c
|
||||
SRC += $(OPUAVOBJ)/manualcontrolsettings.c
|
||||
SRC += $(OPUAVOBJ)/attitudedesired.c
|
||||
SRC += $(OPUAVOBJ)/stabilizationsettings.c
|
||||
SRC += $(OPUAVOBJ)/altitudeactual.c
|
||||
|
||||
## PIOS Hardware (STM32F10x)
|
||||
SRC += $(PIOSSTM32F10X)/pios_sys.c
|
||||
@ -280,6 +284,8 @@ EXTRAINCDIRS += $(MODMANUALCONTROL)
|
||||
EXTRAINCDIRS += $(MODMANUALCONTROLINC)
|
||||
EXTRAINCDIRS += $(MODACTUATOR)
|
||||
EXTRAINCDIRS += $(MODACTUATORINC)
|
||||
EXTRAINCDIRS += $(MODALTITUDE)
|
||||
EXTRAINCDIRS += $(MODALTITUDEINC)
|
||||
EXTRAINCDIRS += $(PIOS)
|
||||
EXTRAINCDIRS += $(PIOSINC)
|
||||
EXTRAINCDIRS += $(PIOSSTM32F10X)
|
||||
|
109
flight/OpenPilot/Modules/Altitude/altitude.c
Normal file
109
flight/OpenPilot/Modules/Altitude/altitude.c
Normal file
@ -0,0 +1,109 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file altitude.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Altitude module, handles temperature and pressure readings from BMP085
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Output object: AltitudeActual
|
||||
*
|
||||
* This module will periodically update the value of the AltitudeActual object.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "openpilot.h"
|
||||
#include "altitudeactual.h" // object that will be updated by the module
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY+3)
|
||||
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
static xTaskHandle taskHandle;
|
||||
|
||||
// Private functions
|
||||
static void altitudeTask(void* parameters);
|
||||
|
||||
/**
|
||||
* Initialise the module, called on startup
|
||||
* \returns 0 on success or -1 if initialisation failed
|
||||
*/
|
||||
int32_t AltitudeInitialize()
|
||||
{
|
||||
// Start main task
|
||||
xTaskCreate(altitudeTask, (signed char*)"Altitude", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module thread, should not return.
|
||||
*/
|
||||
static void altitudeTask(void* parameters)
|
||||
{
|
||||
AltitudeActualData data;
|
||||
portTickType lastSysTime;
|
||||
|
||||
PIOS_BMP085_Init();
|
||||
|
||||
// Main task loop
|
||||
lastSysTime = xTaskGetTickCount();
|
||||
while (1)
|
||||
{
|
||||
// Get the object data
|
||||
AltitudeActualGet(&data);
|
||||
|
||||
// Update the temperature data
|
||||
PIOS_BMP085_StartADC(TemperatureConv);
|
||||
#if 0
|
||||
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
||||
#else
|
||||
vTaskDelay( 5 / portTICK_RATE_MS );
|
||||
#endif
|
||||
PIOS_BMP085_ReadADC();
|
||||
// Convert from 1/10ths of degC to degC
|
||||
data.Temperature = PIOS_BMP085_GetTemperature() / 10.0;
|
||||
|
||||
// Update the pressure data
|
||||
PIOS_BMP085_StartADC(PressureConv);
|
||||
#if 0
|
||||
xSemaphoreTake(PIOS_BMP085_EOC, portMAX_DELAY);
|
||||
#else
|
||||
vTaskDelay( 26 / portTICK_RATE_MS );
|
||||
#endif
|
||||
PIOS_BMP085_ReadADC();
|
||||
// Convert from Pa to kPa
|
||||
data.Pressure = PIOS_BMP085_GetPressure() / 1000.0;
|
||||
|
||||
// Compute the current altitude (all pressures in kPa)
|
||||
data.Altitude = 44330.0 * (1.0 - powf((data.Pressure/ (BMP085_P0 / 1000.0)), (1.0/5.255)));
|
||||
|
||||
// Update the AltitudeActual UAVObject
|
||||
AltitudeActualSet(&data);
|
||||
|
||||
// Delay until it is time to read the next sample
|
||||
vTaskDelayUntil(&lastSysTime, 1000 / portTICK_RATE_MS );
|
||||
}
|
||||
}
|
32
flight/OpenPilot/Modules/Altitude/inc/altitude.h
Normal file
32
flight/OpenPilot/Modules/Altitude/inc/altitude.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file altitude.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Altitude module, reads temperature and pressure from BMP085
|
||||
*
|
||||
* @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 ALTITUDE_H
|
||||
#define ALTITUDE_H
|
||||
|
||||
int32_t AltitudeInitialize();
|
||||
|
||||
#endif // ALTITUDE_H
|
||||
|
@ -134,6 +134,7 @@ void OpenPilotInit()
|
||||
GpsInitialize();
|
||||
ManualControlInitialize();
|
||||
ActuatorInitialize();
|
||||
AltitudeInitialize();
|
||||
|
||||
/* Create test tasks */
|
||||
//xTaskCreate(TaskTesting, (signed portCHAR *)"Testing", configMINIMAL_STACK_SIZE , NULL, 4, NULL);
|
||||
|
100
flight/OpenPilot/UAVObjects/altitudeactual.c
Normal file
100
flight/OpenPilot/UAVObjects/altitudeactual.c
Normal file
@ -0,0 +1,100 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file altitudeactual.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the AltitudeActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: altitudeactual.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 "altitudeactual.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 AltitudeActualInitialize()
|
||||
{
|
||||
// Register object with the object manager
|
||||
handle = UAVObjRegister(ALTITUDEACTUAL_OBJID, ALTITUDEACTUAL_NAME, ALTITUDEACTUAL_METANAME, 0,
|
||||
ALTITUDEACTUAL_ISSINGLEINST, ALTITUDEACTUAL_ISSETTINGS, ALTITUDEACTUAL_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)
|
||||
{
|
||||
AltitudeActualData data;
|
||||
UAVObjMetadata metadata;
|
||||
|
||||
// Initialize object fields to their default values
|
||||
UAVObjGetInstanceData(obj, instId, &data);
|
||||
memset(&data, 0, sizeof(AltitudeActualData));
|
||||
|
||||
UAVObjSetInstanceData(obj, instId, &data);
|
||||
|
||||
// Initialize object metadata to their default values
|
||||
metadata.telemetryAcked = 1;
|
||||
metadata.telemetryUpdateMode = UPDATEMODE_ONCHANGE;
|
||||
metadata.telemetryUpdatePeriod = 0;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.gcsTelemetryUpdatePeriod = 200;
|
||||
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
|
||||
metadata.loggingUpdatePeriod = 0;
|
||||
UAVObjSetMetadata(obj, &metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object handle
|
||||
*/
|
||||
UAVObjHandle AltitudeActualHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
76
flight/OpenPilot/UAVObjects/inc/altitudeactual.h
Normal file
76
flight/OpenPilot/UAVObjects/inc/altitudeactual.h
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file altitudeactual.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the AltitudeActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: altitudeactual.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 ALTITUDEACTUAL_H
|
||||
#define ALTITUDEACTUAL_H
|
||||
|
||||
// Object constants
|
||||
#define ALTITUDEACTUAL_OBJID 2251817750U
|
||||
#define ALTITUDEACTUAL_NAME "AltitudeActual"
|
||||
#define ALTITUDEACTUAL_METANAME "AltitudeActualMeta"
|
||||
#define ALTITUDEACTUAL_ISSINGLEINST 1
|
||||
#define ALTITUDEACTUAL_ISSETTINGS 0
|
||||
#define ALTITUDEACTUAL_NUMBYTES sizeof(AltitudeActualData)
|
||||
|
||||
// Object access macros
|
||||
#define AltitudeActualGet(dataOut) UAVObjGetData(AltitudeActualHandle(), dataOut)
|
||||
#define AltitudeActualSet(dataIn) UAVObjSetData(AltitudeActualHandle(), dataIn)
|
||||
#define AltitudeActualInstGet(instId, dataOut) UAVObjGetInstanceData(AltitudeActualHandle(), instId, dataOut)
|
||||
#define AltitudeActualInstSet(instId, dataIn) UAVObjSetInstanceData(AltitudeActualHandle(), instId, dataIn)
|
||||
#define AltitudeActualConnectQueue(queue) UAVObjConnectQueue(AltitudeActualHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||
#define AltitudeActualConnectCallback(cb) UAVObjConnectCallback(AltitudeActualHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||
#define AltitudeActualCreateInstance() UAVObjCreateInstance(AltitudeActualHandle())
|
||||
#define AltitudeActualRequestUpdate() UAVObjRequestUpdate(AltitudeActualHandle())
|
||||
#define AltitudeActualRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(AltitudeActualHandle(), instId)
|
||||
#define AltitudeActualUpdated() UAVObjUpdated(AltitudeActualHandle())
|
||||
#define AltitudeActualInstUpdated(instId) UAVObjUpdated(AltitudeActualHandle(), instId)
|
||||
#define AltitudeActualGetMetadata(dataOut) UAVObjGetMetadata(AltitudeActualHandle(), dataOut)
|
||||
#define AltitudeActualSetMetadata(dataIn) UAVObjSetMetadata(AltitudeActualHandle(), dataIn)
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
float Altitude;
|
||||
float Temperature;
|
||||
float Pressure;
|
||||
|
||||
} __attribute__((packed)) AltitudeActualData;
|
||||
|
||||
// Field information
|
||||
// Field Altitude information
|
||||
// Field Temperature information
|
||||
// Field Pressure information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t AltitudeActualInitialize();
|
||||
UAVObjHandle AltitudeActualHandle();
|
||||
|
||||
#endif // ALTITUDEACTUAL_H
|
@ -31,6 +31,7 @@
|
||||
#include "actuatorcommand.h"
|
||||
#include "actuatordesired.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "altitudeactual.h"
|
||||
#include "attitudedesired.h"
|
||||
#include "exampleobject1.h"
|
||||
#include "exampleobject2.h"
|
||||
@ -57,6 +58,7 @@ void UAVObjectsInitializeAll()
|
||||
ActuatorCommandInitialize();
|
||||
ActuatorDesiredInitialize();
|
||||
ActuatorSettingsInitialize();
|
||||
AltitudeActualInitialize();
|
||||
AttitudeDesiredInitialize();
|
||||
ExampleObject1Initialize();
|
||||
ExampleObject2Initialize();
|
||||
|
@ -29,4 +29,4 @@
|
||||
/* Public Functions */
|
||||
|
||||
|
||||
#endif /* PIOS_LED_H */
|
||||
#endif /* PIOS_EXTI_H */
|
||||
|
124
ground/src/plugins/uavobjects/altitudeactual.cpp
Normal file
124
ground/src/plugins/uavobjects/altitudeactual.cpp
Normal file
@ -0,0 +1,124 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file altitudeactual.cpp
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the AltitudeActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: altitudeactual.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 "altitudeactual.h"
|
||||
#include "uavobjectfield.h"
|
||||
|
||||
const QString AltitudeActual::NAME = QString("AltitudeActual");
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
AltitudeActual::AltitudeActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList AltitudeElemNames;
|
||||
AltitudeElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Altitude"), QString("m"), UAVObjectField::FLOAT32, AltitudeElemNames, QStringList()) );
|
||||
QStringList TemperatureElemNames;
|
||||
TemperatureElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Temperature"), QString("C"), UAVObjectField::FLOAT32, TemperatureElemNames, QStringList()) );
|
||||
QStringList PressureElemNames;
|
||||
PressureElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Pressure"), QString("kPa"), UAVObjectField::FLOAT32, PressureElemNames, QStringList()) );
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
// Set the default field values
|
||||
setDefaultFieldValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default metadata for this object
|
||||
*/
|
||||
UAVObject::Metadata AltitudeActual::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.gcsTelemetryAcked = 1;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.gcsTelemetryUpdatePeriod = 200;
|
||||
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 AltitudeActual::setDefaultFieldValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object data fields
|
||||
*/
|
||||
AltitudeActual::DataFields AltitudeActual::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object data fields
|
||||
*/
|
||||
void AltitudeActual::setData(const DataFields& data)
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
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* AltitudeActual::clone(quint32 instID)
|
||||
{
|
||||
AltitudeActual* obj = new AltitudeActual();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function to retrieve an instance of the object.
|
||||
*/
|
||||
AltitudeActual* AltitudeActual::GetInstance(UAVObjectManager* objMngr, quint32 instID)
|
||||
{
|
||||
return dynamic_cast<AltitudeActual*>(objMngr->getObject(AltitudeActual::OBJID, instID));
|
||||
}
|
80
ground/src/plugins/uavobjects/altitudeactual.h
Normal file
80
ground/src/plugins/uavobjects/altitudeactual.h
Normal file
@ -0,0 +1,80 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file altitudeactual.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the AltitudeActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: altitudeactual.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 ALTITUDEACTUAL_H
|
||||
#define ALTITUDEACTUAL_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT AltitudeActual: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
float Altitude;
|
||||
float Temperature;
|
||||
float Pressure;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field Altitude information
|
||||
// Field Temperature information
|
||||
// Field Pressure information
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 2251817750U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
AltitudeActual();
|
||||
|
||||
DataFields getData();
|
||||
void setData(const DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
static AltitudeActual* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
void setDefaultFieldValues();
|
||||
|
||||
};
|
||||
|
||||
#endif // ALTITUDEACTUAL_H
|
106
ground/src/plugins/uavobjects/altitudeactual.py
Normal file
106
ground/src/plugins/uavobjects/altitudeactual.py
Normal file
@ -0,0 +1,106 @@
|
||||
##
|
||||
##############################################################################
|
||||
#
|
||||
# @file altitudeactual.py
|
||||
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
# @brief Implementation of the AltitudeActual object. This file has been
|
||||
# automatically generated by the UAVObjectGenerator.
|
||||
#
|
||||
# @note Object definition file: altitudeactual.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(
|
||||
'Altitude',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Temperature',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Pressure',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class AltitudeActual(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 2251817750
|
||||
NAME = "AltitudeActual"
|
||||
METANAME = "AltitudeActualMeta"
|
||||
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 = AltitudeActual()
|
||||
print (x)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#import pdb ; pdb.run('main()')
|
||||
main()
|
@ -11,6 +11,7 @@ HEADERS += uavobjects_global.h \
|
||||
uavobjectsinit.h \
|
||||
uavobjectsplugin.h \
|
||||
examplesettings.h \
|
||||
altitudeactual.h \
|
||||
exampleobject2.h \
|
||||
exampleobject1.h \
|
||||
gpsobject.h \
|
||||
@ -35,6 +36,7 @@ SOURCES += uavobject.cpp \
|
||||
uavobjectfield.cpp \
|
||||
uavobjectsinit.cpp \
|
||||
uavobjectsplugin.cpp \
|
||||
altitudeactual.cpp \
|
||||
examplesettings.cpp \
|
||||
exampleobject2.cpp \
|
||||
exampleobject1.cpp \
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "actuatorcommand.h"
|
||||
#include "actuatordesired.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "altitudeactual.h"
|
||||
#include "attitudedesired.h"
|
||||
#include "exampleobject1.h"
|
||||
#include "exampleobject2.h"
|
||||
@ -59,6 +60,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
||||
objMngr->registerObject( new ActuatorCommand() );
|
||||
objMngr->registerObject( new ActuatorDesired() );
|
||||
objMngr->registerObject( new ActuatorSettings() );
|
||||
objMngr->registerObject( new AltitudeActual() );
|
||||
objMngr->registerObject( new AttitudeDesired() );
|
||||
objMngr->registerObject( new ExampleObject1() );
|
||||
objMngr->registerObject( new ExampleObject2() );
|
||||
|
10
ground/src/shared/uavobjectdefinition/altitudeactual.xml
Normal file
10
ground/src/shared/uavobjectdefinition/altitudeactual.xml
Normal file
@ -0,0 +1,10 @@
|
||||
<xml>
|
||||
<object name="AltitudeActual" singleinstance="true" settings="false">
|
||||
<field name="Altitude" units="m" type="float" elements="1"/>
|
||||
<field name="Temperature" units="C" type="float" elements="1"/>
|
||||
<field name="Pressure" units="kPa" type="float" elements="1"/>
|
||||
<telemetrygcs acked="true" updatemode="periodic" period="200"/>
|
||||
<telemetryflight acked="true" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="never" period="0"/>
|
||||
</object>
|
||||
</xml>
|
Loading…
x
Reference in New Issue
Block a user