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

Merge branch 'corvuscorax/OP-946_refaktor_sensor_and_state' into corvuscorax/OP-947_stateestimator-module

This commit is contained in:
Corvus Corax 2013-05-20 10:34:40 +02:00
commit d258caad3f
26 changed files with 469 additions and 290 deletions

View File

@ -64,8 +64,8 @@
#include "gyrostate.h"
#include "gyrosensor.h"
#include "homelocation.h"
#include "magnetosensor.h"
#include "magnetostate.h"
#include "magsensor.h"
#include "magstate.h"
#include "positionstate.h"
#include "ekfconfiguration.h"
#include "ekfstatevariance.h"
@ -125,7 +125,7 @@ static void settingsUpdatedCb(UAVObjEvent *objEv);
static int32_t getNED(GPSPositionData *gpsPosition, float *NED);
static void magOffsetEstimation(MagnetoSensorData *mag);
static void magOffsetEstimation(MagSensorData *mag);
// check for invalid values
static inline bool invalid(float data)
@ -167,8 +167,8 @@ int32_t AttitudeInitialize(void)
GyroStateInitialize();
AccelSensorInitialize();
AccelStateInitialize();
MagnetoSensorInitialize();
MagnetoStateInitialize();
MagSensorInitialize();
MagStateInitialize();
AirspeedSensorInitialize();
AirspeedStateInitialize();
BaroSensorInitialize();
@ -224,11 +224,13 @@ int32_t AttitudeStart(void)
// Start main task
xTaskCreate(AttitudeTask, (signed char *)"Attitude", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &attitudeTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_ATTITUDE, attitudeTaskHandle);
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_RegisterFlag(PIOS_WDG_ATTITUDE);
#endif
GyroSensorConnectQueue(gyroQueue);
AccelSensorConnectQueue(accelQueue);
MagnetoSensorConnectQueue(magQueue);
MagSensorConnectQueue(magQueue);
AirspeedSensorConnectQueue(airspeedQueue);
BaroSensorConnectQueue(baroQueue);
GPSPositionConnectQueue(gpsQueue);
@ -282,7 +284,9 @@ static void AttitudeTask(__attribute__((unused)) void *parameters)
initialization_required = true;
}
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_UpdateFlag(PIOS_WDG_ATTITUDE);
#endif
}
}
@ -331,10 +335,10 @@ static int32_t updateAttitudeComplementary(bool first_run)
if (xQueueReceive(magQueue, &ev, 0 / portTICK_RATE_MS) != pdTRUE) {
return -1;
}
MagnetoSensorData magData;
MagnetoSensorGet(&magData);
MagSensorData magData;
MagSensorGet(&magData);
#else
MagnetoSensorData magData;
MagSensorData magData;
magData.x = 100.0f;
magData.y = 0.0f;
magData.z = 0.0f;
@ -430,20 +434,20 @@ static int32_t updateAttitudeComplementary(bool first_run)
// Rotate gravity to body frame and cross with accels
float brot[3];
float Rbe[3][3];
MagnetoSensorData mag;
MagSensorData mag;
Quaternion2R(q, Rbe);
MagnetoSensorGet(&mag);
MagSensorGet(&mag);
// TODO: separate filter!
if (revoCalibration.MagBiasNullingRate > 0) {
magOffsetEstimation(&mag);
}
MagnetoStateData mags;
MagStateData mags;
mags.x = mag.x;
mags.y = mag.y;
mags.z = mag.z;
MagnetoStateSet(&mags);
MagStateSet(&mags);
// If the mag is producing bad data don't use it (normally bad calibration)
if (!isnan(mag.x) && !isinf(mag.x) && !isnan(mag.y) && !isinf(mag.y) && !isnan(mag.z) && !isinf(mag.z)) {
@ -608,7 +612,7 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
UAVObjEvent ev;
GyroSensorData gyroSensorData;
AccelSensorData accelSensorData;
MagnetoStateData magData;
MagStateData magData;
AirspeedSensorData airspeedData;
BaroSensorData baroData;
GPSPositionData gpsData;
@ -690,17 +694,17 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
AccelSensorGet(&accelSensorData);
// TODO: separate filter!
if (mag_updated) {
MagnetoSensorData mags;
MagnetoSensorGet(&mags);
MagSensorData mags;
MagSensorGet(&mags);
if (revoCalibration.MagBiasNullingRate > 0) {
magOffsetEstimation(&mags);
}
magData.x = mags.x;
magData.y = mags.y;
magData.z = mags.z;
MagnetoStateSet(&magData);
MagStateSet(&magData);
}
MagnetoStateGet(&magData);
MagStateGet(&magData);
BaroSensorGet(&baroData);
AirspeedSensorGet(&airspeedData);
@ -856,7 +860,7 @@ static int32_t updateAttitudeINSGPS(bool first_run, bool outdoor_mode)
}
// xQueueReceive(magQueue, &ev, 100 / portTICK_RATE_MS);
// MagnetoSensorGet(&magData);
// MagSensorGet(&magData);
AttitudeStateData attitudeState;
AttitudeStateGet(&attitudeState);
@ -1158,10 +1162,10 @@ static void settingsUpdatedCb(UAVObjEvent *ev)
/**
* Perform an update of the @ref MagBias based on
* Magnetometer Offset Cancellation: Theory and Implementation,
* Magmeter Offset Cancellation: Theory and Implementation,
* revisited William Premerlani, October 14, 2011
*/
static void magOffsetEstimation(MagnetoSensorData *mag)
static void magOffsetEstimation(MagSensorData *mag)
{
#if 0
// Constants, to possibly go into a UAVO

View File

@ -41,7 +41,7 @@
#include "hwsettings.h"
#include "magbaro.h"
#include "barosensor.h" // object that will be updated by the module
#include "magnetosensor.h"
#include "magsensor.h"
#include "taskinfo.h"
// Private constants
@ -109,7 +109,7 @@ int32_t MagBaroInitialize()
if (magbaroEnabled) {
#if defined(PIOS_INCLUDE_HMC5883)
MagnetoSensorInitialize();
MagSensorInitialize();
#endif
#if defined(PIOS_INCLUDE_BMP085)
@ -149,7 +149,7 @@ static void magbaroTask(__attribute__((unused)) void *parameters)
#endif
#if defined(PIOS_INCLUDE_HMC5883)
MagnetoSensorData mag;
MagSensorData mag;
PIOS_HMC5883_Init(&pios_hmc5883_cfg);
uint32_t mag_update_time = PIOS_DELAY_GetRaw();
#endif
@ -207,7 +207,7 @@ static void magbaroTask(__attribute__((unused)) void *parameters)
mag.x = mags[0];
mag.y = mags[1];
mag.z = mags[2];
MagnetoSensorSet(&mag);
MagSensorSet(&mag);
mag_update_time = PIOS_DELAY_GetRaw();
}
#endif

View File

@ -4,7 +4,7 @@
* @{
* @addtogroup Sensors
* @brief Acquires sensor data
* Specifically updates the the @ref GyroSensor, @ref AccelSensor, and @ref MagnetoSensor objects
* Specifically updates the the @ref GyroSensor, @ref AccelSensor, and @ref MagSensor objects
* @{
*
* @file sensors.c
@ -32,7 +32,7 @@
/**
* Input objects: None, takes sensor data via pios
* Output objects: @ref GyroSensor @ref AccelSensor @ref MagnetoSensor
* Output objects: @ref GyroSensor @ref AccelSensor @ref MagSensor
*
* The module executes in its own thread.
*
@ -49,7 +49,7 @@
#include <openpilot.h>
#include <homelocation.h>
#include <magnetosensor.h>
#include <magsensor.h>
#include <accelsensor.h>
#include <gyrosensor.h>
#include <attitudestate.h>
@ -73,7 +73,7 @@
// Private functions
static void SensorsTask(void *parameters);
static void settingsUpdatedCb(UAVObjEvent *objEv);
// static void magOffsetEstimation(MagnetoSensorData *mag);
// static void magOffsetEstimation(MagSensorData *mag);
// Private variables
static xTaskHandle sensorsTaskHandle;
@ -110,7 +110,7 @@ int32_t SensorsInitialize(void)
{
GyroSensorInitialize();
AccelSensorInitialize();
MagnetoSensorInitialize();
MagSensorInitialize();
RevoCalibrationInitialize();
AttitudeSettingsInitialize();
@ -131,7 +131,9 @@ int32_t SensorsStart(void)
// Start main task
xTaskCreate(SensorsTask, (signed char *)"Sensors", STACK_SIZE_BYTES / 4, NULL, TASK_PRIORITY, &sensorsTaskHandle);
PIOS_TASK_MONITOR_RegisterTask(TASKINFO_RUNNING_SENSORS, sensorsTaskHandle);
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_RegisterFlag(PIOS_WDG_SENSORS);
#endif
return 0;
}
@ -201,7 +203,9 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
if (accel_test < 0 || gyro_test < 0 || mag_test < 0) {
AlarmsSet(SYSTEMALARMS_ALARM_SENSORS, SYSTEMALARMS_ALARM_CRITICAL);
while (1) {
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_UpdateFlag(PIOS_WDG_SENSORS);
#endif
vTaskDelay(10);
}
}
@ -216,7 +220,9 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
timeval = PIOS_DELAY_GetRaw();
if (error) {
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_UpdateFlag(PIOS_WDG_SENSORS);
#endif
lastSysTime = xTaskGetTickCount();
vTaskDelayUntil(&lastSysTime, SENSOR_PERIOD / portTICK_RATE_MS);
AlarmsSet(SYSTEMALARMS_ALARM_SENSORS, SYSTEMALARMS_ALARM_CRITICAL);
@ -377,7 +383,7 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
// and make it average zero (weakly)
#if defined(PIOS_INCLUDE_HMC5883)
MagnetoSensorData mag;
MagSensorData mag;
if (PIOS_HMC5883_NewDataAvailable() || PIOS_DELAY_DiffuS(mag_update_time) > 150000) {
int16_t values[3];
PIOS_HMC5883_ReadMag(values);
@ -396,12 +402,14 @@ static void SensorsTask(__attribute__((unused)) void *parameters)
mag.z = mags[2];
}
MagnetoSensorSet(&mag);
MagSensorSet(&mag);
mag_update_time = PIOS_DELAY_GetRaw();
}
#endif /* if defined(PIOS_INCLUDE_HMC5883) */
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_UpdateFlag(PIOS_WDG_SENSORS);
#endif
lastSysTime = xTaskGetTickCount();
}

View File

@ -4,7 +4,7 @@
* @{
* @addtogroup Sensors
* @brief Acquires sensor data
* Specifically updates the the @ref GyroSensor, @ref AccelSensor, and @ref MagnetoSensor objects
* Specifically updates the the @ref GyroSensor, @ref AccelSensor, and @ref MagSensor objects
* @{
*
* @file sensors.c
@ -32,7 +32,7 @@
/**
* Input objects: None, takes sensor data via pios
* Output objects: @ref GyroSensor @ref AccelSensor @ref MagnetoSensor
* Output objects: @ref GyroSensor @ref AccelSensor @ref MagSensor
*
* The module executes in its own thread.
*
@ -113,7 +113,7 @@ int32_t SensorsInitialize(void)
// GyrosBiasInitialize();
GPSPositionInitialize();
GPSVelocityInitialize();
MagnetoSensorInitialize();
MagSensorInitialize();
MagBiasInitialize();
RevoCalibrationInitialize();
@ -252,11 +252,11 @@ static void simulateConstant()
// Because most crafts wont get enough information from gravity to zero yaw gyro, we try
// and make it average zero (weakly)
MagnetoSensorData mag;
MagSensorData mag;
mag.x = 400;
mag.y = 0;
mag.z = 800;
MagnetoSensorSet(&mag);
MagSensorSet(&mag);
}
static void simulateModelAgnostic()
@ -314,11 +314,11 @@ static void simulateModelAgnostic()
// Because most crafts wont get enough information from gravity to zero yaw gyro, we try
// and make it average zero (weakly)
MagnetoSensorData mag;
MagSensorData mag;
mag.x = 400;
mag.y = 0;
mag.z = 800;
MagnetoSensorSet(&mag);
MagSensorSet(&mag);
}
float thrustToDegs = 50;
@ -528,12 +528,12 @@ static void simulateModelQuadcopter()
// Update mag periodically
static uint32_t last_mag_time = 0;
if (PIOS_DELAY_DiffuS(last_mag_time) / 1.0e6 > MAG_PERIOD) {
MagnetoSensorData mag;
MagSensorData mag;
mag.x = homeLocation.Be[0] * Rbe[0][0] + homeLocation.Be[1] * Rbe[0][1] + homeLocation.Be[2] * Rbe[0][2];
mag.y = homeLocation.Be[0] * Rbe[1][0] + homeLocation.Be[1] * Rbe[1][1] + homeLocation.Be[2] * Rbe[1][2];
mag.z = homeLocation.Be[0] * Rbe[2][0] + homeLocation.Be[1] * Rbe[2][1] + homeLocation.Be[2] * Rbe[2][2];
MagnetoSensorSet(&mag);
MagSensorSet(&mag);
last_mag_time = PIOS_DELAY_GetRaw();
}
@ -811,11 +811,11 @@ static void simulateModelAirplane()
// Update mag periodically
static uint32_t last_mag_time = 0;
if (PIOS_DELAY_DiffuS(last_mag_time) / 1.0e6 > MAG_PERIOD) {
MagnetoSensorData mag;
MagSensorData mag;
mag.x = 100 + homeLocation.Be[0] * Rbe[0][0] + homeLocation.Be[1] * Rbe[0][1] + homeLocation.Be[2] * Rbe[0][2];
mag.y = 100 + homeLocation.Be[0] * Rbe[1][0] + homeLocation.Be[1] * Rbe[1][1] + homeLocation.Be[2] * Rbe[1][2];
mag.z = 100 + homeLocation.Be[0] * Rbe[2][0] + homeLocation.Be[1] * Rbe[2][1] + homeLocation.Be[2] * Rbe[2][2];
MagnetoSensorSet(&mag);
MagSensorSet(&mag);
last_mag_time = PIOS_DELAY_GetRaw();
}

View File

@ -93,7 +93,7 @@ ifndef TESTAPP
SRC += $(OPUAVSYNTHDIR)/gpstime.c
SRC += $(OPUAVSYNTHDIR)/osdsettings.c
SRC += $(OPUAVSYNTHDIR)/barosensor.c
SRC += $(OPUAVSYNTHDIR)/magnetosensor.c
SRC += $(OPUAVSYNTHDIR)/magsensor.c
else
## Test Code
SRC += $(OPTESTS)/test_common.c

View File

@ -30,8 +30,8 @@ UAVOBJSRCFILENAMES += gyrostate
UAVOBJSRCFILENAMES += gyrosensor
UAVOBJSRCFILENAMES += accelstate
UAVOBJSRCFILENAMES += accelsensor
UAVOBJSRCFILENAMES += magnetosensor
UAVOBJSRCFILENAMES += magnetostate
UAVOBJSRCFILENAMES += magsensor
UAVOBJSRCFILENAMES += magstate
UAVOBJSRCFILENAMES += barosensor
UAVOBJSRCFILENAMES += airspeedsensor
UAVOBJSRCFILENAMES += airspeedsettings

View File

@ -391,7 +391,9 @@ void PIOS_Board_Init(void)
PIOS_IAP_WriteBootCmd(1, 0);
PIOS_IAP_WriteBootCmd(2, 0);
}
#ifdef PIOS_INCLUDE_WDG
PIOS_WDG_Init();
#endif
/* Initialize UAVObject libraries */
EventDispatcherInitialize();
UAVObjInitialize();

View File

@ -35,7 +35,7 @@
#include <barosensor.h>
#include <gpsposition.h>
#include <gyrosensor.h>
#include <magnetosensor.h>
#include <magsensor.h>
#include <manualcontrolsettings.h>
void Stack_Change() {}
@ -138,7 +138,7 @@ void PIOS_Board_Init(void)
AccelSensorInitialize();
BaroSensorInitialize();
MagnetoSensorInitialize();
MagSensorInitialize();
GPSPositionInitialize();
GyroSensorInitialize();

View File

@ -35,8 +35,8 @@ UAVOBJSRCFILENAMES += gyrostate
UAVOBJSRCFILENAMES += gyrosensor
UAVOBJSRCFILENAMES += accelstate
UAVOBJSRCFILENAMES += accelsensor
UAVOBJSRCFILENAMES += magnetostate
UAVOBJSRCFILENAMES += magnetosensor
UAVOBJSRCFILENAMES += magstate
UAVOBJSRCFILENAMES += magsensor
UAVOBJSRCFILENAMES += barosensor
UAVOBJSRCFILENAMES += airspeedsensor
UAVOBJSRCFILENAMES += airspeedsettings

View File

@ -35,7 +35,7 @@
#include <barosensor.h>
#include <gpsposition.h>
#include <gyrosensor.h>
#include <magnetosensor.h>
#include <magsensor.h>
#include <manualcontrolsettings.h>
void Stack_Change() {}
@ -138,7 +138,7 @@ void PIOS_Board_Init(void)
AccelSensorInitialize();
BaroSensorInitialize();
MagnetoSensorInitialize();
MagSensorInitialize();
GPSPositionInitialize();
GyroStatInitialize();
GyroSensorInitialize();

View File

@ -35,8 +35,8 @@ UAVOBJSRCFILENAMES += gyrostate
UAVOBJSRCFILENAMES += gyrosensor
UAVOBJSRCFILENAMES += accelstate
UAVOBJSRCFILENAMES += accelsensor
UAVOBJSRCFILENAMES += magnetosensor
UAVOBJSRCFILENAMES += magnetostate
UAVOBJSRCFILENAMES += magsensor
UAVOBJSRCFILENAMES += magstate
UAVOBJSRCFILENAMES += barosensor
UAVOBJSRCFILENAMES += barostate
UAVOBJSRCFILENAMES += airspeedsensor

View File

@ -69,7 +69,3 @@ const struct fw_version_info fw_version_blob __attribute__((used)) __attribute__
.sha1sum = { ${SHA1} },
.uavosha1 = { ${UAVOSHA1} },
};
/**
* @}
*/

View File

@ -2233,7 +2233,7 @@
<color>4294901760</color>
<mathFunction>None</mathFunction>
<uavField>x</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>6.92916505601691e-310</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>3.86203233966055e-312</yMinimum>
@ -2243,7 +2243,7 @@
<color>4283782655</color>
<mathFunction>None</mathFunction>
<uavField>y</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>1.72723371101889e-77</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>-1</yMinimum>
@ -2253,7 +2253,7 @@
<color>4283804160</color>
<mathFunction>None</mathFunction>
<uavField>z</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>1.72723371102028e-77</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>7.21478569792807e-313</yMinimum>

View File

@ -2264,7 +2264,7 @@
<color>4294901760</color>
<mathFunction>None</mathFunction>
<uavField>x</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>0</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>0</yMinimum>
@ -2274,7 +2274,7 @@
<color>4283782655</color>
<mathFunction>None</mathFunction>
<uavField>y</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>0</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>0</yMinimum>
@ -2284,7 +2284,7 @@
<color>4283804160</color>
<mathFunction>None</mathFunction>
<uavField>z</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>0</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>0</yMinimum>

View File

@ -2242,7 +2242,7 @@
<color>4294901760</color>
<mathFunction>None</mathFunction>
<uavField>x</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>0</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>0</yMinimum>
@ -2252,7 +2252,7 @@
<color>4283782655</color>
<mathFunction>None</mathFunction>
<uavField>y</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>0</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>0</yMinimum>
@ -2262,7 +2262,7 @@
<color>4283804160</color>
<mathFunction>None</mathFunction>
<uavField>z</uavField>
<uavObject>MagnetoState</uavObject>
<uavObject>MagState</uavObject>
<yMaximum>0</yMaximum>
<yMeanSamples>1</yMeanSamples>
<yMinimum>0</yMinimum>

View File

@ -46,7 +46,7 @@
#include <homelocation.h>
#include <accelstate.h>
#include <gyrostate.h>
#include <magnetostate.h>
#include <magstate.h>
#define GRAVITY 9.81f
#include "assertions.h"
@ -585,10 +585,10 @@ void ConfigRevoWidget::doStartSixPointCalibration()
#endif
/* Need to get as many mag updates as possible */
MagnetoState *mag = MagnetoState::GetInstance(getObjectManager());
MagState *mag = MagState::GetInstance(getObjectManager());
Q_ASSERT(mag);
initialMagnetoStateMdata = mag->getMetadata();
mdata = initialMagnetoStateMdata;
initialMagStateMdata = mag->getMetadata();
mdata = initialMagStateMdata;
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC);
mdata.flightTelemetryUpdatePeriod = 100;
mag->setMetadata(mdata);
@ -624,7 +624,7 @@ void ConfigRevoWidget::savePositionData()
AccelState *accelState = AccelState::GetInstance(getObjectManager());
Q_ASSERT(accelState);
MagnetoState *mag = MagnetoState::GetInstance(getObjectManager());
MagState *mag = MagState::GetInstance(getObjectManager());
Q_ASSERT(mag);
connect(accelState, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(doGetSixPointCalibrationMeasurement(UAVObject *)));
@ -653,10 +653,10 @@ void ConfigRevoWidget::doGetSixPointCalibrationMeasurement(UAVObject *obj)
accel_accum_y.append(accelStateData.y);
accel_accum_z.append(accelStateData.z);
#endif
} else if (obj->getObjID() == MagnetoState::OBJID) {
MagnetoState *mag = MagnetoState::GetInstance(getObjectManager());
} else if (obj->getObjID() == MagState::OBJID) {
MagState *mag = MagState::GetInstance(getObjectManager());
Q_ASSERT(mag);
MagnetoState::DataFields magData = mag->getData();
MagState::DataFields magData = mag->getData();
mag_accum_x.append(magData.x);
mag_accum_y.append(magData.y);
mag_accum_z.append(magData.z);
@ -685,7 +685,7 @@ void ConfigRevoWidget::doGetSixPointCalibrationMeasurement(UAVObject *obj)
#endif
// Store the mean for this position for the mag
MagnetoState *mag = MagnetoState::GetInstance(getObjectManager());
MagState *mag = MagState::GetInstance(getObjectManager());
Q_ASSERT(mag);
disconnect(mag, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(doGetSixPointCalibrationMeasurement(UAVObject *)));
mag_data_x[position] = listMean(mag_accum_x);
@ -722,7 +722,7 @@ void ConfigRevoWidget::doGetSixPointCalibrationMeasurement(UAVObject *obj)
#ifdef SIX_POINT_CAL_ACCEL
accelState->setMetadata(initialAccelStateMdata);
#endif
mag->setMetadata(initialMagnetoStateMdata);
mag->setMetadata(initialMagStateMdata);
// Recall saved board rotation
recallBoardRotation();
@ -928,7 +928,7 @@ void ConfigRevoWidget::doStartNoiseMeasurement()
Q_ASSERT(accelState);
GyroState *gyroState = GyroState::GetInstance(getObjectManager());
Q_ASSERT(gyroState);
MagnetoState *mag = MagnetoState::GetInstance(getObjectManager());
MagState *mag = MagState::GetInstance(getObjectManager());
Q_ASSERT(mag);
UAVObject::Metadata mdata;
@ -945,8 +945,8 @@ void ConfigRevoWidget::doStartNoiseMeasurement()
mdata.flightTelemetryUpdatePeriod = 100;
gyroState->setMetadata(mdata);
initialMagnetoStateMdata = mag->getMetadata();
mdata = initialMagnetoStateMdata;
initialMagStateMdata = mag->getMetadata();
mdata = initialMagStateMdata;
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC);
mdata.flightTelemetryUpdatePeriod = 100;
mag->setMetadata(mdata);
@ -990,11 +990,11 @@ void ConfigRevoWidget::doGetNoiseSample(UAVObject *obj)
accel_accum_z.append(accelStateData.z);
break;
}
case MagnetoState::OBJID:
case MagState::OBJID:
{
MagnetoState *mags = MagnetoState::GetInstance(getObjectManager());
MagState *mags = MagState::GetInstance(getObjectManager());
Q_ASSERT(mags);
MagnetoState::DataFields magData = mags->getData();
MagState::DataFields magData = mags->getData();
mag_accum_x.append(magData.x);
mag_accum_y.append(magData.y);
mag_accum_z.append(magData.z);
@ -1017,7 +1017,7 @@ void ConfigRevoWidget::doGetNoiseSample(UAVObject *obj)
gyro_accum_x.length() >= NOISE_SAMPLES &&
accel_accum_x.length() >= NOISE_SAMPLES) {
// No need to for more updates
MagnetoState *mags = MagnetoState::GetInstance(getObjectManager());
MagState *mags = MagState::GetInstance(getObjectManager());
AccelState *accelState = AccelState::GetInstance(getObjectManager());
GyroState *gyroState = GyroState::GetInstance(getObjectManager());
disconnect(accelState, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(doGetNoiseSample(UAVObject *)));

View File

@ -92,7 +92,7 @@ private:
UAVObject::Metadata initialAccelStateMdata;
UAVObject::Metadata initialGyroStateMdata;
UAVObject::Metadata initialMagnetoStateMdata;
UAVObject::Metadata initialMagStateMdata;
UAVObject::Metadata initialBaroSensorMdata;
float initialMagCorrectionRate;

View File

@ -77,7 +77,7 @@ void AutoUpdatePage::updateStatus(uploader::AutoUpdateStep status, QVariant valu
getWizard()->setWindowIcon(qApp->windowIcon());
enableButtons(true);
getWizard()->show();
ui->statusLabel->setText("Something went wrong, you will have to manualy upgrade the board using the uploader plugin");
ui->statusLabel->setText("Something went wrong, you will have to manually upgrade the board using the uploader plugin");
break;
}
}

