1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

New stabilization module based on PI-P algorithm used in FlightOS

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1864 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
les 2010-10-03 20:39:23 +00:00 committed by les
parent dcef777ab0
commit 05a85c8c95
9 changed files with 902 additions and 2 deletions

View File

@ -0,0 +1,43 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup StabilizationModule Stabilization Module
* @brief Stabilization PID loops in an airframe type independent manner
* @note This object updates the @ref ActuatorDesired "Actuator Desired" based on the
* PID loops on the @ref AttitudeDesired "Attitude Desired" and @ref AttitudeActual "Attitude Actual"
* @{
*
* @file stabilization.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Attitude stabilization module.
*
* @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 STABILIZATION_H
#define STABILIZATION_H
int32_t StabilizationInitialize();
#endif // STABILIZATION_H
/**
* @}
* @}
*/

View File

@ -0,0 +1,281 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup StabilizationModule Stabilization Module
* @brief Stabilization PID loops in an airframe type independent manner
* @note This object updates the @ref ActuatorDesired "Actuator Desired" based on the
* PID loops on the @ref AttitudeDesired "Attitude Desired" and @ref AttitudeActual "Attitude Actual"
* @{
*
* @file stabilization.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Attitude stabilization module.
*
* @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 "stabilization.h"
#include "lesstabilizationsettings.h"
#include "actuatordesired.h"
#include "attitudedesired.h"
#include "attitudeactual.h"
#include "attituderaw.h"
#include "manualcontrolcommand.h"
#include "systemsettings.h"
#include "ahrssettings.h"
// Private constants
#define MAX_QUEUE_SIZE 2
#define STACK_SIZE configMINIMAL_STACK_SIZE
#define TASK_PRIORITY (tskIDLE_PRIORITY+4)
#define FAILSAFE_TIMEOUT_MS 100
enum {PID_RATE_ROLL, PID_RATE_PITCH, PID_RATE_YAW, PID_ROLL, PID_PITCH, PID_YAW, PID_MAX};
enum {ROLL,PITCH,YAW,MAX_AXES};
// Private types
typedef struct {
float p;
float i;
float d;
float iLim;
float iAccumulator;
float lastErr;
} pid_type;
// Private variables
static xTaskHandle taskHandle;
static LesStabilizationSettingsData settings;
static xQueueHandle queue;
float dT = 1;
pid_type pids[PID_MAX];
// Private functions
static void stabilizationTask(void* parameters);
static float ApplyPid(pid_type * pid, const float desired, const float actual, const bool angular);
static float bound(float val);
static void ZeroPids(void);
static void SettingsUpdatedCb(UAVObjEvent * ev);
/**
* Module initialization
*/
int32_t StabilizationInitialize()
{
// Initialize variables
// Create object queue
queue = xQueueCreate(MAX_QUEUE_SIZE, sizeof(UAVObjEvent));
// Listen for updates.
AttitudeActualConnectQueue(queue);
AttitudeRawConnectQueue(queue);
LesStabilizationSettingsConnectCallback(SettingsUpdatedCb);
SettingsUpdatedCb(LesStabilizationSettingsHandle());
// Start main task
xTaskCreate(stabilizationTask, (signed char*)"Stabilization", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
return 0;
}
/**
* Module task
*/
static void stabilizationTask(void* parameters)
{
portTickType lastSysTime;
portTickType thisSysTime;
UAVObjEvent ev;
ActuatorDesiredData actuatorDesired;
AttitudeDesiredData attitudeDesired;
AttitudeActualData attitudeActual;
AttitudeRawData attitudeRaw;
SystemSettingsData systemSettings;
ManualControlCommandData manualControl;
// Main task loop
lastSysTime = xTaskGetTickCount();
ZeroPids();
while(1) {
// Wait until the ActuatorDesired object is updated, if a timeout then go to failsafe
if ( xQueueReceive(queue, &ev, FAILSAFE_TIMEOUT_MS / portTICK_RATE_MS) != pdTRUE )
{
AlarmsSet(SYSTEMALARMS_ALARM_STABILIZATION,SYSTEMALARMS_ALARM_WARNING);
}
// Check how long since last update
thisSysTime = xTaskGetTickCount();
if(thisSysTime > lastSysTime) // reuse dt in case of wraparound
dT = (thisSysTime - lastSysTime) / portTICK_RATE_MS / 1000.0f;
lastSysTime = thisSysTime;
ManualControlCommandGet(&manualControl);
AttitudeDesiredGet(&attitudeDesired);
AttitudeActualGet(&attitudeActual);
AttitudeRawGet(&attitudeRaw);
SystemSettingsGet(&systemSettings);
float rates[MAX_AXES]= {0,0,0};
rates[ROLL] = ApplyPid(&pids[PID_ROLL], attitudeDesired.Roll, attitudeActual.Roll ,false);
rates[PITCH] = ApplyPid(&pids[PID_PITCH], attitudeDesired.Pitch, attitudeActual.Pitch,false);
if(settings.YawMode == LESSTABILIZATIONSETTINGS_YAWMODE_RATE) { // rate stabilization on yaw
rates[YAW] = manualControl.Yaw * settings.ManualYawRate;
}else{
rates[YAW] = ApplyPid(&pids[PID_YAW], attitudeDesired.Yaw, attitudeActual.Yaw,true);
}
for(int ct=0; ct< MAX_AXES; ct++)
{
if(fabs(rates[ct]) > settings.MaximumRate[ct])
{
if(rates[ct] > 0)
{
rates[ct] = settings.MaximumRate[ct];
}else
{
rates[ct] = -settings.MaximumRate[ct];
}
}
}
float commands[MAX_AXES];
commands[ROLL] = ApplyPid(&pids[PID_RATE_ROLL], attitudeRaw.gyros_filtered[ROLL], rates[ROLL],false);
commands[PITCH] = ApplyPid(&pids[PID_RATE_PITCH], attitudeRaw.gyros_filtered[PITCH], rates[PITCH],false);
commands[YAW] = ApplyPid(&pids[PID_RATE_YAW], attitudeRaw.gyros_filtered[YAW], rates[YAW],false);
// On fixed wing we don't try to stabilizew yaw
if ( systemSettings.AirframeType < SYSTEMSETTINGS_AIRFRAMETYPE_VTOL)
{
commands[YAW] = -manualControl.Yaw;
}
actuatorDesired.Pitch = bound(-commands[PITCH]);
actuatorDesired.Roll = bound(-commands[ROLL]);
actuatorDesired.Yaw = bound(-commands[YAW]);
// Setup throttle
actuatorDesired.Throttle = attitudeDesired.Throttle;
// Save dT
actuatorDesired.UpdateTime = dT * 1000;
// Write actuator desired (if not in manual mode)
if ( manualControl.FlightMode != MANUALCONTROLCOMMAND_FLIGHTMODE_MANUAL )
{
ActuatorDesiredSet(&actuatorDesired);
}
else
{
ZeroPids();
}
// Clear alarms
AlarmsClear(SYSTEMALARMS_ALARM_STABILIZATION);
}
}
float ApplyPid(pid_type * pid, const float desired, const float actual, const bool angular)
{
float err = desired - actual;
if(angular) //take shortest route to desired position
{
if(err > 180)
{
err -= 360;
}
if(err < -180)
{
err += 360;
}
}
float diff = (err - pid->lastErr);
pid->lastErr = err;
pid->iAccumulator += err * pid->i * dT;
if(fabs(pid->iAccumulator) > pid->iLim) {
if(pid->iAccumulator >0) {
pid->iAccumulator = pid->iLim;
} else {
pid->iAccumulator = -pid->iLim;
}
}
return ((err * pid->p) + pid->iAccumulator + (diff * pid->d / dT));
}
static void ZeroPids(void)
{
for(int ct = 0; ct < PID_MAX; ct++) {
pids[ct].iAccumulator = 0;
pids[ct].lastErr = 0;
}
}
/**
* Bound input value between limits
*/
static float bound(float val)
{
if(val < -1) {
val = -1;
} else if(val > 1) {
val = 1;
}
return val;
}
static void SettingsUpdatedCb(UAVObjEvent * ev)
{
memset(pids,0,sizeof (pid_type) * PID_MAX);
LesStabilizationSettingsGet(&settings);
pids[PID_RATE_ROLL].p = settings.RollRateP;
pids[PID_RATE_PITCH].p = settings.PitchRateP;
pids[PID_RATE_YAW].p = settings.YawRatePI[LESSTABILIZATIONSETTINGS_YAWRATEPI_KP];
pids[PID_RATE_YAW].i = settings.YawRatePI[LESSTABILIZATIONSETTINGS_YAWRATEPI_KI];
pids[PID_RATE_YAW].iLim = settings.YawRatePI[LESSTABILIZATIONSETTINGS_YAWRATEPI_ILIMIT];
float * data = settings.RollPI;
for(int pid=PID_ROLL; pid < PID_MAX; pid++)
{
pids[pid].p = *data++;
pids[pid].i = *data++;
pids[pid].iLim = *data++;
}
}
/**
* @}
* @}
*/

View File

@ -49,6 +49,7 @@
#include "gpstime.h"
#include "guidancesettings.h"
#include "homelocation.h"
#include "lesstabilizationsettings.h"
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
#include "mixersettings.h"
@ -92,6 +93,7 @@ void UAVObjectsInitializeAll()
GPSTimeInitialize();
GuidanceSettingsInitialize();
HomeLocationInitialize();
LesStabilizationSettingsInitialize();
ManualControlCommandInitialize();
ManualControlSettingsInitialize();
MixerSettingsInitialize();

View File

@ -0,0 +1,200 @@
/**
******************************************************************************
*
* @file lesstabilizationsettings.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: lesstabilizationsettings.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 "lesstabilizationsettings.h"
#include "uavobjectfield.h"
const QString LesStabilizationSettings::NAME = QString("LesStabilizationSettings");
/**
* Constructor
*/
LesStabilizationSettings::LesStabilizationSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList UpdatePeriodElemNames;
UpdatePeriodElemNames.append("0");
fields.append( new UAVObjectField(QString("UpdatePeriod"), QString("ms"), UAVObjectField::UINT8, UpdatePeriodElemNames, QStringList()) );
QStringList RollMaxElemNames;
RollMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("RollMax"), QString("degrees"), UAVObjectField::UINT8, RollMaxElemNames, QStringList()) );
QStringList PitchMaxElemNames;
PitchMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("PitchMax"), QString("degrees"), UAVObjectField::UINT8, PitchMaxElemNames, QStringList()) );
QStringList YawMaxElemNames;
YawMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("YawMax"), QString("degrees"), UAVObjectField::UINT8, YawMaxElemNames, QStringList()) );
QStringList YawModeElemNames;
YawModeElemNames.append("0");
QStringList YawModeEnumOptions;
YawModeEnumOptions.append("rate");
YawModeEnumOptions.append("heading");
fields.append( new UAVObjectField(QString("YawMode"), QString(""), UAVObjectField::ENUM, YawModeElemNames, YawModeEnumOptions) );
QStringList ManualYawRateElemNames;
ManualYawRateElemNames.append("0");
fields.append( new UAVObjectField(QString("ManualYawRate"), QString("Degrees/sec"), UAVObjectField::FLOAT32, ManualYawRateElemNames, QStringList()) );
QStringList MaximumRateElemNames;
MaximumRateElemNames.append("Roll");
MaximumRateElemNames.append("Pitch");
MaximumRateElemNames.append("Yaw");
fields.append( new UAVObjectField(QString("MaximumRate"), QString("Degrees/sec"), UAVObjectField::FLOAT32, MaximumRateElemNames, QStringList()) );
QStringList RollRatePElemNames;
RollRatePElemNames.append("0");
fields.append( new UAVObjectField(QString("RollRateP"), QString(""), UAVObjectField::FLOAT32, RollRatePElemNames, QStringList()) );
QStringList PitchRatePElemNames;
PitchRatePElemNames.append("0");
fields.append( new UAVObjectField(QString("PitchRateP"), QString(""), UAVObjectField::FLOAT32, PitchRatePElemNames, QStringList()) );
QStringList YawRatePIElemNames;
YawRatePIElemNames.append("Kp");
YawRatePIElemNames.append("Ki");
YawRatePIElemNames.append("ILimit");
fields.append( new UAVObjectField(QString("YawRatePI"), QString(""), UAVObjectField::FLOAT32, YawRatePIElemNames, QStringList()) );
QStringList RollPIElemNames;
RollPIElemNames.append("Kp");
RollPIElemNames.append("Ki");
RollPIElemNames.append("ILimit");
fields.append( new UAVObjectField(QString("RollPI"), QString(""), UAVObjectField::FLOAT32, RollPIElemNames, QStringList()) );
QStringList PitchPIElemNames;
PitchPIElemNames.append("Kp");
PitchPIElemNames.append("Ki");
PitchPIElemNames.append("ILimit");
fields.append( new UAVObjectField(QString("PitchPI"), QString(""), UAVObjectField::FLOAT32, PitchPIElemNames, QStringList()) );
QStringList YawPIElemNames;
YawPIElemNames.append("Kp");
YawPIElemNames.append("Ki");
YawPIElemNames.append("ILimit");
fields.append( new UAVObjectField(QString("YawPI"), QString(""), UAVObjectField::FLOAT32, YawPIElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
}
/**
* Get the default metadata for this object
*/
UAVObject::Metadata LesStabilizationSettings::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 LesStabilizationSettings::setDefaultFieldValues()
{
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;
}
/**
* Get the object data fields
*/
LesStabilizationSettings::DataFields LesStabilizationSettings::getData()
{
QMutexLocker locker(mutex);
return data;
}
/**
* Set the object data fields
*/
void LesStabilizationSettings::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* LesStabilizationSettings::clone(quint32 instID)
{
LesStabilizationSettings* obj = new LesStabilizationSettings();
obj->initialize(instID, this->getMetaObject());
return obj;
}
/**
* Static function to retrieve an instance of the object.
*/
LesStabilizationSettings* LesStabilizationSettings::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<LesStabilizationSettings*>(objMngr->getObject(LesStabilizationSettings::OBJID, instID));
}

View File

@ -0,0 +1,124 @@
/**
******************************************************************************
*
* @file lesstabilizationsettings.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: lesstabilizationsettings.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 LESSTABILIZATIONSETTINGS_H
#define LESSTABILIZATIONSETTINGS_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT LesStabilizationSettings: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
quint8 UpdatePeriod;
quint8 RollMax;
quint8 PitchMax;
quint8 YawMax;
quint8 YawMode;
float ManualYawRate;
float MaximumRate[3];
float RollRateP;
float PitchRateP;
float YawRatePI[3];
float RollPI[3];
float PitchPI[3];
float YawPI[3];
} __attribute__((packed)) DataFields;
// Field information
// Field UpdatePeriod information
// Field RollMax information
// Field PitchMax information
// Field YawMax information
// Field YawMode information
/* Enumeration options for field YawMode */
typedef enum { YAWMODE_RATE=0, YAWMODE_HEADING=1 } YawModeOptions;
// Field ManualYawRate information
// Field MaximumRate information
/* Array element names for field MaximumRate */
typedef enum { MAXIMUMRATE_ROLL=0, MAXIMUMRATE_PITCH=1, MAXIMUMRATE_YAW=2 } MaximumRateElem;
/* Number of elements for field MaximumRate */
static const quint32 MAXIMUMRATE_NUMELEM = 3;
// Field RollRateP information
// Field PitchRateP information
// Field YawRatePI information
/* Array element names for field YawRatePI */
typedef enum { YAWRATEPI_KP=0, YAWRATEPI_KI=1, YAWRATEPI_ILIMIT=2 } YawRatePIElem;
/* Number of elements for field YawRatePI */
static const quint32 YAWRATEPI_NUMELEM = 3;
// Field RollPI information
/* Array element names for field RollPI */
typedef enum { ROLLPI_KP=0, ROLLPI_KI=1, ROLLPI_ILIMIT=2 } RollPIElem;
/* Number of elements for field RollPI */
static const quint32 ROLLPI_NUMELEM = 3;
// Field PitchPI information
/* Array element names for field PitchPI */
typedef enum { PITCHPI_KP=0, PITCHPI_KI=1, PITCHPI_ILIMIT=2 } PitchPIElem;
/* Number of elements for field PitchPI */
static const quint32 PITCHPI_NUMELEM = 3;
// Field YawPI information
/* Array element names for field YawPI */
typedef enum { YAWPI_KP=0, YAWPI_KI=1, YAWPI_ILIMIT=2 } YawPIElem;
/* Number of elements for field YawPI */
static const quint32 YAWPI_NUMELEM = 3;
// Constants
static const quint32 OBJID = 2839831188U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 1;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
LesStabilizationSettings();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static LesStabilizationSettings* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
void setDefaultFieldValues();
};
#endif // LESSTABILIZATIONSETTINGS_H

View File

@ -0,0 +1,218 @@
##
##############################################################################
#
# @file lesstabilizationsettings.py
# @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
#
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(
'UpdatePeriod',
'B',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'RollMax',
'B',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'PitchMax',
'B',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'YawMax',
'B',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'YawMode',
'b',
1,
[
'0',
],
{
'0' : 'rate',
'1' : 'heading',
}
),
uavobject.UAVObjectField(
'ManualYawRate',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'MaximumRate',
'f',
3,
[
'Roll',
'Pitch',
'Yaw',
],
{
}
),
uavobject.UAVObjectField(
'RollRateP',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'PitchRateP',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'YawRatePI',
'f',
3,
[
'Kp',
'Ki',
'ILimit',
],
{
}
),
uavobject.UAVObjectField(
'RollPI',
'f',
3,
[
'Kp',
'Ki',
'ILimit',
],
{
}
),
uavobject.UAVObjectField(
'PitchPI',
'f',
3,
[
'Kp',
'Ki',
'ILimit',
],
{
}
),
uavobject.UAVObjectField(
'YawPI',
'f',
3,
[
'Kp',
'Ki',
'ILimit',
],
{
}
),
]
class LesStabilizationSettings(uavobject.UAVObject):
## Object constants
OBJID = 2839831188
NAME = "LesStabilizationSettings"
METANAME = "LesStabilizationSettingsMeta"
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 = LesStabilizationSettings()
print (x)
if __name__ == "__main__":
#import pdb ; pdb.run('main()')
main()

