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

OP-165 : Guidance Module

Creating GuidanceModule together with PositionDesired UAVObject (as discussed),
so dschin and me can work on it :-)
Will compile and (on sim_posix) execute, but PID logic is yet untested and preliminary.



git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1722 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
corvus 2010-09-22 22:16:48 +00:00 committed by corvus
parent d9dc37ad33
commit e44045f422
30 changed files with 1843 additions and 12 deletions

View File

@ -188,6 +188,8 @@ SRC += $(OPUAVOBJ)/vtolsettings.c
SRC += $(OPUAVOBJ)/vtolstatus.c
SRC += $(OPUAVOBJ)/mixersettings.c
SRC += $(OPUAVOBJ)/mixerstatus.c
SRC += $(OPUAVOBJ)/guidancesettings.c
SRC += $(OPUAVOBJ)/positiondesired.c
#SRC += $(OPUAVOBJ)/lesstabilizationsettings.c
endif

View File

@ -53,7 +53,7 @@ FLASH_TOOL = OPENOCD
USE_THUMB_MODE = YES
# List of modules to include
MODULES = Telemetry Stabilization/experimental/Stabilization Navigation ManualControl
MODULES = Telemetry Stabilization/experimental/Stabilization ManualControl Guidance
#MODULES = Telemetry GPS ManualControl Actuator Altitude Attitude Stabilization
#MODULES = Telemetry Example
#MODULES = Telemetry MK/MKSerial
@ -164,6 +164,8 @@ SRC += $(OPUAVOBJ)/vtolsettings.c
SRC += $(OPUAVOBJ)/vtolstatus.c
SRC += $(OPUAVOBJ)/mixersettings.c
SRC += $(OPUAVOBJ)/mixerstatus.c
SRC += $(OPUAVOBJ)/guidancesettings.c
SRC += $(OPUAVOBJ)/positiondesired.c
endif
## PIOS Hardware (posix)

View File