View File

@ -42,8 +42,8 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/accessorydesired.h \
$$UAVOBJECT_SYNTHETICS/gyrosensor.h \
$$UAVOBJECT_SYNTHETICS/accelsensor.h \
$$UAVOBJECT_SYNTHETICS/accelstate.h \
$$UAVOBJECT_SYNTHETICS/magnetosensor.h \
$$UAVOBJECT_SYNTHETICS/magnetostate.h \
$$UAVOBJECT_SYNTHETICS/magsensor.h \
$$UAVOBJECT_SYNTHETICS/magstate.h \
$$UAVOBJECT_SYNTHETICS/camerastabsettings.h \
$$UAVOBJECT_SYNTHETICS/flighttelemetrystats.h \
$$UAVOBJECT_SYNTHETICS/systemstats.h \
@ -126,8 +126,8 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/accessorydesired.cpp \
$$UAVOBJECT_SYNTHETICS/accelstate.cpp \
$$UAVOBJECT_SYNTHETICS/gyrostate.cpp \
$$UAVOBJECT_SYNTHETICS/gyrosensor.cpp \
$$UAVOBJECT_SYNTHETICS/magnetosensor.cpp \
$$UAVOBJECT_SYNTHETICS/magnetostate.cpp \
$$UAVOBJECT_SYNTHETICS/magsensor.cpp \
$$UAVOBJECT_SYNTHETICS/magstate.cpp \
$$UAVOBJECT_SYNTHETICS/camerastabsettings.cpp \
$$UAVOBJECT_SYNTHETICS/flighttelemetrystats.cpp \
$$UAVOBJECT_SYNTHETICS/systemstats.cpp \