View File

@ -40,12 +40,15 @@ HEADERS += uavobjects_global.h \
positionactual.h \
flightbatterystate.h \
homelocation.h \
vtolsettings.h \
mixersettings.h \
mixerstatus.h \
velocitydesired.h \
velocityactual.h \
guidancesettings.h \
positiondesired.h
positiondesired.h \
attitudesettings.h \
lesstabilizationsettings.h
SOURCES += uavobject.cpp \
uavmetaobject.cpp \
@ -83,10 +86,13 @@ SOURCES += uavobject.cpp \
positionactual.cpp \
flightbatterystate.cpp \
homelocation.cpp \
vtolsettings.cpp \
mixersettings.cpp \
mixerstatus.cpp \
velocitydesired.cpp \
velocityactual.cpp \
guidancesettings.cpp \
positiondesired.cpp
positiondesired.cpp \
attitudesettings.cpp \
lesstabilizationsettings.cpp
OTHER_FILES += UAVObjects.pluginspec

View File

@ -51,6 +51,7 @@
#include "gpstime.h"
#include "guidancesettings.h"
#include "homelocation.h"
#include "lesstabilizationsettings.h"
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
#include "mixersettings.h"
@ -94,6 +95,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new GPSTime() );
objMngr->registerObject( new GuidanceSettings() );
objMngr->registerObject( new HomeLocation() );
objMngr->registerObject( new LesStabilizationSettings() );
objMngr->registerObject( new ManualControlCommand() );
objMngr->registerObject( new ManualControlSettings() );
objMngr->registerObject( new MixerSettings() );

