1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-01 18:29:16 +01:00

OP-975 remove "magic strings", cleanup

This commit is contained in:
Alessio Morale 2014-04-27 12:58:59 +02:00
parent 76b19f8c35
commit bb35a8fc97
17 changed files with 55 additions and 34 deletions

View File

@ -0,0 +1,16 @@
#ifndef CALIBRATIONUIUTILS_H
#define CALIBRATIONUIUTILS_H
#define CALIBRATION_HELPER_IMAGE_NED QStringLiteral("ned")
#define CALIBRATION_HELPER_IMAGE_DWN QStringLiteral("dwn")
#define CALIBRATION_HELPER_IMAGE_ENU QStringLiteral("enu")
#define CALIBRATION_HELPER_IMAGE_SUW QStringLiteral("suw")
#define CALIBRATION_HELPER_IMAGE_SWD QStringLiteral("swd")
#define CALIBRATION_HELPER_IMAGE_USE QStringLiteral("use")
#define CALIBRATION_HELPER_IMAGE_WDS QStringLiteral("wds")
#define CALIBRATION_HELPER_IMAGE_EMPTY QStringLiteral("empty")
#define CALIBRATION_HELPER_BOARD_PREFIX QStringLiteral("board-")
#define CALIBRATION_HELPER_PLANE_PREFIX QStringLiteral("plane-")
#endif // CALIBRATIONUIUTILS_H

View File

@ -33,14 +33,15 @@
#include <accelgyrosettings.h> #include <accelgyrosettings.h>
#include "calibration/gyrobiascalibrationmodel.h" #include "calibration/gyrobiascalibrationmodel.h"
#include "calibration/calibrationutils.h" #include "calibration/calibrationutils.h"
#include "calibration/calibrationuiutils.h"
static const int LEVEL_SAMPLES = 100; static const int LEVEL_SAMPLES = 100;
#include "gyrobiascalibrationmodel.h" #include "gyrobiascalibrationmodel.h"
namespace OpenPilot { namespace OpenPilot {
GyroBiasCalibrationModel::GyroBiasCalibrationModel(QObject *parent) : GyroBiasCalibrationModel::GyroBiasCalibrationModel(QObject *parent) :
QObject(parent), QObject(parent),
collectingData(false) collectingData(false)
{ {}
}
/******* gyro bias zero ******/ /******* gyro bias zero ******/
@ -66,7 +67,7 @@ void GyroBiasCalibrationModel::start()
attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_FALSE; attitudeSettingsData.BiasCorrectGyro = AttitudeSettings::BIASCORRECTGYRO_FALSE;
attitudeSettings->setData(attitudeSettingsData); attitudeSettings->setData(attitudeSettingsData);
attitudeSettings->updated(); attitudeSettings->updated();
displayVisualHelp("plane-ned"); displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED);
displayInstructions("Calibrating the gyroscopes. Keep the copter/plane steady...", true); displayInstructions("Calibrating the gyroscopes. Keep the copter/plane steady...", true);
gyro_accum_x.clear(); gyro_accum_x.clear();
@ -158,6 +159,7 @@ void GyroBiasCalibrationModel::getSample(UAVObject *obj)
gyroState->setMetadata(initialGyroStateMdata); gyroState->setMetadata(initialGyroStateMdata);
displayInstructions("Calibration done!", false); displayInstructions("Calibration done!", false);
displayVisualHelp(CALIBRATION_HELPER_IMAGE_EMPTY);
// Recall saved board rotation // Recall saved board rotation
recallBoardRotation(); recallBoardRotation();
} }

View File

@ -34,8 +34,7 @@
#include "uavobjectmanager.h" #include "uavobjectmanager.h"
#include "uavobject.h" #include "uavobject.h"
namespace OpenPilot { namespace OpenPilot {
class GyroBiasCalibrationModel : public QObject class GyroBiasCalibrationModel : public QObject {
{
Q_OBJECT Q_OBJECT
public: public:
explicit GyroBiasCalibrationModel(QObject *parent = 0); explicit GyroBiasCalibrationModel(QObject *parent = 0);

View File

@ -29,13 +29,13 @@
#include <attitudestate.h> #include <attitudestate.h>
#include <attitudesettings.h> #include <attitudesettings.h>
#include "extensionsystem/pluginmanager.h" #include "extensionsystem/pluginmanager.h"
#include "calibration/calibrationuiutils.h"
static const int LEVEL_SAMPLES = 100; static const int LEVEL_SAMPLES = 100;
namespace OpenPilot { namespace OpenPilot {
LevelCalibrationModel::LevelCalibrationModel(QObject *parent) : LevelCalibrationModel::LevelCalibrationModel(QObject *parent) :
QObject(parent) QObject(parent)
{ {}
}
/******* Level calibration *******/ /******* Level calibration *******/
@ -63,7 +63,7 @@ void LevelCalibrationModel::start()
/* Show instructions and enable controls */ /* Show instructions and enable controls */
displayInstructions("Place horizontally and click save position...", true); displayInstructions("Place horizontally and click save position...", true);
displayVisualHelp("plane-ned"); displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_NED);
disableAllCalibrations(); disableAllCalibrations();
savePositionEnabledChanged(true); savePositionEnabledChanged(true);
position = 0; position = 0;
@ -131,7 +131,7 @@ void LevelCalibrationModel::getSample(UAVObject *obj)
rot_data_roll = OpenPilot::CalibrationUtils::listMean(rot_accum_roll); rot_data_roll = OpenPilot::CalibrationUtils::listMean(rot_accum_roll);
displayInstructions("Leave horizontally, rotate 180° along yaw axis and click save position...", true); displayInstructions("Leave horizontally, rotate 180° along yaw axis and click save position...", true);
displayVisualHelp("plane-swd"); displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + CALIBRATION_HELPER_IMAGE_SWD);
disableAllCalibrations(); disableAllCalibrations();
@ -145,6 +145,7 @@ void LevelCalibrationModel::getSample(UAVObject *obj)
attitudeState->setMetadata(initialAttitudeStateMdata); attitudeState->setMetadata(initialAttitudeStateMdata);
compute(); compute();
enableAllCalibrations(); enableAllCalibrations();
displayVisualHelp(CALIBRATION_HELPER_IMAGE_EMPTY);
break; break;
} }
} }

