|
|
@ -51,6 +51,7 @@ SensorsComponentController::SensorsComponentController(AutoPilotPlugin* autopilo |
|
|
|
_accelCalRightSideInProgress(false), |
|
|
|
_accelCalRightSideInProgress(false), |
|
|
|
_accelCalNoseDownSideInProgress(false), |
|
|
|
_accelCalNoseDownSideInProgress(false), |
|
|
|
_accelCalTailDownSideInProgress(false), |
|
|
|
_accelCalTailDownSideInProgress(false), |
|
|
|
|
|
|
|
_textLoggingStarted(false), |
|
|
|
_autopilot(autopilot) |
|
|
|
_autopilot(autopilot) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Q_ASSERT(autopilot); |
|
|
|
Q_ASSERT(autopilot); |
|
|
@ -69,9 +70,37 @@ void SensorsComponentController::_appendStatusLog(const QString& text) |
|
|
|
Q_ARG(QVariant, varText)); |
|
|
|
Q_ARG(QVariant, varText)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::calibrateGyro(void) |
|
|
|
void SensorsComponentController::_startCalibration(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_beginTextLogging(); |
|
|
|
_beginTextLogging(); |
|
|
|
|
|
|
|
_hideAllCalAreas(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_compassButton->setEnabled(false); |
|
|
|
|
|
|
|
_gyroButton->setEnabled(false); |
|
|
|
|
|
|
|
_accelButton->setEnabled(false); |
|
|
|
|
|
|
|
_airspeedButton->setEnabled(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::_stopCalibration(bool failed) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_compassButton->setEnabled(true); |
|
|
|
|
|
|
|
_gyroButton->setEnabled(true); |
|
|
|
|
|
|
|
_accelButton->setEnabled(true); |
|
|
|
|
|
|
|
_airspeedButton->setEnabled(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_progressBar->setProperty("value", failed ? 0 : 1); |
|
|
|
|
|
|
|
_updateAndEmitGyroCalInProgress(false); |
|
|
|
|
|
|
|
_refreshParams(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (failed) { |
|
|
|
|
|
|
|
QGCMessageBox::warning("Calibration", "Calibration failed. Calibration log will be displayed."); |
|
|
|
|
|
|
|
_hideAllCalAreas(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::calibrateGyro(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
_startCalibration(); |
|
|
|
|
|
|
|
|
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
Q_ASSERT(uas); |
|
|
|
Q_ASSERT(uas); |
|
|
@ -80,8 +109,7 @@ void SensorsComponentController::calibrateGyro(void) |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::calibrateCompass(void) |
|
|
|
void SensorsComponentController::calibrateCompass(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_hideAllCalAreas(); |
|
|
|
_startCalibration(); |
|
|
|
_beginTextLogging(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
Q_ASSERT(uas); |
|
|
|
Q_ASSERT(uas); |
|
|
@ -90,7 +118,7 @@ void SensorsComponentController::calibrateCompass(void) |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::calibrateAccel(void) |
|
|
|
void SensorsComponentController::calibrateAccel(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_beginTextLogging(); |
|
|
|
_startCalibration(); |
|
|
|
|
|
|
|
|
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
Q_ASSERT(uas); |
|
|
|
Q_ASSERT(uas); |
|
|
@ -99,8 +127,7 @@ void SensorsComponentController::calibrateAccel(void) |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::calibrateAirspeed(void) |
|
|
|
void SensorsComponentController::calibrateAirspeed(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
_hideAllCalAreas(); |
|
|
|
_startCalibration(); |
|
|
|
_beginTextLogging(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
Q_ASSERT(uas); |
|
|
|
Q_ASSERT(uas); |
|
|
@ -109,9 +136,12 @@ void SensorsComponentController::calibrateAirspeed(void) |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::_beginTextLogging(void) |
|
|
|
void SensorsComponentController::_beginTextLogging(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
if (!_textLoggingStarted) { |
|
|
|
|
|
|
|
_textLoggingStarted = true; |
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
UASInterface* uas = _autopilot->uas(); |
|
|
|
Q_ASSERT(uas); |
|
|
|
Q_ASSERT(uas); |
|
|
|
connect(uas, &UASInterface::textMessageReceived, this, &SensorsComponentController::_handleUASTextMessage); |
|
|
|
connect(uas, &UASInterface::textMessageReceived, this, &SensorsComponentController::_handleUASTextMessage); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, int severity, QString text) |
|
|
|
void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, int severity, QString text) |
|
|
@ -129,7 +159,7 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
QStringList ignorePrefixList; |
|
|
|
QStringList ignorePrefixList; |
|
|
|
ignorePrefixList << "[cmd]" << "[mavlink pm]" << "[ekf check]" << "[pm]" << "[inav]"; |
|
|
|
ignorePrefixList << "[cmd]" << "[mavlink pm]" << "[ekf check]" << "[pm]" << "[inav]" << "IN AIR MODE" << "LANDED MODE"; |
|
|
|
foreach (QString ignorePrefix, ignorePrefixList) { |
|
|
|
foreach (QString ignorePrefix, ignorePrefixList) { |
|
|
|
if (text.startsWith(ignorePrefix)) { |
|
|
|
if (text.startsWith(ignorePrefix)) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -150,11 +180,9 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in |
|
|
|
_appendStatusLog(text); |
|
|
|
_appendStatusLog(text); |
|
|
|
|
|
|
|
|
|
|
|
if (text == "gyro calibration: started") { |
|
|
|
if (text == "gyro calibration: started") { |
|
|
|
_hideAllCalAreas(); |
|
|
|
|
|
|
|
_updateAndEmitShowGyroCalArea(true); |
|
|
|
_updateAndEmitShowGyroCalArea(true); |
|
|
|
_updateAndEmitGyroCalInProgress(true); |
|
|
|
_updateAndEmitGyroCalInProgress(true); |
|
|
|
} else if (text == "accel calibration: started") { |
|
|
|
} else if (text == "accel calibration: started") { |
|
|
|
_hideAllCalAreas(); |
|
|
|
|
|
|
|
_accelCalDownSideDone = false; |
|
|
|
_accelCalDownSideDone = false; |
|
|
|
_accelCalUpsideDownSideDone = false; |
|
|
|
_accelCalUpsideDownSideDone = false; |
|
|
|
_accelCalLeftSideDone = false; |
|
|
|
_accelCalLeftSideDone = false; |
|
|
@ -227,34 +255,27 @@ void SensorsComponentController::_handleUASTextMessage(int uasId, int compId, in |
|
|
|
_accelCalTailDownSideInProgress = false; |
|
|
|
_accelCalTailDownSideInProgress = false; |
|
|
|
emit accelCalSidesDoneChanged(); |
|
|
|
emit accelCalSidesDoneChanged(); |
|
|
|
emit accelCalSidesInProgressChanged(); |
|
|
|
emit accelCalSidesInProgressChanged(); |
|
|
|
_refreshParams(); |
|
|
|
_stopCalibration(false /* success */); |
|
|
|
} else if (text == "gyro calibration: done") { |
|
|
|
} else if (text == "gyro calibration: done") { |
|
|
|
_progressBar->setProperty("value", 1); |
|
|
|
_stopCalibration(false /* success */); |
|
|
|
_updateAndEmitGyroCalInProgress(false); |
|
|
|
|
|
|
|
_refreshParams(); |
|
|
|
|
|
|
|
} else if (text == "mag calibration: done" || text == "dpress calibration: done") { |
|
|
|
} else if (text == "mag calibration: done" || text == "dpress calibration: done") { |
|
|
|
_progressBar->setProperty("value", 1); |
|
|
|
_stopCalibration(false /* success */); |
|
|
|
_refreshParams(); |
|
|
|
|
|
|
|
} else if (text.endsWith(" calibration: failed")) { |
|
|
|
} else if (text.endsWith(" calibration: failed")) { |
|
|
|
QGCMessageBox::warning("Calibration", "Calibration failed. Calibration log will be displayed."); |
|
|
|
_stopCalibration(true /* failed */); |
|
|
|
_hideAllCalAreas(); |
|
|
|
|
|
|
|
_progressBar->setProperty("value", 0); |
|
|
|
|
|
|
|
_updateAndEmitGyroCalInProgress(false); |
|
|
|
|
|
|
|
_refreshParams(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void SensorsComponentController::_refreshParams(void) |
|
|
|
void SensorsComponentController::_refreshParams(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#if 0 |
|
|
|
_autopilot->refreshParameter("CAL_MAG0_ID"); |
|
|
|
// FIXME: Not sure if firmware issue yet
|
|
|
|
_autopilot->refreshParameter("CAL_GYRO0_ID"); |
|
|
|
_autopilot->refreshParametersPrefix("CAL_"); |
|
|
|
_autopilot->refreshParameter("CAL_ACC0_ID"); |
|
|
|
_autopilot->refreshParametersPrefix("SENS_"); |
|
|
|
_autopilot->refreshParameter("SENS_DPRES_OFF"); |
|
|
|
#else |
|
|
|
|
|
|
|
// Sending too many parameter requests like above doesn't seem to work. So for now,
|
|
|
|
_autopilot->refreshParameter("CAL_MAG0_ROT"); |
|
|
|
// ask for everything back
|
|
|
|
_autopilot->refreshParameter("CAL_MAG1_ROT"); |
|
|
|
_autopilot->refreshAllParameters(); |
|
|
|
_autopilot->refreshParameter("CAL_MAG2_ROT"); |
|
|
|
#endif |
|
|
|
_autopilot->refreshParameter("SENS_BOARD_ROT"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool SensorsComponentController::fixedWing(void) |
|
|
|
bool SensorsComponentController::fixedWing(void) |
|
|
|