View File

@ -0,0 +1,24 @@
<xml>
<object name="LesStabilizationSettings" singleinstance="true" settings="true">
<description>PID settings used by the Stabilization module to combine the @ref AttitudeActual and @ref AttitudeDesired to compute @ref ActuatorDesired</description>
<field name="UpdatePeriod" units="ms" type="uint8" elements="1" defaultvalue="10"/>
<field name="RollMax" units="degrees" type="uint8" elements="1" defaultvalue="35"/>
<field name="PitchMax" units="degrees" type="uint8" elements="1" defaultvalue="35"/>
<field name="YawMax" units="degrees" type="uint8" elements="1" defaultvalue="35"/>
<field name="YawMode" units="" type="enum" elements="1" options="rate,heading" defaultvalue="rate"/>
<field name="ManualYawRate" units="Degrees/sec" type="float" elements="1" defaultvalue="200"/>
<field name="MaximumRate" units="Degrees/sec" type="float" elements="3" elementnames="Roll,Pitch,Yaw" defaultvalue="300"/>
<field name="RollRateP" units="" type="float" elements="1" defaultvalue="0.0015"/>
<field name="PitchRateP" units="" type="float" elements="1" defaultvalue="0.0015"/>
<field name="YawRatePI" units="" type="float" elements="2" elementnames="Kp,Ki,ILimit" defaultvalue="0.003"/>
<field name="RollPI" units="" type="float" elements="4" elementnames="Kp,Ki,ILimit" defaultvalue="0"/>
<field name="PitchPI" units="" type="float" elements="4" elementnames="Kp,Ki,ILimit" defaultvalue="0"/>
<field name="YawPI" units="" type="float" elements="4" elementnames="Kp,Ki,ILimit" 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>