mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +01:00
OP-1351 Apply and Save logic for gyro bias calibration now works as expected
This commit is contained in:
parent
bd6bd043d1
commit
934a11bd96
@ -25,52 +25,61 @@
|
|||||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <attitudestate.h>
|
|
||||||
#include <attitudesettings.h>
|
|
||||||
#include "extensionsystem/pluginmanager.h"
|
|
||||||
#include <gyrostate.h>
|
|
||||||
#include <gyrosensor.h>
|
|
||||||
#include <revocalibration.h>
|
|
||||||
#include <accelgyrosettings.h>
|
|
||||||
#include "calibration/gyrobiascalibrationmodel.h"
|
#include "calibration/gyrobiascalibrationmodel.h"
|
||||||
#include "calibration/calibrationutils.h"
|
#include "calibration/calibrationutils.h"
|
||||||
#include "calibration/calibrationuiutils.h"
|
#include "calibration/calibrationuiutils.h"
|
||||||
|
#include "extensionsystem/pluginmanager.h"
|
||||||
|
|
||||||
static const int LEVEL_SAMPLES = 100;
|
static const int LEVEL_SAMPLES = 100;
|
||||||
|
|
||||||
namespace OpenPilot {
|
namespace OpenPilot {
|
||||||
GyroBiasCalibrationModel::GyroBiasCalibrationModel(QObject *parent) :
|
GyroBiasCalibrationModel::GyroBiasCalibrationModel(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent), collectingData(false), m_dirty(false)
|
||||||
collectingData(false)
|
{
|
||||||
{}
|
gyroState = GyroState::GetInstance(getObjectManager());
|
||||||
|
Q_ASSERT(gyroState);
|
||||||
|
|
||||||
|
gyroSensor = GyroSensor::GetInstance(getObjectManager());
|
||||||
|
Q_ASSERT(gyroSensor);
|
||||||
|
|
||||||
|
revoCalibration = RevoCalibration::GetInstance(getObjectManager());
|
||||||
|
Q_ASSERT(revoCalibration);
|
||||||
|
|
||||||
|
attitudeSettings = AttitudeSettings::GetInstance(getObjectManager());
|
||||||
|
Q_ASSERT(attitudeSettings);
|
||||||
|
|
||||||
|
accelGyroSettings = AccelGyroSettings::GetInstance(getObjectManager());
|
||||||
|
Q_ASSERT(accelGyroSettings);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/******* gyro bias zero ******/
|
|
||||||
void GyroBiasCalibrationModel::start()
|
void GyroBiasCalibrationModel::start()
|
||||||
{
|
{
|
||||||
// Store and reset board rotation before calibration starts
|
// Store and reset board rotation before calibration starts
|
||||||
storeAndClearBoardRotation();
|
storeAndClearBoardRotation();
|
||||||
|
|
||||||
started();
|
|
||||||
progressChanged(0);
|
|
||||||
|
|
||||||
RevoCalibration *revoCalibration = RevoCalibration::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(revoCalibration);
|
|
||||||
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
||||||
|
memento.revoCalibrationData = revoCalibrationData;
|
||||||
revoCalibrationData.BiasCorrectedRaw = RevoCalibration::BIASCORRECTEDRAW_FALSE;
|
revoCalibrationData.BiasCorrectedRaw = RevoCalibration::BIASCORRECTEDRAW_FALSE;
|
||||||
revoCalibration->setData(revoCalibrationData);
|
revoCalibration->setData(revoCalibrationData);
|
||||||
revoCalibration->updated();
|
|
||||||
|
|
||||||
// Disable gyro bias correction while calibrating
|
// Disable gyro bias correction while calibrating
|
||||||
AttitudeSettings *attitudeSettings = AttitudeSettings::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(attitudeSettings);
|
|
||||||
AttitudeSettings::DataFields attitudeSettingsData = attitudeSettings->getData();
|
AttitudeSettings::DataFields attitudeSettingsData = attitudeSettings->getData();
|
||||||
|
memento.attitudeSettingsData = attitudeSettingsData;
|
||||||
attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_FALSE;
|
attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_FALSE;
|
||||||
attitudeSettings->setData(attitudeSettingsData);
|
attitudeSettings->setData(attitudeSettingsData);
|
||||||
attitudeSettings->updated();
|
|
||||||
|
|
||||||
displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED);
|
UAVObject::Metadata gyroStateMetadata = gyroState->getMetadata();
|
||||||
displayInstructions(tr("Calibrating the gyroscopes. Keep the vehicle steady..."));
|
memento.gyroStateMetadata = gyroStateMetadata;
|
||||||
|
UAVObject::SetFlightTelemetryUpdateMode(gyroStateMetadata, UAVObject::UPDATEMODE_PERIODIC);
|
||||||
|
gyroStateMetadata.flightTelemetryUpdatePeriod = 100;
|
||||||
|
gyroState->setMetadata(gyroStateMetadata);
|
||||||
|
|
||||||
|
UAVObject::Metadata gyroSensorMetadata = gyroSensor->getMetadata();
|
||||||
|
memento.gyroSensorMetadata = gyroSensorMetadata;
|
||||||
|
UAVObject::SetFlightTelemetryUpdateMode(gyroSensorMetadata, UAVObject::UPDATEMODE_PERIODIC);
|
||||||
|
gyroSensorMetadata.flightTelemetryUpdatePeriod = 100;
|
||||||
|
gyroSensor->setMetadata(gyroSensorMetadata);
|
||||||
|
|
||||||
gyro_accum_x.clear();
|
gyro_accum_x.clear();
|
||||||
gyro_accum_y.clear();
|
gyro_accum_y.clear();
|
||||||
@ -80,24 +89,13 @@ void GyroBiasCalibrationModel::start()
|
|||||||
gyro_state_accum_y.clear();
|
gyro_state_accum_y.clear();
|
||||||
gyro_state_accum_z.clear();
|
gyro_state_accum_z.clear();
|
||||||
|
|
||||||
UAVObject::Metadata metadata;
|
// reset dirty state to forget previous unsaved runs
|
||||||
|
m_dirty = false;
|
||||||
|
|
||||||
GyroState *gyroState = GyroState::GetInstance(getObjectManager());
|
started();
|
||||||
Q_ASSERT(gyroState);
|
progressChanged(0);
|
||||||
initialGyroStateMdata = gyroState->getMetadata();
|
displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED);
|
||||||
metadata = initialGyroStateMdata;
|
displayInstructions(tr("Calibrating the gyroscopes. Keep the vehicle steady..."));
|
||||||
UAVObject::SetFlightTelemetryUpdateMode(metadata, UAVObject::UPDATEMODE_PERIODIC);
|
|
||||||
metadata.flightTelemetryUpdatePeriod = 100;
|
|
||||||
gyroState->setMetadata(metadata);
|
|
||||||
|
|
||||||
UAVObject::Metadata gyroSensorMetadata;
|
|
||||||
GyroSensor *gyroSensor = GyroSensor::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(gyroSensor);
|
|
||||||
initialGyroSensorMdata = gyroSensor->getMetadata();
|
|
||||||
gyroSensorMetadata = initialGyroSensorMdata;
|
|
||||||
UAVObject::SetFlightTelemetryUpdateMode(gyroSensorMetadata, UAVObject::UPDATEMODE_PERIODIC);
|
|
||||||
gyroSensorMetadata.flightTelemetryUpdatePeriod = 100;
|
|
||||||
gyroSensor->setMetadata(gyroSensorMetadata);
|
|
||||||
|
|
||||||
// Now connect to the accels and mag updates, gather for 100 samples
|
// Now connect to the accels and mag updates, gather for 100 samples
|
||||||
collectingData = true;
|
collectingData = true;
|
||||||
@ -112,15 +110,10 @@ void GyroBiasCalibrationModel::getSample(UAVObject *obj)
|
|||||||
{
|
{
|
||||||
QMutexLocker lock(&sensorsUpdateLock);
|
QMutexLocker lock(&sensorsUpdateLock);
|
||||||
|
|
||||||
Q_UNUSED(lock);
|
|
||||||
|
|
||||||
switch (obj->getObjID()) {
|
switch (obj->getObjID()) {
|
||||||
case GyroState::OBJID:
|
case GyroState::OBJID:
|
||||||
{
|
{
|
||||||
GyroState *gyroState = GyroState::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(gyroState);
|
|
||||||
GyroState::DataFields gyroStateData = gyroState->getData();
|
GyroState::DataFields gyroStateData = gyroState->getData();
|
||||||
|
|
||||||
gyro_state_accum_x.append(gyroStateData.x);
|
gyro_state_accum_x.append(gyroStateData.x);
|
||||||
gyro_state_accum_y.append(gyroStateData.y);
|
gyro_state_accum_y.append(gyroStateData.y);
|
||||||
gyro_state_accum_z.append(gyroStateData.z);
|
gyro_state_accum_z.append(gyroStateData.z);
|
||||||
@ -128,10 +121,7 @@ void GyroBiasCalibrationModel::getSample(UAVObject *obj)
|
|||||||
}
|
}
|
||||||
case GyroSensor::OBJID:
|
case GyroSensor::OBJID:
|
||||||
{
|
{
|
||||||
GyroSensor *gyroSensor = GyroSensor::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(gyroSensor);
|
|
||||||
GyroSensor::DataFields gyroSensorData = gyroSensor->getData();
|
GyroSensor::DataFields gyroSensorData = gyroSensor->getData();
|
||||||
|
|
||||||
gyro_accum_x.append(gyroSensorData.x);
|
gyro_accum_x.append(gyroSensorData.x);
|
||||||
gyro_accum_y.append(gyroSensorData.y);
|
gyro_accum_y.append(gyroSensorData.y);
|
||||||
gyro_accum_z.append(gyroSensorData.z);
|
gyro_accum_z.append(gyroSensorData.z);
|
||||||
@ -149,61 +139,48 @@ void GyroBiasCalibrationModel::getSample(UAVObject *obj)
|
|||||||
if ((gyro_accum_y.size() >= LEVEL_SAMPLES || (gyro_accum_y.size() == 0 && gyro_state_accum_y.size() >= LEVEL_SAMPLES)) &&
|
if ((gyro_accum_y.size() >= LEVEL_SAMPLES || (gyro_accum_y.size() == 0 && gyro_state_accum_y.size() >= LEVEL_SAMPLES)) &&
|
||||||
collectingData == true) {
|
collectingData == true) {
|
||||||
collectingData = false;
|
collectingData = false;
|
||||||
|
m_dirty = true;
|
||||||
|
|
||||||
GyroState *gyroState = GyroState::GetInstance(getObjectManager());
|
|
||||||
disconnect(gyroState, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(getSample(UAVObject *)));
|
|
||||||
Q_ASSERT(gyroState);
|
|
||||||
|
|
||||||
GyroSensor *gyroSensor = GyroSensor::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(gyroSensor);
|
|
||||||
disconnect(gyroSensor, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(getSample(UAVObject *)));
|
disconnect(gyroSensor, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(getSample(UAVObject *)));
|
||||||
|
disconnect(gyroState, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(getSample(UAVObject *)));
|
||||||
|
|
||||||
stopped();
|
gyroState->setMetadata(memento.gyroStateMetadata);
|
||||||
|
gyroSensor->setMetadata(memento.gyroSensorMetadata);
|
||||||
RevoCalibration *revoCalibration = RevoCalibration::GetInstance(getObjectManager());
|
revoCalibration->setData(memento.revoCalibrationData);
|
||||||
Q_ASSERT(revoCalibration);
|
attitudeSettings->setData(memento.attitudeSettingsData);
|
||||||
AccelGyroSettings *accelGyroSettings = AccelGyroSettings::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(accelGyroSettings);
|
|
||||||
|
|
||||||
RevoCalibration::DataFields revoCalibrationData = revoCalibration->getData();
|
|
||||||
AccelGyroSettings::DataFields accelGyroSettingsData = accelGyroSettings->getData();
|
|
||||||
|
|
||||||
revoCalibrationData.BiasCorrectedRaw = RevoCalibration::BIASCORRECTEDRAW_TRUE;
|
|
||||||
// Update biases based on collected data
|
|
||||||
// check whether the board does supports gyroSensor(updates were received)
|
|
||||||
if (gyro_accum_x.count() < LEVEL_SAMPLES / 10) {
|
|
||||||
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_X] += OpenPilot::CalibrationUtils::listMean(gyro_state_accum_x);
|
|
||||||
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Y] += OpenPilot::CalibrationUtils::listMean(gyro_state_accum_y);
|
|
||||||
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Z] += OpenPilot::CalibrationUtils::listMean(gyro_state_accum_z);
|
|
||||||
} else {
|
|
||||||
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_X] += OpenPilot::CalibrationUtils::listMean(gyro_accum_x);
|
|
||||||
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Y] += OpenPilot::CalibrationUtils::listMean(gyro_accum_y);
|
|
||||||
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Z] += OpenPilot::CalibrationUtils::listMean(gyro_accum_z);
|
|
||||||
}
|
|
||||||
|
|
||||||
revoCalibration->setData(revoCalibrationData);
|
|
||||||
revoCalibration->updated();
|
|
||||||
accelGyroSettings->setData(accelGyroSettingsData);
|
|
||||||
accelGyroSettings->updated();
|
|
||||||
|
|
||||||
AttitudeSettings *attitudeSettings = AttitudeSettings::GetInstance(getObjectManager());
|
|
||||||
Q_ASSERT(attitudeSettings);
|
|
||||||
AttitudeSettings::DataFields attitudeSettingsData = attitudeSettings->getData();
|
|
||||||
attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_TRUE;
|
|
||||||
attitudeSettings->setData(attitudeSettingsData);
|
|
||||||
attitudeSettings->updated();
|
|
||||||
|
|
||||||
gyroState->setMetadata(initialGyroStateMdata);
|
|
||||||
gyroSensor->setMetadata(initialGyroSensorMdata);
|
|
||||||
|
|
||||||
displayInstructions(tr("Gyroscope calibration completed succesfully."), WizardModel::Success);
|
|
||||||
displayVisualHelp(CALIBRATION_HELPER_IMAGE_EMPTY);
|
|
||||||
|
|
||||||
// Recall saved board rotation
|
// Recall saved board rotation
|
||||||
recallBoardRotation();
|
recallBoardRotation();
|
||||||
|
|
||||||
|
stopped();
|
||||||
|
displayInstructions(tr("Gyroscope calibration completed succesfully."), WizardModel::Success);
|
||||||
|
displayVisualHelp(CALIBRATION_HELPER_IMAGE_EMPTY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GyroBiasCalibrationModel::save()
|
||||||
|
{
|
||||||
|
if (!m_dirty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Update biases based on collected data
|
||||||
|
AccelGyroSettings::DataFields accelGyroSettingsData = accelGyroSettings->getData();
|
||||||
|
|
||||||
|
// check whether the board does supports gyroSensor (updates were received)
|
||||||
|
if (gyro_accum_x.count() < LEVEL_SAMPLES / 10) {
|
||||||
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_X] += OpenPilot::CalibrationUtils::listMean(gyro_state_accum_x);
|
||||||
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Y] += OpenPilot::CalibrationUtils::listMean(gyro_state_accum_y);
|
||||||
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Z] += OpenPilot::CalibrationUtils::listMean(gyro_state_accum_z);
|
||||||
|
} else {
|
||||||
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_X] += OpenPilot::CalibrationUtils::listMean(gyro_accum_x);
|
||||||
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Y] += OpenPilot::CalibrationUtils::listMean(gyro_accum_y);
|
||||||
|
accelGyroSettingsData.gyro_bias[AccelGyroSettings::GYRO_BIAS_Z] += OpenPilot::CalibrationUtils::listMean(gyro_accum_z);
|
||||||
|
}
|
||||||
|
|
||||||
|
accelGyroSettings->setData(accelGyroSettingsData);
|
||||||
|
|
||||||
|
m_dirty = false;
|
||||||
|
}
|
||||||
|
|
||||||
UAVObjectManager *GyroBiasCalibrationModel::getObjectManager()
|
UAVObjectManager *GyroBiasCalibrationModel::getObjectManager()
|
||||||
{
|
{
|
||||||
|
@ -34,6 +34,12 @@
|
|||||||
#include "uavobjectmanager.h"
|
#include "uavobjectmanager.h"
|
||||||
#include "uavobject.h"
|
#include "uavobject.h"
|
||||||
|
|
||||||
|
#include <gyrostate.h>
|
||||||
|
#include <gyrosensor.h>
|
||||||
|
#include <attitudesettings.h>
|
||||||
|
#include <revocalibration.h>
|
||||||
|
#include <accelgyrosettings.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
namespace OpenPilot {
|
namespace OpenPilot {
|
||||||
@ -43,27 +49,41 @@ class GyroBiasCalibrationModel : public QObject {
|
|||||||
public:
|
public:
|
||||||
explicit GyroBiasCalibrationModel(QObject *parent = 0);
|
explicit GyroBiasCalibrationModel(QObject *parent = 0);
|
||||||
|
|
||||||
|
bool dirty()
|
||||||
|
{
|
||||||
|
return m_dirty;
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void displayVisualHelp(QString elementID);
|
|
||||||
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
|
|
||||||
void started();
|
void started();
|
||||||
void stopped();
|
void stopped();
|
||||||
void storeAndClearBoardRotation();
|
void storeAndClearBoardRotation();
|
||||||
void recallBoardRotation();
|
void recallBoardRotation();
|
||||||
void progressChanged(int value);
|
void progressChanged(int value);
|
||||||
|
void displayVisualHelp(QString elementID);
|
||||||
|
void displayInstructions(QString text, WizardModel::MessageType type = WizardModel::Info);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
// Slots for gyro bias zero
|
|
||||||
void start();
|
void start();
|
||||||
|
void save();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void getSample(UAVObject *obj);
|
void getSample(UAVObject *obj);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
typedef struct {
|
||||||
|
UAVObject::Metadata gyroStateMetadata;
|
||||||
|
UAVObject::Metadata gyroSensorMetadata;
|
||||||
|
RevoCalibration::DataFields revoCalibrationData;
|
||||||
|
AttitudeSettings::DataFields attitudeSettingsData;
|
||||||
|
} Memento;
|
||||||
|
|
||||||
QMutex sensorsUpdateLock;
|
QMutex sensorsUpdateLock;
|
||||||
|
|
||||||
bool collectingData;
|
bool collectingData;
|
||||||
|
bool m_dirty;
|
||||||
|
|
||||||
|
Memento memento;
|
||||||
|
|
||||||
QList<double> gyro_accum_x;
|
QList<double> gyro_accum_x;
|
||||||
QList<double> gyro_accum_y;
|
QList<double> gyro_accum_y;
|
||||||
@ -71,8 +91,14 @@ private:
|
|||||||
QList<double> gyro_state_accum_x;
|
QList<double> gyro_state_accum_x;
|
||||||
QList<double> gyro_state_accum_y;
|
QList<double> gyro_state_accum_y;
|
||||||
QList<double> gyro_state_accum_z;
|
QList<double> gyro_state_accum_z;
|
||||||
UAVObject::Metadata initialGyroStateMdata;
|
|
||||||
UAVObject::Metadata initialGyroSensorMdata;
|
// convenience pointers
|
||||||
|
GyroState *gyroState;
|
||||||
|
GyroSensor *gyroSensor;
|
||||||
|
RevoCalibration *revoCalibration;
|
||||||
|
AttitudeSettings *attitudeSettings;
|
||||||
|
AccelGyroSettings *accelGyroSettings;
|
||||||
|
|
||||||
UAVObjectManager *getObjectManager();
|
UAVObjectManager *getObjectManager();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,19 @@
|
|||||||
*/
|
*/
|
||||||
#include "configrevowidget.h"
|
#include "configrevowidget.h"
|
||||||
|
|
||||||
|
#include <attitudestate.h>
|
||||||
|
#include <attitudesettings.h>
|
||||||
|
#include <revocalibration.h>
|
||||||
|
#include <accelgyrosettings.h>
|
||||||
|
#include <homelocation.h>
|
||||||
|
#include <accelstate.h>
|
||||||
|
|
||||||
|
#include <magstate.h>
|
||||||
|
|
||||||
|
#include "assertions.h"
|
||||||
|
#include "calibration.h"
|
||||||
|
#include "calibration/calibrationutils.h"
|
||||||
|
|
||||||
#include "math.h"
|
#include "math.h"
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -40,26 +53,12 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
#include <attitudestate.h>
|
|
||||||
#include <attitudesettings.h>
|
|
||||||
#include <revocalibration.h>
|
|
||||||
#include <accelgyrosettings.h>
|
|
||||||
#include <homelocation.h>
|
|
||||||
#include <accelstate.h>
|
|
||||||
|
|
||||||
#include <magstate.h>
|
|
||||||
|
|
||||||
#include "assertions.h"
|
|
||||||
#include "calibration.h"
|
|
||||||
#include "calibration/calibrationutils.h"
|
|
||||||
#define sign(x) ((x < 0) ? -1 : 1)
|
#define sign(x) ((x < 0) ? -1 : 1)
|
||||||
|
|
||||||
// Uncomment this to enable 6 point calibration on the accels
|
// Uncomment this to enable 6 point calibration on the accels
|
||||||
#define NOISE_SAMPLES 50
|
#define NOISE_SAMPLES 50
|
||||||
|
|
||||||
|
|
||||||
// *****************
|
|
||||||
|
|
||||||
class Thread : public QThread {
|
class Thread : public QThread {
|
||||||
public:
|
public:
|
||||||
static void usleep(unsigned long usecs)
|
static void usleep(unsigned long usecs)
|
||||||
@ -68,14 +67,15 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// *****************
|
|
||||||
|
|
||||||
ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
||||||
ConfigTaskWidget(parent),
|
ConfigTaskWidget(parent),
|
||||||
m_ui(new Ui_RevoSensorsWidget()),
|
m_ui(new Ui_RevoSensorsWidget()),
|
||||||
isBoardRotationStored(false)
|
isBoardRotationStored(false)
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
m_ui->tabWidget->setCurrentIndex(0);
|
||||||
|
|
||||||
|
addApplySaveButtons(m_ui->revoCalSettingsSaveRAM, m_ui->revoCalSettingsSaveSD);
|
||||||
|
|
||||||
// Initialization of the visual help
|
// Initialization of the visual help
|
||||||
m_ui->calibrationVisualHelp->setScene(new QGraphicsScene(this));
|
m_ui->calibrationVisualHelp->setScene(new QGraphicsScene(this));
|
||||||
@ -86,11 +86,11 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
|||||||
|
|
||||||
// Must set up the UI (above) before setting up the UAVO mappings or refreshWidgetValues
|
// Must set up the UI (above) before setting up the UAVO mappings or refreshWidgetValues
|
||||||
// will be dealing with some null pointers
|
// will be dealing with some null pointers
|
||||||
addUAVObject("RevoCalibration");
|
// addUAVObject("RevoCalibration");
|
||||||
addUAVObject("HomeLocation");
|
addUAVObject("HomeLocation");
|
||||||
addUAVObject("AttitudeSettings");
|
// addUAVObject("AttitudeSettings");
|
||||||
addUAVObject("RevoSettings");
|
// addUAVObject("RevoSettings");
|
||||||
addUAVObject("AccelGyroSettings");
|
// addUAVObject("AccelGyroSettings");
|
||||||
autoLoadWidgets();
|
autoLoadWidgets();
|
||||||
|
|
||||||
// thermal calibration
|
// thermal calibration
|
||||||
@ -114,7 +114,6 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
|||||||
connect(m_thermalCalibrationModel, SIGNAL(temperatureChanged(float)), this, SLOT(displayTemperature(float)));
|
connect(m_thermalCalibrationModel, SIGNAL(temperatureChanged(float)), this, SLOT(displayTemperature(float)));
|
||||||
connect(m_thermalCalibrationModel, SIGNAL(temperatureGradientChanged(float)), this, SLOT(displayTemperatureGradient(float)));
|
connect(m_thermalCalibrationModel, SIGNAL(temperatureGradientChanged(float)), this, SLOT(displayTemperatureGradient(float)));
|
||||||
connect(m_thermalCalibrationModel, SIGNAL(progressChanged(int)), m_ui->thermalBiasProgress, SLOT(setValue(int)));
|
connect(m_thermalCalibrationModel, SIGNAL(progressChanged(int)), m_ui->thermalBiasProgress, SLOT(setValue(int)));
|
||||||
// note: init for m_thermalCalibrationModel is done in showEvent to prevent cases with "Start" button not enabled due to some timing issue.
|
|
||||||
|
|
||||||
// six point calibration
|
// six point calibration
|
||||||
m_sixPointCalibrationModel = new OpenPilot::SixPointCalibrationModel(this);
|
m_sixPointCalibrationModel = new OpenPilot::SixPointCalibrationModel(this);
|
||||||
@ -169,8 +168,9 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
|
|||||||
|
|
||||||
populateWidgets();
|
populateWidgets();
|
||||||
refreshWidgetsValues();
|
refreshWidgetsValues();
|
||||||
m_ui->tabWidget->setCurrentIndex(0);
|
|
||||||
enableAllCalibrations();
|
enableAllCalibrations();
|
||||||
|
|
||||||
|
forceConnectedState();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigRevoWidget::~ConfigRevoWidget()
|
ConfigRevoWidget::~ConfigRevoWidget()
|
||||||
@ -246,17 +246,21 @@ void ConfigRevoWidget::displayVisualHelp(QString elementID)
|
|||||||
void ConfigRevoWidget::clearInstructions()
|
void ConfigRevoWidget::clearInstructions()
|
||||||
{
|
{
|
||||||
m_ui->calibrationInstructions->clear();
|
m_ui->calibrationInstructions->clear();
|
||||||
|
// addInstructions(tr("Press any Start button to start a calibration step."), WizardModel::Prompt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigRevoWidget::addInstructions(QString text, WizardModel::MessageType type)
|
void ConfigRevoWidget::addInstructions(QString text, WizardModel::MessageType type)
|
||||||
{
|
{
|
||||||
if (!text.isNull()) {
|
if (!text.isNull()) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case WizardModel::Failure:
|
|
||||||
text = QString("<font color='red'>%1</font>").arg(text);
|
|
||||||
break;
|
|
||||||
case WizardModel::Prompt:
|
case WizardModel::Prompt:
|
||||||
text = QString("<font color='blue'>%1</font>").arg(text);
|
text = QString("<b><font color='blue'>%1</font>").arg(text);
|
||||||
|
break;
|
||||||
|
case WizardModel::Success:
|
||||||
|
text = QString("<b><font color='green'>%1</font>").arg(text);
|
||||||
|
break;
|
||||||
|
case WizardModel::Failure:
|
||||||
|
text = QString("<b><font color='red'>%1</font>").arg(text);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -275,8 +279,6 @@ void ConfigRevoWidget::displayTemperatureGradient(float tempGradient)
|
|||||||
m_ui->temperatureGradientLabel->setText(tr("Temperature rise %1 °C/min").arg(tempGradient, 5, 'f', 2));
|
m_ui->temperatureGradientLabel->setText(tr("Temperature rise %1 °C/min").arg(tempGradient, 5, 'f', 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/********** UI Functions *************/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the ConfigTaskWidget parent when RevoCalibration is updated
|
* Called by the ConfigTaskWidget parent when RevoCalibration is updated
|
||||||
* to update the UI
|
* to update the UI
|
||||||
@ -285,9 +287,6 @@ void ConfigRevoWidget::refreshWidgetsValues(UAVObject *object)
|
|||||||
{
|
{
|
||||||
ConfigTaskWidget::refreshWidgetsValues(object);
|
ConfigTaskWidget::refreshWidgetsValues(object);
|
||||||
|
|
||||||
|
|
||||||
m_ui->calibInstructions->setText(QString("Press \"Start\" above to calibrate."));
|
|
||||||
|
|
||||||
m_ui->isSetCheckBox->setEnabled(false);
|
m_ui->isSetCheckBox->setEnabled(false);
|
||||||
|
|
||||||
HomeLocation *homeLocation = HomeLocation::GetInstance(getObjectManager());
|
HomeLocation *homeLocation = HomeLocation::GetInstance(getObjectManager());
|
||||||
@ -298,6 +297,15 @@ void ConfigRevoWidget::refreshWidgetsValues(UAVObject *object)
|
|||||||
m_ui->beBox->setText(beStr);
|
m_ui->beBox->setText(beStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConfigRevoWidget::updateObjectsFromWidgets()
|
||||||
|
{
|
||||||
|
ConfigTaskWidget::updateObjectsFromWidgets();
|
||||||
|
|
||||||
|
if (m_gyroBiasCalibrationModel->dirty()) {
|
||||||
|
m_gyroBiasCalibrationModel->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ConfigRevoWidget::clearHomeLocation()
|
void ConfigRevoWidget::clearHomeLocation()
|
||||||
{
|
{
|
||||||
HomeLocation *homeLocation = HomeLocation::GetInstance(getObjectManager());
|
HomeLocation *homeLocation = HomeLocation::GetInstance(getObjectManager());
|
||||||
@ -318,6 +326,7 @@ void ConfigRevoWidget::clearHomeLocation()
|
|||||||
void ConfigRevoWidget::disableAllCalibrations()
|
void ConfigRevoWidget::disableAllCalibrations()
|
||||||
{
|
{
|
||||||
clearInstructions();
|
clearInstructions();
|
||||||
|
|
||||||
m_ui->sixPointsStartAccel->setEnabled(false);
|
m_ui->sixPointsStartAccel->setEnabled(false);
|
||||||
m_ui->sixPointsStartMag->setEnabled(false);
|
m_ui->sixPointsStartMag->setEnabled(false);
|
||||||
m_ui->boardLevelStart->setEnabled(false);
|
m_ui->boardLevelStart->setEnabled(false);
|
||||||
@ -327,6 +336,11 @@ void ConfigRevoWidget::disableAllCalibrations()
|
|||||||
|
|
||||||
void ConfigRevoWidget::enableAllCalibrations()
|
void ConfigRevoWidget::enableAllCalibrations()
|
||||||
{
|
{
|
||||||
|
// TODO should use a signal from m_gyroBiasCalibrationModel instead
|
||||||
|
if (m_gyroBiasCalibrationModel->dirty()) {
|
||||||
|
widgetsContentsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
m_ui->sixPointsStartAccel->setEnabled(true);
|
m_ui->sixPointsStartAccel->setEnabled(true);
|
||||||
m_ui->sixPointsStartMag->setEnabled(true);
|
m_ui->sixPointsStartMag->setEnabled(true);
|
||||||
m_ui->boardLevelStart->setEnabled(true);
|
m_ui->boardLevelStart->setEnabled(true);
|
||||||
|
@ -75,6 +75,7 @@ private slots:
|
|||||||
|
|
||||||
// ! Overriden method from the configTaskWidget to update UI
|
// ! Overriden method from the configTaskWidget to update UI
|
||||||
virtual void refreshWidgetsValues(UAVObject *object = NULL);
|
virtual void refreshWidgetsValues(UAVObject *object = NULL);
|
||||||
|
virtual void updateObjectsFromWidgets();
|
||||||
|
|
||||||
// Slot for clearing home location
|
// Slot for clearing home location
|
||||||
void clearHomeLocation();
|
void clearHomeLocation();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user