@ -0,0 +1,280 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup GuidanceModule Guidance Module
* @brief Guidance PID loops in an airframe type independent manner
* @note This object updates the @ref AttitudeDesired "Attitude Desired" based on the
* PID loops on the craft position, speed and course
* @{
*
* @file guidance.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Attitude guidance 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 "guidance.h"
#include "guidancesettings.h"
#include "attitudedesired.h"
#include "positiondesired.h"
#include "positionactual.h"
#include "attitudeactual.h"
#include "manualcontrolcommand.h"
#include "systemsettings.h"
// Private constants
#define STACK_SIZE configMINIMAL_STACK_SIZE
#define TASK_PRIORITY (tskIDLE_PRIORITY+4)
#define LATERAL_INTEGRAL_LIMIT 0.5
#define COURSE_INTEGRAL_LIMIT 0.5
#define ENERGY_INTEGRAL_LIMIT 0.5
#define SPEED_INTEGRAL_LIMIT 0.5
#define DEG2RAD ( M_PI / 180.0 )
#define GEE 9.81
// Private types
// Private variables
static xTaskHandle taskHandle;
// Private functions
static void guidanceTask(void* parameters);
static float bound(float val, float min, float max);
static float angleDifference(float val);
/**
* Module initialization
*/
int32_t GuidanceInitialize()
{
// Initialize variables
// Start main task
xTaskCreate(guidanceTask, (signed char*)"Guidance", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
return 0;
}
/**
* Module task
*/
static void guidanceTask(void* parameters)
{
GuidanceSettingsData guidanceSettings;
AttitudeDesiredData attitudeDesired;
AttitudeActualData attitudeActual;
PositionActualData positionActual;
PositionDesiredData positionDesired;
ManualControlCommandData manualControl;
SystemSettingsData systemSettings;
portTickType lastSysTime;
// declarations...
float lateralError, lateralErrorLast, lateralDerivative, lateralIntegralLimit, lateralIntegral;
float courseError, courseErrorLast, courseDerivative, courseIntegralLimit, courseIntegral;
float speedError, speedErrorLast, speedDerivative, speedIntegralLimit, speedIntegral;
float energyError, energyErrorLast, energyDerivative, energyIntegralLimit, energyIntegral;
float sinAlpha, cosAlpha;
// Initialize
lateralIntegral = 0.0;
courseIntegral = 0.0;
speedIntegral = 0.0;
energyIntegral = 0.0;
lateralErrorLast = 0.0;
courseErrorLast = 0.0;
speedErrorLast = 0.0;
energyErrorLast = 0.0;
// Main task loop
lastSysTime = xTaskGetTickCount();
while (1)
{
// Read settings and other objects
GuidanceSettingsGet(&guidanceSettings);
SystemSettingsGet(&systemSettings);
ManualControlCommandGet(&manualControl);
PositionDesiredGet(&positionDesired);
PositionActualGet(&positionActual);
AttitudeActualGet(&attitudeActual);
// lateral PID Loop
// error is the distance between the current position and the imaginary line going through PositionDesired.NED
// at PositionDesired.Heading degrees course
sinAlpha = sin(positionDesired.Heading);
cosAlpha = cos(positionDesired.Heading);
lateralError = (
- sinAlpha * ( positionDesired.NED[0] - positionActual.NED[0] )
+ cosAlpha * ( positionDesired.NED[1] - positionActual.NED[1] )
) / ( sinAlpha*sinAlpha + cosAlpha*cosAlpha );
lateralDerivative = lateralError - lateralErrorLast;
lateralErrorLast = lateralError;
lateralIntegralLimit = LATERAL_INTEGRAL_LIMIT / guidanceSettings.LateralKi;
lateralIntegral = bound(lateralIntegral+lateralError*guidanceSettings.UpdatePeriod,
-lateralIntegralLimit,lateralIntegralLimit);
attitudeDesired.Yaw = angleDifference( bound( ( guidanceSettings.LateralKp*lateralError +
guidanceSettings.LateralKi*lateralIntegral +
guidanceSettings.LateralKd*lateralDerivative
),-90,90
) + positionDesired.Heading
);
if (attitudeDesired.Yaw<0) attitudeDesired.Yaw+=360;
// course PID Loop
// very straighforward
courseError = angleDifference( attitudeDesired.Yaw - positionActual.Heading );
courseDerivative = courseError - courseErrorLast;
courseErrorLast = courseError;
courseIntegralLimit = COURSE_INTEGRAL_LIMIT / guidanceSettings.CourseKi;
courseIntegral = bound(courseIntegral+courseError*guidanceSettings.UpdatePeriod,
-courseIntegralLimit,courseIntegralLimit);
attitudeDesired.Roll = bound( ( guidanceSettings.CourseKp*courseError +
guidanceSettings.CourseKi*courseIntegral +
guidanceSettings.CourseKd*courseDerivative
),-guidanceSettings.RollMax,guidanceSettings.RollMax
);
// speed PID loop
// since desired value is given as groundspeed, but our limits affect airspeed, translation is necessary
// we assume a constant (wind) offset between the two
// (this is not completely correct since there might be an air pressure dependent linear relationship, too
// but this puts only a linear multiplication factor on our error)
speedError = bound(
positionDesired.Groundspeed +
(positionActual.Airspeed-positionActual.Groundspeed)
,guidanceSettings.SpeedMin,guidanceSettings.SpeedMax
) - positionActual.Airspeed;
speedDerivative = speedError - speedErrorLast;
speedErrorLast = speedError;
speedIntegralLimit = SPEED_INTEGRAL_LIMIT / guidanceSettings.SpeedKi;
speedIntegral = bound(speedIntegral+speedError*guidanceSettings.UpdatePeriod,
-speedIntegralLimit,speedIntegralLimit);
attitudeDesired.Pitch = bound( -( guidanceSettings.SpeedKp*speedError +
guidanceSettings.SpeedKi*speedIntegral +
guidanceSettings.SpeedKd*speedDerivative
),guidanceSettings.PitchMin,guidanceSettings.PitchMax
);
// energy PID loop - flight energy = mass_factor*(speed^2+g*altitude) - using mass_factor=1
// the desired energy is calculated from the desired airspeed (which has been calculated above)
// and the desired altitude
energyError = (
( speedError + positionActual.Airspeed ) * ( speedError + positionActual.Airspeed )
+ GEE * -positionDesired.NED[3]
) - (
positionActual.Airspeed * positionActual.Airspeed + positionActual.Climbrate * positionActual.Climbrate
+ GEE * -positionActual.NED[3]
);
energyDerivative = energyError - energyErrorLast;
energyErrorLast = energyError;
energyIntegralLimit = SPEED_INTEGRAL_LIMIT / guidanceSettings.EnergyKi;
energyIntegral = bound(energyIntegral+energyError*guidanceSettings.UpdatePeriod,
-energyIntegralLimit,energyIntegralLimit);
attitudeDesired.Throttle = bound( ( guidanceSettings.EnergyKp*energyError +
guidanceSettings.EnergyKi*energyIntegral +
guidanceSettings.EnergyKd*energyDerivative
),guidanceSettings.ThrottleMin,guidanceSettings.ThrottleMax
);
// adapt roll in case of negative pitch demand
if (attitudeDesired.Pitch < attitudeActual.Pitch) {
if (attitudeDesired.Pitch <= attitudeActual.Pitch - guidanceSettings.PitchRollEpsilon) {
// in case of heavy push, reverse roll
attitudeDesired.Roll = -attitudeDesired.Roll;
} else {
// otherwise linear interpolation between Roll and -Roll
attitudeDesired.Roll -= 2.0 * attitudeDesired.Roll *
( attitudeActual.Pitch - attitudeDesired.Pitch )
/ guidanceSettings.PitchRollEpsilon;
}
}
// Write actuator desired (if not in manual mode)
if ( manualControl.FlightMode == MANUALCONTROLCOMMAND_FLIGHTMODE_AUTO )
{
AttitudeDesiredSet(&attitudeDesired);
}
else
{
lateralIntegral = 0.0;
courseIntegral = 0.0;
speedIntegral = 0.0;
energyIntegral = 0.0;
lateralErrorLast = 0.0;
courseErrorLast = 0.0;
speedErrorLast = 0.0;
energyErrorLast = 0.0;
}
// Clear alarms
AlarmsClear(SYSTEMALARMS_ALARM_GUIDANCE);
// Wait until next update
vTaskDelayUntil(&lastSysTime, guidanceSettings.UpdatePeriod / portTICK_RATE_MS );
}
}
/**
* 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;
}
/**
* Fix result of angular differences
*/
static float angleDifference(float val)
{
while ( val < -180.0 )
{
val += 360.0;
}
while ( val > 180.0 )
{
val -= 360.0;
}
return val;
}
/**
* @}
* @}
*/

View File

@ -0,0 +1,43 @@
/**
******************************************************************************
* @addtogroup OpenPilotModules OpenPilot Modules
* @{
* @addtogroup GuidanceModule Guidance Module
* @brief Guidance PID loops in an airframe type independent manner
* @note This object updates the @ref AttitudeDesired "Attitude Desired" based on the
* PID loops on the craft position, speed and course
* @{
*
* @file guidance.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief guidance 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 GUIDANCE_H
#define GUIDANCE_H
int32_t GuidanceInitialize();
#endif // GUIDANCE_H
/**
* @}
* @}
*/

View File

@ -0,0 +1,132 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup GuidanceSettings GuidanceSettings
* @brief PID settings used by the Guidance module to combine the @ref PositionActual and @ref PositionDesired to compute @ref AttitudeDesired
*
* Autogenerated files and functions for GuidanceSettings Object
* @{
*
* @file guidancesettings.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GuidanceSettings object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: guidancesettings.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 "guidancesettings.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 GuidanceSettingsInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(GUIDANCESETTINGS_OBJID, GUIDANCESETTINGS_NAME, GUIDANCESETTINGS_METANAME, 0,
GUIDANCESETTINGS_ISSINGLEINST, GUIDANCESETTINGS_ISSETTINGS, GUIDANCESETTINGS_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)
{
GuidanceSettingsData data;
UAVObjMetadata metadata;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(GuidanceSettingsData));
data.UpdatePeriod = 10;
data.RollMax = 35;
data.PitchMax = 35;
data.PitchMin = -35;
data.PitchRollEpsilon = 10;
data.ThrottleMax = 1;
data.ThrottleMin = 0;
data.SpeedMax = 100;
data.SpeedMin = 10;
data.SpeedKp = 0.04;
data.SpeedKi = 4e-06;
data.SpeedKd = 0.01;
data.EnergyKp = 0.04;
data.EnergyKi = 4e-06;
data.EnergyKd = 0.01;
data.LateralKp = 0.04;
data.LateralKi = 4e-06;
data.LateralKd = 0.01;
data.CourseKp = 0.04;
data.CourseKi = 4e-06;
data.CourseKd = 0.01;
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 GuidanceSettingsHandle()
{
return handle;
}
/**
* @}
*/

View File

@ -0,0 +1,131 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup GuidanceSettings GuidanceSettings
* @brief PID settings used by the Guidance module to combine the @ref PositionActual and @ref PositionDesired to compute @ref AttitudeDesired
*
* Autogenerated files and functions for GuidanceSettings Object
* @{
*
* @file guidancesettings.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the GuidanceSettings object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: guidancesettings.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 GUIDANCESETTINGS_H
#define GUIDANCESETTINGS_H
// Object constants
#define GUIDANCESETTINGS_OBJID 2093064904U
#define GUIDANCESETTINGS_NAME "GuidanceSettings"
#define GUIDANCESETTINGS_METANAME "GuidanceSettingsMeta"
#define GUIDANCESETTINGS_ISSINGLEINST 1
#define GUIDANCESETTINGS_ISSETTINGS 1
#define GUIDANCESETTINGS_NUMBYTES sizeof(GuidanceSettingsData)
// Object access macros
/**
* @function GuidanceSettingsGet(dataOut)
* @brief Populate a GuidanceSettingsData object
* @param[out] dataOut
*/
#define GuidanceSettingsGet(dataOut) UAVObjGetData(GuidanceSettingsHandle(), dataOut)
#define GuidanceSettingsSet(dataIn) UAVObjSetData(GuidanceSettingsHandle(), dataIn)
#define GuidanceSettingsInstGet(instId, dataOut) UAVObjGetInstanceData(GuidanceSettingsHandle(), instId, dataOut)
#define GuidanceSettingsInstSet(instId, dataIn) UAVObjSetInstanceData(GuidanceSettingsHandle(), instId, dataIn)
#define GuidanceSettingsConnectQueue(queue) UAVObjConnectQueue(GuidanceSettingsHandle(), queue, EV_MASK_ALL_UPDATES)
#define GuidanceSettingsConnectCallback(cb) UAVObjConnectCallback(GuidanceSettingsHandle(), cb, EV_MASK_ALL_UPDATES)
#define GuidanceSettingsCreateInstance() UAVObjCreateInstance(GuidanceSettingsHandle())
#define GuidanceSettingsRequestUpdate() UAVObjRequestUpdate(GuidanceSettingsHandle())
#define GuidanceSettingsRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(GuidanceSettingsHandle(), instId)
#define GuidanceSettingsUpdated() UAVObjUpdated(GuidanceSettingsHandle())
#define GuidanceSettingsInstUpdated(instId) UAVObjUpdated(GuidanceSettingsHandle(), instId)
#define GuidanceSettingsGetMetadata(dataOut) UAVObjGetMetadata(GuidanceSettingsHandle(), dataOut)
#define GuidanceSettingsSetMetadata(dataIn) UAVObjSetMetadata(GuidanceSettingsHandle(), dataIn)
#define GuidanceSettingsReadOnly(dataIn) UAVObjReadOnly(GuidanceSettingsHandle())
// Object data
typedef struct {
uint16_t UpdatePeriod;
float RollMax;
float PitchMax;
float PitchMin;
float PitchRollEpsilon;
float ThrottleMax;
float ThrottleMin;
float SpeedMax;
float SpeedMin;
float SpeedKp;
float SpeedKi;
float SpeedKd;
float EnergyKp;
float EnergyKi;
float EnergyKd;
float LateralKp;
float LateralKi;
float LateralKd;
float CourseKp;
float CourseKi;
float CourseKd;
} __attribute__((packed)) GuidanceSettingsData;
// Field information
// Field UpdatePeriod information
// Field RollMax information
// Field PitchMax information
// Field PitchMin information
// Field PitchRollEpsilon information
// Field ThrottleMax information
// Field ThrottleMin information
// Field SpeedMax information
// Field SpeedMin information
// Field SpeedKp information
// Field SpeedKi information
// Field SpeedKd information
// Field EnergyKp information
// Field EnergyKi information
// Field EnergyKd information
// Field LateralKp information
// Field LateralKi information
// Field LateralKd information
// Field CourseKp information
// Field CourseKi information
// Field CourseKd information
// Generic interface functions
int32_t GuidanceSettingsInitialize();
UAVObjHandle GuidanceSettingsHandle();
#endif // GUIDANCESETTINGS_H
/**
* @}
* @}
*/

View File

@ -41,7 +41,7 @@
#define POSITIONACTUAL_H
// Object constants
#define POSITIONACTUAL_OBJID 2253458392U
#define POSITIONACTUAL_OBJID 3881752126U
#define POSITIONACTUAL_NAME "PositionActual"
#define POSITIONACTUAL_METANAME "PositionActualMeta"
#define POSITIONACTUAL_ISSINGLEINST 1
@ -78,6 +78,8 @@ typedef struct {
float GeoidSeparation;
float Heading;
float Groundspeed;
float Airspeed;
float Climbrate;
int8_t Satellites;
float PDOP;
float HDOP;
@ -97,6 +99,8 @@ typedef enum { POSITIONACTUAL_STATUS_NOGPS=0, POSITIONACTUAL_STATUS_NOFIX=1, POS
// Field GeoidSeparation information
// Field Heading information
// Field Groundspeed information
// Field Airspeed information
// Field Climbrate information
// Field Satellites information
// Field PDOP information
// Field HDOP information

View File

@ -0,0 +1,97 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup PositionDesired PositionDesired
* @brief The desired position that @ref GuidanceModule will try and achieve if FlightMode is Auto. Comes from @ref PathPlannerModule.
*
* Autogenerated files and functions for PositionDesired Object
* @{
*
* @file positiondesired.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the PositionDesired object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: positiondesired.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 POSITIONDESIRED_H
#define POSITIONDESIRED_H
// Object constants
#define POSITIONDESIRED_OBJID 2182398544U
#define POSITIONDESIRED_NAME "PositionDesired"
#define POSITIONDESIRED_METANAME "PositionDesiredMeta"
#define POSITIONDESIRED_ISSINGLEINST 1
#define POSITIONDESIRED_ISSETTINGS 0
#define POSITIONDESIRED_NUMBYTES sizeof(PositionDesiredData)
// Object access macros
/**
* @function PositionDesiredGet(dataOut)
* @brief Populate a PositionDesiredData object
* @param[out] dataOut
*/
#define PositionDesiredGet(dataOut) UAVObjGetData(PositionDesiredHandle(), dataOut)
#define PositionDesiredSet(dataIn) UAVObjSetData(PositionDesiredHandle(), dataIn)
#define PositionDesiredInstGet(instId, dataOut) UAVObjGetInstanceData(PositionDesiredHandle(), instId, dataOut)
#define PositionDesiredInstSet(instId, dataIn) UAVObjSetInstanceData(PositionDesiredHandle(), instId, dataIn)
#define PositionDesiredConnectQueue(queue) UAVObjConnectQueue(PositionDesiredHandle(), queue, EV_MASK_ALL_UPDATES)
#define PositionDesiredConnectCallback(cb) UAVObjConnectCallback(PositionDesiredHandle(), cb, EV_MASK_ALL_UPDATES)
#define PositionDesiredCreateInstance() UAVObjCreateInstance(PositionDesiredHandle())
#define PositionDesiredRequestUpdate() UAVObjRequestUpdate(PositionDesiredHandle())
#define PositionDesiredRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(PositionDesiredHandle(), instId)
#define PositionDesiredUpdated() UAVObjUpdated(PositionDesiredHandle())
#define PositionDesiredInstUpdated(instId) UAVObjUpdated(PositionDesiredHandle(), instId)
#define PositionDesiredGetMetadata(dataOut) UAVObjGetMetadata(PositionDesiredHandle(), dataOut)
#define PositionDesiredSetMetadata(dataIn) UAVObjSetMetadata(PositionDesiredHandle(), dataIn)
#define PositionDesiredReadOnly(dataIn) UAVObjReadOnly(PositionDesiredHandle())
// Object data
typedef struct {
float NED[3];
float Heading;
float Groundspeed;
} __attribute__((packed)) PositionDesiredData;
// Field information
// Field NED information
/* Number of elements for field NED */
#define POSITIONDESIRED_NED_NUMELEM 3
// Field Heading information
// Field Groundspeed information
// Generic interface functions
int32_t PositionDesiredInitialize();
UAVObjHandle PositionDesiredHandle();
#endif // POSITIONDESIRED_H
/**
* @}
* @}
*/

View File

@ -71,7 +71,7 @@
// Object data
typedef struct {
uint8_t Alarm[10];
uint8_t Alarm[11];
} __attribute__((packed)) SystemAlarmsData;
@ -80,9 +80,9 @@ typedef struct {
/* Enumeration options for field Alarm */
typedef enum { SYSTEMALARMS_ALARM_OK=0, SYSTEMALARMS_ALARM_WARNING=1, SYSTEMALARMS_ALARM_ERROR=2, SYSTEMALARMS_ALARM_CRITICAL=3 } SystemAlarmsAlarmOptions;
/* Array element names for field Alarm */
typedef enum { SYSTEMALARMS_ALARM_OUTOFMEMORY=0, SYSTEMALARMS_ALARM_STACKOVERFLOW=1, SYSTEMALARMS_ALARM_CPUOVERLOAD=2, SYSTEMALARMS_ALARM_EVENTSYSTEM=3, SYSTEMALARMS_ALARM_SDCARD=4, SYSTEMALARMS_ALARM_TELEMETRY=5, SYSTEMALARMS_ALARM_MANUALCONTROL=6, SYSTEMALARMS_ALARM_ACTUATOR=7, SYSTEMALARMS_ALARM_STABILIZATION=8, SYSTEMALARMS_ALARM_AHRSCOMMS=9 } SystemAlarmsAlarmElem;
typedef enum { SYSTEMALARMS_ALARM_OUTOFMEMORY=0, SYSTEMALARMS_ALARM_STACKOVERFLOW=1, SYSTEMALARMS_ALARM_CPUOVERLOAD=2, SYSTEMALARMS_ALARM_EVENTSYSTEM=3, SYSTEMALARMS_ALARM_SDCARD=4, SYSTEMALARMS_ALARM_TELEMETRY=5, SYSTEMALARMS_ALARM_MANUALCONTROL=6, SYSTEMALARMS_ALARM_ACTUATOR=7, SYSTEMALARMS_ALARM_STABILIZATION=8, SYSTEMALARMS_ALARM_GUIDANCE=9, SYSTEMALARMS_ALARM_AHRSCOMMS=10 } SystemAlarmsAlarmElem;
/* Number of elements for field Alarm */
#define SYSTEMALARMS_ALARM_NUMELEM 10
#define SYSTEMALARMS_ALARM_NUMELEM 11
// Generic interface functions

View File

@ -0,0 +1,111 @@
/**
******************************************************************************
* @addtogroup UAVObjects OpenPilot UAVObjects
* @{
* @addtogroup PositionDesired PositionDesired
* @brief The desired position that @ref GuidanceModule will try and achieve if FlightMode is Auto. Comes from @ref PathPlannerModule.
*
* Autogenerated files and functions for PositionDesired Object
* @{
*
* @file positiondesired.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the PositionDesired object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: positiondesired.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 "positiondesired.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 PositionDesiredInitialize()
{
// Register object with the object manager
handle = UAVObjRegister(POSITIONDESIRED_OBJID, POSITIONDESIRED_NAME, POSITIONDESIRED_METANAME, 0,
POSITIONDESIRED_ISSINGLEINST, POSITIONDESIRED_ISSETTINGS, POSITIONDESIRED_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)
{
PositionDesiredData data;
UAVObjMetadata metadata;
// Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(PositionDesiredData));
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_NEVER;
metadata.loggingUpdatePeriod = 0;
UAVObjSetMetadata(obj, &metadata);
}
/**
* Get object handle
*/
UAVObjHandle PositionDesiredHandle()
{
return handle;
}
/**
* @}
*/

View File

@ -49,6 +49,7 @@
#include "gpsposition.h"
#include "gpssatellites.h"
#include "gpstime.h"
#include "guidancesettings.h"
#include "homelocation.h"
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
@ -58,6 +59,7 @@
#include "navigationsettings.h"
#include "objectpersistence.h"
#include "positionactual.h"
#include "positiondesired.h"
#include "stabilizationsettings.h"
#include "systemalarms.h"
#include "systemsettings.h"
@ -94,6 +96,7 @@ void UAVObjectsInitializeAll()
GPSPositionInitialize();
GPSSatellitesInitialize();
GPSTimeInitialize();
GuidanceSettingsInitialize();
HomeLocationInitialize();
ManualControlCommandInitialize();
ManualControlSettingsInitialize();
@ -103,6 +106,7 @@ void UAVObjectsInitializeAll()
NavigationSettingsInitialize();
ObjectPersistenceInitialize();
PositionActualInitialize();
PositionDesiredInitialize();
StabilizationSettingsInitialize();
SystemAlarmsInitialize();
SystemSettingsInitialize();

View File

@ -0,0 +1,209 @@
/**
******************************************************************************
*
* @file guidancesettings.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: guidancesettings.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 "guidancesettings.h"
#include "uavobjectfield.h"
const QString GuidanceSettings::NAME = QString("GuidanceSettings");
/**
* Constructor
*/
GuidanceSettings::GuidanceSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList UpdatePeriodElemNames;
UpdatePeriodElemNames.append("0");
fields.append( new UAVObjectField(QString("UpdatePeriod"), QString("ms"), UAVObjectField::UINT16, UpdatePeriodElemNames, QStringList()) );
QStringList RollMaxElemNames;
RollMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("RollMax"), QString("degrees"), UAVObjectField::FLOAT32, RollMaxElemNames, QStringList()) );
QStringList PitchMaxElemNames;
PitchMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("PitchMax"), QString("degrees"), UAVObjectField::FLOAT32, PitchMaxElemNames, QStringList()) );
QStringList PitchMinElemNames;
PitchMinElemNames.append("0");
fields.append( new UAVObjectField(QString("PitchMin"), QString("degrees"), UAVObjectField::FLOAT32, PitchMinElemNames, QStringList()) );
QStringList PitchRollEpsilonElemNames;
PitchRollEpsilonElemNames.append("0");
fields.append( new UAVObjectField(QString("PitchRollEpsilon"), QString("degrees"), UAVObjectField::FLOAT32, PitchRollEpsilonElemNames, QStringList()) );
QStringList ThrottleMaxElemNames;
ThrottleMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("ThrottleMax"), QString("%"), UAVObjectField::FLOAT32, ThrottleMaxElemNames, QStringList()) );
QStringList ThrottleMinElemNames;
ThrottleMinElemNames.append("0");
fields.append( new UAVObjectField(QString("ThrottleMin"), QString("%"), UAVObjectField::FLOAT32, ThrottleMinElemNames, QStringList()) );
QStringList SpeedMaxElemNames;
SpeedMaxElemNames.append("0");
fields.append( new UAVObjectField(QString("SpeedMax"), QString("m/s"), UAVObjectField::FLOAT32, SpeedMaxElemNames, QStringList()) );
QStringList SpeedMinElemNames;
SpeedMinElemNames.append("0");
fields.append( new UAVObjectField(QString("SpeedMin"), QString("m/s"), UAVObjectField::FLOAT32, SpeedMinElemNames, QStringList()) );
QStringList SpeedKpElemNames;
SpeedKpElemNames.append("0");
fields.append( new UAVObjectField(QString("SpeedKp"), QString(""), UAVObjectField::FLOAT32, SpeedKpElemNames, QStringList()) );
QStringList SpeedKiElemNames;
SpeedKiElemNames.append("0");
fields.append( new UAVObjectField(QString("SpeedKi"), QString(""), UAVObjectField::FLOAT32, SpeedKiElemNames, QStringList()) );
QStringList SpeedKdElemNames;
SpeedKdElemNames.append("0");
fields.append( new UAVObjectField(QString("SpeedKd"), QString(""), UAVObjectField::FLOAT32, SpeedKdElemNames, QStringList()) );
QStringList EnergyKpElemNames;
EnergyKpElemNames.append("0");
fields.append( new UAVObjectField(QString("EnergyKp"), QString(""), UAVObjectField::FLOAT32, EnergyKpElemNames, QStringList()) );
QStringList EnergyKiElemNames;
EnergyKiElemNames.append("0");
fields.append( new UAVObjectField(QString("EnergyKi"), QString(""), UAVObjectField::FLOAT32, EnergyKiElemNames, QStringList()) );
QStringList EnergyKdElemNames;
EnergyKdElemNames.append("0");
fields.append( new UAVObjectField(QString("EnergyKd"), QString(""), UAVObjectField::FLOAT32, EnergyKdElemNames, QStringList()) );
QStringList LateralKpElemNames;
LateralKpElemNames.append("0");
fields.append( new UAVObjectField(QString("LateralKp"), QString(""), UAVObjectField::FLOAT32, LateralKpElemNames, QStringList()) );
QStringList LateralKiElemNames;
LateralKiElemNames.append("0");
fields.append( new UAVObjectField(QString("LateralKi"), QString(""), UAVObjectField::FLOAT32, LateralKiElemNames, QStringList()) );
QStringList LateralKdElemNames;
LateralKdElemNames.append("0");
fields.append( new UAVObjectField(QString("LateralKd"), QString(""), UAVObjectField::FLOAT32, LateralKdElemNames, QStringList()) );
QStringList CourseKpElemNames;
CourseKpElemNames.append("0");
fields.append( new UAVObjectField(QString("CourseKp"), QString(""), UAVObjectField::FLOAT32, CourseKpElemNames, QStringList()) );
QStringList CourseKiElemNames;
CourseKiElemNames.append("0");
fields.append( new UAVObjectField(QString("CourseKi"), QString(""), UAVObjectField::FLOAT32, CourseKiElemNames, QStringList()) );
QStringList CourseKdElemNames;
CourseKdElemNames.append("0");
fields.append( new UAVObjectField(QString("CourseKd"), QString(""), UAVObjectField::FLOAT32, CourseKdElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
}
/**
* Get the default metadata for this object
*/
UAVObject::Metadata GuidanceSettings::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 GuidanceSettings::setDefaultFieldValues()
{
data.UpdatePeriod = 10;
data.RollMax = 35;
data.PitchMax = 35;
data.PitchMin = -35;
data.PitchRollEpsilon = 10;
data.ThrottleMax = 1;
data.ThrottleMin = 0;
data.SpeedMax = 100;
data.SpeedMin = 10;
data.SpeedKp = 0.04;
data.SpeedKi = 4e-06;
data.SpeedKd = 0.01;
data.EnergyKp = 0.04;
data.EnergyKi = 4e-06;
data.EnergyKd = 0.01;
data.LateralKp = 0.04;
data.LateralKi = 4e-06;
data.LateralKd = 0.01;
data.CourseKp = 0.04;
data.CourseKi = 4e-06;
data.CourseKd = 0.01;
}
/**
* Get the object data fields
*/
GuidanceSettings::DataFields GuidanceSettings::getData()
{
QMutexLocker locker(mutex);
return data;
}
/**
* Set the object data fields
*/
void GuidanceSettings::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* GuidanceSettings::clone(quint32 instID)
{
GuidanceSettings* obj = new GuidanceSettings();
obj->initialize(instID, this->getMetaObject());
return obj;
}
/**
* Static function to retrieve an instance of the object.
*/
GuidanceSettings* GuidanceSettings::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<GuidanceSettings*>(objMngr->getObject(GuidanceSettings::OBJID, instID));
}

View File

@ -0,0 +1,118 @@
/**
******************************************************************************
*
* @file guidancesettings.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: guidancesettings.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 GUIDANCESETTINGS_H
#define GUIDANCESETTINGS_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT GuidanceSettings: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
quint16 UpdatePeriod;
float RollMax;
float PitchMax;
float PitchMin;
float PitchRollEpsilon;
float ThrottleMax;
float ThrottleMin;
float SpeedMax;
float SpeedMin;
float SpeedKp;
float SpeedKi;
float SpeedKd;
float EnergyKp;
float EnergyKi;
float EnergyKd;
float LateralKp;
float LateralKi;
float LateralKd;
float CourseKp;
float CourseKi;
float CourseKd;
} __attribute__((packed)) DataFields;
// Field information
// Field UpdatePeriod information
// Field RollMax information
// Field PitchMax information
// Field PitchMin information
// Field PitchRollEpsilon information
// Field ThrottleMax information
// Field ThrottleMin information
// Field SpeedMax information
// Field SpeedMin information
// Field SpeedKp information
// Field SpeedKi information
// Field SpeedKd information
// Field EnergyKp information
// Field EnergyKi information
// Field EnergyKd information
// Field LateralKp information
// Field LateralKi information
// Field LateralKd information
// Field CourseKp information
// Field CourseKi information
// Field CourseKd information
// Constants
static const quint32 OBJID = 2093064904U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 1;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
GuidanceSettings();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static GuidanceSettings* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
void setDefaultFieldValues();
};
#endif // GUIDANCESETTINGS_H

View File

@ -0,0 +1,286 @@
##
##############################################################################
#
# @file guidancesettings.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the GuidanceSettings object. This file has been
# automatically generated by the UAVObjectGenerator.
#
# @note Object definition file: guidancesettings.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',
'H',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'RollMax',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'PitchMax',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'PitchMin',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'PitchRollEpsilon',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'ThrottleMax',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'ThrottleMin',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'SpeedMax',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'SpeedMin',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'SpeedKp',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'SpeedKi',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'SpeedKd',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'EnergyKp',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'EnergyKi',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'EnergyKd',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'LateralKp',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'LateralKi',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'LateralKd',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'CourseKp',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'CourseKi',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'CourseKd',
'f',
1,
[
'0',
],
{
}
),
]
class GuidanceSettings(uavobject.UAVObject):
## Object constants
OBJID = 2093064904
NAME = "GuidanceSettings"
METANAME = "GuidanceSettingsMeta"
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 = GuidanceSettings()
print (x)
if __name__ == "__main__":
#import pdb ; pdb.run('main()')
main()

View File

@ -68,6 +68,12 @@ PositionActual::PositionActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS,
QStringList GroundspeedElemNames;
GroundspeedElemNames.append("0");
fields.append( new UAVObjectField(QString("Groundspeed"), QString("m/s"), UAVObjectField::FLOAT32, GroundspeedElemNames, QStringList()) );
QStringList AirspeedElemNames;
AirspeedElemNames.append("0");
fields.append( new UAVObjectField(QString("Airspeed"), QString("m/s"), UAVObjectField::FLOAT32, AirspeedElemNames, QStringList()) );
QStringList ClimbrateElemNames;
ClimbrateElemNames.append("0");
fields.append( new UAVObjectField(QString("Climbrate"), QString("m/s"), UAVObjectField::FLOAT32, ClimbrateElemNames, QStringList()) );
QStringList SatellitesElemNames;
SatellitesElemNames.append("0");
fields.append( new UAVObjectField(QString("Satellites"), QString(""), UAVObjectField::INT8, SatellitesElemNames, QStringList()) );

View File

@ -50,6 +50,8 @@ public:
float GeoidSeparation;
float Heading;
float Groundspeed;
float Airspeed;
float Climbrate;
qint8 Satellites;
float PDOP;
float HDOP;
@ -69,6 +71,8 @@ public:
// Field GeoidSeparation information
// Field Heading information
// Field Groundspeed information
// Field Airspeed information
// Field Climbrate information
// Field Satellites information
// Field PDOP information
// Field HDOP information
@ -82,7 +86,7 @@ public:
// Constants
static const quint32 OBJID = 2253458392U;
static const quint32 OBJID = 3881752126U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;

View File

@ -111,6 +111,26 @@ _fields = [ \
{
}
),
uavobject.UAVObjectField(
'Airspeed',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'Climbrate',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'Satellites',
'b',
@ -180,7 +200,7 @@ _fields = [ \
class PositionActual(uavobject.UAVObject):
## Object constants
OBJID = 2253458392
OBJID = 3881752126
NAME = "PositionActual"
METANAME = "PositionActualMeta"
ISSINGLEINST = 1

View File

@ -0,0 +1,136 @@
/**
******************************************************************************
*
* @file positiondesired.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: positiondesired.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 "positiondesired.h"
#include "uavobjectfield.h"
const QString PositionDesired::NAME = QString("PositionDesired");
/**
* Constructor
*/
PositionDesired::PositionDesired(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{
// Create fields
QList<UAVObjectField*> fields;
QStringList NEDElemNames;
NEDElemNames.append("0");
NEDElemNames.append("1");
NEDElemNames.append("2");
fields.append( new UAVObjectField(QString("NED"), QString("m"), UAVObjectField::FLOAT32, NEDElemNames, QStringList()) );
QStringList HeadingElemNames;
HeadingElemNames.append("0");
fields.append( new UAVObjectField(QString("Heading"), QString("degrees"), UAVObjectField::FLOAT32, HeadingElemNames, QStringList()) );
QStringList GroundspeedElemNames;
GroundspeedElemNames.append("0");
fields.append( new UAVObjectField(QString("Groundspeed"), QString("m/s"), UAVObjectField::FLOAT32, GroundspeedElemNames, QStringList()) );
// Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES);
// Set the default field values
setDefaultFieldValues();
}
/**
* Get the default metadata for this object
*/
UAVObject::Metadata PositionDesired::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_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 PositionDesired::setDefaultFieldValues()
{
}
/**
* Get the object data fields
*/
PositionDesired::DataFields PositionDesired::getData()
{
QMutexLocker locker(mutex);
return data;
}
/**
* Set the object data fields
*/
void PositionDesired::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* PositionDesired::clone(quint32 instID)
{
PositionDesired* obj = new PositionDesired();
obj->initialize(instID, this->getMetaObject());
return obj;
}
/**
* Static function to retrieve an instance of the object.
*/
PositionDesired* PositionDesired::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{
return dynamic_cast<PositionDesired*>(objMngr->getObject(PositionDesired::OBJID, instID));
}

View File

@ -0,0 +1,84 @@
/**
******************************************************************************
*
* @file positiondesired.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: positiondesired.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 POSITIONDESIRED_H
#define POSITIONDESIRED_H
#include "uavdataobject.h"
#include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT PositionDesired: public UAVDataObject
{
Q_OBJECT
public:
// Field structure
typedef struct {
float NED[3];
float Heading;
float Groundspeed;
} __attribute__((packed)) DataFields;
// Field information
// Field NED information
/* Number of elements for field NED */
static const quint32 NED_NUMELEM = 3;
// Field Heading information
// Field Groundspeed information
// Constants
static const quint32 OBJID = 2182398544U;
static const QString NAME;
static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields);
// Functions
PositionDesired();
DataFields getData();
void setData(const DataFields& data);
Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID);
static PositionDesired* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private:
DataFields data;
void setDefaultFieldValues();
};
#endif // POSITIONDESIRED_H

