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

OP-1150 UI for thermal calibration: fill calibraion extent fields for baro

This commit is contained in:
Alessio Morale 2014-01-28 23:11:04 +01:00
parent f1bea0556d
commit bd5824f83d
2 changed files with 16 additions and 6 deletions

View File

@ -76,7 +76,6 @@ bool ThermalCalibrationHelper::setupBoardForCalibration()
for (int i = 0; i < AccelGyroSettings::GYRO_TEMP_COEFF_NUMELEM; i++) { for (int i = 0; i < AccelGyroSettings::GYRO_TEMP_COEFF_NUMELEM; i++) {
data.gyro_temp_coeff[i] = 0.0f; data.gyro_temp_coeff[i] = 0.0f;
} }
accelGyroSettings->setData(data); accelGyroSettings->setData(data);
// clean any correction before calibrating // clean any correction before calibrating
@ -86,6 +85,9 @@ bool ThermalCalibrationHelper::setupBoardForCalibration()
for (uint i = 0; i < RevoSettings::BAROTEMPCORRECTIONPOLYNOMIAL_NUMELEM; i++) { for (uint i = 0; i < RevoSettings::BAROTEMPCORRECTIONPOLYNOMIAL_NUMELEM; i++) {
revoSettingsData.BaroTempCorrectionPolynomial[i] = 0.0f; revoSettingsData.BaroTempCorrectionPolynomial[i] = 0.0f;
} }
revoSettingsData.BaroTempCorrectionExtent[0] = 0.0f;
revoSettingsData.BaroTempCorrectionExtent[1] = 0.0f;
revoSettings->setData(revoSettingsData); revoSettings->setData(revoSettingsData);
return true; return true;
@ -297,6 +299,8 @@ void ThermalCalibrationHelper::calculate()
m_results.baroCalibrated = ThermalCalibration::BarometerCalibration(datax, datat, m_results.baro, &m_results.baroInSigma, &m_results.baroOutSigma); m_results.baroCalibrated = ThermalCalibration::BarometerCalibration(datax, datat, m_results.baro, &m_results.baroInSigma, &m_results.baroOutSigma);
m_results.baroTempMin = datat.array().minCoeff();
m_results.baroTempMax = datat.array().maxCoeff();
setProcessPercentage(processPercentage() + 2); setProcessPercentage(processPercentage() + 2);
count = m_gyroSamples.count(); count = m_gyroSamples.count();
datax.resize(count); datax.resize(count);
@ -388,7 +392,7 @@ void ThermalCalibrationHelper::updateTemp(float temp)
} else if (m_gradient > .1 && m_initialGradient / 2.0f > m_gradient) { } else if (m_gradient > .1 && m_initialGradient / 2.0f > m_gradient) {
qDebug() << "M_gradient " << m_gradient << " Elapsed" << elapsed << " m_initialGradient" << m_initialGradient; qDebug() << "M_gradient " << m_gradient << " Elapsed" << elapsed << " m_initialGradient" << m_initialGradient;
// make a rough estimation of the time needed // make a rough estimation of the time needed
m_targetduration = elapsed * 5; m_targetduration = elapsed * 7;
} }
} }
} }
@ -440,10 +444,14 @@ void ThermalCalibrationHelper::copyResultToSettings()
if (m_results.baroCalibrated) { if (m_results.baroCalibrated) {
RevoSettings *revosettings = RevoSettings::GetInstance(objManager); RevoSettings *revosettings = RevoSettings::GetInstance(objManager);
Q_ASSERT(revosettings); Q_ASSERT(revosettings);
revosettings->setBaroTempCorrectionPolynomial_a(m_results.baro[0]); RevoSettings::DataFields revosettingsdata = revosettings->getData();
revosettings->setBaroTempCorrectionPolynomial_b(m_results.baro[1]); revosettingsdata.BaroTempCorrectionPolynomial[0] = m_results.baro[0];
revosettings->setBaroTempCorrectionPolynomial_c(m_results.baro[2]); revosettingsdata.BaroTempCorrectionPolynomial[1] = m_results.baro[1];
revosettings->setBaroTempCorrectionPolynomial_d(m_results.baro[3]); revosettingsdata.BaroTempCorrectionPolynomial[2] = m_results.baro[2];
revosettingsdata.BaroTempCorrectionPolynomial[3] = m_results.baro[3];
revosettingsdata.BaroTempCorrectionExtent[0] = m_results.baroTempMin;
revosettingsdata.BaroTempCorrectionExtent[1] = m_results.baroTempMax;
revosettings->setData(revosettingsdata);
revosettings->updated(); revosettings->updated();
} }

View File

@ -77,6 +77,8 @@ typedef struct {
float gyroInSigma[3]; float gyroInSigma[3];
float gyroOutSigma[3]; float gyroOutSigma[3];
float baroTempMin;
float baroTempMax;
} thermalCalibrationResults; } thermalCalibrationResults;
class ThermalCalibrationHelper : public QObject { class ThermalCalibrationHelper : public QObject {
Q_OBJECT Q_OBJECT