1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-02-20 10:54:14 +01:00

Flight: VTOLStatus object that returns the thrusts on all the engines

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1588 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
peabody124 2010-09-12 02:54:34 +00:00 committed by peabody124
parent bba3b0c64a
commit dceb20b16d
12 changed files with 713 additions and 32 deletions

View File

@ -178,6 +178,7 @@ SRC += $(OPUAVOBJ)/attituderaw.c
SRC += $(OPUAVOBJ)/homelocation.c
SRC += $(OPUAVOBJ)/attitudesettings.c
SRC += $(OPUAVOBJ)/vtolsettings.c
SRC += $(OPUAVOBJ)/vtolstatus.c
endif
## PIOS Hardware (STM32F10x)

View File

@ -34,6 +34,7 @@
#include "actuator.h"
#include "actuatorsettings.h"
#include "vtolsettings.h"
#include "vtolstatus.h"
#include "systemsettings.h"
#include "actuatordesired.h"
#include "actuatorcommand.h"
@ -60,6 +61,8 @@ static int32_t mixerCCPM( ActuatorSettingsData* settings, const ActuatorDesiredD
static int16_t scaleChannel(float value, int16_t max, int16_t min, int16_t neutral);
static void setFailsafe();
static float bound(float val, float min, float max);
/**
* @brief Module initialization
* @return 0
@ -278,7 +281,11 @@ static int32_t mixerFixedWingElevon(const ActuatorSettingsData* settings, const
static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDesiredData* desired, ActuatorCommandData* cmd)
{
VTOLSettingsData vtolSettings;
VTOLStatusData vtolStatus;
VTOLSettingsGet(&vtolSettings);
VTOLStatusGet(&vtolStatus);
const int vtolMin = 0;
if(((settings->VTOLMotorN != ACTUATORSETTINGS_VTOLMOTORN_NONE) +
(settings->VTOLMotorNE != ACTUATORSETTINGS_VTOLMOTORS_NONE) +
@ -292,77 +299,86 @@ static int32_t mixerVTOL(const ActuatorSettingsData* settings, const ActuatorDes
}
if(settings->VTOLMotorN != ACTUATORSETTINGS_VTOLMOTORN_NONE) {
cmd->Channel[settings->VTOLMotorN] = scaleChannel(desired->Throttle * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_THROTTLE] +
desired->Pitch * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_ROLL] +
desired->Yaw * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_YAW],
vtolStatus.MotorN = bound(desired->Throttle * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_THROTTLE] +
desired->Pitch * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_ROLL] +
desired->Yaw * vtolSettings.MotorN[VTOLSETTINGS_MOTORN_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorN] = scaleChannel(vtolStatus.MotorN,
settings->ChannelMax[settings->VTOLMotorN],
settings->ChannelMin[settings->VTOLMotorN],
settings->ChannelNeutral[settings->VTOLMotorN]);
}
if(settings->VTOLMotorNE != ACTUATORSETTINGS_VTOLMOTORNE_NONE) {
cmd->Channel[settings->VTOLMotorNE] = scaleChannel(desired->Throttle * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_THROTTLE] +
desired->Pitch * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_PITCH] +
desired->Roll * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_ROLL] +
desired->Yaw * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_YAW],
vtolStatus.MotorNE = bound(desired->Throttle * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_THROTTLE] +
desired->Pitch * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_PITCH] +
desired->Roll * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_ROLL] +
desired->Yaw * vtolSettings.MotorNE[VTOLSETTINGS_MOTORNE_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorNE] = scaleChannel(vtolStatus.MotorNE,
settings->ChannelMax[settings->VTOLMotorNE],
settings->ChannelMin[settings->VTOLMotorNE],
settings->ChannelNeutral[settings->VTOLMotorNE]);
}
if(settings->VTOLMotorE != ACTUATORSETTINGS_VTOLMOTORE_NONE) {
cmd->Channel[settings->VTOLMotorE] = scaleChannel(desired->Throttle * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_THROTTLE] +
desired->Pitch * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORE_ROLL] +
desired->Yaw * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_YAW],
vtolStatus.MotorE = bound(desired->Throttle * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_THROTTLE] +
desired->Pitch * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORE_ROLL] +
desired->Yaw * vtolSettings.MotorE[VTOLSETTINGS_MOTORE_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorE] = scaleChannel(vtolStatus.MotorE,
settings->ChannelMax[settings->VTOLMotorE],
settings->ChannelMin[settings->VTOLMotorE],
settings->ChannelNeutral[settings->VTOLMotorE]);
}
if(settings->VTOLMotorSE != ACTUATORSETTINGS_VTOLMOTORSE_NONE) {
cmd->Channel[settings->VTOLMotorSE] = scaleChannel(desired->Throttle * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_THROTTLE] +
desired->Pitch * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORSE_ROLL] +
desired->Yaw * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_YAW],
vtolStatus.MotorSE = bound(desired->Throttle * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_THROTTLE] +
desired->Pitch * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORSE_ROLL] +
desired->Yaw * vtolSettings.MotorSE[VTOLSETTINGS_MOTORSE_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorSE] = scaleChannel(vtolStatus.MotorSE,
settings->ChannelMax[settings->VTOLMotorSE],
settings->ChannelMin[settings->VTOLMotorSE],
settings->ChannelNeutral[settings->VTOLMotorSE]);
}
if(settings->VTOLMotorS != ACTUATORSETTINGS_VTOLMOTORS_NONE) {
cmd->Channel[settings->VTOLMotorS] = scaleChannel(desired->Throttle * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_THROTTLE] +
desired->Pitch * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORS_ROLL] +
desired->Yaw * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_YAW],
vtolStatus.MotorS = bound(desired->Throttle * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_THROTTLE] +
desired->Pitch * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORS_ROLL] +
desired->Yaw * vtolSettings.MotorS[VTOLSETTINGS_MOTORS_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorS] = scaleChannel(vtolStatus.MotorS,
settings->ChannelMax[settings->VTOLMotorS],
settings->ChannelMin[settings->VTOLMotorS],
settings->ChannelNeutral[settings->VTOLMotorS]);
}
if(settings->VTOLMotorSW != ACTUATORSETTINGS_VTOLMOTORSW_NONE) {
cmd->Channel[settings->VTOLMotorSW] = scaleChannel(desired->Throttle * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_THROTTLE] +
desired->Pitch * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORSW_ROLL] +
desired->Yaw * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_YAW],
vtolStatus.MotorSW = bound(desired->Throttle * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_THROTTLE] +
desired->Pitch * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORSW_ROLL] +
desired->Yaw * vtolSettings.MotorSW[VTOLSETTINGS_MOTORSW_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorSW] = scaleChannel(vtolStatus.MotorSW,
settings->ChannelMax[settings->VTOLMotorSW],
settings->ChannelMin[settings->VTOLMotorSW],
settings->ChannelNeutral[settings->VTOLMotorSW]);
}
if(settings->VTOLMotorW != ACTUATORSETTINGS_VTOLMOTORW_NONE) {
cmd->Channel[settings->VTOLMotorW] = scaleChannel(desired->Throttle * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_THROTTLE] +
desired->Pitch * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORW_ROLL] +
desired->Yaw * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_YAW],
vtolStatus.MotorW = bound(desired->Throttle * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_THROTTLE] +
desired->Pitch * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_PITCH] +
desired->Roll * vtolSettings.MotorN[VTOLSETTINGS_MOTORW_ROLL] +
desired->Yaw * vtolSettings.MotorW[VTOLSETTINGS_MOTORW_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorW] = scaleChannel(vtolStatus.MotorW,
settings->ChannelMax[settings->VTOLMotorW],
settings->ChannelMin[settings->VTOLMotorW],
settings->ChannelNeutral[settings->VTOLMotorW]);
}
if(settings->VTOLMotorNW != ACTUATORSETTINGS_VTOLMOTORNW_NONE) {
cmd->Channel[settings->VTOLMotorNW] = scaleChannel(desired->Throttle * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_THROTTLE] +
desired->Pitch * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_PITCH] +
desired->Roll * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_ROLL] +
desired->Yaw * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_YAW],
vtolStatus.MotorNW = bound(desired->Throttle * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_THROTTLE] +
desired->Pitch * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_PITCH] +
desired->Roll * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_ROLL] +
desired->Yaw * vtolSettings.MotorNW[VTOLSETTINGS_MOTORNW_YAW],vtolMin,1);
cmd->Channel[settings->VTOLMotorNW] = scaleChannel(vtolStatus.MotorNW,
settings->ChannelMax[settings->VTOLMotorNW],
settings->ChannelMin[settings->VTOLMotorNW],
settings->ChannelNeutral[settings->VTOLMotorNW]);
}
VTOLStatusSet(&vtolStatus);
return 0;
}
@ -586,6 +602,22 @@ static void setFailsafe()
ActuatorCommandSet(&cmd);
}
/**
* Bound input value between limits
*/
static float bound(float val, float min, float max)
{
if ( val < min )
{
val = min;
}
else if ( val > max )
{
val = max;
}
return val;
}
/**
* @}
* @}

View File

@ -0,0 +1,105 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup VTOLStatus VTOLStatus
* @brief Status for VTOL crafts showing the thrust from each engine
*
* Autogenerated files and functions for VTOLStatus Object
* @{
*
* @file vtolstatus.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the VTOLStatus object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: vtolstatus.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 VTOLSTATUS_H
#define VTOLSTATUS_H
// Object constants
#define VTOLSTATUS_OBJID 957086004U
#define VTOLSTATUS_NAME "VTOLStatus"
#define VTOLSTATUS_METANAME "VTOLStatusMeta"
#define VTOLSTATUS_ISSINGLEINST 1
#define VTOLSTATUS_ISSETTINGS 0
#define VTOLSTATUS_NUMBYTES sizeof(VTOLStatusData)
// Object access macros
/**
* @function VTOLStatusGet(dataOut)
* @brief Populate a VTOLStatusData object
* @param[out] dataOut
*/
#define VTOLStatusGet(dataOut) UAVObjGetData(VTOLStatusHandle(), dataOut)
#define VTOLStatusSet(dataIn) UAVObjSetData(VTOLStatusHandle(), dataIn)
#define VTOLStatusInstGet(instId, dataOut) UAVObjGetInstanceData(VTOLStatusHandle(), instId, dataOut)
#define VTOLStatusInstSet(instId, dataIn) UAVObjSetInstanceData(VTOLStatusHandle(), instId, dataIn)
#define VTOLStatusConnectQueue(queue) UAVObjConnectQueue(VTOLStatusHandle(), queue, EV_MASK_ALL_UPDATES)
#define VTOLStatusConnectCallback(cb) UAVObjConnectCallback(VTOLStatusHandle(), cb, EV_MASK_ALL_UPDATES)
#define VTOLStatusCreateInstance() UAVObjCreateInstance(VTOLStatusHandle())
#define VTOLStatusRequestUpdate() UAVObjRequestUpdate(VTOLStatusHandle())
#define VTOLStatusRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(VTOLStatusHandle(), instId)
#define VTOLStatusUpdated() UAVObjUpdated(VTOLStatusHandle())
#define VTOLStatusInstUpdated(instId) UAVObjUpdated(VTOLStatusHandle(), instId)
#define VTOLStatusGetMetadata(dataOut) UAVObjGetMetadata(VTOLStatusHandle(), dataOut)
#define VTOLStatusSetMetadata(dataIn) UAVObjSetMetadata(VTOLStatusHandle(), dataIn)
#define VTOLStatusReadOnly(dataIn) UAVObjReadOnly(VTOLStatusHandle())
// Object data
typedef struct {
float MotorN;
float MotorNE;
float MotorE;
float MotorSE;
float MotorS;
float MotorSW;
float MotorW;
float MotorNW;
} __attribute__((packed)) VTOLStatusData;
// Field information
// Field MotorN information
// Field MotorNE information
// Field MotorE information
// Field MotorSE information
// Field MotorS information
// Field MotorSW information
// Field MotorW information
// Field MotorNW information
// Generic interface functions
int32_t VTOLStatusInitialize();
UAVObjHandle VTOLStatusHandle();
#endif // VTOLSTATUS_H
/**
* @}
* @}
*/

View File

@ -62,6 +62,7 @@
#include "systemstats.h"
#include "telemetrysettings.h"
#include "vtolsettings.h"
#include "vtolstatus.h"
/**
@ -104,5 +105,6 @@ void UAVObjectsInitializeAll()
SystemStatsInitialize();
TelemetrySettingsInitialize();
VTOLSettingsInitialize();
VTOLStatusInitialize();
}

View File

@ -0,0 +1,111 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup VTOLStatus VTOLStatus
* @brief Status for VTOL crafts showing the thrust from each engine
*
* Autogenerated files and functions for VTOLStatus Object
* @{
*
* @file vtolstatus.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the VTOLStatus object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: vtolstatus.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 "vtolstatus.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 VTOLStatusInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(VTOLSTATUS_OBJID, VTOLSTATUS_NAME, VTOLSTATUS_METANAME, 0,
VTOLSTATUS_ISSINGLEINST, VTOLSTATUS_ISSETTINGS, VTOLSTATUS_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)
{
VTOLStatusData data;
UAVObjMetadata metadata;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(VTOLStatusData));
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 VTOLStatusHandle()
{
return handle;
}
/**
* @}
*/

View File

@ -2856,6 +2856,12 @@
65E8F0EE11EFF25C00BBF654 /* startup_stm32f10x_HD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_HD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_HD.S; sourceTree = SOURCE_ROOT; };
65E8F0F111EFF25C00BBF654 /* startup_stm32f10x_MD.S */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.asm; name = startup_stm32f10x_MD.S; path = ../../PiOS/STM32F10x/startup_stm32f10x_MD.S; sourceTree = SOURCE_ROOT; };
65EF3922123AEED000D1B036 /* vtolsettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = vtolsettings.xml; sourceTree = "<group>"; };
65EF392E123AF96500D1B036 /* vtolstatus.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = vtolstatus.xml; sourceTree = "<group>"; };
65EF392F123AF97D00D1B036 /* attitudesettings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = attitudesettings.c; sourceTree = "<group>"; };
65EF3930123AF97D00D1B036 /* gpssatellites.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gpssatellites.c; sourceTree = "<group>"; };
65EF3931123AF97D00D1B036 /* gpstime.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gpstime.c; sourceTree = "<group>"; };
65EF3932123AF97D00D1B036 /* vtolsettings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vtolsettings.c; sourceTree = "<group>"; };
65EF3933123AF97D00D1B036 /* vtolstatus.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vtolstatus.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
@ -6731,6 +6737,7 @@
65B367FD121C2620003EAD18 /* systemstats.xml */,
65B367FE121C2620003EAD18 /* telemetrysettings.xml */,
65EF3922123AEED000D1B036 /* vtolsettings.xml */,
65EF392E123AF96500D1B036 /* vtolstatus.xml */,
);
path = uavobjectdefinition;
sourceTree = "<group>";
@ -7093,6 +7100,7 @@
65E8EF6E11EEA61E00BBF654 /* UAVObjects */ = {
isa = PBXGroup;
children = (
65EF392F123AF97D00D1B036 /* attitudesettings.c */,
65C259551224BFAF0081B6ED /* ahrscalibration.c */,
65C259561224BFAF0081B6ED /* ahrssettings.c */,
65C259571224BFAF0081B6ED /* baroaltitude.c */,
@ -7115,6 +7123,8 @@
65E8EF7D11EEA61E00BBF654 /* flighttelemetrystats.c */,
65E8EF7E11EEA61E00BBF654 /* gcstelemetrystats.c */,
65C259581224BFAF0081B6ED /* gpsposition.c */,
65EF3930123AF97D00D1B036 /* gpssatellites.c */,
65EF3931123AF97D00D1B036 /* gpstime.c */,
65E8EF8011EEA61E00BBF654 /* inc */,
65E8EF9E11EEA61E00BBF654 /* manualcontrolcommand.c */,
65E8EF9F11EEA61E00BBF654 /* manualcontrolsettings.c */,
@ -7129,6 +7139,8 @@
65E8EFA811EEA61E00BBF654 /* uavobjectsinit.c */,
65E8EFA911EEA61E00BBF654 /* uavobjectsinittemplate.c */,
65E8EFAA11EEA61E00BBF654 /* uavobjecttemplate.c */,
65EF3932123AF97D00D1B036 /* vtolsettings.c */,
65EF3933123AF97D00D1B036 /* vtolstatus.c */,
);
name = UAVObjects;
path = ../../OpenPilot/UAVObjects;

View File

@ -44,6 +44,7 @@ HEADERS += uavobjects_global.h \
flightbatterystate.h \
homelocation.h \
vtolsettings.h \
vtolstatus.h \
attitudesettings.h
SOURCES += uavobject.cpp \
uavmetaobject.cpp \
@ -85,5 +86,6 @@ SOURCES += uavobject.cpp \
flightbatterystate.cpp \
homelocation.cpp \
vtolsettings.cpp \
vtolstatus.cpp \
attitudesettings.cpp
OTHER_FILES += UAVObjects.pluginspec

View File

@ -64,6 +64,7 @@
#include "systemstats.h"
#include "telemetrysettings.h"
#include "vtolsettings.h"
#include "vtolstatus.h"
/**
@ -106,5 +107,6 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new SystemStats() );
objMngr->registerObject( new TelemetrySettings() );
objMngr->registerObject( new VTOLSettings() );
objMngr->registerObject( new VTOLStatus() );
}

View File

@ -0,0 +1,149 @@
/**
******************************************************************************
*
* @file vtolstatus.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: vtolstatus.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 "vtolstatus.h"
#include "uavobjectfield.h"
const QString VTOLStatus::NAME = QString("VTOLStatus");
/**
* Constructor
*/
VTOLStatus::VTOLStatus(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList MotorNElemNames;
MotorNElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorN"), QString(""), UAVObjectField::FLOAT32, MotorNElemNames, QStringList()) );
QStringList MotorNEElemNames;
MotorNEElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorNE"), QString(""), UAVObjectField::FLOAT32, MotorNEElemNames, QStringList()) );
QStringList MotorEElemNames;
MotorEElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorE"), QString(""), UAVObjectField::FLOAT32, MotorEElemNames, QStringList()) );
QStringList MotorSEElemNames;
MotorSEElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorSE"), QString(""), UAVObjectField::FLOAT32, MotorSEElemNames, QStringList()) );
QStringList MotorSElemNames;
MotorSElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorS"), QString(""), UAVObjectField::FLOAT32, MotorSElemNames, QStringList()) );
QStringList MotorSWElemNames;
MotorSWElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorSW"), QString(""), UAVObjectField::FLOAT32, MotorSWElemNames, QStringList()) );
QStringList MotorWElemNames;
MotorWElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorW"), QString(""), UAVObjectField::FLOAT32, MotorWElemNames, QStringList()) );
QStringList MotorNWElemNames;
MotorNWElemNames.append("0");
fields.append( new UAVObjectField(QString("MotorNW"), QString(""), UAVObjectField::FLOAT32, MotorNWElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
}
/**
* Get the default metadata for this object
*/
UAVObject::Metadata VTOLStatus::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 VTOLStatus::setDefaultFieldValues()
{
}
/**
* Get the object data fields
*/
VTOLStatus::DataFields VTOLStatus::getData()
{
QMutexLocker locker(mutex);
return data;
}
/**
* Set the object data fields
*/
void VTOLStatus::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* VTOLStatus::clone(quint32 instID)
{
VTOLStatus* obj = new VTOLStatus();
obj->initialize(instID, this->getMetaObject());
return obj;
}
/**
* Static function to retrieve an instance of the object.
*/
VTOLStatus* VTOLStatus::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<VTOLStatus*>(objMngr->getObject(VTOLStatus::OBJID, instID));
}

View File

@ -0,0 +1,92 @@
/**
******************************************************************************
*
* @file vtolstatus.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: vtolstatus.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 VTOLSTATUS_H
#define VTOLSTATUS_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT VTOLStatus: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
float MotorN;
float MotorNE;
float MotorE;
float MotorSE;
float MotorS;
float MotorSW;
float MotorW;
float MotorNW;
} __attribute__((packed)) DataFields;
// Field information
// Field MotorN information
// Field MotorNE information
// Field MotorE information
// Field MotorSE information
// Field MotorS information
// Field MotorSW information
// Field MotorW information
// Field MotorNW information
// Constants
static const quint32 OBJID = 957086004U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
VTOLStatus();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static VTOLStatus* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
void setDefaultFieldValues();
};
#endif // VTOLSTATUS_H

View File

@ -0,0 +1,156 @@
##
##############################################################################
#
# @file vtolstatus.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the VTOLStatus object. This file has been
# automatically generated by the UAVObjectGenerator.
#
# @note Object definition file: vtolstatus.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(
'MotorN',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorNE',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorE',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorSE',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorS',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorSW',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorW',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MotorNW',
'f',
1,
[
'0',
],
{
}
),
]
class VTOLStatus(uavobject.UAVObject):
## Object constants
OBJID = 957086004
NAME = "VTOLStatus"
METANAME = "VTOLStatusMeta"
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 = VTOLStatus()
print (x)
if __name__ == "__main__":
#import pdb ; pdb.run('main()')
main()

View File

@ -0,0 +1,17 @@
<xml>
<object name="VTOLStatus" singleinstance="true" settings="false">
<description>Status for VTOL crafts showing the thrust from each engine</description>
<field name="MotorN" units="" type="float" elements="1"/>
<field name="MotorNE" units="" type="float" elements="1"/>
<field name="MotorE" units="" type="float" elements="1"/>
<field name="MotorSE" units="" type="float" elements="1"/>
<field name="MotorS" units="" type="float" elements="1"/>
<field name="MotorSW" units="" type="float" elements="1"/>
<field name="MotorW" units="" type="float" elements="1"/>
<field name="MotorNW" units="" type="float" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
<logging updatemode="periodic" period="1000"/>
</object>
</xml>