View File

@ -7,15 +7,67 @@
<x>0</x>
<y>0</y>
<width>822</width>
<height>350</height>
<height>523</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>804</width>
<height>505</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="buttonFrame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>0</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="autoUpdateButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Start a guided procedure to manually
recover a system which does not boot.
Rescue is possible in USB mode only.</string>
</property>
<property name="text">
<string>Auto Update</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="haltButton">
<property name="enabled">
@ -32,6 +84,21 @@ through serial or USB)</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Reset the system.
(Only enabled if telemetry link is established, either
through serial or USB)</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="bootButton">
<property name="enabled">
@ -68,34 +135,6 @@ menu on the right.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="eraseBootButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Reboot the board and clear its settings memory.&lt;/p&gt;&lt;p&gt; Useful if the board cannot boot properly.&lt;/p&gt;&lt;p&gt; Blue led starts blinking quick for 20-30 seconds than the board will start normally&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If telemetry is not running, select the link using the dropdown&lt;/p&gt;&lt;p&gt;menu on the right.&lt;/p&gt;&lt;p&gt;PLEASE NOTE: Supported with bootloader versions 4.0 and earlier&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Erase settings</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="resetButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="toolTip">
<string>Reset the system.
(Only enabled if telemetry link is established, either
through serial or USB)</string>
</property>
<property name="text">
<string>Reset</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="rescueButton">
<property name="toolTip">
@ -109,6 +148,19 @@ Rescue is possible in USB mode only.</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="eraseBootButton">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Reboot the board and clear its settings memory.&lt;/p&gt;&lt;p&gt; Useful if the board cannot boot properly.&lt;/p&gt;&lt;p&gt; Blue led starts blinking quick for 20-30 seconds than the board will start normally&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;p&gt;If telemetry is not running, select the link using the dropdown&lt;/p&gt;&lt;p&gt;menu on the right.&lt;/p&gt;&lt;p&gt;PLEASE NOTE: Supported with bootloader versions 4.0 and earlier&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Erase settings</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
@ -124,6 +176,12 @@ Rescue is possible in USB mode only.</string>
</item>
<item>
<widget class="QComboBox" name="telemetryLink">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="toolTip">
<string>When telemetry is not connected, select the communication
method using this combo box.
@ -179,6 +237,42 @@ halting a running board.</string>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="autoUpdateGroupBox">
<property name="title">
<string>Auto update</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="1">
<widget class="QPushButton" name="autoUpdateOkButton">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QProgressBar" name="autoUpdateProgressBar">
<property name="value">
<number>0</number>
</property>
<property name="textVisible">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="autoUpdateLabel">
<property name="text">
<string>Progress</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QSplitter" name="splitter">
<property name="orientation">
@ -200,7 +294,10 @@ halting a running board.</string>
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;To upgrade the firmware in your boards, proceed as follows:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;To upgrade the firmware in your boards,&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;press Auto Update and follow instructions&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;or&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;proceed as follows:&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;- Connect telemetry&lt;/span&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'Ubuntu'; font-size:11pt;&quot;&gt;- Once telemetry is running, press &amp;quot;Halt&amp;quot; above&lt;/span&gt;&lt;/p&gt;
@ -229,6 +326,10 @@ p, li { white-space: pre-wrap; }
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../coreplugin/core.qrc"/>
</resources>

