mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-29 14:52:12 +01:00
merged chages 995:1015 into posix branch
(See? That's why I hate branching - thank the gods that subversion has the "merge" command) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1016 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
ca66593709
commit
c7479b796b
@ -57,7 +57,7 @@ FLASH_TOOL = OPENOCD
|
||||
USE_THUMB_MODE = YES
|
||||
|
||||
# List of modules to include
|
||||
MODULES = Telemetry GPS ManualControl Actuator Altitude Attitude Stabilization
|
||||
MODULES = Telemetry GPS ManualControl Actuator Altitude AHRSComms Stabilization
|
||||
#MODULES = Telemetry Example
|
||||
#MODULES = Telemetry MK/MKSerial
|
||||
|
||||
@ -159,10 +159,12 @@ SRC += $(OPUAVOBJ)/manualcontrolcommand.c
|
||||
SRC += $(OPUAVOBJ)/manualcontrolsettings.c
|
||||
SRC += $(OPUAVOBJ)/attitudedesired.c
|
||||
SRC += $(OPUAVOBJ)/stabilizationsettings.c
|
||||
SRC += $(OPUAVOBJ)/ahrsstatus.c
|
||||
SRC += $(OPUAVOBJ)/altitudeactual.c
|
||||
SRC += $(OPUAVOBJ)/attitudeactual.c
|
||||
SRC += $(OPUAVOBJ)/attitudesettings.c
|
||||
SRC += $(OPUAVOBJ)/flightbatterystate.c
|
||||
SRC += $(OPUAVOBJ)/headingactual.c
|
||||
endif
|
||||
|
||||
## PIOS Hardware (STM32F10x)
|
||||
@ -189,6 +191,7 @@ SRC += $(PIOSCOMMON)/pios_sdcard.c
|
||||
SRC += $(PIOSCOMMON)/pios_com.c
|
||||
SRC += $(PIOSCOMMON)/pios_bmp085.c
|
||||
SRC += $(PIOSCOMMON)/pios_opahrs.c
|
||||
SRC += $(PIOSCOMMON)/pios_opahrs_proto.c
|
||||
SRC += $(PIOSCOMMON)/printf-stdarg.c
|
||||
|
||||
## CMSIS for STM32
|
||||
@ -275,21 +278,6 @@ EXTRAINCDIRS += $(OPUAVTALK)
|
||||
EXTRAINCDIRS += $(OPUAVTALKINC)
|
||||
EXTRAINCDIRS += $(OPUAVOBJ)
|
||||
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||
EXTRAINCDIRS += $(MODEXAMPLE)
|
||||
EXTRAINCDIRS += $(MODEXAMPLEINC)
|
||||
EXTRAINCDIRS += $(MODSYSTEMINC)
|
||||
EXTRAINCDIRS += $(MODTELEMETRY)
|
||||
EXTRAINCDIRS += $(MODTELEMETRYINC)
|
||||
EXTRAINCDIRS += $(MODGPS)
|
||||
EXTRAINCDIRS += $(MODGPSINC)
|
||||
EXTRAINCDIRS += $(MODMANUALCONTROL)
|
||||
EXTRAINCDIRS += $(MODMANUALCONTROLINC)
|
||||
EXTRAINCDIRS += $(MODACTUATOR)
|
||||
EXTRAINCDIRS += $(MODACTUATORINC)
|
||||
EXTRAINCDIRS += $(MODALTITUDE)
|
||||
EXTRAINCDIRS += $(MODALTITUDEINC)
|
||||
EXTRAINCDIRS += $(MODATTITUDE)
|
||||
EXTRAINCDIRS += $(MODATTITUDEINC)
|
||||
EXTRAINCDIRS += $(PIOS)
|
||||
EXTRAINCDIRS += $(PIOSINC)
|
||||
EXTRAINCDIRS += $(PIOSSTM32F10X)
|
||||
|
@ -145,10 +145,12 @@ SRC += $(OPUAVOBJ)/manualcontrolcommand.c
|
||||
SRC += $(OPUAVOBJ)/manualcontrolsettings.c
|
||||
SRC += $(OPUAVOBJ)/attitudedesired.c
|
||||
SRC += $(OPUAVOBJ)/stabilizationsettings.c
|
||||
SRC += $(OPUAVOBJ)/ahrsstatus.c
|
||||
SRC += $(OPUAVOBJ)/altitudeactual.c
|
||||
SRC += $(OPUAVOBJ)/attitudeactual.c
|
||||
SRC += $(OPUAVOBJ)/attitudesettings.c
|
||||
SRC += $(OPUAVOBJ)/flightbatterystate.c
|
||||
SRC += $(OPUAVOBJ)/headingactual.c
|
||||
endif
|
||||
|
||||
## PIOS Hardware (posix)
|
||||
@ -193,21 +195,6 @@ EXTRAINCDIRS += $(OPUAVTALK)
|
||||
EXTRAINCDIRS += $(OPUAVTALKINC)
|
||||
EXTRAINCDIRS += $(OPUAVOBJ)
|
||||
EXTRAINCDIRS += $(OPUAVOBJINC)
|
||||
EXTRAINCDIRS += $(MODEXAMPLE)
|
||||
EXTRAINCDIRS += $(MODEXAMPLEINC)
|
||||
EXTRAINCDIRS += $(MODSYSTEMINC)
|
||||
EXTRAINCDIRS += $(MODTELEMETRY)
|
||||
EXTRAINCDIRS += $(MODTELEMETRYINC)
|
||||
EXTRAINCDIRS += $(MODGPS)
|
||||
EXTRAINCDIRS += $(MODGPSINC)
|
||||
EXTRAINCDIRS += $(MODMANUALCONTROL)
|
||||
EXTRAINCDIRS += $(MODMANUALCONTROLINC)
|
||||
EXTRAINCDIRS += $(MODACTUATOR)
|
||||
EXTRAINCDIRS += $(MODACTUATORINC)
|
||||
EXTRAINCDIRS += $(MODALTITUDE)
|
||||
EXTRAINCDIRS += $(MODALTITUDEINC)
|
||||
EXTRAINCDIRS += $(MODATTITUDE)
|
||||
EXTRAINCDIRS += $(MODATTITUDEINC)
|
||||
EXTRAINCDIRS += $(PIOS)
|
||||
EXTRAINCDIRS += $(PIOSINC)
|
||||
EXTRAINCDIRS += $(PIOSPOSIX)
|
||||
|
182
flight/OpenPilot.posix/Modules/AHRSComms/ahrs_comms.c
Normal file
182
flight/OpenPilot.posix/Modules/AHRSComms/ahrs_comms.c
Normal file
@ -0,0 +1,182 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file ahrs_comms.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Module to handle all comms to the AHRS on a periodic basis.
|
||||
*
|
||||
* @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: AttitudeSettings
|
||||
* Output object: AttitudeActual
|
||||
*
|
||||
* This module will periodically update the value of latest attitude solution
|
||||
* that is available from the AHRS.
|
||||
* The module settings can configure how often AHRS is polled for a new solution.
|
||||
*
|
||||
* The module executes in its own thread.
|
||||
*
|
||||
* UAVObjects are automatically generated by the UAVObjectGenerator from
|
||||
* the object definition XML file.
|
||||
*
|
||||
* 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 "ahrs_comms.h"
|
||||
#include "attitudeactual.h"
|
||||
#include "attitudesettings.h"
|
||||
#include "headingactual.h"
|
||||
#include "ahrsstatus.h"
|
||||
#include "alarms.h"
|
||||
|
||||
#include "pios_opahrs.h" // library for OpenPilot AHRS access functions
|
||||
#include "pios_opahrs_proto.h"
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE 400
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY+4)
|
||||
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
static xTaskHandle taskHandle;
|
||||
|
||||
// Private functions
|
||||
static void ahrscommsTask(void* parameters);
|
||||
static void update_attitude_actual(struct opahrs_msg_v1_rsp_attitude * attitude);
|
||||
static void update_heading_actual(struct opahrs_msg_v1_rsp_heading * heading);
|
||||
static void update_ahrs_status(struct opahrs_msg_v1_rsp_serial * serial);
|
||||
|
||||
/**
|
||||
* Initialise the module, called on startup
|
||||
* \returns 0 on success or -1 if initialisation failed
|
||||
*/
|
||||
int32_t AHRSCommsInitialize(void)
|
||||
{
|
||||
PIOS_OPAHRS_Init();
|
||||
|
||||
// Start main task
|
||||
xTaskCreate(ahrscommsTask, (signed char*)"AHRSComms", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module thread, should not return.
|
||||
*/
|
||||
static void ahrscommsTask(void* parameters)
|
||||
{
|
||||
// Main task loop
|
||||
while (1) {
|
||||
struct opahrs_msg_v1 rsp;
|
||||
|
||||
AlarmsSet(SYSTEMALARMS_ALARM_AHRSCOMMS, SYSTEMALARMS_ALARM_CRITICAL);
|
||||
|
||||
/* Spin here until we're in sync */
|
||||
while (PIOS_OPAHRS_resync() != OPAHRS_RESULT_OK) {
|
||||
vTaskDelay(100 / portTICK_RATE_MS);
|
||||
}
|
||||
|
||||
/* Give the other side a chance to keep up */
|
||||
//vTaskDelay(100 / portTICK_RATE_MS);
|
||||
|
||||
if (PIOS_OPAHRS_GetSerial(&rsp) == OPAHRS_RESULT_OK) {
|
||||
update_ahrs_status(&(rsp.payload.user.v.rsp.serial));
|
||||
} else {
|
||||
/* Comms error */
|
||||
continue;
|
||||
}
|
||||
|
||||
AlarmsClear(SYSTEMALARMS_ALARM_AHRSCOMMS);
|
||||
|
||||
/* We're in sync with the AHRS, spin here until an error occurs */
|
||||
while (1) {
|
||||
AttitudeSettingsData settings;
|
||||
|
||||
/* Update settings with latest value */
|
||||
AttitudeSettingsGet(&settings);
|
||||
|
||||
if (PIOS_OPAHRS_GetAttitude(&rsp) == OPAHRS_RESULT_OK) {
|
||||
update_attitude_actual(&(rsp.payload.user.v.rsp.attitude));
|
||||
} else {
|
||||
/* Comms error */
|
||||
break;
|
||||
}
|
||||
|
||||
if (PIOS_OPAHRS_GetHeading(&rsp) == OPAHRS_RESULT_OK) {
|
||||
update_heading_actual(&(rsp.payload.user.v.rsp.heading));
|
||||
} else {
|
||||
/* Comms error */
|
||||
break;
|
||||
}
|
||||
|
||||
/* Wait for the next update interval */
|
||||
vTaskDelay( settings.UpdatePeriod / portTICK_RATE_MS );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void update_attitude_actual(struct opahrs_msg_v1_rsp_attitude * attitude)
|
||||
{
|
||||
AttitudeActualData data;
|
||||
|
||||
data.q1 = attitude->quaternion.q1;
|
||||
data.q2 = attitude->quaternion.q2;
|
||||
data.q3 = attitude->quaternion.q3;
|
||||
data.q4 = attitude->quaternion.q4;
|
||||
|
||||
data.Roll = attitude->euler.roll;
|
||||
data.Pitch = attitude->euler.pitch;
|
||||
data.Yaw = attitude->euler.yaw;
|
||||
|
||||
AttitudeActualSet(&data);
|
||||
}
|
||||
|
||||
static void update_heading_actual(struct opahrs_msg_v1_rsp_heading * heading)
|
||||
{
|
||||
HeadingActualData data;
|
||||
|
||||
data.raw[HEADINGACTUAL_RAW_X] = heading->raw_mag.x;
|
||||
data.raw[HEADINGACTUAL_RAW_Y] = heading->raw_mag.y;
|
||||
data.raw[HEADINGACTUAL_RAW_Z] = heading->raw_mag.z;
|
||||
|
||||
data.heading = heading->heading;
|
||||
|
||||
HeadingActualSet(&data);
|
||||
}
|
||||
|
||||
static void update_ahrs_status(struct opahrs_msg_v1_rsp_serial * serial)
|
||||
{
|
||||
AhrsStatusData data;
|
||||
|
||||
// Get the current object data
|
||||
AhrsStatusGet(&data);
|
||||
|
||||
for (uint8_t i = 0; i < sizeof(serial->serial_bcd); i++) {
|
||||
data.SerialNumber[i] = serial->serial_bcd[i];
|
||||
}
|
||||
|
||||
AhrsStatusSet(&data);
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file attitude.h
|
||||
* @file ahrs_comms.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Module to read the attitude solution from the AHRS on a periodic basis.
|
||||
* @brief Module to handle all comms to the AHRS on a periodic basis.
|
||||
*
|
||||
* @see The GNU Public License (GPL) Version 3
|
||||
*
|
||||
@ -23,12 +23,12 @@
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
#ifndef ATTITUDE_H
|
||||
#define ATTITUDE_H
|
||||
#ifndef AHRS_COMMS_H
|
||||
#define AHRS_COMMS_H
|
||||
|
||||
#include "openpilot.h"
|
||||
|
||||
int32_t AttitudeInitialize(void);
|
||||
int32_t AHRSCommsInitialize(void);
|
||||
|
||||
#endif // ATTITUDE_H
|
||||
#endif // AHRS_COMMS_H
|
||||
|
@ -1,121 +0,0 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file attitude.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Module to read the attitude solution from the AHRS on a periodic basis.
|
||||
*
|
||||
* @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: AttitudeSettings
|
||||
* Output object: AttitudeActual
|
||||
*
|
||||
* This module will periodically update the value of latest attitude solution
|
||||
* that is available from the AHRS.
|
||||
* The module settings can configure how often AHRS is polled for a new solution.
|
||||
*
|
||||
* The module executes in its own thread.
|
||||
*
|
||||
* UAVObjects are automatically generated by the UAVObjectGenerator from
|
||||
* the object definition XML file.
|
||||
*
|
||||
* 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 "attitude.h"
|
||||
#include "attitudeactual.h" // object that will be updated by the module
|
||||
#include "attitudesettings.h" // object holding module settings
|
||||
|
||||
#include "pios_opahrs.h" // library for OpenPilot AHRS access functions
|
||||
|
||||
// Private constants
|
||||
#define STACK_SIZE 200
|
||||
#define TASK_PRIORITY (tskIDLE_PRIORITY+4)
|
||||
|
||||
// Private types
|
||||
|
||||
// Private variables
|
||||
static xTaskHandle taskHandle;
|
||||
|
||||
// Private functions
|
||||
static void attitudeTask(void* parameters);
|
||||
|
||||
/**
|
||||
* Initialise the module, called on startup
|
||||
* \returns 0 on success or -1 if initialisation failed
|
||||
*/
|
||||
int32_t AttitudeInitialize(void)
|
||||
{
|
||||
// Start main task
|
||||
xTaskCreate(attitudeTask, (signed char*)"Attitude", STACK_SIZE, NULL, TASK_PRIORITY, &taskHandle);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Module thread, should not return.
|
||||
*/
|
||||
static void attitudeTask(void* parameters)
|
||||
{
|
||||
AttitudeSettingsData settings;
|
||||
AttitudeActualData data;
|
||||
|
||||
// Main task loop
|
||||
while (1)
|
||||
{
|
||||
// Update settings with latest value
|
||||
AttitudeSettingsGet(&settings);
|
||||
|
||||
// Get the current object data
|
||||
AttitudeActualGet(&data);
|
||||
|
||||
// Query the latest attitude solution from the AHRS
|
||||
PIOS_OPAHRS_ReadAttitude();
|
||||
|
||||
// Update the data
|
||||
data.seq++;
|
||||
data.q1 += 0.111;
|
||||
data.q2 += 1.1;
|
||||
data.q3 += 7.0;
|
||||
data.q4 -= 2.321;
|
||||
|
||||
data.Roll += 0.01;
|
||||
data.Pitch -= 0.03;
|
||||
data.Yaw += 0.05;
|
||||
|
||||
// Update the ExampleObject, after this function is called
|
||||
// notifications to any other modules listening to that object
|
||||
// will be sent and the GCS object will be updated through the
|
||||
// telemetry link. All operations will take place asynchronously
|
||||
// and the following call will return immediately.
|
||||
AttitudeActualSet(&data);
|
||||
|
||||
// Since this module executes at fixed time intervals, we need to
|
||||
// block the task until it is time for the next update.
|
||||
// The settings field is in ms, to convert to RTOS ticks we need
|
||||
// to divide by portTICK_RATE_MS.
|
||||
vTaskDelay( settings.UpdatePeriod / portTICK_RATE_MS );
|
||||
}
|
||||
}
|
@ -76,10 +76,12 @@ void PIOS_Board_Init(void) {
|
||||
|
||||
/* MicroSD Interface
|
||||
*
|
||||
* NOTE: Leave this declared as const static data so that it ends up in the
|
||||
* NOTE: Leave this declared as const data so that it ends up in the
|
||||
* .rodata section (ie. Flash) rather than in the .bss section (RAM).
|
||||
*/
|
||||
void PIOS_SPI_sdcard_irq_handler(void);
|
||||
void DMA1_Channel2_IRQHandler() __attribute__ ((alias ("PIOS_SPI_sdcard_irq_handler")));
|
||||
void DMA1_Channel3_IRQHandler() __attribute__ ((alias ("PIOS_SPI_sdcard_irq_handler")));
|
||||
const struct pios_spi_cfg pios_spi_sdcard_cfg = {
|
||||
.regs = SPI1,
|
||||
.init = {
|
||||
@ -172,10 +174,12 @@ const struct pios_spi_cfg pios_spi_sdcard_cfg = {
|
||||
|
||||
/* AHRS Interface
|
||||
*
|
||||
* NOTE: Leave this declared as const static data so that it ends up in the
|
||||
* NOTE: Leave this declared as const data so that it ends up in the
|
||||
* .rodata section (ie. Flash) rather than in the .bss section (RAM).
|
||||
*/
|
||||
void PIOS_SPI_ahrs_irq_handler(void);
|
||||
void DMA1_Channel4_IRQHandler() __attribute__ ((alias ("PIOS_SPI_ahrs_irq_handler")));
|
||||
void DMA1_Channel5_IRQHandler() __attribute__ ((alias ("PIOS_SPI_ahrs_irq_handler")));
|
||||
const struct pios_spi_cfg pios_spi_ahrs_cfg = {
|
||||
.regs = SPI2,
|
||||
.init = {
|
||||
@ -189,6 +193,7 @@ const struct pios_spi_cfg pios_spi_ahrs_cfg = {
|
||||
.SPI_CPHA = SPI_CPHA_2Edge,
|
||||
.SPI_BaudRatePrescaler = 7 << 3, /* Maximum divider (ie. slowest clock rate) */
|
||||
},
|
||||
.use_crc = TRUE,
|
||||
.dma = {
|
||||
.ahb_clk = RCC_AHBPeriph_DMA1,
|
||||
|
||||
@ -253,7 +258,7 @@ const struct pios_spi_cfg pios_spi_ahrs_cfg = {
|
||||
.init = {
|
||||
.GPIO_Pin = GPIO_Pin_14,
|
||||
.GPIO_Speed = GPIO_Speed_50MHz,
|
||||
.GPIO_Mode = GPIO_Mode_IPU,
|
||||
.GPIO_Mode = GPIO_Mode_IN_FLOATING,
|
||||
},
|
||||
},
|
||||
.mosi = {
|
||||
|
102
flight/OpenPilot.posix/UAVObjects/ahrsstatus.c
Normal file
102
flight/OpenPilot.posix/UAVObjects/ahrsstatus.c
Normal file
@ -0,0 +1,102 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file ahrsstatus.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the AhrsStatus object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: ahrsstatus.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 "ahrsstatus.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 AhrsStatusInitialize()
|
||||
{
|
||||
// Register object with the object manager
|
||||
handle = UAVObjRegister(AHRSSTATUS_OBJID, AHRSSTATUS_NAME, AHRSSTATUS_METANAME, 0,
|
||||
AHRSSTATUS_ISSINGLEINST, AHRSSTATUS_ISSETTINGS, AHRSSTATUS_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)
|
||||
{
|
||||
AhrsStatusData data;
|
||||
UAVObjMetadata metadata;
|
||||
|
||||
// Initialize object fields to their default values
|
||||
UAVObjGetInstanceData(obj, instId, &data);
|
||||
memset(&data, 0, sizeof(AhrsStatusData));
|
||||
|
||||
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 AhrsStatusHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
102
flight/OpenPilot.posix/UAVObjects/headingactual.c
Normal file
102
flight/OpenPilot.posix/UAVObjects/headingactual.c
Normal file
@ -0,0 +1,102 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file headingactual.c
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the HeadingActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: headingactual.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 "headingactual.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 HeadingActualInitialize()
|
||||
{
|
||||
// Register object with the object manager
|
||||
handle = UAVObjRegister(HEADINGACTUAL_OBJID, HEADINGACTUAL_NAME, HEADINGACTUAL_METANAME, 0,
|
||||
HEADINGACTUAL_ISSINGLEINST, HEADINGACTUAL_ISSETTINGS, HEADINGACTUAL_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)
|
||||
{
|
||||
HeadingActualData data;
|
||||
UAVObjMetadata metadata;
|
||||
|
||||
// Initialize object fields to their default values
|
||||
UAVObjGetInstanceData(obj, instId, &data);
|
||||
memset(&data, 0, sizeof(HeadingActualData));
|
||||
|
||||
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 = 500;
|
||||
metadata.gcsTelemetryAcked = 0;
|
||||
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
|
||||
metadata.gcsTelemetryUpdatePeriod = 0;
|
||||
metadata.loggingUpdateMode = UPDATEMODE_NEVER;
|
||||
metadata.loggingUpdatePeriod = 0;
|
||||
UAVObjSetMetadata(obj, &metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get object handle
|
||||
*/
|
||||
UAVObjHandle HeadingActualHandle()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
|
||||
|
74
flight/OpenPilot.posix/UAVObjects/inc/ahrsstatus.h
Normal file
74
flight/OpenPilot.posix/UAVObjects/inc/ahrsstatus.h
Normal file
@ -0,0 +1,74 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file ahrsstatus.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the AhrsStatus object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: ahrsstatus.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 AHRSSTATUS_H
|
||||
#define AHRSSTATUS_H
|
||||
|
||||
// Object constants
|
||||
#define AHRSSTATUS_OBJID 3344048156U
|
||||
#define AHRSSTATUS_NAME "AhrsStatus"
|
||||
#define AHRSSTATUS_METANAME "AhrsStatusMeta"
|
||||
#define AHRSSTATUS_ISSINGLEINST 1
|
||||
#define AHRSSTATUS_ISSETTINGS 0
|
||||
#define AHRSSTATUS_NUMBYTES sizeof(AhrsStatusData)
|
||||
|
||||
// Object access macros
|
||||
#define AhrsStatusGet(dataOut) UAVObjGetData(AhrsStatusHandle(), dataOut)
|
||||
#define AhrsStatusSet(dataIn) UAVObjSetData(AhrsStatusHandle(), dataIn)
|
||||
#define AhrsStatusInstGet(instId, dataOut) UAVObjGetInstanceData(AhrsStatusHandle(), instId, dataOut)
|
||||
#define AhrsStatusInstSet(instId, dataIn) UAVObjSetInstanceData(AhrsStatusHandle(), instId, dataIn)
|
||||
#define AhrsStatusConnectQueue(queue) UAVObjConnectQueue(AhrsStatusHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||
#define AhrsStatusConnectCallback(cb) UAVObjConnectCallback(AhrsStatusHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||
#define AhrsStatusCreateInstance() UAVObjCreateInstance(AhrsStatusHandle())
|
||||
#define AhrsStatusRequestUpdate() UAVObjRequestUpdate(AhrsStatusHandle())
|
||||
#define AhrsStatusRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(AhrsStatusHandle(), instId)
|
||||
#define AhrsStatusUpdated() UAVObjUpdated(AhrsStatusHandle())
|
||||
#define AhrsStatusInstUpdated(instId) UAVObjUpdated(AhrsStatusHandle(), instId)
|
||||
#define AhrsStatusGetMetadata(dataOut) UAVObjGetMetadata(AhrsStatusHandle(), dataOut)
|
||||
#define AhrsStatusSetMetadata(dataIn) UAVObjSetMetadata(AhrsStatusHandle(), dataIn)
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
uint8_t SerialNumber[25];
|
||||
|
||||
} __attribute__((packed)) AhrsStatusData;
|
||||
|
||||
// Field information
|
||||
// Field SerialNumber information
|
||||
/* Number of elements for field SerialNumber */
|
||||
#define AHRSSTATUS_SERIALNUMBER_NUMELEM 25
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t AhrsStatusInitialize();
|
||||
UAVObjHandle AhrsStatusHandle();
|
||||
|
||||
#endif // AHRSSTATUS_H
|
@ -33,7 +33,7 @@
|
||||
#define ATTITUDEACTUAL_H
|
||||
|
||||
// Object constants
|
||||
#define ATTITUDEACTUAL_OBJID 1730350400U
|
||||
#define ATTITUDEACTUAL_OBJID 4233858292U
|
||||
#define ATTITUDEACTUAL_NAME "AttitudeActual"
|
||||
#define ATTITUDEACTUAL_METANAME "AttitudeActualMeta"
|
||||
#define ATTITUDEACTUAL_ISSINGLEINST 1
|
||||
@ -57,7 +57,6 @@
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
uint32_t seq;
|
||||
float q1;
|
||||
float q2;
|
||||
float q3;
|
||||
@ -69,7 +68,6 @@ typedef struct {
|
||||
} __attribute__((packed)) AttitudeActualData;
|
||||
|
||||
// Field information
|
||||
// Field seq information
|
||||
// Field q1 information
|
||||
// Field q2 information
|
||||
// Field q3 information
|
||||
|
78
flight/OpenPilot.posix/UAVObjects/inc/headingactual.h
Normal file
78
flight/OpenPilot.posix/UAVObjects/inc/headingactual.h
Normal file
@ -0,0 +1,78 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
*
|
||||
* @file headingactual.h
|
||||
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
|
||||
* @brief Implementation of the HeadingActual object. This file has been
|
||||
* automatically generated by the UAVObjectGenerator.
|
||||
*
|
||||
* @note Object definition file: headingactual.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 HEADINGACTUAL_H
|
||||
#define HEADINGACTUAL_H
|
||||
|
||||
// Object constants
|
||||
#define HEADINGACTUAL_OBJID 2921442332U
|
||||
#define HEADINGACTUAL_NAME "HeadingActual"
|
||||
#define HEADINGACTUAL_METANAME "HeadingActualMeta"
|
||||
#define HEADINGACTUAL_ISSINGLEINST 1
|
||||
#define HEADINGACTUAL_ISSETTINGS 0
|
||||
#define HEADINGACTUAL_NUMBYTES sizeof(HeadingActualData)
|
||||
|
||||
// Object access macros
|
||||
#define HeadingActualGet(dataOut) UAVObjGetData(HeadingActualHandle(), dataOut)
|
||||
#define HeadingActualSet(dataIn) UAVObjSetData(HeadingActualHandle(), dataIn)
|
||||
#define HeadingActualInstGet(instId, dataOut) UAVObjGetInstanceData(HeadingActualHandle(), instId, dataOut)
|
||||
#define HeadingActualInstSet(instId, dataIn) UAVObjSetInstanceData(HeadingActualHandle(), instId, dataIn)
|
||||
#define HeadingActualConnectQueue(queue) UAVObjConnectQueue(HeadingActualHandle(), queue, EV_MASK_ALL_UPDATES)
|
||||
#define HeadingActualConnectCallback(cb) UAVObjConnectCallback(HeadingActualHandle(), cb, EV_MASK_ALL_UPDATES)
|
||||
#define HeadingActualCreateInstance() UAVObjCreateInstance(HeadingActualHandle())
|
||||
#define HeadingActualRequestUpdate() UAVObjRequestUpdate(HeadingActualHandle())
|
||||
#define HeadingActualRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(HeadingActualHandle(), instId)
|
||||
#define HeadingActualUpdated() UAVObjUpdated(HeadingActualHandle())
|
||||
#define HeadingActualInstUpdated(instId) UAVObjUpdated(HeadingActualHandle(), instId)
|
||||
#define HeadingActualGetMetadata(dataOut) UAVObjGetMetadata(HeadingActualHandle(), dataOut)
|
||||
#define HeadingActualSetMetadata(dataIn) UAVObjSetMetadata(HeadingActualHandle(), dataIn)
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
int16_t raw[3];
|
||||
float heading;
|
||||
|
||||
} __attribute__((packed)) HeadingActualData;
|
||||
|
||||
// Field information
|
||||
// Field raw information
|
||||
/* Array element names for field raw */
|
||||
typedef enum { HEADINGACTUAL_RAW_X=0, HEADINGACTUAL_RAW_Y=1, HEADINGACTUAL_RAW_Z=2, } HeadingActualrawElem;
|
||||
/* Number of elements for field raw */
|
||||
#define HEADINGACTUAL_RAW_NUMELEM 3
|
||||
// Field heading information
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
int32_t HeadingActualInitialize();
|
||||
UAVObjHandle HeadingActualHandle();
|
||||
|
||||
#endif // HEADINGACTUAL_H
|
@ -33,7 +33,7 @@
|
||||
#define SYSTEMALARMS_H
|
||||
|
||||
// Object constants
|
||||
#define SYSTEMALARMS_OBJID 2311311520U
|
||||
#define SYSTEMALARMS_OBJID 2311311584U
|
||||
#define SYSTEMALARMS_NAME "SystemAlarms"
|
||||
#define SYSTEMALARMS_METANAME "SystemAlarmsMeta"
|
||||
#define SYSTEMALARMS_ISSINGLEINST 1
|
||||
@ -57,7 +57,7 @@
|
||||
|
||||
// Object data
|
||||
typedef struct {
|
||||
uint8_t Alarm[9];
|
||||
uint8_t Alarm[10];
|
||||
|
||||
} __attribute__((packed)) SystemAlarmsData;
|
||||
|
||||
@ -66,9 +66,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, } 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 9
|
||||
#define SYSTEMALARMS_ALARM_NUMELEM 10
|
||||
|
||||
|
||||
// Generic interface functions
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "actuatorcommand.h"
|
||||
#include "actuatordesired.h"
|
||||
#include "actuatorsettings.h"
|
||||
#include "ahrsstatus.h"
|
||||
#include "altitudeactual.h"
|
||||
#include "attitudeactual.h"
|
||||
#include "attitudedesired.h"
|
||||
@ -41,6 +42,7 @@
|
||||
#include "flightbatterystate.h"
|
||||
#include "flighttelemetrystats.h"
|
||||
#include "gcstelemetrystats.h"
|
||||
#include "headingactual.h"
|
||||
#include "manualcontrolcommand.h"
|
||||
#include "manualcontrolsettings.h"
|
||||
#include "objectpersistence.h"
|
||||
@ -61,6 +63,7 @@ void UAVObjectsInitializeAll()
|
||||
ActuatorCommandInitialize();
|
||||
ActuatorDesiredInitialize();
|
||||
ActuatorSettingsInitialize();
|
||||
AhrsStatusInitialize();
|
||||
AltitudeActualInitialize();
|
||||
AttitudeActualInitialize();
|
||||
AttitudeDesiredInitialize();
|
||||
@ -71,6 +74,7 @@ void UAVObjectsInitializeAll()
|
||||
FlightBatteryStateInitialize();
|
||||
FlightTelemetryStatsInitialize();
|
||||
GCSTelemetryStatsInitialize();
|
||||
HeadingActualInitialize();
|
||||
ManualControlCommandInitialize();
|
||||
ManualControlSettingsInitialize();
|
||||
ObjectPersistenceInitialize();
|
||||
|
Loading…
x
Reference in New Issue
Block a user