View File

@ -39,8 +39,7 @@
#include <accelstate.h> #include <accelstate.h>
#include <magstate.h> #include <magstate.h>
namespace OpenPilot { namespace OpenPilot {
class LevelCalibrationModel : public QObject class LevelCalibrationModel : public QObject {
{
Q_OBJECT Q_OBJECT
public: public:
explicit LevelCalibrationModel(QObject *parent = 0); explicit LevelCalibrationModel(QObject *parent = 0);

View File

@ -30,6 +30,7 @@
#include "extensionsystem/pluginmanager.h" #include "extensionsystem/pluginmanager.h"
#include <QMessageBox> #include <QMessageBox>
#include "math.h" #include "math.h"
#include "calibration/calibrationuiutils.h"
#define POINT_SAMPLE_SIZE 50 #define POINT_SAMPLE_SIZE 50
#define GRAVITY 9.81f #define GRAVITY 9.81f
@ -151,7 +152,7 @@ void SixPointCalibrationModel::start(bool calibrateAccel, bool calibrateMag)
/* Show instructions and enable controls */ /* Show instructions and enable controls */
displayInstructions("Place horizontally, nose pointing north and click save position...", true); displayInstructions("Place horizontally, nose pointing north and click save position...", true);
showHelp("ned"); showHelp(CALIBRATION_HELPER_IMAGE_NED);
disableAllCalibrations(); disableAllCalibrations();
savePositionEnabledChanged(true); savePositionEnabledChanged(true);
position = 0; position = 0;
@ -242,29 +243,30 @@ void SixPointCalibrationModel::getSample(UAVObject *obj)
position = (position + 1) % 6; position = (position + 1) % 6;
if (position == 1) { if (position == 1) {
displayInstructions("Place with nose down, right side west and click save position...", false); displayInstructions("Place with nose down, right side west and click save position...", false);
showHelp("dwn"); showHelp(CALIBRATION_HELPER_IMAGE_DWN);
} }
if (position == 2) { if (position == 2) {
displayInstructions("Place right side down, nose west and click save position...", false); displayInstructions("Place right side down, nose west and click save position...", false);
showHelp("wds"); showHelp(CALIBRATION_HELPER_IMAGE_WDS);
} }
if (position == 3) { if (position == 3) {
displayInstructions("Place upside down, nose east and click save position...", false); displayInstructions("Place upside down, nose east and click save position...", false);
showHelp("enu"); showHelp(CALIBRATION_HELPER_IMAGE_ENU);
} }
if (position == 4) { if (position == 4) {
displayInstructions("Place with nose up, left side north and click save position...", false); displayInstructions("Place with nose up, left side north and click save position...", false);
showHelp("use"); showHelp(CALIBRATION_HELPER_IMAGE_USE);
} }
if (position == 5) { if (position == 5) {
displayInstructions("Place with left side down, nose south and click save position...", false); displayInstructions("Place with left side down, nose south and click save position...", false);
showHelp("suw"); showHelp(CALIBRATION_HELPER_IMAGE_SUW);
} }
if (position == 0) { if (position == 0) {
compute(calibratingMag, calibratingAccel); compute(calibratingMag, calibratingAccel);
savePositionEnabledChanged(false); savePositionEnabledChanged(false);
enableAllCalibrations(); enableAllCalibrations();
showHelp(CALIBRATION_HELPER_IMAGE_EMPTY);
/* Cleanup original settings */ /* Cleanup original settings */
accelState->setMetadata(initialAccelStateMdata); accelState->setMetadata(initialAccelStateMdata);
@ -381,13 +383,16 @@ UAVObjectManager *SixPointCalibrationModel::getObjectManager()
Q_ASSERT(objMngr); Q_ASSERT(objMngr);
return objMngr; return objMngr;
} }
void SixPointCalibrationModel::showHelp(QString image){ void SixPointCalibrationModel::showHelp(QString image)
{
if(calibratingAccel){ if (image == CALIBRATION_HELPER_IMAGE_EMPTY) {
displayVisualHelp(image); displayVisualHelp(image);
}else { } else {
displayVisualHelp("plane-" + image); if (calibratingAccel) {
displayVisualHelp(CALIBRATION_HELPER_BOARD_PREFIX + image);
} else {
displayVisualHelp(CALIBRATION_HELPER_PLANE_PREFIX + image);
}
} }
} }
} }

View File

@ -54,7 +54,8 @@ HEADERS += configplugin.h \
calibration/thermal/compensationcalculationtransition.h \ calibration/thermal/compensationcalculationtransition.h \
calibration/sixpointcalibrationmodel.h \ calibration/sixpointcalibrationmodel.h \
calibration/levelcalibrationmodel.h \ calibration/levelcalibrationmodel.h \
calibration/gyrobiascalibrationmodel.h calibration/gyrobiascalibrationmodel.h \
calibration/calibrationuiutils.h
SOURCES += configplugin.cpp \ SOURCES += configplugin.cpp \
configgadgetwidget.cpp \ configgadgetwidget.cpp \

View File

@ -30,22 +30,20 @@
<file>images/pipx-normal.png</file> <file>images/pipx-normal.png</file>
<file>images/revolution_top.png</file> <file>images/revolution_top.png</file>
<file>calibration/WizardStepIndicator.qml</file> <file>calibration/WizardStepIndicator.qml</file>
<file>images/calibration/plane-horizontal.png</file> <file>images/calibration/board-dwn.png</file>
<file>images/calibration/plane-horizontal-rotated.png</file> <file>images/calibration/board-enu.png</file>
<file>images/calibration/dwn.png</file>
<file>images/calibration/enu.png</file>
<file>images/calibration/plane-dwn.png</file> <file>images/calibration/plane-dwn.png</file>
<file>images/calibration/plane-enu.png</file> <file>images/calibration/plane-enu.png</file>
<file>images/calibration/plane-ned.png</file> <file>images/calibration/plane-ned.png</file>
<file>images/calibration/plane-suw.png</file> <file>images/calibration/plane-suw.png</file>
<file>images/calibration/plane-use.png</file> <file>images/calibration/plane-use.png</file>
<file>images/calibration/plane-wds.png</file> <file>images/calibration/plane-wds.png</file>
<file>images/calibration/ned.png</file> <file>images/calibration/board-ned.png</file>
<file>images/calibration/suw.png</file> <file>images/calibration/board-suw.png</file>
<file>images/calibration/use.png</file> <file>images/calibration/board-use.png</file>
<file>images/calibration/wds.png</file> <file>images/calibration/board-wds.png</file>
<file>images/calibration/empty.png</file> <file>images/calibration/empty.png</file>
<file>images/calibration/plane-swd.png</file> <file>images/calibration/plane-swd.png</file>
<file>images/calibration/swd.png</file> <file>images/calibration/board-swd.png</file>
</qresource> </qresource>
</RCC> </RCC>

View File

@ -139,7 +139,7 @@ ConfigRevoWidget::ConfigRevoWidget(QWidget *parent) :
m_gyroBiasCalibrationModel = new OpenPilot::GyroBiasCalibrationModel(this); m_gyroBiasCalibrationModel = new OpenPilot::GyroBiasCalibrationModel(this);
connect(m_ui->gyroBiasStart, SIGNAL(clicked()), m_gyroBiasCalibrationModel, SLOT(start())); connect(m_ui->gyroBiasStart, SIGNAL(clicked()), m_gyroBiasCalibrationModel, SLOT(start()));
connect(m_gyroBiasCalibrationModel , SIGNAL(progressChanged(int)), this->m_ui->gyroBiasProgress, SLOT(setValue(int))); connect(m_gyroBiasCalibrationModel, SIGNAL(progressChanged(int)), this->m_ui->gyroBiasProgress, SLOT(setValue(int)));
connect(m_gyroBiasCalibrationModel, SIGNAL(disableAllCalibrations()), this, SLOT(disableAllCalibrations())); connect(m_gyroBiasCalibrationModel, SIGNAL(disableAllCalibrations()), this, SLOT(disableAllCalibrations()));
connect(m_gyroBiasCalibrationModel, SIGNAL(enableAllCalibrations()), this, SLOT(enableAllCalibrations())); connect(m_gyroBiasCalibrationModel, SIGNAL(enableAllCalibrations()), this, SLOT(enableAllCalibrations()));

View File

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

View File

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 86 KiB

View File

Before

Width:  |  Height:  |  Size: 75 KiB

After

Width:  |  Height:  |  Size: 75 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 117 KiB

After

Width:  |  Height:  |  Size: 117 KiB

View File

Before

Width:  |  Height:  |  Size: 56 KiB

After

Width:  |  Height:  |  Size: 56 KiB

View File

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB