From d71e9df8c51fa0b6fc05db70f61656e1ae158816 Mon Sep 17 00:00:00 2001 From: peabody124 Date: Mon, 4 Oct 2010 02:01:31 +0000 Subject: [PATCH] Flight/UAVObjects: Add a few files that were missed earlier, and get posix worlking again git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1869 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Makefile.posix | 5 +- .../UAVObjects/inc/lesstabilizationsettings.h | 137 ++++++++++++++++++ .../UAVObjects/lesstabilizationsettings.c | 134 +++++++++++++++++ 3 files changed, 272 insertions(+), 4 deletions(-) create mode 100644 flight/OpenPilot/UAVObjects/inc/lesstabilizationsettings.h create mode 100644 flight/OpenPilot/UAVObjects/lesstabilizationsettings.c diff --git a/flight/OpenPilot/Makefile.posix b/flight/OpenPilot/Makefile.posix index 4b2d8d7a7..d264151a9 100644 --- a/flight/OpenPilot/Makefile.posix +++ b/flight/OpenPilot/Makefile.posix @@ -156,12 +156,9 @@ SRC += $(OPUAVOBJ)/ahrscalibration.c SRC += $(OPUAVOBJ)/ahrssettings.c SRC += $(OPUAVOBJ)/gpstime.c SRC += $(OPUAVOBJ)/gpssatellites.c -SRC += $(OPUAVOBJ)/attitudesettings.c -SRC += $(OPUAVOBJ)/vtolsettings.c -SRC += $(OPUAVOBJ)/vtolstatus.c SRC += $(OPUAVOBJ)/mixersettings.c SRC += $(OPUAVOBJ)/mixerstatus.c -#SRC += $(OPUAVOBJ)/lesstabilizationsettings.c +SRC += $(OPUAVOBJ)/lesstabilizationsettings.c SRC += $(OPUAVOBJ)/positiondesired.c SRC += $(OPUAVOBJ)/velocitydesired.c SRC += $(OPUAVOBJ)/velocityactual.c diff --git a/flight/OpenPilot/UAVObjects/inc/lesstabilizationsettings.h b/flight/OpenPilot/UAVObjects/inc/lesstabilizationsettings.h new file mode 100644 index 000000000..45e121d90 --- /dev/null +++ b/flight/OpenPilot/UAVObjects/inc/lesstabilizationsettings.h @@ -0,0 +1,137 @@ +/** + ****************************************************************************** + * @addtogroup UAVObjects OpenPilot UAVObjects + * @{ + * @addtogroup LesStabilizationSettings LesStabilizationSettings + * @brief PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired + * + * Autogenerated files and functions for LesStabilizationSettings Object + + * @{ + * + * @file lesstabilizationsettings.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the LesStabilizationSettings object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: lesstabilizationsettings.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 LESSTABILIZATIONSETTINGS_H +#define LESSTABILIZATIONSETTINGS_H + +// Object constants +#define LESSTABILIZATIONSETTINGS_OBJID 2839831188U +#define LESSTABILIZATIONSETTINGS_NAME "LesStabilizationSettings" +#define LESSTABILIZATIONSETTINGS_METANAME "LesStabilizationSettingsMeta" +#define LESSTABILIZATIONSETTINGS_ISSINGLEINST 1 +#define LESSTABILIZATIONSETTINGS_ISSETTINGS 1 +#define LESSTABILIZATIONSETTINGS_NUMBYTES sizeof(LesStabilizationSettingsData) + +// Object access macros +/** + * @function LesStabilizationSettingsGet(dataOut) + * @brief Populate a LesStabilizationSettingsData object + * @param[out] dataOut + */ +#define LesStabilizationSettingsGet(dataOut) UAVObjGetData(LesStabilizationSettingsHandle(), dataOut) +#define LesStabilizationSettingsSet(dataIn) UAVObjSetData(LesStabilizationSettingsHandle(), dataIn) +#define LesStabilizationSettingsInstGet(instId, dataOut) UAVObjGetInstanceData(LesStabilizationSettingsHandle(), instId, dataOut) +#define LesStabilizationSettingsInstSet(instId, dataIn) UAVObjSetInstanceData(LesStabilizationSettingsHandle(), instId, dataIn) +#define LesStabilizationSettingsConnectQueue(queue) UAVObjConnectQueue(LesStabilizationSettingsHandle(), queue, EV_MASK_ALL_UPDATES) +#define LesStabilizationSettingsConnectCallback(cb) UAVObjConnectCallback(LesStabilizationSettingsHandle(), cb, EV_MASK_ALL_UPDATES) +#define LesStabilizationSettingsCreateInstance() UAVObjCreateInstance(LesStabilizationSettingsHandle()) +#define LesStabilizationSettingsRequestUpdate() UAVObjRequestUpdate(LesStabilizationSettingsHandle()) +#define LesStabilizationSettingsRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(LesStabilizationSettingsHandle(), instId) +#define LesStabilizationSettingsUpdated() UAVObjUpdated(LesStabilizationSettingsHandle()) +#define LesStabilizationSettingsInstUpdated(instId) UAVObjUpdated(LesStabilizationSettingsHandle(), instId) +#define LesStabilizationSettingsGetMetadata(dataOut) UAVObjGetMetadata(LesStabilizationSettingsHandle(), dataOut) +#define LesStabilizationSettingsSetMetadata(dataIn) UAVObjSetMetadata(LesStabilizationSettingsHandle(), dataIn) +#define LesStabilizationSettingsReadOnly(dataIn) UAVObjReadOnly(LesStabilizationSettingsHandle()) + +// Object data +typedef struct { + uint8_t UpdatePeriod; + uint8_t RollMax; + uint8_t PitchMax; + uint8_t YawMax; + uint8_t YawMode; + float ManualYawRate; + float MaximumRate[3]; + float RollRateP; + float PitchRateP; + float YawRatePI[3]; + float RollPI[3]; + float PitchPI[3]; + float YawPI[3]; + +} __attribute__((packed)) LesStabilizationSettingsData; + +// Field information +// Field UpdatePeriod information +// Field RollMax information +// Field PitchMax information +// Field YawMax information +// Field YawMode information +/* Enumeration options for field YawMode */ +typedef enum { LESSTABILIZATIONSETTINGS_YAWMODE_RATE=0, LESSTABILIZATIONSETTINGS_YAWMODE_HEADING=1 } LesStabilizationSettingsYawModeOptions; +// Field ManualYawRate information +// Field MaximumRate information +/* Array element names for field MaximumRate */ +typedef enum { LESSTABILIZATIONSETTINGS_MAXIMUMRATE_ROLL=0, LESSTABILIZATIONSETTINGS_MAXIMUMRATE_PITCH=1, LESSTABILIZATIONSETTINGS_MAXIMUMRATE_YAW=2 } LesStabilizationSettingsMaximumRateElem; +/* Number of elements for field MaximumRate */ +#define LESSTABILIZATIONSETTINGS_MAXIMUMRATE_NUMELEM 3 +// Field RollRateP information +// Field PitchRateP information +// Field YawRatePI information +/* Array element names for field YawRatePI */ +typedef enum { LESSTABILIZATIONSETTINGS_YAWRATEPI_KP=0, LESSTABILIZATIONSETTINGS_YAWRATEPI_KI=1, LESSTABILIZATIONSETTINGS_YAWRATEPI_ILIMIT=2 } LesStabilizationSettingsYawRatePIElem; +/* Number of elements for field YawRatePI */ +#define LESSTABILIZATIONSETTINGS_YAWRATEPI_NUMELEM 3 +// Field RollPI information +/* Array element names for field RollPI */ +typedef enum { LESSTABILIZATIONSETTINGS_ROLLPI_KP=0, LESSTABILIZATIONSETTINGS_ROLLPI_KI=1, LESSTABILIZATIONSETTINGS_ROLLPI_ILIMIT=2 } LesStabilizationSettingsRollPIElem; +/* Number of elements for field RollPI */ +#define LESSTABILIZATIONSETTINGS_ROLLPI_NUMELEM 3 +// Field PitchPI information +/* Array element names for field PitchPI */ +typedef enum { LESSTABILIZATIONSETTINGS_PITCHPI_KP=0, LESSTABILIZATIONSETTINGS_PITCHPI_KI=1, LESSTABILIZATIONSETTINGS_PITCHPI_ILIMIT=2 } LesStabilizationSettingsPitchPIElem; +/* Number of elements for field PitchPI */ +#define LESSTABILIZATIONSETTINGS_PITCHPI_NUMELEM 3 +// Field YawPI information +/* Array element names for field YawPI */ +typedef enum { LESSTABILIZATIONSETTINGS_YAWPI_KP=0, LESSTABILIZATIONSETTINGS_YAWPI_KI=1, LESSTABILIZATIONSETTINGS_YAWPI_ILIMIT=2 } LesStabilizationSettingsYawPIElem; +/* Number of elements for field YawPI */ +#define LESSTABILIZATIONSETTINGS_YAWPI_NUMELEM 3 + + +// Generic interface functions +int32_t LesStabilizationSettingsInitialize(); +UAVObjHandle LesStabilizationSettingsHandle(); + +#endif // LESSTABILIZATIONSETTINGS_H + +/** + * @} + * @} + */ diff --git a/flight/OpenPilot/UAVObjects/lesstabilizationsettings.c b/flight/OpenPilot/UAVObjects/lesstabilizationsettings.c new file mode 100644 index 000000000..acedd5f2a --- /dev/null +++ b/flight/OpenPilot/UAVObjects/lesstabilizationsettings.c @@ -0,0 +1,134 @@ +/** + ****************************************************************************** + * @addtogroup UAVObjects OpenPilot UAVObjects + * @{ + * @addtogroup LesStabilizationSettings LesStabilizationSettings + * @brief PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired + * + * Autogenerated files and functions for LesStabilizationSettings Object + * @{ + * + * @file lesstabilizationsettings.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Implementation of the LesStabilizationSettings object. This file has been + * automatically generated by the UAVObjectGenerator. + * + * @note Object definition file: lesstabilizationsettings.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 "lesstabilizationsettings.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 LesStabilizationSettingsInitialize() +{ + // Register object with the object manager + handle = UAVObjRegister(LESSTABILIZATIONSETTINGS_OBJID, LESSTABILIZATIONSETTINGS_NAME, LESSTABILIZATIONSETTINGS_METANAME, 0, + LESSTABILIZATIONSETTINGS_ISSINGLEINST, LESSTABILIZATIONSETTINGS_ISSETTINGS, LESSTABILIZATIONSETTINGS_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) +{ + LesStabilizationSettingsData data; + UAVObjMetadata metadata; + + // Initialize object fields to their default values + UAVObjGetInstanceData(obj, instId, &data); + memset(&data, 0, sizeof(LesStabilizationSettingsData)); + data.UpdatePeriod = 10; + data.RollMax = 35; + data.PitchMax = 35; + data.YawMax = 35; + data.YawMode = 0; + data.ManualYawRate = 200; + data.MaximumRate[0] = 300; + data.MaximumRate[1] = 300; + data.MaximumRate[2] = 300; + data.RollRateP = 0.0015; + data.PitchRateP = 0.0015; + data.YawRatePI[0] = 0.003; + data.YawRatePI[1] = 0.003; + data.YawRatePI[2] = 0.003; + data.RollPI[0] = 0; + data.RollPI[1] = 0; + data.RollPI[2] = 0; + data.PitchPI[0] = 0; + data.PitchPI[1] = 0; + data.PitchPI[2] = 0; + data.YawPI[0] = 0; + data.YawPI[1] = 0; + data.YawPI[2] = 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 LesStabilizationSettingsHandle() +{ + return handle; +} + +/** + * @} + */ +