View File

@ -60,6 +60,11 @@ UploaderGadgetWidget::UploaderGadgetWidget(QWidget *parent) : QWidget(parent)
connect(cm, SIGNAL(deviceConnected(QIODevice *)), this, SLOT(onPhisicalHWConnect()));
getSerialPorts();
m_config->autoUpdateButton->setEnabled(autoUpdateCapable());
connect(m_config->autoUpdateButton, SIGNAL(clicked()), this, SLOT(startAutoUpdate()));
connect(m_config->autoUpdateOkButton, SIGNAL(clicked()), this, SLOT(closeAutoUpdate()));
m_config->autoUpdateGroupBox->setVisible(false);
QIcon rbi;
rbi.addFile(QString(":uploader/images/view-refresh.svg"));
m_config->refreshPorts->setIcon(rbi);
@ -816,6 +821,67 @@ void UploaderGadgetWidget::downloadEnded(bool succeed)
m_config->rescueButton->setEnabled(true);
}
void UploaderGadgetWidget::startAutoUpdate()
{
m_config->buttonFrame->setEnabled(false);
m_config->splitter->setEnabled(false);
m_config->autoUpdateGroupBox->setVisible(true);
m_config->autoUpdateOkButton->setEnabled(false);
connect(this, SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep, QVariant)), this, SLOT(autoUpdateStatus(uploader::AutoUpdateStep, QVariant)));
autoUpdate();
}
void UploaderGadgetWidget::finishAutoUpdate()
{
disconnect(this, SIGNAL(autoUpdateSignal(uploader::AutoUpdateStep, QVariant)), this, SLOT(autoUpdateStatus(uploader::AutoUpdateStep, QVariant)));
m_config->autoUpdateOkButton->setEnabled(true);
}
void UploaderGadgetWidget::closeAutoUpdate()
{
m_config->autoUpdateGroupBox->setVisible(false);
m_config->buttonFrame->setEnabled(true);
m_config->splitter->setEnabled(true);
}
void UploaderGadgetWidget::autoUpdateStatus(uploader::AutoUpdateStep status, QVariant value)
{
switch (status) {
case uploader::WAITING_DISCONNECT:
m_config->autoUpdateLabel->setText("Waiting for all OpenPilot boards to be disconnected from USB.");
break;
case uploader::WAITING_CONNECT:
m_config->autoUpdateLabel->setText("Please connect the OpenPilot board to the USB port.");
m_config->autoUpdateProgressBar->setValue(value.toInt());
break;
case uploader::JUMP_TO_BL:
m_config->autoUpdateProgressBar->setValue(0);
m_config->autoUpdateLabel->setText("Bringing the board into boot loader mode.");
break;
case uploader::LOADING_FW:
m_config->autoUpdateLabel->setText("Preparing to upload firmware to the board.");
break;
case uploader::UPLOADING_FW:
m_config->autoUpdateLabel->setText("Uploading firmware to the board.");
m_config->autoUpdateProgressBar->setValue(value.toInt());
break;
case uploader::UPLOADING_DESC:
m_config->autoUpdateLabel->setText("Uploading description of the new firmware to the board.");
break;
case uploader::BOOTING:
m_config->autoUpdateLabel->setText("Rebooting the board.");
break;
case uploader::SUCCESS:
m_config->autoUpdateLabel->setText("<font color='green'>Board was updated successfully, press OK to finish.</font>");
finishAutoUpdate();
break;
case uploader::FAILURE:
m_config->autoUpdateLabel->setText("<font color='red'>Something went wrong, you will have to manually upgrade the board. Press OK to continue.</font>");
finishAutoUpdate();
break;
}
}
/**
Update log entry
*/

