mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
Flight/Guidance: Initial template for guidance module
Flight: Create PositionDesired (the active waypoint) UAVObject and make the FlightSituationActual no update since it not used. Flight: New velocity desired object that passes information between the look computing the desired velocity and the PID loop to get it (updated at different rates) UAVObjects/PositionActual: Remove unused GPS fields UAVObjects/PositionActual VelocityActual: Split the velocity into a separate object. ALso make sure all the information telemetered around is in cm to avoid using floats. UAVObject/GuidanceSettings: New guidance settings object for the guidance module Flight/Posix: Add the new objects to the Posix sim Flight/Guidance: Computes a desired velocity based on position error than runs a PID loop to control roll and pitch to achieve that velocity. All distances are in cm, and updated the PositionActual fields to reflect this and use int32. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1760 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ca4f3b53fa
commit
77b68e5169
@ -898,15 +898,15 @@ void process_spi_request(void)
|
||||
user_tx_v1.payload.user.v.rsp.update.quaternion.q4 =
|
||||
attitude_data.quaternion.q4;
|
||||
|
||||
// TODO: separate this from INSGPS
|
||||
user_tx_v1.payload.user.v.rsp.update.NED[0] = Nav.Pos[0];
|
||||
user_tx_v1.payload.user.v.rsp.update.NED[1] = Nav.Pos[1];
|
||||
user_tx_v1.payload.user.v.rsp.update.NED[2] = Nav.Pos[2];
|
||||
user_tx_v1.payload.user.v.rsp.update.Vel[0] = Nav.Vel[0];
|
||||
user_tx_v1.payload.user.v.rsp.update.Vel[1] = Nav.Vel[1];
|
||||
user_tx_v1.payload.user.v.rsp.update.Vel[2] = Nav.Vel[2];
|
||||
|
||||
// compute the idle fraction
|
||||
// convert all to cm/s
|
||||
user_tx_v1.payload.user.v.rsp.update.NED[0] = Nav.Pos[0]*100;
|
||||
user_tx_v1.payload.user.v.rsp.update.NED[1] = Nav.Pos[1]*100;
|
||||
user_tx_v1.payload.user.v.rsp.update.NED[2] = Nav.Pos[2]*100;
|
||||
user_tx_v1.payload.user.v.rsp.update.Vel[0] = Nav.Vel[0]*100;
|
||||
user_tx_v1.payload.user.v.rsp.update.Vel[1] = Nav.Vel[1]*100;
|
||||
user_tx_v1.payload.user.v.rsp.update.Vel[2] = Nav.Vel[2]*100;
|
||||
|
||||
// compute the idle fraction
|
||||
user_tx_v1.payload.user.v.rsp.update.load =
|
||||
((float)running_counts /
|
||||
(float)(idle_counts + running_counts)) * 100;
|
||||
|
Binary file not shown.
@ -57,13 +57,12 @@ FLASH_TOOL = OPENOCD
|
||||
USE_THUMB_MODE = YES
|
||||
|
||||
# List of modules to include
|
||||
MODULES = Telemetry GPS ManualControl Altitude AHRSComms Stabilization/simple/Stabilization Watchdog
|
||||
MODULES = Telemetry GPS ManualControl Altitude AHRSComms Stabilization/simple/Stabilization Guidance Watchdog
|
||||
#matrix based actuator mixer
|
||||
#MODULES += Actuator/matrix/Actuator
|
||||
#original actuator with separate mixers for fixed wing, heli and VTOL
|
||||
MODULES += Actuator
|
||||
|
||||
|
||||
#MODULES = Telemetry Example
|
||||
#MODULES = Telemetry MK/MKSerial
|
||||
#MODULES = Telemetry
|
||||
@ -186,6 +185,10 @@ SRC += $(OPUAVOBJ)/vtolstatus.c
|
||||
SRC += $(OPUAVOBJ)/mixersettings.c
|
||||
SRC += $(OPUAVOBJ)/mixerstatus.c
|
||||
#SRC += $(OPUAVOBJ)/lesstabilizationsettings.c
|
||||
SRC += $(OPUAVOBJ)/positiondesired.c
|
||||
SRC += $(OPUAVOBJ)/velocitydesired.c
|
||||
SRC += $(OPUAVOBJ)/velocityactual.c
|
||||
SRC += $(OPUAVOBJ)/guidancesettings.c
|
||||
endif
|
||||
|
||||
## PIOS Hardware (STM32F10x)
|
||||
|
@ -53,7 +53,7 @@ FLASH_TOOL = OPENOCD
|
||||
USE_THUMB_MODE = YES
|
||||
|
||||
# List of modules to include
|
||||
MODULES = Telemetry Stabilization/experimental/Stabilization ManualControl
|
||||
MODULES = Telemetry Stabilization/experimental/Stabilization Navigation Guidance ManualControl
|
||||
#MODULES = Telemetry GPS ManualControl Actuator Altitude Attitude Stabilization
|
||||
#MODULES = Telemetry Example
|
||||
#MODULES = Telemetry MK/MKSerial
|
||||
@ -149,6 +149,9 @@ SRC += $(OPUAVOBJ)/stabilizationsettings.c
|
||||
SRC += $(OPUAVOBJ)/ahrsstatus.c
|
||||
SRC += $(OPUAVOBJ)/baroaltitude.c
|
||||
SRC += $(OPUAVOBJ)/attitudeactual.c
|
||||
SRC += $(OPUAVOBJ)/flightsituationactual.c
|
||||
SRC += $(OPUAVOBJ)/navigationsettings.c
|
||||
SRC += $(OPUAVOBJ)/navigationdesired.c
|
||||
SRC += $(OPUAVOBJ)/flightbatterystate.c
|
||||
SRC += $(OPUAVOBJ)/attituderaw.c
|
||||
SRC += $(OPUAVOBJ)/homelocation.c
|
||||
@ -161,6 +164,11 @@ SRC += $(OPUAVOBJ)/vtolsettings.c
|
||||
SRC += $(OPUAVOBJ)/vtolstatus.c
|
||||
SRC += $(OPUAVOBJ)/mixersettings.c
|
||||
SRC += $(OPUAVOBJ)/mixerstatus.c
|
||||
#SRC += $(OPUAVOBJ)/lesstabilizationsettings.c
|
||||
SRC += $(OPUAVOBJ)/positiondesired.c
|
||||
SRC += $(OPUAVOBJ)/velocitydesired.c
|
||||
SRC += $(OPUAVOBJ)/velocityactual.c
|
||||
SRC += $(OPUAVOBJ)/guidancesettings.c
|
||||
endif
|
||||
|
||||
## PIOS Hardware (posix)
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "stdbool.h"
|
||||
#include "gpsposition.h"
|
||||
#include "positionactual.h"
|
||||
#include "velocityactual.h"
|
||||
#include "homelocation.h"
|
||||
#include "ahrscalibration.h"
|
||||
#include "CoordinateConversions.h"
|
||||
@ -500,13 +501,17 @@ static void process_update(struct opahrs_msg_v1_rsp_update * update)
|
||||
|
||||
PositionActualData pos;
|
||||
PositionActualGet(&pos);
|
||||
pos.NED[0] = update->NED[0];
|
||||
pos.NED[1] = update->NED[1];
|
||||
pos.NED[2] = update->NED[2];
|
||||
pos.Vel[0] = update->Vel[0];
|
||||
pos.Vel[1] = update->Vel[1];
|
||||
pos.Vel[2] = update->Vel[2];
|
||||
pos.North = update->NED[0];
|
||||
pos.East = update->NED[1];
|
||||
pos.Down = update->NED[2];
|
||||
PositionActualSet(&pos);
|
||||
|
||||
VelocityActualData vel;
|
||||
VelocityActualGet(&vel);
|
||||
vel.North = update->Vel[0];
|
||||
vel.East = update->Vel[1];
|
||||
vel.Down = update->Vel[2];
|
||||
VelocityActualSet(&vel);
|
||||
|
||||
AhrsStatusData status;
|
||||
AhrsStatusGet(&status);
|
||||
|
160
flight/OpenPilot/Modules/FlightSituation/flightsituation.c
Normal file
160
flight/OpenPilot/Modules/FlightSituation/flightsituation.c
Normal file
@ -0,0 +1,160 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup OpenPilotModules OpenPilot Modules
|
||||
* @{
|
||||
* @addtogroup FlightSituationModule FlightSituation Module
|
||||
* @brief Sensor Merge of all Flight data into most likely situation
|
||||
* @note This object updates the @ref FlightSituationActual UAVObject
|
||||
* @{
|
||||
*
|
||||
* @file flightsituation.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 "flightsituation.h"
|
||||
#include "flightsituationactual.h"
|
||||
#include "attitudeactual.h"
|
||||
#include "altitudeactual.h"
|
||||
#include "headingactual.h"
|
||||
#include "positionactual.h"
|
||||
#include "systemsettings.h"
|
||||
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY+4)
|
||||
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
static xTaskHandle taskHandle;
|
||||
|
||||
// Private functions
|
||||
static void flightSituationTask(void* parameters);
|
||||
|
||||
/**
|
||||
* Module initialization
|
||||
*/
|
||||
int32_t FlightSituationInitialize()
|
||||
{
|
||||
// Initialize variables
|
||||
|
||||
// Start main task
|
||||
xTaskCreate(flightSituationTask, (signed char*)"FlightSituation", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module task
|
||||
*/
|
||||
static void flightSituationTask(void* parameters)
|
||||
{
|
||||
AttitudeActualData attitudeActual;
|
||||
AltitudeActualData altitudeActual;
|
||||
HeadingActualData headingActual;
|
||||
PositionActualData positionActual;
|
||||
SystemSettingsData systemSettings;
|
||||
FlightSituationActualData flightSituationActual;
|
||||
portTickType lastSysTime;
|
||||
|
||||
// private variables
|
||||
float altitudeLast=0.0;
|
||||
// Main task loop
|
||||
lastSysTime = xTaskGetTickCount();
|
||||
while (1)
|
||||
{
|
||||
// Read settings and other objects
|
||||
SystemSettingsGet(&systemSettings);
|
||||
AttitudeActualGet(&attitudeActual);
|
||||
AltitudeActualGet(&altitudeActual);
|
||||
HeadingActualGet(&headingActual);
|
||||
PositionActualGet(&positionActual);
|
||||
FlightSituationActualGet(&flightSituationActual);
|
||||
|
||||
// TODO: plausibility check of GPS data,
|
||||
// innertial navigation with kalman feed-in of GPS data
|
||||
// sensor fusion
|
||||
// STUB code:
|
||||
flightSituationActual.Latitude = positionActual.Latitude;
|
||||
flightSituationActual.Longitude = positionActual.Longitude;
|
||||
|
||||
|
||||
// TODO: fuse altitude information with GPS data plus
|
||||
// plausibility check
|
||||
// STUB Code:
|
||||
flightSituationActual.Altitude = altitudeActual.Altitude;
|
||||
|
||||
// TODO: get altitude over ground from somewhere:
|
||||
// method 1: reflection sensor
|
||||
// method 2: crude database with ground hight information
|
||||
// method 3: manual setting of ground hight at start pos
|
||||
// STUB code:
|
||||
flightSituationActual.ATG = altitudeActual.Altitude;
|
||||
|
||||
// TODO: use some more sophisticated Kalman filtering
|
||||
// and several sources (including speed and pitch!)
|
||||
// to get this one right
|
||||
flightSituationActual.Climbrate = 0.9*flightSituationActual.Climbrate + 0.1*((flightSituationActual.Altitude-altitudeLast)*10);
|
||||
// the times 10 is because timescale is 1/10th
|
||||
// of a second right now
|
||||
altitudeLast = flightSituationActual.Altitude;
|
||||
|
||||
// TODO: heading: sensor fusion from AttitudeActual.yaw
|
||||
// and HeadingActual - with plausibility checks
|
||||
// BUT ??? what to do with heli- / multicopters
|
||||
// that can fly sideways?
|
||||
// Maybe the AHRS can give us a movement vector too?
|
||||
flightSituationActual.Heading = positionActual.Heading;
|
||||
|
||||
// TODO: airspeed - is THE critical measure to prevent stall
|
||||
// and judge which maneuvers are safe.
|
||||
// However AFAIK we have no sensor for it yet, do we?
|
||||
// Even with moderate winds, a glider or other UAV
|
||||
// can easily fly (seemingly) backwards, so airspeed
|
||||
// and groundspeed can significantly differ!
|
||||
flightSituationActual.Airspeed = positionActual.Groundspeed;
|
||||
|
||||
// TODO: this can possibly be taken from GPS
|
||||
// with just a bit of plausibility checking
|
||||
// and replacing by above if missing
|
||||
flightSituationActual.Course = positionActual.Heading;
|
||||
flightSituationActual.Groundspeed = positionActual.Groundspeed;
|
||||
|
||||
|
||||
FlightSituationActualSet(&flightSituationActual);
|
||||
|
||||
// Clear alarms
|
||||
// TODO create a new alarm
|
||||
//AlarmsClear(SYSTEMALARMS_ALARM_STABILIZATION);
|
||||
|
||||
// Wait until next update
|
||||
// TODO non-hardcoded update rate
|
||||
vTaskDelayUntil(&lastSysTime, 100 / portTICK_RATE_MS );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -0,0 +1,42 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup OpenPilotModules OpenPilot Modules
|
||||
* @{
|
||||
* @addtogroup FlightSituationModule FlightSituation Module
|
||||
* @brief Sensor Merge of all Flight data into most likely situation
|
||||
* @note This object updates the @ref FlightSituationActual UAVObject
|
||||
* @{
|
||||
*
|
||||
* @file flightsituation.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 FLIGHTSITUATION_H
|
||||
#define FLIGHTSITUATION_H
|
||||
|
||||
int32_t FlightSituationInitialize();
|
||||
|
||||
#endif // FLIGHTSITUATION_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
232
flight/OpenPilot/Modules/Guidance/guidance.c
Normal file
232
flight/OpenPilot/Modules/Guidance/guidance.c
Normal file
@ -0,0 +1,232 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file guidance.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief This module compared @ref PositionActuatl to @ref ActiveWaypoint
|
||||
* and sets @ref AttitudeDesired. It only does this when the FlightMode field
|
||||
* of @ref ManualControlCommand is Auto.
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
|
||||
/**
|
||||
* Input object: ActiveWaypoint
|
||||
* Input object: PositionActual
|
||||
* Input object: ManualControlCommand
|
||||
* Output object: AttitudeDesired
|
||||
*
|
||||
* This module will periodically update the value of the AttitudeDesired object.
|
||||
*
|
||||
* The module executes in its own thread in this example.
|
||||
*
|
||||
* Modules have no API, all communication to other modules is done through UAVObjects.
|
||||
* However modules may use the API exposed by shared libraries.
|
||||
* See the OpenPilot wiki for more details.
|
||||
* http://www.openpilot.org/OpenPilot_Application_Architecture
|
||||
*
|
||||
*/
|
||||
|
||||
#include "openpilot.h"
|
||||
#include "guidance.h"
|
||||
#include "guidancesettings.h"
|
||||
#include "attitudeactual.h"
|
||||
#include "attitudedesired.h"
|
||||
#include "positiondesired.h" // object that will be updated by the module
|
||||
#include "positionactual.h"
|
||||
#include "manualcontrolcommand.h"
|
||||
#include "stabilizationsettings.h"
|
||||
#include "systemsettings.h"
|
||||
#include "velocitydesired.h"
|
||||
#include "velocityactual.h"
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE configMINIMAL_STACK_SIZE
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY+1)
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
static xTaskHandle guidanceTaskHandle;
|
||||
static xTaskHandle velocityPIDTaskHandle;
|
||||
|
||||
// Private functions
|
||||
static void guidanceTask(void* parameters);
|
||||
static void velocityPIDTask(void* parameters);
|
||||
static float bound(float val, float min, float max);
|
||||
|
||||
/**
|
||||
* Initialise the module, called on startup
|
||||
* \returns 0 on success or -1 if initialisation failed
|
||||
*/
|
||||
int32_t GuidanceInitialize()
|
||||
{
|
||||
// Start main task
|
||||
xTaskCreate(guidanceTask, (signed char*)"Guidance", STACK_SIZE, NULL, TASK_PRIORITY, &guidanceTaskHandle);
|
||||
xTaskCreate(velocityPIDTask, (signed char*)"VelocityPID", STACK_SIZE, NULL, TASK_PRIORITY, &velocityPIDTaskHandle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module thread, should not return.
|
||||
*/
|
||||
static void guidanceTask(void* parameters)
|
||||
{
|
||||
SystemSettingsData systemSettings;
|
||||
GuidanceSettingsData guidanceSettings;
|
||||
ManualControlCommandData manualControl;
|
||||
PositionActualData positionActual;
|
||||
PositionDesiredData positionDesired;
|
||||
VelocityDesiredData velocityDesired;
|
||||
|
||||
portTickType lastSysTime;
|
||||
|
||||
// Main task loop
|
||||
lastSysTime = xTaskGetTickCount();
|
||||
while (1)
|
||||
{
|
||||
ManualControlCommandGet(&manualControl);
|
||||
SystemSettingsGet(&systemSettings);
|
||||
GuidanceSettingsGet(&guidanceSettings);
|
||||
|
||||
if((manualControl.FlightMode == MANUALCONTROLCOMMAND_FLIGHTMODE_AUTO) &&
|
||||
(systemSettings.AirframeType == SYSTEMSETTINGS_AIRFRAMETYPE_VTOL)) {
|
||||
|
||||
PositionActualGet(&positionActual);
|
||||
PositionDesiredGet(&positionDesired);
|
||||
|
||||
// Note all distances in cm
|
||||
float dNorth = positionDesired.North - positionActual.North;
|
||||
float dEast = positionDesired.East - positionActual.East;
|
||||
float distance = sqrt(pow(dNorth,2) + pow(dEast,2));
|
||||
float groundspeed = guidanceSettings.GroundVelocityP * distance; //bound(guidanceSettings.GroundVelocityP * distance, 0, guidanceSettings.MaxGroundspeed);
|
||||
float heading = atan2f(dEast,dNorth);
|
||||
|
||||
velocityDesired.North = groundspeed * cosf(heading);
|
||||
velocityDesired.East = groundspeed * sinf(heading);
|
||||
|
||||
float dDown = positionDesired.Down - positionActual.Down;
|
||||
velocityDesired.Down = bound(guidanceSettings.VertVelocityP * dDown, -guidanceSettings.MaxVerticalSpeed, guidanceSettings.MaxVerticalSpeed);
|
||||
|
||||
VelocityDesiredSet(&velocityDesired);
|
||||
|
||||
}
|
||||
vTaskDelayUntil(&lastSysTime, guidanceSettings.VelUpdatePeriod / portTICK_RATE_MS );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Module thread, should not return.
|
||||
*/
|
||||
static void velocityPIDTask(void* parameters)
|
||||
{
|
||||
portTickType lastSysTime;
|
||||
VelocityDesiredData velocityDesired;
|
||||
VelocityActualData velocityActual;
|
||||
AttitudeDesiredData attitudeDesired;
|
||||
AttitudeActualData attitudeActual;
|
||||
GuidanceSettingsData guidanceSettings;
|
||||
StabilizationSettingsData stabSettings;
|
||||
SystemSettingsData systemSettings;
|
||||
ManualControlCommandData manualControl;
|
||||
|
||||
float northError;
|
||||
float northDerivative;
|
||||
float northIntegral;
|
||||
float northErrorLast = 0;
|
||||
float northCommand;
|
||||
float eastError;
|
||||
float eastDerivative;
|
||||
float eastIntegral = 0;
|
||||
float eastErrorLast = 0;
|
||||
float eastCommand;
|
||||
float downError;
|
||||
float downDerivative;
|
||||
float downIntegral = 0;
|
||||
float downErrorLast = 0;
|
||||
|
||||
// Main task loop
|
||||
lastSysTime = xTaskGetTickCount();
|
||||
while (1)
|
||||
{
|
||||
ManualControlCommandGet(&manualControl);
|
||||
SystemSettingsGet(&systemSettings);
|
||||
GuidanceSettingsGet(&guidanceSettings);
|
||||
if((manualControl.FlightMode == MANUALCONTROLCOMMAND_FLIGHTMODE_AUTO) &&
|
||||
(systemSettings.AirframeType == SYSTEMSETTINGS_AIRFRAMETYPE_VTOL)) {
|
||||
VelocityActualGet(&velocityActual);
|
||||
VelocityDesiredGet(&velocityDesired);
|
||||
AttitudeDesiredGet(&attitudeDesired);
|
||||
VelocityDesiredGet(&velocityDesired);
|
||||
AttitudeActualGet(&attitudeActual);
|
||||
StabilizationSettingsGet(&stabSettings);
|
||||
|
||||
attitudeDesired.Yaw = 0; // try and face north
|
||||
|
||||
// Yaw and pitch output from ground speed PID loop
|
||||
northError = velocityDesired.North - velocityActual.North;
|
||||
northDerivative = (northError - northErrorLast) / guidanceSettings.VelPIDUpdatePeriod;
|
||||
northIntegral = bound(northIntegral+northError*guidanceSettings.VelPIDUpdatePeriod, -guidanceSettings.MaxVelIntegral, guidanceSettings.MaxVelIntegral);
|
||||
northErrorLast = northError;
|
||||
northCommand = northError*guidanceSettings.VelP + northDerivative*guidanceSettings.VelD + northIntegral*guidanceSettings.VelI;
|
||||
|
||||
eastError = velocityDesired.East - velocityActual.East;
|
||||
eastDerivative = (eastError - eastErrorLast) / guidanceSettings.VelPIDUpdatePeriod;
|
||||
eastIntegral = bound(eastIntegral+eastError*guidanceSettings.VelPIDUpdatePeriod, -guidanceSettings.MaxVelIntegral, guidanceSettings.MaxVelIntegral);
|
||||
eastErrorLast = eastError;
|
||||
eastCommand = eastError*guidanceSettings.VelP + eastDerivative*guidanceSettings.VelD + eastIntegral*guidanceSettings.VelI;
|
||||
|
||||
// Project the north and east command signals into the pitch and roll based on yaw. For this to behave well the
|
||||
// craft should move similarly for 5 deg roll versus 5 deg pitch
|
||||
attitudeDesired.Pitch = bound(-northCommand * cosf(attitudeActual.Yaw * M_PI / 180) + eastCommand * sinf(attitudeActual.Yaw * M_PI / 180),
|
||||
-stabSettings.PitchMax, stabSettings.PitchMax);
|
||||
attitudeDesired.Roll = bound(-northCommand * sinf(attitudeActual.Yaw * M_PI / 180) + eastCommand * cosf(attitudeActual.Yaw * M_PI / 180),
|
||||
-stabSettings.RollMax, stabSettings.RollMax);
|
||||
|
||||
downError = velocityDesired.Down - velocityActual.Down;
|
||||
downDerivative = (downError - downErrorLast) / guidanceSettings.VelPIDUpdatePeriod;
|
||||
downIntegral = bound(downIntegral+downError*guidanceSettings.VelPIDUpdatePeriod, -guidanceSettings.MaxThrottleIntegral, guidanceSettings.MaxThrottleIntegral);
|
||||
downErrorLast = downError;
|
||||
attitudeDesired.Throttle = bound(downError*guidanceSettings.DownP + downDerivative*guidanceSettings.DownD + downIntegral*guidanceSettings.DownI,
|
||||
0, 1);
|
||||
|
||||
AttitudeDesiredSet(&attitudeDesired);
|
||||
|
||||
}
|
||||
vTaskDelayUntil(&lastSysTime, guidanceSettings.VelPIDUpdatePeriod / 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;
|
||||
}
|
||||
|
32
flight/OpenPilot/Modules/Guidance/inc/guidance.h
Normal file
32
flight/OpenPilot/Modules/Guidance/inc/guidance.h
Normal file
@ -0,0 +1,32 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file examplemodperiodic.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Example module to be used as a template for actual modules.
|
||||
*
|
||||
* @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 EXAMPLEMODPERIODIC_H
|
||||
#define EXAMPLEMODPERIODIC_H
|
||||
|
||||
int32_t ExampleModPeriodicInitialize();
|
||||
|
||||
#endif // EXAMPLEMODPERIODIC_H
|
||||
|
125
flight/OpenPilot/UAVObjects/guidancesettings.c
Normal file
125
flight/OpenPilot/UAVObjects/guidancesettings.c
Normal file
@ -0,0 +1,125 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup GuidanceSettings GuidanceSettings
|
||||
* @brief Settings for the @ref GuidanceModule
|
||||
*
|
||||
* 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.MaxGroundspeed = 100;
|
||||
data.GroundVelocityP = 0.1;
|
||||
data.MaxVerticalSpeed = 100;
|
||||
data.VertVelocityP = 0.1;
|
||||
data.VelP = 0.1;
|
||||
data.VelI = 0.1;
|
||||
data.VelD = 0;
|
||||
data.DownP = 0;
|
||||
data.DownI = 0;
|
||||
data.DownD = 0;
|
||||
data.MaxVelIntegral = 2;
|
||||
data.MaxThrottleIntegral = 1;
|
||||
data.VelUpdatePeriod = 100;
|
||||
data.VelPIDUpdatePeriod = 20;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
117
flight/OpenPilot/UAVObjects/inc/guidancesettings.h
Normal file
117
flight/OpenPilot/UAVObjects/inc/guidancesettings.h
Normal file
@ -0,0 +1,117 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup GuidanceSettings GuidanceSettings
|
||||
* @brief Settings for the @ref GuidanceModule
|
||||
*
|
||||
* 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 2428005802U
|
||||
#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 {
|
||||
int32_t MaxGroundspeed;
|
||||
float GroundVelocityP;
|
||||
int32_t MaxVerticalSpeed;
|
||||
float VertVelocityP;
|
||||
float VelP;
|
||||
float VelI;
|
||||
float VelD;
|
||||
float DownP;
|
||||
float DownI;
|
||||
float DownD;
|
||||
float MaxVelIntegral;
|
||||
float MaxThrottleIntegral;
|
||||
int32_t VelUpdatePeriod;
|
||||
int32_t VelPIDUpdatePeriod;
|
||||
|
||||
} __attribute__((packed)) GuidanceSettingsData;
|
||||
|
||||
// Field information
|
||||
// Field MaxGroundspeed information
|
||||
// Field GroundVelocityP information
|
||||
// Field MaxVerticalSpeed information
|
||||
// Field VertVelocityP information
|
||||
// Field VelP information
|
||||
// Field VelI information
|
||||
// Field VelD information
|
||||
// Field DownP information
|
||||
// Field DownI information
|
||||
// Field DownD information
|
||||
// Field MaxVelIntegral information
|
||||
// Field MaxThrottleIntegral information
|
||||
// Field VelUpdatePeriod information
|
||||
// Field VelPIDUpdatePeriod information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t GuidanceSettingsInitialize();
|
||||
UAVObjHandle GuidanceSettingsHandle();
|
||||
|
||||
#endif // GUIDANCESETTINGS_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -3,7 +3,7 @@
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup PositionActual PositionActual
|
||||
* @brief Deprecated for GPS position.
|
||||
* @brief Contains the current position relative to @ref HomeLocation
|
||||
*
|
||||
* Autogenerated files and functions for PositionActual Object
|
||||
|
||||
@ -41,7 +41,7 @@
|
||||
#define POSITIONACTUAL_H
|
||||
|
||||
// Object constants
|
||||
#define POSITIONACTUAL_OBJID 3881752126U
|
||||
#define POSITIONACTUAL_OBJID 3765671478U
|
||||
#define POSITIONACTUAL_NAME "PositionActual"
|
||||
#define POSITIONACTUAL_METANAME "PositionActualMeta"
|
||||
#define POSITIONACTUAL_ISSINGLEINST 1
|
||||
@ -71,46 +71,16 @@
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
uint8_t Status;
|
||||
float Latitude;
|
||||
float Longitude;
|
||||
float Altitude;
|
||||
float GeoidSeparation;
|
||||
float Heading;
|
||||
float Groundspeed;
|
||||
float Airspeed;
|
||||
float Climbrate;
|
||||
int8_t Satellites;
|
||||
float PDOP;
|
||||
float HDOP;
|
||||
float VDOP;
|
||||
float NED[3];
|
||||
float Vel[3];
|
||||
int32_t North;
|
||||
int32_t East;
|
||||
int32_t Down;
|
||||
|
||||
} __attribute__((packed)) PositionActualData;
|
||||
|
||||
// Field information
|
||||
// Field Status information
|
||||
/* Enumeration options for field Status */
|
||||
typedef enum { POSITIONACTUAL_STATUS_NOGPS=0, POSITIONACTUAL_STATUS_NOFIX=1, POSITIONACTUAL_STATUS_FIX2D=2, POSITIONACTUAL_STATUS_FIX3D=3 } PositionActualStatusOptions;
|
||||
// Field Latitude information
|
||||
// Field Longitude information
|
||||
// Field Altitude information
|
||||
// Field GeoidSeparation information
|
||||
// Field Heading information
|
||||
// Field Groundspeed information
|
||||
// Field Airspeed information
|
||||
// Field Climbrate information
|
||||
// Field Satellites information
|
||||
// Field PDOP information
|
||||
// Field HDOP information
|
||||
// Field VDOP information
|
||||
// Field NED information
|
||||
/* Number of elements for field NED */
|
||||
#define POSITIONACTUAL_NED_NUMELEM 3
|
||||
// Field Vel information
|
||||
/* Number of elements for field Vel */
|
||||
#define POSITIONACTUAL_VEL_NUMELEM 3
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
|
95
flight/OpenPilot/UAVObjects/inc/positiondesired.h
Normal file
95
flight/OpenPilot/UAVObjects/inc/positiondesired.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup PositionDesired PositionDesired
|
||||
* @brief The position the craft is trying t achieve. Can come from GCS or @ref PathPlanner
|
||||
*
|
||||
* 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 801433018U
|
||||
#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 {
|
||||
int32_t North;
|
||||
int32_t East;
|
||||
int32_t Down;
|
||||
|
||||
} __attribute__((packed)) PositionDesiredData;
|
||||
|
||||
// Field information
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t PositionDesiredInitialize();
|
||||
UAVObjHandle PositionDesiredHandle();
|
||||
|
||||
#endif // POSITIONDESIRED_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -71,7 +71,7 @@
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
uint8_t Alarm[11];
|
||||
uint8_t Alarm[10];
|
||||
|
||||
} __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_GUIDANCE=9, SYSTEMALARMS_ALARM_AHRSCOMMS=10 } 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_AHRSCOMMS=9 } SystemAlarmsAlarmElem;
|
||||
/* Number of elements for field Alarm */
|
||||
#define SYSTEMALARMS_ALARM_NUMELEM 11
|
||||
#define SYSTEMALARMS_ALARM_NUMELEM 10
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
|
95
flight/OpenPilot/UAVObjects/inc/velocityactual.h
Normal file
95
flight/OpenPilot/UAVObjects/inc/velocityactual.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup VelocityActual VelocityActual
|
||||
* @brief Updated by @ref AHRSCommsModule and used within @ref GuidanceModulefor velocity control
|
||||
*
|
||||
* Autogenerated files and functions for VelocityActual Object
|
||||
|
||||
* @{
|
||||
*
|
||||
* @file velocityactual.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the VelocityActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: velocityactual.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 VELOCITYACTUAL_H
|
||||
#define VELOCITYACTUAL_H
|
||||
|
||||
// Object constants
|
||||
#define VELOCITYACTUAL_OBJID 1207999624U
|
||||
#define VELOCITYACTUAL_NAME "VelocityActual"
|
||||
#define VELOCITYACTUAL_METANAME "VelocityActualMeta"
|
||||
#define VELOCITYACTUAL_ISSINGLEINST 1
|
||||
#define VELOCITYACTUAL_ISSETTINGS 0
|
||||
#define VELOCITYACTUAL_NUMBYTES sizeof(VelocityActualData)
|
||||
|
||||
// Object access macros
|
||||
/**
|
||||
* @function VelocityActualGet(dataOut)
|
||||
* @brief Populate a VelocityActualData object
|
||||
* @param[out] dataOut
|
||||
*/
|
||||
#define VelocityActualGet(dataOut) UAVObjGetData(VelocityActualHandle(), dataOut)
|
||||
#define VelocityActualSet(dataIn) UAVObjSetData(VelocityActualHandle(), dataIn)
|
||||
#define VelocityActualInstGet(instId, dataOut) UAVObjGetInstanceData(VelocityActualHandle(), instId, dataOut)
|
||||
#define VelocityActualInstSet(instId, dataIn) UAVObjSetInstanceData(VelocityActualHandle(), instId, dataIn)
|
||||
#define VelocityActualConnectQueue(queue) UAVObjConnectQueue(VelocityActualHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||
#define VelocityActualConnectCallback(cb) UAVObjConnectCallback(VelocityActualHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||
#define VelocityActualCreateInstance() UAVObjCreateInstance(VelocityActualHandle())
|
||||
#define VelocityActualRequestUpdate() UAVObjRequestUpdate(VelocityActualHandle())
|
||||
#define VelocityActualRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(VelocityActualHandle(), instId)
|
||||
#define VelocityActualUpdated() UAVObjUpdated(VelocityActualHandle())
|
||||
#define VelocityActualInstUpdated(instId) UAVObjUpdated(VelocityActualHandle(), instId)
|
||||
#define VelocityActualGetMetadata(dataOut) UAVObjGetMetadata(VelocityActualHandle(), dataOut)
|
||||
#define VelocityActualSetMetadata(dataIn) UAVObjSetMetadata(VelocityActualHandle(), dataIn)
|
||||
#define VelocityActualReadOnly(dataIn) UAVObjReadOnly(VelocityActualHandle())
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
int32_t North;
|
||||
int32_t East;
|
||||
int32_t Down;
|
||||
|
||||
} __attribute__((packed)) VelocityActualData;
|
||||
|
||||
// Field information
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t VelocityActualInitialize();
|
||||
UAVObjHandle VelocityActualHandle();
|
||||
|
||||
#endif // VELOCITYACTUAL_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
95
flight/OpenPilot/UAVObjects/inc/velocitydesired.h
Normal file
95
flight/OpenPilot/UAVObjects/inc/velocitydesired.h
Normal file
@ -0,0 +1,95 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup VelocityDesired VelocityDesired
|
||||
* @brief Used within @ref GuidanceModule to communicate between the task computing the desired velocity and the PID loop to achieve it (running at different rates).
|
||||
*
|
||||
* Autogenerated files and functions for VelocityDesired Object
|
||||
|
||||
* @{
|
||||
*
|
||||
* @file velocitydesired.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the VelocityDesired object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: velocitydesired.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 VELOCITYDESIRED_H
|
||||
#define VELOCITYDESIRED_H
|
||||
|
||||
// Object constants
|
||||
#define VELOCITYDESIRED_OBJID 305094202U
|
||||
#define VELOCITYDESIRED_NAME "VelocityDesired"
|
||||
#define VELOCITYDESIRED_METANAME "VelocityDesiredMeta"
|
||||
#define VELOCITYDESIRED_ISSINGLEINST 1
|
||||
#define VELOCITYDESIRED_ISSETTINGS 0
|
||||
#define VELOCITYDESIRED_NUMBYTES sizeof(VelocityDesiredData)
|
||||
|
||||
// Object access macros
|
||||
/**
|
||||
* @function VelocityDesiredGet(dataOut)
|
||||
* @brief Populate a VelocityDesiredData object
|
||||
* @param[out] dataOut
|
||||
*/
|
||||
#define VelocityDesiredGet(dataOut) UAVObjGetData(VelocityDesiredHandle(), dataOut)
|
||||
#define VelocityDesiredSet(dataIn) UAVObjSetData(VelocityDesiredHandle(), dataIn)
|
||||
#define VelocityDesiredInstGet(instId, dataOut) UAVObjGetInstanceData(VelocityDesiredHandle(), instId, dataOut)
|
||||
#define VelocityDesiredInstSet(instId, dataIn) UAVObjSetInstanceData(VelocityDesiredHandle(), instId, dataIn)
|
||||
#define VelocityDesiredConnectQueue(queue) UAVObjConnectQueue(VelocityDesiredHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||
#define VelocityDesiredConnectCallback(cb) UAVObjConnectCallback(VelocityDesiredHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||
#define VelocityDesiredCreateInstance() UAVObjCreateInstance(VelocityDesiredHandle())
|
||||
#define VelocityDesiredRequestUpdate() UAVObjRequestUpdate(VelocityDesiredHandle())
|
||||
#define VelocityDesiredRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(VelocityDesiredHandle(), instId)
|
||||
#define VelocityDesiredUpdated() UAVObjUpdated(VelocityDesiredHandle())
|
||||
#define VelocityDesiredInstUpdated(instId) UAVObjUpdated(VelocityDesiredHandle(), instId)
|
||||
#define VelocityDesiredGetMetadata(dataOut) UAVObjGetMetadata(VelocityDesiredHandle(), dataOut)
|
||||
#define VelocityDesiredSetMetadata(dataIn) UAVObjSetMetadata(VelocityDesiredHandle(), dataIn)
|
||||
#define VelocityDesiredReadOnly(dataIn) UAVObjReadOnly(VelocityDesiredHandle())
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
int32_t North;
|
||||
int32_t East;
|
||||
int32_t Down;
|
||||
|
||||
} __attribute__((packed)) VelocityDesiredData;
|
||||
|
||||
// Field information
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t VelocityDesiredInitialize();
|
||||
UAVObjHandle VelocityDesiredHandle();
|
||||
|
||||
#endif // VELOCITYDESIRED_H
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
*/
|
@ -3,7 +3,7 @@
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup PositionActual PositionActual
|
||||
* @brief Deprecated for GPS position.
|
||||
* @brief Contains the current position relative to @ref HomeLocation
|
||||
*
|
||||
* Autogenerated files and functions for PositionActual Object
|
||||
* @{
|
||||
|
111
flight/OpenPilot/UAVObjects/positiondesired.c
Normal file
111
flight/OpenPilot/UAVObjects/positiondesired.c
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup PositionDesired PositionDesired
|
||||
* @brief The position the craft is trying t achieve. Can come from GCS or @ref PathPlanner
|
||||
*
|
||||
* 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_ONCHANGE;
|
||||
metadata.telemetryUpdatePeriod = 0;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
UAVObjSetMetadata(obj, &metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object handle
|
||||
*/
|
||||
UAVObjHandle PositionDesiredHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -48,6 +48,7 @@
|
||||
#include "gpsposition.h"
|
||||
#include "gpssatellites.h"
|
||||
#include "gpstime.h"
|
||||
#include "guidancesettings.h"
|
||||
#include "homelocation.h"
|
||||
#include "manualcontrolcommand.h"
|
||||
#include "manualcontrolsettings.h"
|
||||
@ -55,11 +56,14 @@
|
||||
#include "mixerstatus.h"
|
||||
#include "objectpersistence.h"
|
||||
#include "positionactual.h"
|
||||
#include "positiondesired.h"
|
||||
#include "stabilizationsettings.h"
|
||||
#include "systemalarms.h"
|
||||
#include "systemsettings.h"
|
||||
#include "systemstats.h"
|
||||
#include "telemetrysettings.h"
|
||||
#include "velocityactual.h"
|
||||
#include "velocitydesired.h"
|
||||
#include "vtolsettings.h"
|
||||
#include "vtolstatus.h"
|
||||
|
||||
@ -90,6 +94,7 @@ void UAVObjectsInitializeAll()
|
||||
GPSPositionInitialize();
|
||||
GPSSatellitesInitialize();
|
||||
GPSTimeInitialize();
|
||||
GuidanceSettingsInitialize();
|
||||
HomeLocationInitialize();
|
||||
ManualControlCommandInitialize();
|
||||
ManualControlSettingsInitialize();
|
||||
@ -97,11 +102,14 @@ void UAVObjectsInitializeAll()
|
||||
MixerStatusInitialize();
|
||||
ObjectPersistenceInitialize();
|
||||
PositionActualInitialize();
|
||||
PositionDesiredInitialize();
|
||||
StabilizationSettingsInitialize();
|
||||
SystemAlarmsInitialize();
|
||||
SystemSettingsInitialize();
|
||||
SystemStatsInitialize();
|
||||
TelemetrySettingsInitialize();
|
||||
VelocityActualInitialize();
|
||||
VelocityDesiredInitialize();
|
||||
VTOLSettingsInitialize();
|
||||
VTOLStatusInitialize();
|
||||
|
||||
|
111
flight/OpenPilot/UAVObjects/velocityactual.c
Normal file
111
flight/OpenPilot/UAVObjects/velocityactual.c
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup VelocityActual VelocityActual
|
||||
* @brief Updated by @ref AHRSCommsModule and used within @ref GuidanceModulefor velocity control
|
||||
*
|
||||
* Autogenerated files and functions for VelocityActual Object
|
||||
* @{
|
||||
*
|
||||
* @file velocityactual.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the VelocityActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: velocityactual.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 "velocityactual.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 VelocityActualInitialize()
|
||||
{
|
||||
// Register object with the object manager
|
||||
handle = UAVObjRegister(VELOCITYACTUAL_OBJID, VELOCITYACTUAL_NAME, VELOCITYACTUAL_METANAME, 0,
|
||||
VELOCITYACTUAL_ISSINGLEINST, VELOCITYACTUAL_ISSETTINGS, VELOCITYACTUAL_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)
|
||||
{
|
||||
VelocityActualData data;
|
||||
UAVObjMetadata metadata;
|
||||
|
||||
// Initialize object fields to their default values
|
||||
UAVObjGetInstanceData(obj, instId, &data);
|
||||
memset(&data, 0, sizeof(VelocityActualData));
|
||||
|
||||
UAVObjSetInstanceData(obj, instId, &data);
|
||||
|
||||
// Initialize object metadata to their default values
|
||||
metadata.access = ACCESS_READWRITE;
|
||||
metadata.gcsAccess = ACCESS_READWRITE;
|
||||
metadata.telemetryAcked = 0;
|
||||
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.telemetryUpdatePeriod = 1000;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
UAVObjSetMetadata(obj, &metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object handle
|
||||
*/
|
||||
UAVObjHandle VelocityActualHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
111
flight/OpenPilot/UAVObjects/velocitydesired.c
Normal file
111
flight/OpenPilot/UAVObjects/velocitydesired.c
Normal file
@ -0,0 +1,111 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @addtogroup UAVObjects OpenPilot UAVObjects
|
||||
* @{
|
||||
* @addtogroup VelocityDesired VelocityDesired
|
||||
* @brief Used within @ref GuidanceModule to communicate between the task computing the desired velocity and the PID loop to achieve it (running at different rates).
|
||||
*
|
||||
* Autogenerated files and functions for VelocityDesired Object
|
||||
* @{
|
||||
*
|
||||
* @file velocitydesired.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the VelocityDesired object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: velocitydesired.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 "velocitydesired.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 VelocityDesiredInitialize()
|
||||
{
|
||||
// Register object with the object manager
|
||||
handle = UAVObjRegister(VELOCITYDESIRED_OBJID, VELOCITYDESIRED_NAME, VELOCITYDESIRED_METANAME, 0,
|
||||
VELOCITYDESIRED_ISSINGLEINST, VELOCITYDESIRED_ISSETTINGS, VELOCITYDESIRED_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)
|
||||
{
|
||||
VelocityDesiredData data;
|
||||
UAVObjMetadata metadata;
|
||||
|
||||
// Initialize object fields to their default values
|
||||
UAVObjGetInstanceData(obj, instId, &data);
|
||||
memset(&data, 0, sizeof(VelocityDesiredData));
|
||||
|
||||
UAVObjSetInstanceData(obj, instId, &data);
|
||||
|
||||
// Initialize object metadata to their default values
|
||||
metadata.access = ACCESS_READWRITE;
|
||||
metadata.gcsAccess = ACCESS_READWRITE;
|
||||
metadata.telemetryAcked = 0;
|
||||
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.telemetryUpdatePeriod = 1000;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
UAVObjSetMetadata(obj, &metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object handle
|
||||
*/
|
||||
UAVObjHandle VelocityDesiredHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -319,8 +319,8 @@ struct opahrs_msg_v1_rsp_update {
|
||||
float q3;
|
||||
float q4;
|
||||
} quaternion;
|
||||
float NED[3];
|
||||
float Vel[3];
|
||||
int32_t NED[3];
|
||||
int32_t Vel[3];
|
||||
uint8_t load;
|
||||
uint8_t idle_time;
|
||||
uint8_t run_time;
|
||||
|
@ -32,22 +32,6 @@
|
||||
654330231218E9780063F913 /* insgps.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = insgps.c; path = ../../AHRS/insgps.c; sourceTree = SOURCE_ROOT; };
|
||||
6543304F121980300063F913 /* insgps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = insgps.h; sourceTree = "<group>"; };
|
||||
655268BC121FBD2900410C6E /* ahrscalibration.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ahrscalibration.xml; sourceTree = "<group>"; };
|
||||
655E4A05124B1CFC00687939 /* pios_board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_board.h; sourceTree = "<group>"; };
|
||||
655E4A06124B1CFC00687939 /* STM32103CB_AHRS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STM32103CB_AHRS.h; sourceTree = "<group>"; };
|
||||
655E4A07124B1CFC00687939 /* STM3210E_OP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = STM3210E_OP.h; sourceTree = "<group>"; };
|
||||
65632C62124DC5F700469B77 /* ahrscalibration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrscalibration.h; sourceTree = "<group>"; };
|
||||
65632C63124DC5F700469B77 /* ahrssettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrssettings.h; sourceTree = "<group>"; };
|
||||
65632C64124DC5F700469B77 /* attituderaw.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = attituderaw.h; sourceTree = "<group>"; };
|
||||
65632C65124DC5F700469B77 /* attitudesettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = attitudesettings.h; sourceTree = "<group>"; };
|
||||
65632C66124DC5F700469B77 /* baroaltitude.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = baroaltitude.h; sourceTree = "<group>"; };
|
||||
65632C67124DC5F700469B77 /* gpsposition.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gpsposition.h; sourceTree = "<group>"; };
|
||||
65632C68124DC5F700469B77 /* gpssatellites.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gpssatellites.h; sourceTree = "<group>"; };
|
||||
65632C69124DC5F700469B77 /* gpstime.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gpstime.h; sourceTree = "<group>"; };
|
||||
65632C6A124DC5F700469B77 /* homelocation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = homelocation.h; sourceTree = "<group>"; };
|
||||
65632C6B124DC5F700469B77 /* mixersettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mixersettings.h; sourceTree = "<group>"; };
|
||||
65632C6C124DC5F700469B77 /* mixerstatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mixerstatus.h; sourceTree = "<group>"; };
|
||||
65632C6D124DC5F700469B77 /* vtolsettings.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vtolsettings.h; sourceTree = "<group>"; };
|
||||
65632C6E124DC5F700469B77 /* vtolstatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vtolstatus.h; sourceTree = "<group>"; };
|
||||
657CEEAD121DB6C8007A1FBE /* homelocation.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = homelocation.xml; sourceTree = "<group>"; };
|
||||
657CEEB7121DBC63007A1FBE /* CoordinateConversions.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = CoordinateConversions.c; sourceTree = "<group>"; };
|
||||
657CEEB9121DBC63007A1FBE /* CoordinateConversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoordinateConversions.h; sourceTree = "<group>"; };
|
||||
@ -2599,6 +2583,7 @@
|
||||
65B7E6AE120DF1E2000C1123 /* ahrs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ahrs.c; path = ../../AHRS/ahrs.c; sourceTree = SOURCE_ROOT; };
|
||||
65B7E6B0120DF1E2000C1123 /* ahrs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs.h; sourceTree = "<group>"; };
|
||||
65B7E6B1120DF1E2000C1123 /* ahrs_fsm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ahrs_fsm.h; sourceTree = "<group>"; };
|
||||
65B7E6B3120DF1E2000C1123 /* pios_board.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_board.h; sourceTree = "<group>"; };
|
||||
65B7E6B4120DF1E2000C1123 /* pios_config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pios_config.h; sourceTree = "<group>"; };
|
||||
65B7E6B6120DF1E2000C1123 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = ../../AHRS/Makefile; sourceTree = SOURCE_ROOT; };
|
||||
65B7E6B7120DF1E2000C1123 /* pios_board.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = pios_board.c; path = ../../AHRS/pios_board.c; sourceTree = SOURCE_ROOT; };
|
||||
@ -2608,6 +2593,8 @@
|
||||
65C259561224BFAF0081B6ED /* ahrssettings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ahrssettings.c; sourceTree = "<group>"; };
|
||||
65C259571224BFAF0081B6ED /* baroaltitude.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = baroaltitude.c; sourceTree = "<group>"; };
|
||||
65C259581224BFAF0081B6ED /* gpsposition.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gpsposition.c; sourceTree = "<group>"; };
|
||||
65D2CA841248F9A400B1E7D6 /* mixersettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = mixersettings.xml; sourceTree = "<group>"; };
|
||||
65D2CA851248F9A400B1E7D6 /* mixerstatus.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = mixerstatus.xml; sourceTree = "<group>"; };
|
||||
65E8EF1F11EEA61E00BBF654 /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; name = Makefile; path = ../../OpenPilot/Makefile; sourceTree = SOURCE_ROOT; };
|
||||
65E8EF2011EEA61E00BBF654 /* Makefile.posix */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Makefile.posix; path = ../../OpenPilot/Makefile.posix; sourceTree = SOURCE_ROOT; };
|
||||
65E8EF2311EEA61E00BBF654 /* actuator.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = actuator.c; path = ../../OpenPilot/Modules/Actuator/actuator.c; sourceTree = SOURCE_ROOT; };
|
||||
@ -2942,16 +2929,6 @@
|
||||
path = inc;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
655E4A04124B1CFC00687939 /* Boards */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
655E4A05124B1CFC00687939 /* pios_board.h */,
|
||||
655E4A06124B1CFC00687939 /* STM32103CB_AHRS.h */,
|
||||
655E4A07124B1CFC00687939 /* STM3210E_OP.h */,
|
||||
);
|
||||
path = Boards;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
657CEEB5121DBC49007A1FBE /* flight */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@ -6733,6 +6710,8 @@
|
||||
65B367E3121C2620003EAD18 /* uavobjectdefinition */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
65D2CA841248F9A400B1E7D6 /* mixersettings.xml */,
|
||||
65D2CA851248F9A400B1E7D6 /* mixerstatus.xml */,
|
||||
655268BC121FBD2900410C6E /* ahrscalibration.xml */,
|
||||
659ED317122226B60011010E /* ahrssettings.xml */,
|
||||
65B367E7121C2620003EAD18 /* ahrsstatus.xml */,
|
||||
@ -6795,6 +6774,7 @@
|
||||
6543304F121980300063F913 /* insgps.h */,
|
||||
65B7E6B0120DF1E2000C1123 /* ahrs.h */,
|
||||
65B7E6B1120DF1E2000C1123 /* ahrs_fsm.h */,
|
||||
65B7E6B3120DF1E2000C1123 /* pios_board.h */,
|
||||
65B7E6B4120DF1E2000C1123 /* pios_config.h */,
|
||||
);
|
||||
name = inc;
|
||||
@ -7181,19 +7161,6 @@
|
||||
65E8EF8011EEA61E00BBF654 /* inc */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
65632C62124DC5F700469B77 /* ahrscalibration.h */,
|
||||
65632C63124DC5F700469B77 /* ahrssettings.h */,
|
||||
65632C64124DC5F700469B77 /* attituderaw.h */,
|
||||
65632C65124DC5F700469B77 /* attitudesettings.h */,
|
||||
65632C66124DC5F700469B77 /* baroaltitude.h */,
|
||||
65632C67124DC5F700469B77 /* gpsposition.h */,
|
||||
65632C68124DC5F700469B77 /* gpssatellites.h */,
|
||||
65632C69124DC5F700469B77 /* gpstime.h */,
|
||||
65632C6A124DC5F700469B77 /* homelocation.h */,
|
||||
65632C6B124DC5F700469B77 /* mixersettings.h */,
|
||||
65632C6C124DC5F700469B77 /* mixerstatus.h */,
|
||||
65632C6D124DC5F700469B77 /* vtolsettings.h */,
|
||||
65632C6E124DC5F700469B77 /* vtolstatus.h */,
|
||||
65E8EF8111EEA61E00BBF654 /* actuatorcommand.h */,
|
||||
65E8EF8211EEA61E00BBF654 /* actuatordesired.h */,
|
||||
65E8EF8311EEA61E00BBF654 /* actuatorsettings.h */,
|
||||
@ -7247,7 +7214,6 @@
|
||||
65E8F02F11EFF25C00BBF654 /* PiOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
655E4A04124B1CFC00687939 /* Boards */,
|
||||
65E8F03011EFF25C00BBF654 /* Common */,
|
||||
65E8F03811EFF25C00BBF654 /* inc */,
|
||||
65E8F05711EFF25C00BBF654 /* pios.h */,
|
||||
|
@ -220,15 +220,15 @@ void FGSimulator::processUpdate(const QByteArray& inp)
|
||||
attActual->setData(attActualData);
|
||||
|
||||
// Update gps objects
|
||||
PositionActual::DataFields gpsData;
|
||||
memset(&gpsData, 0, sizeof(PositionActual::DataFields));
|
||||
GPSPosition::DataFields gpsData;
|
||||
memset(&gpsData, 0, sizeof(GPSPosition::DataFields));
|
||||
gpsData.Altitude = altitude;
|
||||
gpsData.Heading = heading;
|
||||
gpsData.Groundspeed = groundspeed;
|
||||
gpsData.Latitude = latitude;
|
||||
gpsData.Longitude = longitude;
|
||||
gpsData.Satellites = 10;
|
||||
gpsData.Status = PositionActual::STATUS_FIX3D;
|
||||
posActual->setData(gpsData);
|
||||
gpsData.Status = GPSPosition::STATUS_FIX3D;
|
||||
gpsPos->setData(gpsData);
|
||||
}
|
||||
|
||||
|
@ -230,9 +230,9 @@ void IL2Simulator::processUpdate(const QByteArray& inp)
|
||||
attActual->setData(attActualData);
|
||||
|
||||
// Update gps objects
|
||||
PositionActual::DataFields gpsData;
|
||||
memset(&gpsData, 0, sizeof(PositionActual::DataFields));
|
||||
gpsData.Altitude = current.Z;
|
||||
GPSPosition::DataFields gpsData;
|
||||
memset(&gpsData, 0, sizeof(GPSPosition::DataFields));
|
||||
gpsData.Altitude = current.Z;
|
||||
gpsData.Heading = current.azimuth;
|
||||
gpsData.Groundspeed = current.groundspeed;
|
||||
gpsData.Latitude = settings.latitude.toFloat() + current.Y * DEG2M;
|
||||
@ -259,6 +259,6 @@ void IL2Simulator::processUpdate(const QByteArray& inp)
|
||||
// issue manual update
|
||||
attActual->updated();
|
||||
altActual->updated();
|
||||
posActual->updated();
|
||||
gpsPos->updated();
|
||||
}
|
||||
|
||||
|
@ -118,7 +118,7 @@ void Simulator::onStart()
|
||||
actDesired = ActuatorDesired::GetInstance(objManager);
|
||||
altActual = BaroAltitude::GetInstance(objManager);
|
||||
attActual = AttitudeActual::GetInstance(objManager);
|
||||
posActual = PositionActual::GetInstance(objManager);
|
||||
gpsPos = GPSPosition::GetInstance(objManager);
|
||||
telStats = GCSTelemetryStats::GetInstance(objManager);
|
||||
|
||||
// Listen to autopilot connection events
|
||||
@ -202,7 +202,7 @@ void Simulator::setupObjects()
|
||||
setupInputObject(actDesired, 75);
|
||||
setupOutputObject(altActual, 250);
|
||||
setupOutputObject(attActual, 75);
|
||||
setupOutputObject(posActual, 250);
|
||||
setupOutputObject(gpsPos, 250);
|
||||
}
|
||||
|
||||
void Simulator::setupInputObject(UAVObject* obj, int updatePeriod)
|
||||
|
@ -39,7 +39,7 @@
|
||||
// #include "uavobjects/altitudeactual.h"
|
||||
#include "uavobjects/baroaltitude.h"
|
||||
#include "uavobjects/attitudeactual.h"
|
||||
#include "uavobjects/positionactual.h"
|
||||
#include "uavobjects/gpsposition.h"
|
||||
#include "uavobjects/gcstelemetrystats.h"
|
||||
|
||||
|
||||
@ -145,7 +145,7 @@ protected:
|
||||
ActuatorDesired* actDesired;
|
||||
BaroAltitude* altActual;
|
||||
AttitudeActual* attActual;
|
||||
PositionActual* posActual;
|
||||
GPSPosition* gpsPos;
|
||||
GCSTelemetryStats* telStats;
|
||||
|
||||
SimulatorSettings settings;
|
||||
|
@ -1466,9 +1466,9 @@ QPointF OPMapGadgetWidget::getLatLon()
|
||||
BaseECEF[2] = obj->getField(QString("ECEF"))->getDouble(2);
|
||||
|
||||
obj = dynamic_cast<UAVDataObject*>(m_objManager->getObject(QString("PositionActual")));
|
||||
NED[0] = obj->getField(QString("NED"))->getDouble(0);
|
||||
NED[1] = obj->getField(QString("NED"))->getDouble(1);
|
||||
NED[2] = obj->getField(QString("NED"))->getDouble(2);
|
||||
NED[0] = obj->getField(QString("North"))->getDouble() / 100;
|
||||
NED[1] = obj->getField(QString("East"))->getDouble() / 100;
|
||||
NED[2] = obj->getField(QString("Down"))->getDouble() / 100;
|
||||
|
||||
Utils::CoordinateConversions().GetLLA(BaseECEF, NED, LLA);
|
||||
return QPointF(LLA[0],LLA[1]);
|
||||
|
@ -351,18 +351,6 @@ void TestDataGen::genTestData()
|
||||
baroAltitudeData.Pressure = baroAltitudeData.Altitude * 0.01 + baroAltitudeData.Temperature;
|
||||
baroAltitude->setData(baroAltitudeData);
|
||||
|
||||
|
||||
// Update gps objects
|
||||
PositionActual::DataFields gpsData;
|
||||
gpsData.Altitude = 0;
|
||||
gpsData.Heading = 0;
|
||||
gpsData.Groundspeed = 0;
|
||||
gpsData.Latitude = 0;
|
||||
gpsData.Longitude = 0;
|
||||
gpsData.Satellites = 10;
|
||||
gps->setData(gpsData);
|
||||
|
||||
|
||||
// Update Attitude Raw data
|
||||
AttitudeRaw::DataFields attData;
|
||||
// attData.accels[0] = 4 * sin(2 * testTime) + 1 * cos(6 * testTime) + 4;
|
||||
|
181
ground/src/plugins/uavobjects/guidancesettings.cpp
Normal file
181
ground/src/plugins/uavobjects/guidancesettings.cpp
Normal file
@ -0,0 +1,181 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 MaxGroundspeedElemNames;
|
||||
MaxGroundspeedElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("MaxGroundspeed"), QString("cm/s"), UAVObjectField::INT32, MaxGroundspeedElemNames, QStringList()) );
|
||||
QStringList GroundVelocityPElemNames;
|
||||
GroundVelocityPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("GroundVelocityP"), QString(""), UAVObjectField::FLOAT32, GroundVelocityPElemNames, QStringList()) );
|
||||
QStringList MaxVerticalSpeedElemNames;
|
||||
MaxVerticalSpeedElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("MaxVerticalSpeed"), QString("cm/s"), UAVObjectField::INT32, MaxVerticalSpeedElemNames, QStringList()) );
|
||||
QStringList VertVelocityPElemNames;
|
||||
VertVelocityPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VertVelocityP"), QString(""), UAVObjectField::FLOAT32, VertVelocityPElemNames, QStringList()) );
|
||||
QStringList VelPElemNames;
|
||||
VelPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VelP"), QString(""), UAVObjectField::FLOAT32, VelPElemNames, QStringList()) );
|
||||
QStringList VelIElemNames;
|
||||
VelIElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VelI"), QString(""), UAVObjectField::FLOAT32, VelIElemNames, QStringList()) );
|
||||
QStringList VelDElemNames;
|
||||
VelDElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VelD"), QString(""), UAVObjectField::FLOAT32, VelDElemNames, QStringList()) );
|
||||
QStringList DownPElemNames;
|
||||
DownPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("DownP"), QString(""), UAVObjectField::FLOAT32, DownPElemNames, QStringList()) );
|
||||
QStringList DownIElemNames;
|
||||
DownIElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("DownI"), QString(""), UAVObjectField::FLOAT32, DownIElemNames, QStringList()) );
|
||||
QStringList DownDElemNames;
|
||||
DownDElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("DownD"), QString(""), UAVObjectField::FLOAT32, DownDElemNames, QStringList()) );
|
||||
QStringList MaxVelIntegralElemNames;
|
||||
MaxVelIntegralElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("MaxVelIntegral"), QString("deg"), UAVObjectField::FLOAT32, MaxVelIntegralElemNames, QStringList()) );
|
||||
QStringList MaxThrottleIntegralElemNames;
|
||||
MaxThrottleIntegralElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("MaxThrottleIntegral"), QString("deg"), UAVObjectField::FLOAT32, MaxThrottleIntegralElemNames, QStringList()) );
|
||||
QStringList VelUpdatePeriodElemNames;
|
||||
VelUpdatePeriodElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VelUpdatePeriod"), QString(""), UAVObjectField::INT32, VelUpdatePeriodElemNames, QStringList()) );
|
||||
QStringList VelPIDUpdatePeriodElemNames;
|
||||
VelPIDUpdatePeriodElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VelPIDUpdatePeriod"), QString(""), UAVObjectField::INT32, VelPIDUpdatePeriodElemNames, 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.MaxGroundspeed = 100;
|
||||
data.GroundVelocityP = 0.1;
|
||||
data.MaxVerticalSpeed = 100;
|
||||
data.VertVelocityP = 0.1;
|
||||
data.VelP = 0.1;
|
||||
data.VelI = 0.1;
|
||||
data.VelD = 0;
|
||||
data.DownP = 0;
|
||||
data.DownI = 0;
|
||||
data.DownD = 0;
|
||||
data.MaxVelIntegral = 2;
|
||||
data.MaxThrottleIntegral = 1;
|
||||
data.VelUpdatePeriod = 100;
|
||||
data.VelPIDUpdatePeriod = 20;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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));
|
||||
}
|
104
ground/src/plugins/uavobjects/guidancesettings.h
Normal file
104
ground/src/plugins/uavobjects/guidancesettings.h
Normal file
@ -0,0 +1,104 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 {
|
||||
qint32 MaxGroundspeed;
|
||||
float GroundVelocityP;
|
||||
qint32 MaxVerticalSpeed;
|
||||
float VertVelocityP;
|
||||
float VelP;
|
||||
float VelI;
|
||||
float VelD;
|
||||
float DownP;
|
||||
float DownI;
|
||||
float DownD;
|
||||
float MaxVelIntegral;
|
||||
float MaxThrottleIntegral;
|
||||
qint32 VelUpdatePeriod;
|
||||
qint32 VelPIDUpdatePeriod;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field MaxGroundspeed information
|
||||
// Field GroundVelocityP information
|
||||
// Field MaxVerticalSpeed information
|
||||
// Field VertVelocityP information
|
||||
// Field VelP information
|
||||
// Field VelI information
|
||||
// Field VelD information
|
||||
// Field DownP information
|
||||
// Field DownI information
|
||||
// Field DownD information
|
||||
// Field MaxVelIntegral information
|
||||
// Field MaxThrottleIntegral information
|
||||
// Field VelUpdatePeriod information
|
||||
// Field VelPIDUpdatePeriod information
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 2428005802U;
|
||||
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
|
216
ground/src/plugins/uavobjects/guidancesettings.py
Normal file
216
ground/src/plugins/uavobjects/guidancesettings.py
Normal file
@ -0,0 +1,216 @@
|
||||
##
|
||||
##############################################################################
|
||||
#
|
||||
# @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(
|
||||
'MaxGroundspeed',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'GroundVelocityP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'MaxVerticalSpeed',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VertVelocityP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VelP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VelI',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VelD',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'DownP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'DownI',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'DownD',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'MaxVelIntegral',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'MaxThrottleIntegral',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VelUpdatePeriod',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VelPIDUpdatePeriod',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class GuidanceSettings(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 2428005802
|
||||
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()
|
@ -42,60 +42,15 @@ PositionActual::PositionActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS,
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList StatusElemNames;
|
||||
StatusElemNames.append("0");
|
||||
QStringList StatusEnumOptions;
|
||||
StatusEnumOptions.append("NoGPS");
|
||||
StatusEnumOptions.append("NoFix");
|
||||
StatusEnumOptions.append("Fix2D");
|
||||
StatusEnumOptions.append("Fix3D");
|
||||
fields.append( new UAVObjectField(QString("Status"), QString(""), UAVObjectField::ENUM, StatusElemNames, StatusEnumOptions) );
|
||||
QStringList LatitudeElemNames;
|
||||
LatitudeElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Latitude"), QString("degrees"), UAVObjectField::FLOAT32, LatitudeElemNames, QStringList()) );
|
||||
QStringList LongitudeElemNames;
|
||||
LongitudeElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Longitude"), QString("degrees"), UAVObjectField::FLOAT32, LongitudeElemNames, QStringList()) );
|
||||
QStringList AltitudeElemNames;
|
||||
AltitudeElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Altitude"), QString("meters"), UAVObjectField::FLOAT32, AltitudeElemNames, QStringList()) );
|
||||
QStringList GeoidSeparationElemNames;
|
||||
GeoidSeparationElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("GeoidSeparation"), QString("meters"), UAVObjectField::FLOAT32, GeoidSeparationElemNames, 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()) );
|
||||
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()) );
|
||||
QStringList PDOPElemNames;
|
||||
PDOPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("PDOP"), QString(""), UAVObjectField::FLOAT32, PDOPElemNames, QStringList()) );
|
||||
QStringList HDOPElemNames;
|
||||
HDOPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("HDOP"), QString(""), UAVObjectField::FLOAT32, HDOPElemNames, QStringList()) );
|
||||
QStringList VDOPElemNames;
|
||||
VDOPElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("VDOP"), QString(""), UAVObjectField::FLOAT32, VDOPElemNames, QStringList()) );
|
||||
QStringList NEDElemNames;
|
||||
NEDElemNames.append("0");
|
||||
NEDElemNames.append("1");
|
||||
NEDElemNames.append("2");
|
||||
fields.append( new UAVObjectField(QString("NED"), QString("m"), UAVObjectField::FLOAT32, NEDElemNames, QStringList()) );
|
||||
QStringList VelElemNames;
|
||||
VelElemNames.append("0");
|
||||
VelElemNames.append("1");
|
||||
VelElemNames.append("2");
|
||||
fields.append( new UAVObjectField(QString("Vel"), QString("m"), UAVObjectField::FLOAT32, VelElemNames, QStringList()) );
|
||||
QStringList NorthElemNames;
|
||||
NorthElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("North"), QString("cm"), UAVObjectField::INT32, NorthElemNames, QStringList()) );
|
||||
QStringList EastElemNames;
|
||||
EastElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("East"), QString("cm"), UAVObjectField::INT32, EastElemNames, QStringList()) );
|
||||
QStringList DownElemNames;
|
||||
DownElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Down"), QString("cm"), UAVObjectField::INT32, DownElemNames, QStringList()) );
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
|
@ -43,50 +43,20 @@ class UAVOBJECTS_EXPORT PositionActual: public UAVDataObject
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint8 Status;
|
||||
float Latitude;
|
||||
float Longitude;
|
||||
float Altitude;
|
||||
float GeoidSeparation;
|
||||
float Heading;
|
||||
float Groundspeed;
|
||||
float Airspeed;
|
||||
float Climbrate;
|
||||
qint8 Satellites;
|
||||
float PDOP;
|
||||
float HDOP;
|
||||
float VDOP;
|
||||
float NED[3];
|
||||
float Vel[3];
|
||||
qint32 North;
|
||||
qint32 East;
|
||||
qint32 Down;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field Status information
|
||||
/* Enumeration options for field Status */
|
||||
typedef enum { STATUS_NOGPS=0, STATUS_NOFIX=1, STATUS_FIX2D=2, STATUS_FIX3D=3 } StatusOptions;
|
||||
// Field Latitude information
|
||||
// Field Longitude information
|
||||
// Field Altitude information
|
||||
// Field GeoidSeparation information
|
||||
// Field Heading information
|
||||
// Field Groundspeed information
|
||||
// Field Airspeed information
|
||||
// Field Climbrate information
|
||||
// Field Satellites information
|
||||
// Field PDOP information
|
||||
// Field HDOP information
|
||||
// Field VDOP information
|
||||
// Field NED information
|
||||
/* Number of elements for field NED */
|
||||
static const quint32 NED_NUMELEM = 3;
|
||||
// Field Vel information
|
||||
/* Number of elements for field Vel */
|
||||
static const quint32 VEL_NUMELEM = 3;
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 3881752126U;
|
||||
static const quint32 OBJID = 3765671478U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
|
@ -38,22 +38,8 @@ from collections import namedtuple
|
||||
# This is a list of instances of the data fields contained in this object
|
||||
_fields = [ \
|
||||
uavobject.UAVObjectField(
|
||||
'Status',
|
||||
'b',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
'0' : 'NoGPS',
|
||||
'1' : 'NoFix',
|
||||
'2' : 'Fix2D',
|
||||
'3' : 'Fix3D',
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Latitude',
|
||||
'f',
|
||||
'North',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
@ -62,8 +48,8 @@ _fields = [ \
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Longitude',
|
||||
'f',
|
||||
'East',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
@ -72,8 +58,8 @@ _fields = [ \
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Altitude',
|
||||
'f',
|
||||
'Down',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
@ -81,126 +67,12 @@ _fields = [ \
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'GeoidSeparation',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Heading',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Groundspeed',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Airspeed',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Climbrate',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Satellites',
|
||||
'b',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'PDOP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'HDOP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'VDOP',
|
||||
'f',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'NED',
|
||||
'f',
|
||||
3,
|
||||
[
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Vel',
|
||||
'f',
|
||||
3,
|
||||
[
|
||||
'0',
|
||||
'1',
|
||||
'2',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class PositionActual(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 3881752126
|
||||
OBJID = 3765671478
|
||||
NAME = "PositionActual"
|
||||
METANAME = "PositionActualMeta"
|
||||
ISSINGLEINST = 1
|
||||
|
134
ground/src/plugins/uavobjects/positiondesired.cpp
Normal file
134
ground/src/plugins/uavobjects/positiondesired.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 NorthElemNames;
|
||||
NorthElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("North"), QString("cm"), UAVObjectField::INT32, NorthElemNames, QStringList()) );
|
||||
QStringList EastElemNames;
|
||||
EastElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("East"), QString("cm"), UAVObjectField::INT32, EastElemNames, QStringList()) );
|
||||
QStringList DownElemNames;
|
||||
DownElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Down"), QString("cm"), UAVObjectField::INT32, DownElemNames, 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_ONCHANGE;
|
||||
metadata.flightTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize object fields with the default values.
|
||||
* If a default value is not specified the object fields
|
||||
* will be initialized to zero.
|
||||
*/
|
||||
void 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));
|
||||
}
|
82
ground/src/plugins/uavobjects/positiondesired.h
Normal file
82
ground/src/plugins/uavobjects/positiondesired.h
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @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 {
|
||||
qint32 North;
|
||||
qint32 East;
|
||||
qint32 Down;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 801433018U;
|
||||
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
|
106
ground/src/plugins/uavobjects/positiondesired.py
Normal file
106
ground/src/plugins/uavobjects/positiondesired.py
Normal file
@ -0,0 +1,106 @@
|
||||
##
|
||||
##############################################################################
|
||||
#
|
||||
# @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(
|
||||
'North',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'East',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Down',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class PositionDesired(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 801433018
|
||||
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()
|
@ -52,7 +52,6 @@ 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");
|
||||
|
@ -43,7 +43,7 @@ class UAVOBJECTS_EXPORT SystemAlarms: public UAVDataObject
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
quint8 Alarm[11];
|
||||
quint8 Alarm[10];
|
||||
|
||||
} __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_GUIDANCE=9, ALARM_AHRSCOMMS=10 } 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_AHRSCOMMS=9 } AlarmElem;
|
||||
/* Number of elements for field Alarm */
|
||||
static const quint32 ALARM_NUMELEM = 11;
|
||||
static const quint32 ALARM_NUMELEM = 10;
|
||||
|
||||
|
||||
// Constants
|
||||
|
@ -40,7 +40,7 @@ _fields = [ \
|
||||
uavobject.UAVObjectField(
|
||||
'Alarm',
|
||||
'b',
|
||||
11,
|
||||
10,
|
||||
[
|
||||
'OutOfMemory',
|
||||
'StackOverflow',
|
||||
@ -51,7 +51,6 @@ _fields = [ \
|
||||
'ManualControl',
|
||||
'Actuator',
|
||||
'Stabilization',
|
||||
'Guidance',
|
||||
'AHRSComms',
|
||||
],
|
||||
{
|
||||
|
@ -1,89 +1,100 @@
|
||||
TEMPLATE = lib
|
||||
TARGET = UAVObjects
|
||||
DEFINES += UAVOBJECTS_LIBRARY
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(uavobjects_dependencies.pri)
|
||||
HEADERS += uavobjects_global.h \
|
||||
uavobject.h \
|
||||
uavmetaobject.h \
|
||||
uavobjectmanager.h \
|
||||
uavdataobject.h \
|
||||
uavobjectfield.h \
|
||||
uavobjectsinit.h \
|
||||
uavobjectsplugin.h \
|
||||
examplesettings.h \
|
||||
ahrsstatus.h \
|
||||
ahrscalibration.h \
|
||||
baroaltitude.h \
|
||||
attitudeactual.h \
|
||||
ahrssettings.h \
|
||||
exampleobject2.h \
|
||||
exampleobject1.h \
|
||||
gcstelemetrystats.h \
|
||||
attituderaw.h \
|
||||
flighttelemetrystats.h \
|
||||
systemstats.h \
|
||||
systemalarms.h \
|
||||
objectpersistence.h \
|
||||
telemetrysettings.h \
|
||||
systemsettings.h \
|
||||
stabilizationsettings.h \
|
||||
manualcontrolsettings.h \
|
||||
manualcontrolcommand.h \
|
||||
attitudedesired.h \
|
||||
actuatorsettings.h \
|
||||
actuatordesired.h \
|
||||
actuatorcommand.h \
|
||||
gpsposition.h \
|
||||
gpstime.h \
|
||||
gpssatellites.h \
|
||||
positionactual.h \
|
||||
flightbatterystate.h \
|
||||
homelocation.h \
|
||||
vtolsettings.h \
|
||||
vtolstatus.h \
|
||||
attitudesettings.h \
|
||||
mixersettings.h \
|
||||
mixerstatus.h
|
||||
SOURCES += uavobject.cpp \
|
||||
uavmetaobject.cpp \
|
||||
uavobjectmanager.cpp \
|
||||
uavdataobject.cpp \
|
||||
uavobjectfield.cpp \
|
||||
uavobjectsinit.cpp \
|
||||
uavobjectsplugin.cpp \
|
||||
ahrsstatus.cpp \
|
||||
ahrscalibration.cpp \
|
||||
baroaltitude.cpp \
|
||||
attitudeactual.cpp \
|
||||
ahrssettings.cpp \
|
||||
examplesettings.cpp \
|
||||
exampleobject2.cpp \
|
||||
exampleobject1.cpp \
|
||||
gcstelemetrystats.cpp \
|
||||
attituderaw.cpp \
|
||||
flighttelemetrystats.cpp \
|
||||
systemstats.cpp \
|
||||
systemalarms.cpp \
|
||||
objectpersistence.cpp \
|
||||
telemetrysettings.cpp \
|
||||
systemsettings.cpp \
|
||||
stabilizationsettings.cpp \
|
||||
manualcontrolsettings.cpp \
|
||||
manualcontrolcommand.cpp \
|
||||
attitudedesired.cpp \
|
||||
actuatorsettings.cpp \
|
||||
actuatordesired.cpp \
|
||||
actuatorcommand.cpp \
|
||||
gpsposition.cpp \
|
||||
gpstime.cpp \
|
||||
gpssatellites.cpp \
|
||||
positionactual.cpp \
|
||||
flightbatterystate.cpp \
|
||||
homelocation.cpp \
|
||||
vtolsettings.cpp \
|
||||
vtolstatus.cpp \
|
||||
attitudesettings.cpp \
|
||||
mixersettings.cpp \
|
||||
mixerstatus.cpp
|
||||
OTHER_FILES += UAVObjects.pluginspec
|
||||
TEMPLATE = lib
|
||||
TARGET = UAVObjects
|
||||
DEFINES += UAVOBJECTS_LIBRARY
|
||||
include(../../openpilotgcsplugin.pri)
|
||||
include(uavobjects_dependencies.pri)
|
||||
HEADERS += uavobjects_global.h \
|
||||
uavobject.h \
|
||||
uavmetaobject.h \
|
||||
uavobjectmanager.h \
|
||||
uavdataobject.h \
|
||||
uavobjectfield.h \
|
||||
uavobjectsinit.h \
|
||||
uavobjectsplugin.h \
|
||||
examplesettings.h \
|
||||
ahrsstatus.h \
|
||||
ahrscalibration.h \
|
||||
baroaltitude.h \
|
||||
attitudeactual.h \
|
||||
ahrssettings.h \
|
||||
exampleobject2.h \
|
||||
exampleobject1.h \
|
||||
gcstelemetrystats.h \
|
||||
attituderaw.h \
|
||||
flighttelemetrystats.h \
|
||||
systemstats.h \
|
||||
systemalarms.h \
|
||||
objectpersistence.h \
|
||||
telemetrysettings.h \
|
||||
systemsettings.h \
|
||||
stabilizationsettings.h \
|
||||
manualcontrolsettings.h \
|
||||
manualcontrolcommand.h \
|
||||
attitudedesired.h \
|
||||
actuatorsettings.h \
|
||||
actuatordesired.h \
|
||||
actuatorcommand.h \
|
||||
gpsposition.h \
|
||||
gpstime.h \
|
||||
gpssatellites.h \
|
||||
positionactual.h \
|
||||
flightbatterystate.h \
|
||||
homelocation.h \
|
||||
vtolsettings.h \
|
||||
vtolstatus.h \
|
||||
attitudesettings.h \
|
||||
mixersettings.h \
|
||||
mixerstatus.h \
|
||||
positiondesired.h \
|
||||
velocitydesired.h \
|
||||
velocityactual.h \
|
||||
vtolstatus.h \
|
||||
guidancesettings.h \
|
||||
attitudesettings.h
|
||||
SOURCES += uavobject.cpp \
|
||||
uavmetaobject.cpp \
|
||||
uavobjectmanager.cpp \
|
||||
uavdataobject.cpp \
|
||||
uavobjectfield.cpp \
|
||||
uavobjectsinit.cpp \
|
||||
uavobjectsplugin.cpp \
|
||||
ahrsstatus.cpp \
|
||||
ahrscalibration.cpp \
|
||||
baroaltitude.cpp \
|
||||
attitudeactual.cpp \
|
||||
ahrssettings.cpp \
|
||||
examplesettings.cpp \
|
||||
exampleobject2.cpp \
|
||||
exampleobject1.cpp \
|
||||
gcstelemetrystats.cpp \
|
||||
attituderaw.cpp \
|
||||
flighttelemetrystats.cpp \
|
||||
systemstats.cpp \
|
||||
systemalarms.cpp \
|
||||
objectpersistence.cpp \
|
||||
telemetrysettings.cpp \
|
||||
systemsettings.cpp \
|
||||
stabilizationsettings.cpp \
|
||||
manualcontrolsettings.cpp \
|
||||
manualcontrolcommand.cpp \
|
||||
attitudedesired.cpp \
|
||||
actuatorsettings.cpp \
|
||||
actuatordesired.cpp \
|
||||
actuatorcommand.cpp \
|
||||
gpsposition.cpp \
|
||||
gpstime.cpp \
|
||||
gpssatellites.cpp \
|
||||
positionactual.cpp \
|
||||
flightbatterystate.cpp \
|
||||
homelocation.cpp \
|
||||
vtolsettings.cpp \
|
||||
vtolstatus.cpp \
|
||||
attitudesettings.cpp \
|
||||
mixersettings.cpp \
|
||||
mixerstatus.cpp \
|
||||
positiondesired.cpp \
|
||||
velocitydesired.cpp \
|
||||
velocityactual.cpp \
|
||||
guidancesettings.cpp \
|
||||
attitudesettings.cpp
|
||||
OTHER_FILES += UAVObjects.pluginspec
|
||||
|
@ -50,6 +50,7 @@
|
||||
#include "gpsposition.h"
|
||||
#include "gpssatellites.h"
|
||||
#include "gpstime.h"
|
||||
#include "guidancesettings.h"
|
||||
#include "homelocation.h"
|
||||
#include "manualcontrolcommand.h"
|
||||
#include "manualcontrolsettings.h"
|
||||
@ -57,11 +58,14 @@
|
||||
#include "mixerstatus.h"
|
||||
#include "objectpersistence.h"
|
||||
#include "positionactual.h"
|
||||
#include "positiondesired.h"
|
||||
#include "stabilizationsettings.h"
|
||||
#include "systemalarms.h"
|
||||
#include "systemsettings.h"
|
||||
#include "systemstats.h"
|
||||
#include "telemetrysettings.h"
|
||||
#include "velocityactual.h"
|
||||
#include "velocitydesired.h"
|
||||
#include "vtolsettings.h"
|
||||
#include "vtolstatus.h"
|
||||
|
||||
@ -92,6 +96,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() );
|
||||
@ -99,11 +104,14 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
|
||||
objMngr->registerObject( new MixerStatus() );
|
||||
objMngr->registerObject( new ObjectPersistence() );
|
||||
objMngr->registerObject( new PositionActual() );
|
||||
objMngr->registerObject( new PositionDesired() );
|
||||
objMngr->registerObject( new StabilizationSettings() );
|
||||
objMngr->registerObject( new SystemAlarms() );
|
||||
objMngr->registerObject( new SystemSettings() );
|
||||
objMngr->registerObject( new SystemStats() );
|
||||
objMngr->registerObject( new TelemetrySettings() );
|
||||
objMngr->registerObject( new VelocityActual() );
|
||||
objMngr->registerObject( new VelocityDesired() );
|
||||
objMngr->registerObject( new VTOLSettings() );
|
||||
objMngr->registerObject( new VTOLStatus() );
|
||||
|
||||
|
134
ground/src/plugins/uavobjects/velocityactual.cpp
Normal file
134
ground/src/plugins/uavobjects/velocityactual.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file velocityactual.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: velocityactual.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 "velocityactual.h"
|
||||
#include "uavobjectfield.h"
|
||||
|
||||
const QString VelocityActual::NAME = QString("VelocityActual");
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
VelocityActual::VelocityActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList NorthElemNames;
|
||||
NorthElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("North"), QString("cm/s"), UAVObjectField::INT32, NorthElemNames, QStringList()) );
|
||||
QStringList EastElemNames;
|
||||
EastElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("East"), QString("cm/s"), UAVObjectField::INT32, EastElemNames, QStringList()) );
|
||||
QStringList DownElemNames;
|
||||
DownElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Down"), QString("cm/s"), UAVObjectField::INT32, DownElemNames, QStringList()) );
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
// Set the default field values
|
||||
setDefaultFieldValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default metadata for this object
|
||||
*/
|
||||
UAVObject::Metadata VelocityActual::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.flightAccess = ACCESS_READWRITE;
|
||||
metadata.gcsAccess = ACCESS_READWRITE;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 0;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.flightTelemetryUpdatePeriod = 1000;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize object fields with the default values.
|
||||
* If a default value is not specified the object fields
|
||||
* will be initialized to zero.
|
||||
*/
|
||||
void VelocityActual::setDefaultFieldValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object data fields
|
||||
*/
|
||||
VelocityActual::DataFields VelocityActual::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object data fields
|
||||
*/
|
||||
void VelocityActual::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* VelocityActual::clone(quint32 instID)
|
||||
{
|
||||
VelocityActual* obj = new VelocityActual();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function to retrieve an instance of the object.
|
||||
*/
|
||||
VelocityActual* VelocityActual::GetInstance(UAVObjectManager* objMngr, quint32 instID)
|
||||
{
|
||||
return dynamic_cast<VelocityActual*>(objMngr->getObject(VelocityActual::OBJID, instID));
|
||||
}
|
82
ground/src/plugins/uavobjects/velocityactual.h
Normal file
82
ground/src/plugins/uavobjects/velocityactual.h
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file velocityactual.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: velocityactual.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 VELOCITYACTUAL_H
|
||||
#define VELOCITYACTUAL_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT VelocityActual: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
qint32 North;
|
||||
qint32 East;
|
||||
qint32 Down;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 1207999624U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
VelocityActual();
|
||||
|
||||
DataFields getData();
|
||||
void setData(const DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
static VelocityActual* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
void setDefaultFieldValues();
|
||||
|
||||
};
|
||||
|
||||
#endif // VELOCITYACTUAL_H
|
106
ground/src/plugins/uavobjects/velocityactual.py
Normal file
106
ground/src/plugins/uavobjects/velocityactual.py
Normal file
@ -0,0 +1,106 @@
|
||||
##
|
||||
##############################################################################
|
||||
#
|
||||
# @file velocityactual.py
|
||||
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
# @brief Implementation of the VelocityActual object. This file has been
|
||||
# automatically generated by the UAVObjectGenerator.
|
||||
#
|
||||
# @note Object definition file: velocityactual.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(
|
||||
'North',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'East',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Down',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class VelocityActual(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 1207999624
|
||||
NAME = "VelocityActual"
|
||||
METANAME = "VelocityActualMeta"
|
||||
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 = VelocityActual()
|
||||
print (x)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#import pdb ; pdb.run('main()')
|
||||
main()
|
134
ground/src/plugins/uavobjects/velocitydesired.cpp
Normal file
134
ground/src/plugins/uavobjects/velocitydesired.cpp
Normal file
@ -0,0 +1,134 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file velocitydesired.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: velocitydesired.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 "velocitydesired.h"
|
||||
#include "uavobjectfield.h"
|
||||
|
||||
const QString VelocityDesired::NAME = QString("VelocityDesired");
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
VelocityDesired::VelocityDesired(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
|
||||
{
|
||||
// Create fields
|
||||
QList<UAVObjectField*> fields;
|
||||
QStringList NorthElemNames;
|
||||
NorthElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("North"), QString("cm/s"), UAVObjectField::INT32, NorthElemNames, QStringList()) );
|
||||
QStringList EastElemNames;
|
||||
EastElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("East"), QString("cm/s"), UAVObjectField::INT32, EastElemNames, QStringList()) );
|
||||
QStringList DownElemNames;
|
||||
DownElemNames.append("0");
|
||||
fields.append( new UAVObjectField(QString("Down"), QString("cm/s"), UAVObjectField::INT32, DownElemNames, QStringList()) );
|
||||
|
||||
// Initialize object
|
||||
initializeFields(fields, (quint8*)&data, NUMBYTES);
|
||||
// Set the default field values
|
||||
setDefaultFieldValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the default metadata for this object
|
||||
*/
|
||||
UAVObject::Metadata VelocityDesired::getDefaultMetadata()
|
||||
{
|
||||
UAVObject::Metadata metadata;
|
||||
metadata.flightAccess = ACCESS_READWRITE;
|
||||
metadata.gcsAccess = ACCESS_READWRITE;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UAVObject::UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.flightTelemetryAcked = 0;
|
||||
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.flightTelemetryUpdatePeriod = 1000;
|
||||
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
|
||||
metadata.loggingUpdatePeriod = 1000;
|
||||
return metadata;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize object fields with the default values.
|
||||
* If a default value is not specified the object fields
|
||||
* will be initialized to zero.
|
||||
*/
|
||||
void VelocityDesired::setDefaultFieldValues()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object data fields
|
||||
*/
|
||||
VelocityDesired::DataFields VelocityDesired::getData()
|
||||
{
|
||||
QMutexLocker locker(mutex);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the object data fields
|
||||
*/
|
||||
void VelocityDesired::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* VelocityDesired::clone(quint32 instID)
|
||||
{
|
||||
VelocityDesired* obj = new VelocityDesired();
|
||||
obj->initialize(instID, this->getMetaObject());
|
||||
return obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Static function to retrieve an instance of the object.
|
||||
*/
|
||||
VelocityDesired* VelocityDesired::GetInstance(UAVObjectManager* objMngr, quint32 instID)
|
||||
{
|
||||
return dynamic_cast<VelocityDesired*>(objMngr->getObject(VelocityDesired::OBJID, instID));
|
||||
}
|
82
ground/src/plugins/uavobjects/velocitydesired.h
Normal file
82
ground/src/plugins/uavobjects/velocitydesired.h
Normal file
@ -0,0 +1,82 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file velocitydesired.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: velocitydesired.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 VELOCITYDESIRED_H
|
||||
#define VELOCITYDESIRED_H
|
||||
|
||||
#include "uavdataobject.h"
|
||||
#include "uavobjectmanager.h"
|
||||
|
||||
class UAVOBJECTS_EXPORT VelocityDesired: public UAVDataObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
// Field structure
|
||||
typedef struct {
|
||||
qint32 North;
|
||||
qint32 East;
|
||||
qint32 Down;
|
||||
|
||||
} __attribute__((packed)) DataFields;
|
||||
|
||||
// Field information
|
||||
// Field North information
|
||||
// Field East information
|
||||
// Field Down information
|
||||
|
||||
|
||||
// Constants
|
||||
static const quint32 OBJID = 305094202U;
|
||||
static const QString NAME;
|
||||
static const bool ISSINGLEINST = 1;
|
||||
static const bool ISSETTINGS = 0;
|
||||
static const quint32 NUMBYTES = sizeof(DataFields);
|
||||
|
||||
// Functions
|
||||
VelocityDesired();
|
||||
|
||||
DataFields getData();
|
||||
void setData(const DataFields& data);
|
||||
Metadata getDefaultMetadata();
|
||||
UAVDataObject* clone(quint32 instID);
|
||||
|
||||
static VelocityDesired* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
|
||||
|
||||
private:
|
||||
DataFields data;
|
||||
|
||||
void setDefaultFieldValues();
|
||||
|
||||
};
|
||||
|
||||
#endif // VELOCITYDESIRED_H
|
106
ground/src/plugins/uavobjects/velocitydesired.py
Normal file
106
ground/src/plugins/uavobjects/velocitydesired.py
Normal file
@ -0,0 +1,106 @@
|
||||
##
|
||||
##############################################################################
|
||||
#
|
||||
# @file velocitydesired.py
|
||||
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
# @brief Implementation of the VelocityDesired object. This file has been
|
||||
# automatically generated by the UAVObjectGenerator.
|
||||
#
|
||||
# @note Object definition file: velocitydesired.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(
|
||||
'North',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'East',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
uavobject.UAVObjectField(
|
||||
'Down',
|
||||
'i',
|
||||
1,
|
||||
[
|
||||
'0',
|
||||
],
|
||||
{
|
||||
}
|
||||
),
|
||||
]
|
||||
|
||||
|
||||
class VelocityDesired(uavobject.UAVObject):
|
||||
## Object constants
|
||||
OBJID = 305094202
|
||||
NAME = "VelocityDesired"
|
||||
METANAME = "VelocityDesiredMeta"
|
||||
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 = VelocityDesired()
|
||||
print (x)
|
||||
|
||||
if __name__ == "__main__":
|
||||
#import pdb ; pdb.run('main()')
|
||||
main()
|
23
ground/src/shared/uavobjectdefinition/guidancesettings.xml
Normal file
23
ground/src/shared/uavobjectdefinition/guidancesettings.xml
Normal file
@ -0,0 +1,23 @@
|
||||
<xml>
|
||||
<object name="GuidanceSettings" singleinstance="true" settings="true">
|
||||
<description>Settings for the @ref GuidanceModule</description>
|
||||
<field name="MaxGroundspeed" units="cm/s" type="int32" elements="1" defaultvalue="100"/>
|
||||
<field name="GroundVelocityP" units="" type="float" elements="1" defaultvalue="0.1"/>
|
||||
<field name="MaxVerticalSpeed" units="cm/s" type="int32" elements="1" defaultvalue="100"/>
|
||||
<field name="VertVelocityP" units="" type="float" elements="1" defaultvalue="0.1"/>
|
||||
<field name="VelP" units="" type="float" elements="1" defaultvalue="0.1"/>
|
||||
<field name="VelI" units="" type="float" elements="1" defaultvalue="0.1"/>
|
||||
<field name="VelD" units="" type="float" elements="1" defaultvalue="0.0"/>
|
||||
<field name="DownP" units="" type="float" elements="1" defaultvalue="0.0"/>
|
||||
<field name="DownI" units="" type="float" elements="1" defaultvalue="0.0"/>
|
||||
<field name="DownD" units="" type="float" elements="1" defaultvalue="0.0"/>
|
||||
<field name="MaxVelIntegral" units="deg" type="float" elements="1" defaultvalue="2"/>
|
||||
<field name="MaxThrottleIntegral" units="deg" type="float" elements="1" defaultvalue="1"/>
|
||||
<field name="VelUpdatePeriod" units="" type="int32" elements="1" defaultvalue="100"/>
|
||||
<field name="VelPIDUpdatePeriod" units="" type="int32" elements="1" defaultvalue="20"/>
|
||||
<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>
|
@ -1,21 +1,9 @@
|
||||
<xml>
|
||||
<object name="PositionActual" singleinstance="true" settings="false">
|
||||
<description>Deprecated for GPS position.</description>
|
||||
<field name="Status" units="" type="enum" elements="1" options="NoGPS,NoFix,Fix2D,Fix3D"/>
|
||||
<field name="Latitude" units="degrees" type="float" elements="1"/>
|
||||
<field name="Longitude" units="degrees" type="float" elements="1"/>
|
||||
<field name="Altitude" units="meters" type="float" elements="1"/>
|
||||
<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"/>
|
||||
<field name="VDOP" units="" type="float" elements="1"/>
|
||||
<field name="NED" units="m" type="float" elements="3"/>
|
||||
<field name="Vel" units="m" type="float" elements="3"/>
|
||||
<description>Contains the current position relative to @ref HomeLocation</description>
|
||||
<field name="North" units="cm" type="int32" elements="1"/>
|
||||
<field name="East" units="cm" type="int32" elements="1"/>
|
||||
<field name="Down" units="cm" type="int32" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||
|
12
ground/src/shared/uavobjectdefinition/positiondesired.xml
Normal file
12
ground/src/shared/uavobjectdefinition/positiondesired.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<xml>
|
||||
<object name="PositionDesired" singleinstance="true" settings="false">
|
||||
<description>The position the craft is trying t achieve. Can come from GCS or @ref PathPlanner </description>
|
||||
<field name="North" units="cm" type="int32" elements="1"/>
|
||||
<field name="East" units="cm" type="int32" elements="1"/>
|
||||
<field name="Down" units="cm" type="int32" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="onchange" period="0"/>
|
||||
<logging updatemode="periodic" period="1000"/>
|
||||
</object>
|
||||
</xml>
|
@ -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,Guidance,AHRSComms"/>
|
||||
elementnames="OutOfMemory,StackOverflow,CPUOverload,EventSystem,SDCard,Telemetry,ManualControl,Actuator,Stabilization,AHRSComms"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="true" updatemode="onchange" period="0"/>
|
||||
<telemetryflight acked="true" updatemode="periodic" period="4000"/>
|
||||
|
12
ground/src/shared/uavobjectdefinition/velocityactual.xml
Normal file
12
ground/src/shared/uavobjectdefinition/velocityactual.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<xml>
|
||||
<object name="VelocityActual" singleinstance="true" settings="false">
|
||||
<description>Updated by @ref AHRSCommsModule and used within @ref GuidanceModulefor velocity control</description>
|
||||
<field name="North" units="cm/s" type="int32" elements="1"/>
|
||||
<field name="East" units="cm/s" type="int32" elements="1"/>
|
||||
<field name="Down" units="cm/s" type="int32" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||
<logging updatemode="periodic" period="1000"/>
|
||||
</object>
|
||||
</xml>
|
12
ground/src/shared/uavobjectdefinition/velocitydesired.xml
Normal file
12
ground/src/shared/uavobjectdefinition/velocitydesired.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<xml>
|
||||
<object name="VelocityDesired" singleinstance="true" settings="false">
|
||||
<description>Used within @ref GuidanceModule to communicate between the task computing the desired velocity and the PID loop to achieve it (running at different rates).</description>
|
||||
<field name="North" units="cm/s" type="int32" elements="1"/>
|
||||
<field name="East" units="cm/s" type="int32" elements="1"/>
|
||||
<field name="Down" units="cm/s" type="int32" elements="1"/>
|
||||
<access gcs="readwrite" flight="readwrite"/>
|
||||
<telemetrygcs acked="false" updatemode="manual" period="0"/>
|
||||
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
|
||||
<logging updatemode="periodic" period="1000"/>
|
||||
</object>
|
||||
</xml>
|
Loading…
x
Reference in New Issue
Block a user