View File

@ -0,0 +1,108 @@
##
##############################################################################
#
# @file positiondesired.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the PositionDesired object. This file has been
# automatically generated by the UAVObjectGenerator.
#
# @note Object definition file: positiondesired.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(
'NED',
'f',
3,
[
'0',
'1',
'2',
],
{
}
),
uavobject.UAVObjectField(
'Heading',
'f',
1,
[
'0',
],
{
}
),
uavobject.UAVObjectField(
'Groundspeed',
'f',
1,
[
'0',
],
{
}
),
]
class PositionDesired(uavobject.UAVObject):
## Object constants
OBJID = 2182398544
NAME = "PositionDesired"
METANAME = "PositionDesiredMeta"
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 = PositionDesired()
print (x)
if __name__ == "__main__":
#import pdb ; pdb.run('main()')
main()

View File

@ -52,6 +52,7 @@ SystemAlarms::SystemAlarms(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAM
AlarmElemNames.append("ManualControl");
AlarmElemNames.append("Actuator");
AlarmElemNames.append("Stabilization");
AlarmElemNames.append("Guidance");
AlarmElemNames.append("AHRSComms");
QStringList AlarmEnumOptions;
AlarmEnumOptions.append("OK");

View File

@ -43,7 +43,7 @@ class UAVOBJECTS_EXPORT SystemAlarms: public UAVDataObject
public:
// Field structure
typedef struct {
quint8 Alarm[10];
quint8 Alarm[11];
} __attribute__((packed)) DataFields;
@ -52,9 +52,9 @@ public:
/* Enumeration options for field Alarm */
typedef enum { ALARM_OK=0, ALARM_WARNING=1, ALARM_ERROR=2, ALARM_CRITICAL=3 } AlarmOptions;
/* Array element names for field Alarm */
typedef enum { ALARM_OUTOFMEMORY=0, ALARM_STACKOVERFLOW=1, ALARM_CPUOVERLOAD=2, ALARM_EVENTSYSTEM=3, ALARM_SDCARD=4, ALARM_TELEMETRY=5, ALARM_MANUALCONTROL=6, ALARM_ACTUATOR=7, ALARM_STABILIZATION=8, ALARM_AHRSCOMMS=9 } AlarmElem;
typedef enum { ALARM_OUTOFMEMORY=0, ALARM_STACKOVERFLOW=1, ALARM_CPUOVERLOAD=2, ALARM_EVENTSYSTEM=3, ALARM_SDCARD=4, ALARM_TELEMETRY=5, ALARM_MANUALCONTROL=6, ALARM_ACTUATOR=7, ALARM_STABILIZATION=8, ALARM_GUIDANCE=9, ALARM_AHRSCOMMS=10 } AlarmElem;
/* Number of elements for field Alarm */
static const quint32 ALARM_NUMELEM = 10;
static const quint32 ALARM_NUMELEM = 11;
// Constants

View File

@ -40,7 +40,7 @@ _fields = [ \
uavobject.UAVObjectField(
'Alarm',
'b',
10,
11,
[
'OutOfMemory',
'StackOverflow',
@ -51,6 +51,7 @@ _fields = [ \
'ManualControl',
'Actuator',
'Stabilization',
'Guidance',
'AHRSComms',
],
{

View File

@ -40,6 +40,8 @@ HEADERS += uavobjects_global.h \
gpsposition.h \
gpstime.h \
gpssatellites.h \
guidancesettings.h \
positiondesired.h \
positionactual.h \
flightbatterystate.h \
homelocation.h \
@ -84,6 +86,8 @@ SOURCES += uavobject.cpp \
gpsposition.cpp \
gpstime.cpp \
gpssatellites.cpp \
guidancesettings.cpp \
positiondesired.cpp \
positionactual.cpp \
flightbatterystate.cpp \
homelocation.cpp \

View File

@ -51,6 +51,7 @@
#include "gpsposition.h"
#include "gpssatellites.h"
#include "gpstime.h"
#include "guidancesettings.h"
#include "homelocation.h"
#include "manualcontrolcommand.h"
#include "manualcontrolsettings.h"
@ -60,6 +61,7 @@
#include "navigationsettings.h"
#include "objectpersistence.h"
#include "positionactual.h"
#include "positiondesired.h"
#include "stabilizationsettings.h"
#include "systemalarms.h"
#include "systemsettings.h"
@ -96,6 +98,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new GPSPosition() );
objMngr->registerObject( new GPSSatellites() );
objMngr->registerObject( new GPSTime() );
objMngr->registerObject( new GuidanceSettings() );
objMngr->registerObject( new HomeLocation() );
objMngr->registerObject( new ManualControlCommand() );
objMngr->registerObject( new ManualControlSettings() );
@ -105,6 +108,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new NavigationSettings() );
objMngr->registerObject( new ObjectPersistence() );
objMngr->registerObject( new PositionActual() );
objMngr->registerObject( new PositionDesired() );
objMngr->registerObject( new StabilizationSettings() );
objMngr->registerObject( new SystemAlarms() );
objMngr->registerObject( new SystemSettings() );

View File

@ -0,0 +1,30 @@
<xml>
<object name="GuidanceSettings" singleinstance="true" settings="true">
<description>PID settings used by the Guidance module to combine the @ref PositionActual and @ref PositionDesired to compute @ref AttitudeDesired</description>
<field name="UpdatePeriod" units="ms" type="uint16" elements="1" defaultvalue="10"/>
<field name="RollMax" units="degrees" type="float" elements="1" defaultvalue="35"/>
<field name="PitchMax" units="degrees" type="float" elements="1" defaultvalue="35"/>
<field name="PitchMin" units="degrees" type="float" elements="1" defaultvalue="-35"/>
<field name="PitchRollEpsilon" units="degrees" type="float" elements="1" defaultvalue="10"/>
<field name="ThrottleMax" units="%" type="float" elements="1" defaultvalue="1.0"/>
<field name="ThrottleMin" units="%" type="float" elements="1" defaultvalue="0"/>
<field name="SpeedMax" units="m/s" type="float" elements="1" defaultvalue="100"/>
<field name="SpeedMin" units="m/s" type="float" elements="1" defaultvalue="10"/>
<field name="SpeedKp" units="" type="float" elements="1" defaultvalue="0.04"/>
<field name="SpeedKi" units="" type="float" elements="1" defaultvalue="0.000004"/>
<field name="SpeedKd" units="" type="float" elements="1" defaultvalue="0.01"/>
<field name="EnergyKp" units="" type="float" elements="1" defaultvalue="0.04"/>
<field name="EnergyKi" units="" type="float" elements="1" defaultvalue="0.000004"/>
<field name="EnergyKd" units="" type="float" elements="1" defaultvalue="0.01"/>
<field name="LateralKp" units="" type="float" elements="1" defaultvalue="0.04"/>
<field name="LateralKi" units="" type="float" elements="1" defaultvalue="0.000004"/>
<field name="LateralKd" units="" type="float" elements="1" defaultvalue="0.01"/>
<field name="CourseKp" units="" type="float" elements="1" defaultvalue="0.04"/>
<field name="CourseKi" units="" type="float" elements="1" defaultvalue="0.000004"/>
<field name="CourseKd" units="" type="float" elements="1" defaultvalue="0.01"/>
<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>

View File

@ -8,6 +8,8 @@
<field name="GeoidSeparation" units="meters" type="float" elements="1"/>
<field name="Heading" units="degrees" type="float" elements="1"/>
<field name="Groundspeed" units="m/s" type="float" elements="1"/>
<field name="Airspeed" units="m/s" type="float" elements="1"/>
<field name="Climbrate" units="m/s" type="float" elements="1"/>
<field name="Satellites" units="" type="int8" elements="1"/>
<field name="PDOP" units="" type="float" elements="1"/>
<field name="HDOP" units="" type="float" elements="1"/>

View File

@ -0,0 +1,12 @@
<xml>
<object name="PositionDesired" singleinstance="true" settings="false">
<description>The desired position that @ref GuidanceModule will try and achieve if FlightMode is Auto. Comes from @ref PathPlannerModule.</description>
<field name="NED" units="m" type="float" elements="3"/>
<field name="Heading" units="degrees" type="float" elements="1"/>
<field name="Groundspeed" units="m/s" 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="never" period="0"/>
</object>
</xml>

View File

@ -2,7 +2,7 @@
<object name="SystemAlarms" singleinstance="true" settings="false">
<description>Alarms from OpenPilot to indicate failure conditions or warnings. Set by various modules.</description>
<field name="Alarm" units="" type="enum" options="OK,Warning,Error,Critical"
elementnames="OutOfMemory,StackOverflow,CPUOverload,EventSystem,SDCard,Telemetry,ManualControl,Actuator,Stabilization,AHRSComms"/>
elementnames="OutOfMemory,StackOverflow,CPUOverload,EventSystem,SDCard,Telemetry,ManualControl,Actuator,Stabilization,Guidance,AHRSComms"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
<telemetryflight acked="true" updatemode="periodic" period="4000"/>