1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-10 18:24:11 +01:00

attituderaw: Replace HeadingActual with AttitudeRaw

AttitudeRaw now includes:
 - magnetometers XYZ (in mG)
 - gyros XYZ (raw ADC samples)
 - accelerometers XYZ (raw ADC samples)
 - placeholder for gyro temp sensors (read as zero for now)

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1289 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
stac 2010-08-14 23:42:14 +00:00 committed by stac
parent 5d635d4233
commit c3e509c2cb
18 changed files with 337 additions and 309 deletions

View File

@ -36,7 +36,6 @@ struct mag_sensor {
uint8_t id[4]; uint8_t id[4];
struct { struct {
int16_t axis[3]; int16_t axis[3];
float heading;
} raw; } raw;
}; };
@ -48,6 +47,18 @@ struct accel_sensor {
} raw; } raw;
}; };
struct gyro_sensor {
struct {
uint16_t x;
uint16_t y;
uint16_t z;
} raw;
struct {
uint16_t xy;
uint16_t z;
} temp;
};
struct attitude_solution { struct attitude_solution {
struct { struct {
float q1; float q1;
@ -65,6 +76,8 @@ struct attitude_solution {
static struct mag_sensor mag_data; static struct mag_sensor mag_data;
static struct accel_sensor accel_data; static struct accel_sensor accel_data;
static struct gyro_sensor gyro_data;
static struct attitude_solution attitude_data = { static struct attitude_solution attitude_data = {
.quaternion = { .quaternion = {
.q1 = 1.011, .q1 = 1.011,
@ -137,14 +150,23 @@ int main()
// Get magnetic readings // Get magnetic readings
PIOS_HMC5843_ReadMag(mag_data.raw.axis); PIOS_HMC5843_ReadMag(mag_data.raw.axis);
// Calculate the heading
mag_data.raw.heading = atan2((double)(mag_data.raw.axis[0]), (double)(-1 * mag_data.raw.axis[1])) * (180 / M_PI);
if(mag_data.raw.heading < 0) mag_data.raw.heading += 360;
// Test ADC // Test ADC
accel_data.raw.x = PIOS_ADC_PinGet(0); accel_data.raw.x = PIOS_ADC_PinGet(2);
accel_data.raw.y = PIOS_ADC_PinGet(1); accel_data.raw.y = PIOS_ADC_PinGet(1);
accel_data.raw.z = PIOS_ADC_PinGet(2); accel_data.raw.z = PIOS_ADC_PinGet(0);
gyro_data.raw.x = PIOS_ADC_PinGet(3);
gyro_data.raw.y = PIOS_ADC_PinGet(4);
gyro_data.raw.z = PIOS_ADC_PinGet(5);
#if 0
/* Turn this on when the temperature ADCs are configured */
gyro_data.temp.xy = PIOS_ADC_PinGet(6);
gyro_data.temp.z = PIOS_ADC_PinGet(7);
#else
gyro_data.temp.xy = 0;
gyro_data.temp.z = 0;
#endif
//PIOS_COM_SendFormattedString(PIOS_COM_AUX, "ADC Values: %d,%d,%d,%d,%d,%d\r\n", PIOS_ADC_PinGet(0), PIOS_ADC_PinGet(1), PIOS_ADC_PinGet(2), PIOS_ADC_PinGet(3), PIOS_ADC_PinGet(4), PIOS_ADC_PinGet(5)); //PIOS_COM_SendFormattedString(PIOS_COM_AUX, "ADC Values: %d,%d,%d,%d,%d,%d\r\n", PIOS_ADC_PinGet(0), PIOS_ADC_PinGet(1), PIOS_ADC_PinGet(2), PIOS_ADC_PinGet(3), PIOS_ADC_PinGet(4), PIOS_ADC_PinGet(5));
@ -243,13 +265,23 @@ void process_spi_request(void)
dump_spi_message(PIOS_COM_AUX, "I", (uint8_t *)&user_tx_v1, sizeof(user_tx_v1)); dump_spi_message(PIOS_COM_AUX, "I", (uint8_t *)&user_tx_v1, sizeof(user_tx_v1));
lfsm_user_set_tx_v1 (&user_tx_v1); lfsm_user_set_tx_v1 (&user_tx_v1);
break; break;
case OPAHRS_MSG_V1_REQ_HEADING: case OPAHRS_MSG_V1_REQ_ATTITUDERAW:
opahrs_msg_v1_init_user_tx (&user_tx_v1, OPAHRS_MSG_V1_RSP_HEADING); opahrs_msg_v1_init_user_tx (&user_tx_v1, OPAHRS_MSG_V1_RSP_ATTITUDERAW);
user_tx_v1.payload.user.v.rsp.heading.raw_mag.x = mag_data.raw.axis[0]; user_tx_v1.payload.user.v.rsp.attituderaw.mags.x = mag_data.raw.axis[0];
user_tx_v1.payload.user.v.rsp.heading.raw_mag.y = mag_data.raw.axis[1]; user_tx_v1.payload.user.v.rsp.attituderaw.mags.y = mag_data.raw.axis[1];
user_tx_v1.payload.user.v.rsp.heading.raw_mag.z = mag_data.raw.axis[2]; user_tx_v1.payload.user.v.rsp.attituderaw.mags.z = mag_data.raw.axis[2];
user_tx_v1.payload.user.v.rsp.heading.heading = mag_data.raw.heading;
dump_spi_message(PIOS_COM_AUX, "H", (uint8_t *)&user_tx_v1, sizeof(user_tx_v1)); user_tx_v1.payload.user.v.rsp.attituderaw.gyros.x = gyro_data.raw.x;
user_tx_v1.payload.user.v.rsp.attituderaw.gyros.y = gyro_data.raw.y;
user_tx_v1.payload.user.v.rsp.attituderaw.gyros.z = gyro_data.raw.z;
user_tx_v1.payload.user.v.rsp.attituderaw.gyros.xy_temp = gyro_data.temp.xy;
user_tx_v1.payload.user.v.rsp.attituderaw.gyros.z_temp = gyro_data.temp.z;
user_tx_v1.payload.user.v.rsp.attituderaw.accels.x = accel_data.raw.x;
user_tx_v1.payload.user.v.rsp.attituderaw.accels.y = accel_data.raw.y;
user_tx_v1.payload.user.v.rsp.attituderaw.accels.z = accel_data.raw.z;
dump_spi_message(PIOS_COM_AUX, "R", (uint8_t *)&user_tx_v1, sizeof(user_tx_v1));
lfsm_user_set_tx_v1 (&user_tx_v1); lfsm_user_set_tx_v1 (&user_tx_v1);
break; break;
case OPAHRS_MSG_V1_REQ_ATTITUDE: case OPAHRS_MSG_V1_REQ_ATTITUDE:

View File

@ -118,105 +118,14 @@ TIM8 | | | |
#define PIOS_COM_AUX 0 #define PIOS_COM_AUX 0
#define PIOS_COM_DEBUG PIOS_COM_AUX #define PIOS_COM_DEBUG PIOS_COM_AUX
#if 0
//------------------------- //-------------------------
// ADC // ADC
// PIOS_ADC_PinGet(0) = Accel Z // PIOS_ADC_PinGet(0) = Accel Z
// PIOS_ADC_PinGet(1) = // PIOS_ADC_PinGet(1) = Accel Y
// PIOS_ADC_PinGet(2) = // PIOS_ADC_PinGet(2) = Accel X
// PIOS_ADC_PinGet(3) = // PIOS_ADC_PinGet(3) = Gyro X
// PIOS_ADC_PinGet(4) = Accel ? // PIOS_ADC_PinGet(4) = Gyro Y
// PIOS_ADC_PinGet(5) = // PIOS_ADC_PinGet(5) = Gyro Z
// PIOS_ADC_PinGet(6) =
// PIOS_ADC_PinGet(7) =
//-------------------------
//#define PIOS_ADC_OVERSAMPLING_RATE 1
#define PIOS_ADC_USE_TEMP_SENSOR 0
#define PIOS_ADC_TEMP_SENSOR_ADC ADC1
#define PIOS_ADC_TEMP_SENSOR_ADC_CHANNEL 1
#define PIOS_ADC_PIN1_GPIO_PORT GPIOA // PA0 (Accel Z)
#define PIOS_ADC_PIN1_GPIO_PIN GPIO_Pin_0 // ADC12_IN0
#define PIOS_ADC_PIN1_GPIO_CHANNEL ADC_Channel_0
#define PIOS_ADC_PIN1_ADC ADC1
#define PIOS_ADC_PIN1_ADC_NUMBER 1
#define PIOS_ADC_PIN2_GPIO_PORT GPIOA // PA1 (Accel Y)
#define PIOS_ADC_PIN2_GPIO_PIN GPIO_Pin_1 // ADC123_IN1
#define PIOS_ADC_PIN2_GPIO_CHANNEL ADC_Channel_1
#define PIOS_ADC_PIN2_ADC ADC1
#define PIOS_ADC_PIN2_ADC_NUMBER 2
#define PIOS_ADC_PIN3_GPIO_PORT GPIOA // PA1 (Accel X)
#define PIOS_ADC_PIN3_GPIO_PIN GPIO_Pin_2 // ADC12_IN2
#define PIOS_ADC_PIN3_GPIO_CHANNEL ADC_Channel_2
#define PIOS_ADC_PIN3_ADC ADC1
#define PIOS_ADC_PIN3_ADC_NUMBER 3
#define PIOS_ADC_PIN4_GPIO_PORT GPIOA // PA4 (Gyro X)
#define PIOS_ADC_PIN4_GPIO_PIN GPIO_Pin_4 // ADC12_IN4
#define PIOS_ADC_PIN4_GPIO_CHANNEL ADC_Channel_4
#define PIOS_ADC_PIN4_ADC ADC1
#define PIOS_ADC_PIN4_ADC_NUMBER 4
#define PIOS_ADC_PIN5_GPIO_PORT GPIOA // PA5 (Gyro Y)
#define PIOS_ADC_PIN5_GPIO_PIN GPIO_Pin_5 // ADC12_IN5
#define PIOS_ADC_PIN5_GPIO_CHANNEL ADC_Channel_5
#define PIOS_ADC_PIN5_ADC ADC2
#define PIOS_ADC_PIN5_ADC_NUMBER 1
#define PIOS_ADC_PIN6_GPIO_PORT GPIOA // PA6 (XY Temp)
#define PIOS_ADC_PIN6_GPIO_PIN GPIO_Pin_6 // ADC12_IN6
#define PIOS_ADC_PIN6_GPIO_CHANNEL ADC_Channel_6
#define PIOS_ADC_PIN6_ADC ADC2
#define PIOS_ADC_PIN6_ADC_NUMBER 2
#define PIOS_ADC_PIN7_GPIO_PORT GPIOA // PA7 (Gyro Z)
#define PIOS_ADC_PIN7_GPIO_PIN GPIO_Pin_7 // ADC12_IN7
#define PIOS_ADC_PIN7_GPIO_CHANNEL ADC_Channel_7
#define PIOS_ADC_PIN7_ADC ADC2
#define PIOS_ADC_PIN7_ADC_NUMBER 3
#define PIOS_ADC_PIN8_GPIO_PORT GPIOB // PB1 (Z Temp)
#define PIOS_ADC_PIN8_GPIO_PIN GPIO_Pin_1 // ADC12_IN9
#define PIOS_ADC_PIN8_GPIO_CHANNEL ADC_Channel_9
#define PIOS_ADC_PIN8_ADC ADC2
#define PIOS_ADC_PIN8_ADC_NUMBER 4
#define PIOS_ADC_NUM_PINS 8
#define PIOS_ADC_PORTS { PIOS_ADC_PIN1_GPIO_PORT, PIOS_ADC_PIN2_GPIO_PORT, PIOS_ADC_PIN3_GPIO_PORT, PIOS_ADC_PIN4_GPIO_PORT, PIOS_ADC_PIN5_GPIO_PORT, PIOS_ADC_PIN6_GPIO_PORT, PIOS_ADC_PIN7_GPIO_PORT, PIOS_ADC_PIN8_GPIO_PORT }
#define PIOS_ADC_PINS { PIOS_ADC_PIN1_GPIO_PIN, PIOS_ADC_PIN2_GPIO_PIN, PIOS_ADC_PIN3_GPIO_PIN, PIOS_ADC_PIN4_GPIO_PIN, PIOS_ADC_PIN5_GPIO_PIN, PIOS_ADC_PIN6_GPIO_PIN, PIOS_ADC_PIN7_GPIO_PIN, PIOS_ADC_PIN8_GPIO_PIN }
#define PIOS_ADC_CHANNELS { PIOS_ADC_PIN1_GPIO_CHANNEL, PIOS_ADC_PIN2_GPIO_CHANNEL, PIOS_ADC_PIN3_GPIO_CHANNEL, PIOS_ADC_PIN4_GPIO_CHANNEL, PIOS_ADC_PIN5_GPIO_CHANNEL, PIOS_ADC_PIN6_GPIO_CHANNEL, PIOS_ADC_PIN7_GPIO_CHANNEL, PIOS_ADC_PIN8_GPIO_CHANNEL }
#define PIOS_ADC_MAPPING { PIOS_ADC_PIN1_ADC, PIOS_ADC_PIN2_ADC, PIOS_ADC_PIN3_ADC, PIOS_ADC_PIN4_ADC, PIOS_ADC_PIN5_ADC, PIOS_ADC_PIN6_ADC, PIOS_ADC_PIN7_ADC, PIOS_ADC_PIN8_ADC }
#define PIOS_ADC_CHANNEL_MAPPING { PIOS_ADC_PIN1_ADC_NUMBER, PIOS_ADC_PIN2_ADC_NUMBER, PIOS_ADC_PIN3_ADC_NUMBER, PIOS_ADC_PIN4_ADC_NUMBER, PIOS_ADC_PIN5_ADC_NUMBER, PIOS_ADC_PIN6_ADC_NUMBER, PIOS_ADC_PIN7_ADC_NUMBER, PIOS_ADC_PIN8_ADC_NUMBER }
#define PIOS_ADC_NUM_CHANNELS (PIOS_ADC_NUM_PINS + PIOS_ADC_USE_TEMP_SENSOR)
#define PIOS_ADC_NUM_ADC_CHANNELS 2
#define PIOS_ADC_USE_ADC2 1
#define PIOS_ADC_CLOCK_FUNCTION RCC_APB2PeriphClockCmd(RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC2, ENABLE)
#define PIOS_ADC_ADCCLK RCC_PCLK2_Div8
/* RCC_PCLK2_Div2: ADC clock = PCLK2/2 */
/* RCC_PCLK2_Div4: ADC clock = PCLK2/4 */
/* RCC_PCLK2_Div6: ADC clock = PCLK2/6 */
/* RCC_PCLK2_Div8: ADC clock = PCLK2/8 */
#define PIOS_ADC_SAMPLE_TIME ADC_SampleTime_239Cycles5
/* Sample time: */
/* With an ADCCLK = 14 MHz and a sampling time of 293.5 cycles: */
/* Tconv = 239.5 + 12.5 = 252 cycles = 18<31>s */
/* (1 / (ADCCLK / CYCLES)) = Sample Time (<28>S) */
#define PIOS_ADC_IRQ_PRIO PIOS_IRQ_PRIO_HIGH
#endif
//-------------------------
// ADC
// PIOS_ADC_PinGet(0) = Accel Z
// PIOS_ADC_PinGet(1) =
// PIOS_ADC_PinGet(2) =
// PIOS_ADC_PinGet(3) =
// PIOS_ADC_PinGet(4) = Accel ?
// PIOS_ADC_PinGet(5) =
// PIOS_ADC_PinGet(6) =
// PIOS_ADC_PinGet(7) =
//------------------------- //-------------------------
//#define PIOS_ADC_OVERSAMPLING_RATE 1 //#define PIOS_ADC_OVERSAMPLING_RATE 1
#define PIOS_ADC_USE_TEMP_SENSOR 0 #define PIOS_ADC_USE_TEMP_SENSOR 0

View File

@ -167,7 +167,7 @@ SRC += $(OPUAVOBJ)/flightsituationactual.c
SRC += $(OPUAVOBJ)/navigationsettings.c SRC += $(OPUAVOBJ)/navigationsettings.c
SRC += $(OPUAVOBJ)/navigationdesired.c SRC += $(OPUAVOBJ)/navigationdesired.c
SRC += $(OPUAVOBJ)/flightbatterystate.c SRC += $(OPUAVOBJ)/flightbatterystate.c
SRC += $(OPUAVOBJ)/headingactual.c SRC += $(OPUAVOBJ)/attituderaw.c
endif endif
## PIOS Hardware (STM32F10x) ## PIOS Hardware (STM32F10x)

View File

@ -4,7 +4,7 @@
* @{ * @{
* @addtogroup AHRSCommsModule AHRSComms Module * @addtogroup AHRSCommsModule AHRSComms Module
* @brief Handles communication with AHRS and updating position * @brief Handles communication with AHRS and updating position
* Specifically updates the the @ref AttitudeActual "AttitudeActual" and @ref HeadingActual "HeadingActual" settings objects * Specifically updates the the @ref AttitudeActual "AttitudeActual" and @ref AttitudeRaw "AttitudeRaw" settings objects
* @{ * @{
* *
* @file ahrs_comms.c * @file ahrs_comms.c
@ -53,7 +53,7 @@
#include "ahrs_comms.h" #include "ahrs_comms.h"
#include "attitudeactual.h" #include "attitudeactual.h"
#include "attitudesettings.h" #include "attitudesettings.h"
#include "headingactual.h" #include "attituderaw.h"
#include "ahrsstatus.h" #include "ahrsstatus.h"
#include "alarms.h" #include "alarms.h"
@ -72,7 +72,7 @@ static xTaskHandle taskHandle;
// Private functions // Private functions
static void ahrscommsTask(void* parameters); static void ahrscommsTask(void* parameters);
static void update_attitude_actual(struct opahrs_msg_v1_rsp_attitude * attitude); 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_attitude_raw(struct opahrs_msg_v1_rsp_attituderaw * attituderaw);
static void update_ahrs_status(struct opahrs_msg_v1_rsp_serial * serial); static void update_ahrs_status(struct opahrs_msg_v1_rsp_serial * serial);
/** /**
@ -131,8 +131,8 @@ static void ahrscommsTask(void* parameters)
break; break;
} }
if (PIOS_OPAHRS_GetHeading(&rsp) == OPAHRS_RESULT_OK) { if (PIOS_OPAHRS_GetAttitudeRaw(&rsp) == OPAHRS_RESULT_OK) {
update_heading_actual(&(rsp.payload.user.v.rsp.heading)); update_attitude_raw(&(rsp.payload.user.v.rsp.attituderaw));
} else { } else {
/* Comms error */ /* Comms error */
break; break;
@ -160,17 +160,26 @@ static void update_attitude_actual(struct opahrs_msg_v1_rsp_attitude * attitude)
AttitudeActualSet(&data); AttitudeActualSet(&data);
} }
static void update_heading_actual(struct opahrs_msg_v1_rsp_heading * heading) static void update_attitude_raw(struct opahrs_msg_v1_rsp_attituderaw * attituderaw)
{ {
HeadingActualData data; AttitudeRawData data;
data.raw[HEADINGACTUAL_RAW_X] = heading->raw_mag.x; data.magnetometers[ATTITUDERAW_MAGNETOMETERS_X] = attituderaw->mags.x;
data.raw[HEADINGACTUAL_RAW_Y] = heading->raw_mag.y; data.magnetometers[ATTITUDERAW_MAGNETOMETERS_Y] = attituderaw->mags.y;
data.raw[HEADINGACTUAL_RAW_Z] = heading->raw_mag.z; data.magnetometers[ATTITUDERAW_MAGNETOMETERS_Z] = attituderaw->mags.z;
data.heading = heading->heading; data.gyros[ATTITUDERAW_GYROS_X] = attituderaw->gyros.x;
data.gyros[ATTITUDERAW_GYROS_Y] = attituderaw->gyros.y;
data.gyros[ATTITUDERAW_GYROS_Z] = attituderaw->gyros.z;
HeadingActualSet(&data); data.gyrotemp[ATTITUDERAW_GYROTEMP_XY] = attituderaw->gyros.xy_temp;
data.gyrotemp[ATTITUDERAW_GYROTEMP_Z] = attituderaw->gyros.z_temp;
data.accelerometers[ATTITUDERAW_ACCELEROMETERS_X] = attituderaw->accels.x;
data.accelerometers[ATTITUDERAW_ACCELEROMETERS_Y] = attituderaw->accels.y;
data.accelerometers[ATTITUDERAW_ACCELEROMETERS_Z] = attituderaw->accels.z;
AttitudeRawSet(&data);
} }
static void update_ahrs_status(struct opahrs_msg_v1_rsp_serial * serial) static void update_ahrs_status(struct opahrs_msg_v1_rsp_serial * serial)

View File

@ -1,12 +1,12 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file headingactual.c * @file attituderaw.c
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the HeadingActual object. This file has been * @brief Implementation of the AttitudeRaw object. This file has been
* automatically generated by the UAVObjectGenerator. * automatically generated by the UAVObjectGenerator.
* *
* @note Object definition file: headingactual.xml. * @note Object definition file: attituderaw.xml.
* This is an automatically generated file. * This is an automatically generated file.
* DO NOT modify manually. * DO NOT modify manually.
* *
@ -30,7 +30,7 @@
*/ */
#include "openpilot.h" #include "openpilot.h"
#include "headingactual.h" #include "attituderaw.h"
// Private variables // Private variables
static UAVObjHandle handle; static UAVObjHandle handle;
@ -43,11 +43,11 @@ static void setDefaults(UAVObjHandle obj, uint16_t instId);
* \return 0 Success * \return 0 Success
* \return -1 Failure * \return -1 Failure
*/ */
int32_t HeadingActualInitialize() int32_t AttitudeRawInitialize()
{ {
// Register object with the object manager // Register object with the object manager
handle = UAVObjRegister(HEADINGACTUAL_OBJID, HEADINGACTUAL_NAME, HEADINGACTUAL_METANAME, 0, handle = UAVObjRegister(ATTITUDERAW_OBJID, ATTITUDERAW_NAME, ATTITUDERAW_METANAME, 0,
HEADINGACTUAL_ISSINGLEINST, HEADINGACTUAL_ISSETTINGS, HEADINGACTUAL_NUMBYTES, &setDefaults); ATTITUDERAW_ISSINGLEINST, ATTITUDERAW_ISSETTINGS, ATTITUDERAW_NUMBYTES, &setDefaults);
// Done // Done
if (handle != 0) if (handle != 0)
@ -67,12 +67,12 @@ int32_t HeadingActualInitialize()
*/ */
static void setDefaults(UAVObjHandle obj, uint16_t instId) static void setDefaults(UAVObjHandle obj, uint16_t instId)
{ {
HeadingActualData data; AttitudeRawData data;
UAVObjMetadata metadata; UAVObjMetadata metadata;
// Initialize object fields to their default values // Initialize object fields to their default values
UAVObjGetInstanceData(obj, instId, &data); UAVObjGetInstanceData(obj, instId, &data);
memset(&data, 0, sizeof(HeadingActualData)); memset(&data, 0, sizeof(AttitudeRawData));
UAVObjSetInstanceData(obj, instId, &data); UAVObjSetInstanceData(obj, instId, &data);
@ -81,7 +81,7 @@ static void setDefaults(UAVObjHandle obj, uint16_t instId)
metadata.gcsAccess = ACCESS_READWRITE; metadata.gcsAccess = ACCESS_READWRITE;
metadata.telemetryAcked = 0; metadata.telemetryAcked = 0;
metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC; metadata.telemetryUpdateMode = UPDATEMODE_PERIODIC;
metadata.telemetryUpdatePeriod = 500; metadata.telemetryUpdatePeriod = 1000;
metadata.gcsTelemetryAcked = 0; metadata.gcsTelemetryAcked = 0;
metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL; metadata.gcsTelemetryUpdateMode = UPDATEMODE_MANUAL;
metadata.gcsTelemetryUpdatePeriod = 0; metadata.gcsTelemetryUpdatePeriod = 0;
@ -93,7 +93,7 @@ static void setDefaults(UAVObjHandle obj, uint16_t instId)
/** /**
* Get object handle * Get object handle
*/ */
UAVObjHandle HeadingActualHandle() UAVObjHandle AttitudeRawHandle()
{ {
return handle; return handle;
} }

View File

@ -0,0 +1,94 @@
/**
******************************************************************************
*
* @file attituderaw.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @brief Implementation of the AttitudeRaw object. This file has been
* automatically generated by the UAVObjectGenerator.
*
* @note Object definition file: attituderaw.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 ATTITUDERAW_H
#define ATTITUDERAW_H
// Object constants
#define ATTITUDERAW_OBJID 4179445416U
#define ATTITUDERAW_NAME "AttitudeRaw"
#define ATTITUDERAW_METANAME "AttitudeRawMeta"
#define ATTITUDERAW_ISSINGLEINST 1
#define ATTITUDERAW_ISSETTINGS 0
#define ATTITUDERAW_NUMBYTES sizeof(AttitudeRawData)
// Object access macros
#define AttitudeRawGet(dataOut) UAVObjGetData(AttitudeRawHandle(), dataOut)
#define AttitudeRawSet(dataIn) UAVObjSetData(AttitudeRawHandle(), dataIn)
#define AttitudeRawInstGet(instId, dataOut) UAVObjGetInstanceData(AttitudeRawHandle(), instId, dataOut)
#define AttitudeRawInstSet(instId, dataIn) UAVObjSetInstanceData(AttitudeRawHandle(), instId, dataIn)
#define AttitudeRawConnectQueue(queue) UAVObjConnectQueue(AttitudeRawHandle(), queue, EV_MASK_ALL_UPDATES)
#define AttitudeRawConnectCallback(cb) UAVObjConnectCallback(AttitudeRawHandle(), cb, EV_MASK_ALL_UPDATES)
#define AttitudeRawCreateInstance() UAVObjCreateInstance(AttitudeRawHandle())
#define AttitudeRawRequestUpdate() UAVObjRequestUpdate(AttitudeRawHandle())
#define AttitudeRawRequestInstUpdate(instId) UAVObjRequestInstanceUpdate(AttitudeRawHandle(), instId)
#define AttitudeRawUpdated() UAVObjUpdated(AttitudeRawHandle())
#define AttitudeRawInstUpdated(instId) UAVObjUpdated(AttitudeRawHandle(), instId)
#define AttitudeRawGetMetadata(dataOut) UAVObjGetMetadata(AttitudeRawHandle(), dataOut)
#define AttitudeRawSetMetadata(dataIn) UAVObjSetMetadata(AttitudeRawHandle(), dataIn)
// Object data
typedef struct {
int16_t magnetometers[3];
uint16_t gyros[3];
uint16_t gyrotemp[2];
uint16_t accelerometers[3];
} __attribute__((packed)) AttitudeRawData;
// Field information
// Field magnetometers information
/* Array element names for field magnetometers */
typedef enum { ATTITUDERAW_MAGNETOMETERS_X=0, ATTITUDERAW_MAGNETOMETERS_Y=1, ATTITUDERAW_MAGNETOMETERS_Z=2 } AttitudeRawmagnetometersElem;
/* Number of elements for field magnetometers */
#define ATTITUDERAW_MAGNETOMETERS_NUMELEM 3
// Field gyros information
/* Array element names for field gyros */
typedef enum { ATTITUDERAW_GYROS_X=0, ATTITUDERAW_GYROS_Y=1, ATTITUDERAW_GYROS_Z=2 } AttitudeRawgyrosElem;
/* Number of elements for field gyros */
#define ATTITUDERAW_GYROS_NUMELEM 3
// Field gyrotemp information
/* Array element names for field gyrotemp */
typedef enum { ATTITUDERAW_GYROTEMP_XY=0, ATTITUDERAW_GYROTEMP_Z=1 } AttitudeRawgyrotempElem;
/* Number of elements for field gyrotemp */
#define ATTITUDERAW_GYROTEMP_NUMELEM 2
// Field accelerometers information
/* Array element names for field accelerometers */
typedef enum { ATTITUDERAW_ACCELEROMETERS_X=0, ATTITUDERAW_ACCELEROMETERS_Y=1, ATTITUDERAW_ACCELEROMETERS_Z=2 } AttitudeRawaccelerometersElem;
/* Number of elements for field accelerometers */
#define ATTITUDERAW_ACCELEROMETERS_NUMELEM 3
// Generic interface functions
int32_t AttitudeRawInitialize();
UAVObjHandle AttitudeRawHandle();
#endif // ATTITUDERAW_H

View File

@ -1,78 +0,0 @@
/**
******************************************************************************
*
* @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

View File

@ -35,6 +35,7 @@
#include "altitudeactual.h" #include "altitudeactual.h"
#include "attitudeactual.h" #include "attitudeactual.h"
#include "attitudedesired.h" #include "attitudedesired.h"
#include "attituderaw.h"
#include "attitudesettings.h" #include "attitudesettings.h"
#include "exampleobject1.h" #include "exampleobject1.h"
#include "exampleobject2.h" #include "exampleobject2.h"
@ -43,7 +44,6 @@
#include "flightsituationactual.h" #include "flightsituationactual.h"
#include "flighttelemetrystats.h" #include "flighttelemetrystats.h"
#include "gcstelemetrystats.h" #include "gcstelemetrystats.h"
#include "headingactual.h"
#include "manualcontrolcommand.h" #include "manualcontrolcommand.h"
#include "manualcontrolsettings.h" #include "manualcontrolsettings.h"
#include "navigationdesired.h" #include "navigationdesired.h"
@ -70,6 +70,7 @@ void UAVObjectsInitializeAll()
AltitudeActualInitialize(); AltitudeActualInitialize();
AttitudeActualInitialize(); AttitudeActualInitialize();
AttitudeDesiredInitialize(); AttitudeDesiredInitialize();
AttitudeRawInitialize();
AttitudeSettingsInitialize(); AttitudeSettingsInitialize();
ExampleObject1Initialize(); ExampleObject1Initialize();
ExampleObject2Initialize(); ExampleObject2Initialize();
@ -78,7 +79,6 @@ void UAVObjectsInitializeAll()
FlightSituationActualInitialize(); FlightSituationActualInitialize();
FlightTelemetryStatsInitialize(); FlightTelemetryStatsInitialize();
GCSTelemetryStatsInitialize(); GCSTelemetryStatsInitialize();
HeadingActualInitialize();
ManualControlCommandInitialize(); ManualControlCommandInitialize();
ManualControlSettingsInitialize(); ManualControlSettingsInitialize();
NavigationDesiredInitialize(); NavigationDesiredInitialize();

View File

@ -222,8 +222,7 @@ extern enum opahrs_result PIOS_OPAHRS_Sync(struct opahrs_msg_v1 *rsp)
return opahrs_msg_v1_recv_rsp (OPAHRS_MSG_V1_RSP_SYNC, rsp); return opahrs_msg_v1_recv_rsp (OPAHRS_MSG_V1_RSP_SYNC, rsp);
} }
enum opahrs_result PIOS_OPAHRS_GetAttitudeRaw(struct opahrs_msg_v1 *rsp)
enum opahrs_result PIOS_OPAHRS_GetHeading(struct opahrs_msg_v1 *rsp)
{ {
struct opahrs_msg_v1 req; struct opahrs_msg_v1 req;
enum opahrs_result rc; enum opahrs_result rc;
@ -232,8 +231,8 @@ enum opahrs_result PIOS_OPAHRS_GetHeading(struct opahrs_msg_v1 *rsp)
return -1; return -1;
} }
/* Make up a serial number request */ /* Make up an attituderaw request */
opahrs_msg_v1_init_user_tx (&req, OPAHRS_MSG_V1_REQ_HEADING); opahrs_msg_v1_init_user_tx (&req, OPAHRS_MSG_V1_REQ_ATTITUDERAW);
/* Send the message until it is received */ /* Send the message until it is received */
rc = opahrs_msg_v1_send_req (&req); rc = opahrs_msg_v1_send_req (&req);
@ -242,7 +241,7 @@ enum opahrs_result PIOS_OPAHRS_GetHeading(struct opahrs_msg_v1 *rsp)
return rc; return rc;
} }
return opahrs_msg_v1_recv_rsp (OPAHRS_MSG_V1_RSP_HEADING, rsp); return opahrs_msg_v1_recv_rsp (OPAHRS_MSG_V1_RSP_ATTITUDERAW, rsp);
} }
enum opahrs_result PIOS_OPAHRS_GetAttitude(struct opahrs_msg_v1 *rsp) enum opahrs_result PIOS_OPAHRS_GetAttitude(struct opahrs_msg_v1 *rsp)
@ -254,7 +253,7 @@ enum opahrs_result PIOS_OPAHRS_GetAttitude(struct opahrs_msg_v1 *rsp)
return -1; return -1;
} }
/* Make up a serial number request */ /* Make up an attitude solution request */
opahrs_msg_v1_init_user_tx (&req, OPAHRS_MSG_V1_REQ_ATTITUDE); opahrs_msg_v1_init_user_tx (&req, OPAHRS_MSG_V1_REQ_ATTITUDE);
/* Send the message until it is received */ /* Send the message until it is received */

View File

@ -42,7 +42,7 @@ extern void PIOS_OPAHRS_Init(void);
extern enum opahrs_result PIOS_OPAHRS_Sync(struct opahrs_msg_v1 *rsp); extern enum opahrs_result PIOS_OPAHRS_Sync(struct opahrs_msg_v1 *rsp);
extern enum opahrs_result PIOS_OPAHRS_GetSerial(struct opahrs_msg_v1 *rsp); extern enum opahrs_result PIOS_OPAHRS_GetSerial(struct opahrs_msg_v1 *rsp);
extern enum opahrs_result PIOS_OPAHRS_GetAttitude(struct opahrs_msg_v1 *rsp); extern enum opahrs_result PIOS_OPAHRS_GetAttitude(struct opahrs_msg_v1 *rsp);
extern enum opahrs_result PIOS_OPAHRS_GetHeading(struct opahrs_msg_v1 *rsp); extern enum opahrs_result PIOS_OPAHRS_GetAttitudeRaw(struct opahrs_msg_v1 *rsp);
extern enum opahrs_result PIOS_OPAHRS_resync(void); extern enum opahrs_result PIOS_OPAHRS_resync(void);
#endif /* PIOS_OPAHRS_H */ #endif /* PIOS_OPAHRS_H */

View File

@ -184,19 +184,19 @@ struct opahrs_msg_v1_req_reset {
struct opahrs_msg_v1_req_serial { struct opahrs_msg_v1_req_serial {
} __attribute__((__packed__)); } __attribute__((__packed__));
struct opahrs_msg_v1_req_heading { struct opahrs_msg_v1_req_attituderaw {
} __attribute__((__packed__)); } __attribute__((__packed__));
struct opahrs_msg_v1_req_attitude { struct opahrs_msg_v1_req_attitude {
} __attribute__((__packed__)); } __attribute__((__packed__));
union opahrs_msg_v1_req { union opahrs_msg_v1_req {
struct opahrs_msg_v1_req_nop nop; struct opahrs_msg_v1_req_nop nop;
struct opahrs_msg_v1_req_sync sync; struct opahrs_msg_v1_req_sync sync;
struct opahrs_msg_v1_req_reset reset; struct opahrs_msg_v1_req_reset reset;
struct opahrs_msg_v1_req_serial serial; struct opahrs_msg_v1_req_serial serial;
struct opahrs_msg_v1_req_heading heading; struct opahrs_msg_v1_req_attituderaw attituderaw;
struct opahrs_msg_v1_req_attitude attitude; struct opahrs_msg_v1_req_attitude attitude;
} __attribute__((__packed__)); } __attribute__((__packed__));
struct opahrs_msg_v1_rsp_sync { struct opahrs_msg_v1_rsp_sync {
@ -212,15 +212,24 @@ struct opahrs_msg_v1_rsp_serial {
uint8_t serial_bcd[25]; uint8_t serial_bcd[25];
} __attribute__((__packed__)); } __attribute__((__packed__));
struct opahrs_msg_v1_rsp_heading { struct opahrs_msg_v1_rsp_attituderaw {
struct { struct {
float scale;
int16_t x; int16_t x;
int16_t y; int16_t y;
int16_t z; int16_t z;
} raw_mag; } mags;
struct {
uint16_t heading; uint16_t x;
uint16_t y;
uint16_t z;
uint16_t xy_temp;
uint16_t z_temp;
} gyros;
struct {
uint16_t x;
uint16_t y;
uint16_t z;
} accels;
} __attribute__((__packed__)); } __attribute__((__packed__));
struct opahrs_msg_v1_rsp_attitude { struct opahrs_msg_v1_rsp_attitude {
@ -238,10 +247,10 @@ struct opahrs_msg_v1_rsp_attitude {
} __attribute__((__packed__)); } __attribute__((__packed__));
union opahrs_msg_v1_rsp { union opahrs_msg_v1_rsp {
struct opahrs_msg_v1_rsp_sync sync; struct opahrs_msg_v1_rsp_sync sync;
struct opahrs_msg_v1_rsp_serial serial; struct opahrs_msg_v1_rsp_serial serial;
struct opahrs_msg_v1_rsp_heading heading; struct opahrs_msg_v1_rsp_attituderaw attituderaw;
struct opahrs_msg_v1_rsp_attitude attitude; struct opahrs_msg_v1_rsp_attitude attitude;
} __attribute__((__packed__)); } __attribute__((__packed__));
enum opahrs_msg_v1_tag { enum opahrs_msg_v1_tag {
@ -249,12 +258,12 @@ enum opahrs_msg_v1_tag {
OPAHRS_MSG_V1_REQ_SYNC, OPAHRS_MSG_V1_REQ_SYNC,
OPAHRS_MSG_V1_REQ_RESET, OPAHRS_MSG_V1_REQ_RESET,
OPAHRS_MSG_V1_REQ_SERIAL, OPAHRS_MSG_V1_REQ_SERIAL,
OPAHRS_MSG_V1_REQ_HEADING, OPAHRS_MSG_V1_REQ_ATTITUDERAW,
OPAHRS_MSG_V1_REQ_ATTITUDE, OPAHRS_MSG_V1_REQ_ATTITUDE,
OPAHRS_MSG_V1_RSP_SYNC, OPAHRS_MSG_V1_RSP_SYNC,
OPAHRS_MSG_V1_RSP_SERIAL, OPAHRS_MSG_V1_RSP_SERIAL,
OPAHRS_MSG_V1_RSP_HEADING, OPAHRS_MSG_V1_RSP_ATTITUDERAW,
OPAHRS_MSG_V1_RSP_ATTITUDE, OPAHRS_MSG_V1_RSP_ATTITUDE,
}; };

View File

@ -1,7 +1,7 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file headingactual.cpp * @file attituderaw.cpp
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
@ -9,7 +9,7 @@
* @addtogroup UAVObjectsPlugin UAVObjects Plugin * @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{ * @{
* *
* @note Object definition file: headingactual.xml. * @note Object definition file: attituderaw.xml.
* This is an automatically generated file. * This is an automatically generated file.
* DO NOT modify manually. * DO NOT modify manually.
* *
@ -30,26 +30,37 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#include "headingactual.h" #include "attituderaw.h"
#include "uavobjectfield.h" #include "uavobjectfield.h"
const QString HeadingActual::NAME = QString("HeadingActual"); const QString AttitudeRaw::NAME = QString("AttitudeRaw");
/** /**
* Constructor * Constructor
*/ */
HeadingActual::HeadingActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) AttitudeRaw::AttitudeRaw(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME)
{ {
// Create fields // Create fields
QList<UAVObjectField*> fields; QList<UAVObjectField*> fields;
QStringList rawElemNames; QStringList magnetometersElemNames;
rawElemNames.append("X"); magnetometersElemNames.append("X");
rawElemNames.append("Y"); magnetometersElemNames.append("Y");
rawElemNames.append("Z"); magnetometersElemNames.append("Z");
fields.append( new UAVObjectField(QString("raw"), QString("mGa"), UAVObjectField::INT16, rawElemNames, QStringList()) ); fields.append( new UAVObjectField(QString("magnetometers"), QString("mGa"), UAVObjectField::INT16, magnetometersElemNames, QStringList()) );
QStringList headingElemNames; QStringList gyrosElemNames;
headingElemNames.append("0"); gyrosElemNames.append("X");
fields.append( new UAVObjectField(QString("heading"), QString("degrees"), UAVObjectField::FLOAT32, headingElemNames, QStringList()) ); gyrosElemNames.append("Y");
gyrosElemNames.append("Z");
fields.append( new UAVObjectField(QString("gyros"), QString("raw"), UAVObjectField::UINT16, gyrosElemNames, QStringList()) );
QStringList gyrotempElemNames;
gyrotempElemNames.append("XY");
gyrotempElemNames.append("Z");
fields.append( new UAVObjectField(QString("gyrotemp"), QString("raw"), UAVObjectField::UINT16, gyrotempElemNames, QStringList()) );
QStringList accelerometersElemNames;
accelerometersElemNames.append("X");
accelerometersElemNames.append("Y");
accelerometersElemNames.append("Z");
fields.append( new UAVObjectField(QString("accelerometers"), QString("raw"), UAVObjectField::UINT16, accelerometersElemNames, QStringList()) );
// Initialize object // Initialize object
initializeFields(fields, (quint8*)&data, NUMBYTES); initializeFields(fields, (quint8*)&data, NUMBYTES);
@ -60,7 +71,7 @@ HeadingActual::HeadingActual(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, N
/** /**
* Get the default metadata for this object * Get the default metadata for this object
*/ */
UAVObject::Metadata HeadingActual::getDefaultMetadata() UAVObject::Metadata AttitudeRaw::getDefaultMetadata()
{ {
UAVObject::Metadata metadata; UAVObject::Metadata metadata;
metadata.flightAccess = ACCESS_READWRITE; metadata.flightAccess = ACCESS_READWRITE;
@ -70,7 +81,7 @@ UAVObject::Metadata HeadingActual::getDefaultMetadata()
metadata.gcsTelemetryUpdatePeriod = 0; metadata.gcsTelemetryUpdatePeriod = 0;
metadata.flightTelemetryAcked = 0; metadata.flightTelemetryAcked = 0;
metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC; metadata.flightTelemetryUpdateMode = UAVObject::UPDATEMODE_PERIODIC;
metadata.flightTelemetryUpdatePeriod = 500; metadata.flightTelemetryUpdatePeriod = 1000;
metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER; metadata.loggingUpdateMode = UAVObject::UPDATEMODE_NEVER;
metadata.loggingUpdatePeriod = 0; metadata.loggingUpdatePeriod = 0;
return metadata; return metadata;
@ -81,7 +92,7 @@ UAVObject::Metadata HeadingActual::getDefaultMetadata()
* If a default value is not specified the object fields * If a default value is not specified the object fields
* will be initialized to zero. * will be initialized to zero.
*/ */
void HeadingActual::setDefaultFieldValues() void AttitudeRaw::setDefaultFieldValues()
{ {
} }
@ -89,7 +100,7 @@ void HeadingActual::setDefaultFieldValues()
/** /**
* Get the object data fields * Get the object data fields
*/ */
HeadingActual::DataFields HeadingActual::getData() AttitudeRaw::DataFields AttitudeRaw::getData()
{ {
QMutexLocker locker(mutex); QMutexLocker locker(mutex);
return data; return data;
@ -98,7 +109,7 @@ HeadingActual::DataFields HeadingActual::getData()
/** /**
* Set the object data fields * Set the object data fields
*/ */
void HeadingActual::setData(const DataFields& data) void AttitudeRaw::setData(const DataFields& data)
{ {
QMutexLocker locker(mutex); QMutexLocker locker(mutex);
// Get metadata // Get metadata
@ -117,9 +128,9 @@ void HeadingActual::setData(const DataFields& data)
* Do not use this function directly to create new instances, the * Do not use this function directly to create new instances, the
* UAVObjectManager should be used instead. * UAVObjectManager should be used instead.
*/ */
UAVDataObject* HeadingActual::clone(quint32 instID) UAVDataObject* AttitudeRaw::clone(quint32 instID)
{ {
HeadingActual* obj = new HeadingActual(); AttitudeRaw* obj = new AttitudeRaw();
obj->initialize(instID, this->getMetaObject()); obj->initialize(instID, this->getMetaObject());
return obj; return obj;
} }
@ -127,7 +138,7 @@ UAVDataObject* HeadingActual::clone(quint32 instID)
/** /**
* Static function to retrieve an instance of the object. * Static function to retrieve an instance of the object.
*/ */
HeadingActual* HeadingActual::GetInstance(UAVObjectManager* objMngr, quint32 instID) AttitudeRaw* AttitudeRaw::GetInstance(UAVObjectManager* objMngr, quint32 instID)
{ {
return dynamic_cast<HeadingActual*>(objMngr->getObject(HeadingActual::OBJID, instID)); return dynamic_cast<AttitudeRaw*>(objMngr->getObject(AttitudeRaw::OBJID, instID));
} }

View File

@ -1,7 +1,7 @@
/** /**
****************************************************************************** ******************************************************************************
* *
* @file headingactual.h * @file attituderaw.h
* @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
* @see The GNU Public License (GPL) Version 3 * @see The GNU Public License (GPL) Version 3
* @addtogroup GCSPlugins GCS Plugins * @addtogroup GCSPlugins GCS Plugins
@ -9,7 +9,7 @@
* @addtogroup UAVObjectsPlugin UAVObjects Plugin * @addtogroup UAVObjectsPlugin UAVObjects Plugin
* @{ * @{
* *
* @note Object definition file: headingactual.xml. * @note Object definition file: attituderaw.xml.
* This is an automatically generated file. * This is an automatically generated file.
* DO NOT modify manually. * DO NOT modify manually.
* *
@ -30,49 +30,65 @@
* with this program; if not, write to the Free Software Foundation, Inc., * with this program; if not, write to the Free Software Foundation, Inc.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifndef HEADINGACTUAL_H #ifndef ATTITUDERAW_H
#define HEADINGACTUAL_H #define ATTITUDERAW_H
#include "uavdataobject.h" #include "uavdataobject.h"
#include "uavobjectmanager.h" #include "uavobjectmanager.h"
class UAVOBJECTS_EXPORT HeadingActual: public UAVDataObject class UAVOBJECTS_EXPORT AttitudeRaw: public UAVDataObject
{ {
Q_OBJECT Q_OBJECT
public: public:
// Field structure // Field structure
typedef struct { typedef struct {
qint16 raw[3]; qint16 magnetometers[3];
float heading; quint16 gyros[3];
quint16 gyrotemp[2];
quint16 accelerometers[3];
} __attribute__((packed)) DataFields; } __attribute__((packed)) DataFields;
// Field information // Field information
// Field raw information // Field magnetometers information
/* Array element names for field raw */ /* Array element names for field magnetometers */
typedef enum { RAW_X=0, RAW_Y=1, RAW_Z=2 } rawElem; typedef enum { MAGNETOMETERS_X=0, MAGNETOMETERS_Y=1, MAGNETOMETERS_Z=2 } magnetometersElem;
/* Number of elements for field raw */ /* Number of elements for field magnetometers */
static const quint32 RAW_NUMELEM = 3; static const quint32 MAGNETOMETERS_NUMELEM = 3;
// Field heading information // Field gyros information
/* Array element names for field gyros */
typedef enum { GYROS_X=0, GYROS_Y=1, GYROS_Z=2 } gyrosElem;
/* Number of elements for field gyros */
static const quint32 GYROS_NUMELEM = 3;
// Field gyrotemp information
/* Array element names for field gyrotemp */
typedef enum { GYROTEMP_XY=0, GYROTEMP_Z=1 } gyrotempElem;
/* Number of elements for field gyrotemp */
static const quint32 GYROTEMP_NUMELEM = 2;
// Field accelerometers information
/* Array element names for field accelerometers */
typedef enum { ACCELEROMETERS_X=0, ACCELEROMETERS_Y=1, ACCELEROMETERS_Z=2 } accelerometersElem;
/* Number of elements for field accelerometers */
static const quint32 ACCELEROMETERS_NUMELEM = 3;
// Constants // Constants
static const quint32 OBJID = 2921442332U; static const quint32 OBJID = 4179445416U;
static const QString NAME; static const QString NAME;
static const bool ISSINGLEINST = 1; static const bool ISSINGLEINST = 1;
static const bool ISSETTINGS = 0; static const bool ISSETTINGS = 0;
static const quint32 NUMBYTES = sizeof(DataFields); static const quint32 NUMBYTES = sizeof(DataFields);
// Functions // Functions
HeadingActual(); AttitudeRaw();
DataFields getData(); DataFields getData();
void setData(const DataFields& data); void setData(const DataFields& data);
Metadata getDefaultMetadata(); Metadata getDefaultMetadata();
UAVDataObject* clone(quint32 instID); UAVDataObject* clone(quint32 instID);
static HeadingActual* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0); static AttitudeRaw* GetInstance(UAVObjectManager* objMngr, quint32 instID = 0);
private: private:
DataFields data; DataFields data;
@ -81,4 +97,4 @@ private:
}; };
#endif // HEADINGACTUAL_H #endif // ATTITUDERAW_H

View File

@ -1,12 +1,12 @@
## ##
############################################################################## ##############################################################################
# #
# @file headingactual.py # @file attituderaw.py
# @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. # @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
# @brief Implementation of the HeadingActual object. This file has been # @brief Implementation of the AttitudeRaw object. This file has been
# automatically generated by the UAVObjectGenerator. # automatically generated by the UAVObjectGenerator.
# #
# @note Object definition file: headingactual.xml. # @note Object definition file: attituderaw.xml.
# This is an automatically generated file. # This is an automatically generated file.
# DO NOT modify manually. # DO NOT modify manually.
# #
@ -38,7 +38,7 @@ from collections import namedtuple
# This is a list of instances of the data fields contained in this object # This is a list of instances of the data fields contained in this object
_fields = [ \ _fields = [ \
uavobject.UAVObjectField( uavobject.UAVObjectField(
'raw', 'magnetometers',
'h', 'h',
3, 3,
[ [
@ -50,11 +50,36 @@ _fields = [ \
} }
), ),
uavobject.UAVObjectField( uavobject.UAVObjectField(
'heading', 'gyros',
'f', 'H',
1, 3,
[ [
'0', 'X',
'Y',
'Z',
],
{
}
),
uavobject.UAVObjectField(
'gyrotemp',
'H',
2,
[
'XY',
'Z',
],
{
}
),
uavobject.UAVObjectField(
'accelerometers',
'H',
3,
[
'X',
'Y',
'Z',
], ],
{ {
} }
@ -62,11 +87,11 @@ _fields = [ \
] ]
class HeadingActual(uavobject.UAVObject): class AttitudeRaw(uavobject.UAVObject):
## Object constants ## Object constants
OBJID = 2921442332 OBJID = 4179445416
NAME = "HeadingActual" NAME = "AttitudeRaw"
METANAME = "HeadingActualMeta" METANAME = "AttitudeRawMeta"
ISSINGLEINST = 1 ISSINGLEINST = 1
ISSETTINGS = 0 ISSETTINGS = 0
@ -90,7 +115,7 @@ class HeadingActual(uavobject.UAVObject):
def main(): def main():
# Instantiate the object and dump out some interesting info # Instantiate the object and dump out some interesting info
x = HeadingActual() x = AttitudeRaw()
print (x) print (x)
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -19,7 +19,7 @@ HEADERS += uavobjects_global.h \
exampleobject2.h \ exampleobject2.h \
exampleobject1.h \ exampleobject1.h \
gcstelemetrystats.h \ gcstelemetrystats.h \
headingactual.h \ attituderaw.h \
flighttelemetrystats.h \ flighttelemetrystats.h \
systemstats.h \ systemstats.h \
systemalarms.h \ systemalarms.h \
@ -53,7 +53,7 @@ SOURCES += uavobject.cpp \
exampleobject2.cpp \ exampleobject2.cpp \
exampleobject1.cpp \ exampleobject1.cpp \
gcstelemetrystats.cpp \ gcstelemetrystats.cpp \
headingactual.cpp \ attituderaw.cpp \
flighttelemetrystats.cpp \ flighttelemetrystats.cpp \
systemstats.cpp \ systemstats.cpp \
systemalarms.cpp \ systemalarms.cpp \

View File

@ -37,6 +37,7 @@
#include "altitudeactual.h" #include "altitudeactual.h"
#include "attitudeactual.h" #include "attitudeactual.h"
#include "attitudedesired.h" #include "attitudedesired.h"
#include "attituderaw.h"
#include "attitudesettings.h" #include "attitudesettings.h"
#include "exampleobject1.h" #include "exampleobject1.h"
#include "exampleobject2.h" #include "exampleobject2.h"
@ -45,7 +46,6 @@
#include "flightsituationactual.h" #include "flightsituationactual.h"
#include "flighttelemetrystats.h" #include "flighttelemetrystats.h"
#include "gcstelemetrystats.h" #include "gcstelemetrystats.h"
#include "headingactual.h"
#include "manualcontrolcommand.h" #include "manualcontrolcommand.h"
#include "manualcontrolsettings.h" #include "manualcontrolsettings.h"
#include "navigationdesired.h" #include "navigationdesired.h"
@ -72,6 +72,7 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new AltitudeActual() ); objMngr->registerObject( new AltitudeActual() );
objMngr->registerObject( new AttitudeActual() ); objMngr->registerObject( new AttitudeActual() );
objMngr->registerObject( new AttitudeDesired() ); objMngr->registerObject( new AttitudeDesired() );
objMngr->registerObject( new AttitudeRaw() );
objMngr->registerObject( new AttitudeSettings() ); objMngr->registerObject( new AttitudeSettings() );
objMngr->registerObject( new ExampleObject1() ); objMngr->registerObject( new ExampleObject1() );
objMngr->registerObject( new ExampleObject2() ); objMngr->registerObject( new ExampleObject2() );
@ -80,7 +81,6 @@ void UAVObjectsInitialize(UAVObjectManager* objMngr)
objMngr->registerObject( new FlightSituationActual() ); objMngr->registerObject( new FlightSituationActual() );
objMngr->registerObject( new FlightTelemetryStats() ); objMngr->registerObject( new FlightTelemetryStats() );
objMngr->registerObject( new GCSTelemetryStats() ); objMngr->registerObject( new GCSTelemetryStats() );
objMngr->registerObject( new HeadingActual() );
objMngr->registerObject( new ManualControlCommand() ); objMngr->registerObject( new ManualControlCommand() );
objMngr->registerObject( new ManualControlSettings() ); objMngr->registerObject( new ManualControlSettings() );
objMngr->registerObject( new NavigationDesired() ); objMngr->registerObject( new NavigationDesired() );

View File

@ -0,0 +1,12 @@
<xml>
<object name="AttitudeRaw" singleinstance="true" settings="false">
<field name="magnetometers" units="mGa" type="int16" elementnames="X,Y,Z"/>
<field name="gyros" units="raw" type="uint16" elementnames="X,Y,Z"/>
<field name="gyrotemp" units="raw" type="uint16" elementnames="XY,Z"/>
<field name="accelerometers" units="raw" type="uint16" elementnames="X,Y,Z"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="periodic" period="1000"/>
<logging updatemode="never" period="0"/>
</object>
</xml>

View File

@ -1,10 +0,0 @@
<xml>
<object name="HeadingActual" singleinstance="true" settings="false">
<field name="raw" units="mGa" type="int16" elementnames="X,Y,Z"/>
<field name="heading" units="degrees" type="float" elements="1"/>
<access gcs="readwrite" flight="readwrite"/>
<telemetrygcs acked="false" updatemode="manual" period="0"/>
<telemetryflight acked="false" updatemode="periodic" period="500"/>
<logging updatemode="never" period="0"/>
</object>
</xml>