View File

@ -118,6 +118,10 @@ private slots:
void uploadEnded(bool succeed);
void downloadStarted();
void downloadEnded(bool succeed);
void startAutoUpdate();
void finishAutoUpdate();
void closeAutoUpdate();
void autoUpdateStatus(uploader::AutoUpdateStep status, QVariant value);
};
#endif // UPLOADERGADGETWIDGET_H

4
make/.gitattributes vendored
View File

@ -6,8 +6,6 @@
*.py text eol=lf
*.sh text eol=lf
/doxygen/*.cfg text eol=lf
/templates/firmware_info.c.template text eol=lf
/templates/gcs_version_info.h.template text eol=crlf
/doxygen/* text eol=lf
/templates/*.txt text eol=crlf
/uncrustify/*.cfg text eol=lf

View File

@ -133,10 +133,10 @@ endef
define OPFW_TEMPLATE
FORCE:
$(1).firmware_info.c: $(1) $(ROOT_DIR)/make/templates/firmware_info.c.template FORCE
$(1).firmware_info.c: $(1) $(ROOT_DIR)/flight/templates/firmware_info.c.template FORCE
@$(ECHO) $(MSG_FWINFO) $$(call toprel, $$@)
$(V1) $(VERSION_INFO) \
--template=$(ROOT_DIR)/make/templates/firmware_info.c.template \
--template=$(ROOT_DIR)/flight/templates/firmware_info.c.template \
--outfile=$$@ \
--image=$(1) \
--type=$(2) \

View File

@ -1,5 +1,5 @@
<xml>
<object name="MagnetoSensor" singleinstance="true" settings="false">
<object name="MagSensor" singleinstance="true" settings="false">
<description>The mag data.</description>
<field name="x" units="mGa" type="float" elements="1"/>
<field name="y" units="mGa" type="float" elements="1"/>

View File

@ -1,5 +1,5 @@
<xml>
<object name="MagnetoState" singleinstance="true" settings="false">
<object name="MagState" singleinstance="true" settings="false">
<description>The mag data.</description>
<field name="x" units="mGa" type="float" elements="1"/>
<field name="y" units="mGa" type="float" elements="1"/>