@ -294,7 +294,7 @@ void APMSensorsComponentController::calibrateAccel(void)
@@ -294,7 +294,7 @@ void APMSensorsComponentController::calibrateAccel(void)
_calTypeInProgress = CalTypeAccel ;
_vehicle - > setConnectionLostEnabled ( false ) ;
_startLogCalibration ( ) ;
_uas - > startCalibration ( UASInterfac e: : Start CalibrationAccel) ;
_vehicle - > startCalibration ( Vehicl e: : CalibrationAccel ) ;
}
void APMSensorsComponentController : : calibrateMotorInterference ( void )
@ -305,7 +305,7 @@ void APMSensorsComponentController::calibrateMotorInterference(void)
@@ -305,7 +305,7 @@ void APMSensorsComponentController::calibrateMotorInterference(void)
_appendStatusLog ( tr ( " Raise the throttle slowly to between 50% ~ 75% (the props will spin!) for 5 ~ 10 seconds. " ) ) ;
_appendStatusLog ( tr ( " Quickly bring the throttle back down to zero " ) ) ;
_appendStatusLog ( tr ( " Press the Next button to complete the calibration " ) ) ;
_uas - > startCalibration ( UASInterfac e: : Start CalibrationCompassMot) ;
_vehicle - > startCalibration ( Vehicl e: : CalibrationAPM CompassMot ) ;
}
void APMSensorsComponentController : : levelHorizon ( void )
@ -314,7 +314,7 @@ void APMSensorsComponentController::levelHorizon(void)
@@ -314,7 +314,7 @@ void APMSensorsComponentController::levelHorizon(void)
_vehicle - > setConnectionLostEnabled ( false ) ;
_startLogCalibration ( ) ;
_appendStatusLog ( tr ( " Hold the vehicle in its level flight position. " ) ) ;
_uas - > startCalibration ( UASInterfac e: : Start CalibrationLevel) ;
_vehicle - > startCalibration ( Vehicl e: : CalibrationLevel ) ;
}
void APMSensorsComponentController : : calibratePressure ( void )
@ -323,7 +323,16 @@ void APMSensorsComponentController::calibratePressure(void)
@@ -323,7 +323,16 @@ void APMSensorsComponentController::calibratePressure(void)
_vehicle - > setConnectionLostEnabled ( false ) ;
_startLogCalibration ( ) ;
_appendStatusLog ( tr ( " Requesting pressure calibration... " ) ) ;
_uas - > startCalibration ( UASInterface : : StartCalibrationPressure ) ;
_vehicle - > startCalibration ( Vehicle : : CalibrationAPMPressureAirspeed ) ;
}
void APMSensorsComponentController : : calibrateGyro ( void )
{
_calTypeInProgress = CalTypeGyro ;
_vehicle - > setConnectionLostEnabled ( false ) ;
_startLogCalibration ( ) ;
_appendStatusLog ( tr ( " Requesting gyro calibration... " ) ) ;
_vehicle - > startCalibration ( Vehicle : : CalibrationGyro ) ;
}
void APMSensorsComponentController : : _handleUASTextMessage ( int uasId , int compId , int severity , QString text )
@ -444,203 +453,6 @@ void APMSensorsComponentController::_handleUASTextMessage(int uasId, int compId,
@@ -444,203 +453,6 @@ void APMSensorsComponentController::_handleUASTextMessage(int uasId, int compId,
_stopCalibration ( StopCalibrationFailed ) ;
return ;
}
#if 0
if ( text . contains ( QLatin1Literal ( " progress < " ) ) ) {
QString percent = text . split ( " < " ) . last ( ) . split ( " > " ) . first ( ) ;
bool ok ;
int p = percent . toInt ( & ok ) ;
if ( ok & & _progressBar ) {
_progressBar - > setProperty ( " value " , ( float ) ( p / 100.0 ) ) ;
}
return ;
}
QString anyKey ( QStringLiteral ( " and press any " ) ) ;
if ( text . contains ( anyKey ) ) {
text = text . left ( text . indexOf ( anyKey ) ) + QStringLiteral ( " and click Next to continue. " ) ;
_nextButton - > setEnabled ( true ) ;
}
_appendStatusLog ( text ) ;
qCDebug ( APMSensorsComponentControllerLog ) < < text < < severity ;
if ( text . contains ( QLatin1String ( " Calibration successful " ) ) ) {
_stopCalibration ( StopCalibrationSuccess ) ;
return ;
}
if ( text . contains ( QLatin1String ( " FAILED " ) ) ) {
_stopCalibration ( StopCalibrationFailed ) ;
return ;
}
// All calibration messages start with [cal]
QString calPrefix ( QStringLiteral ( " [cal] " ) ) ;
if ( ! text . startsWith ( calPrefix ) ) {
return ;
}
text = text . right ( text . length ( ) - calPrefix . length ( ) ) ;
QString calStartPrefix ( QStringLiteral ( " calibration started: " ) ) ;
if ( text . startsWith ( calStartPrefix ) ) {
text = text . right ( text . length ( ) - calStartPrefix . length ( ) ) ;
_startVisualCalibration ( ) ;
if ( text = = QLatin1Literal ( " accel " ) | | text = = QLatin1Literal ( " mag " ) | | text = = QLatin1Literal ( " gyro " ) ) {
// Reset all progress indication
_orientationCalDownSideDone = false ;
_orientationCalUpsideDownSideDone = false ;
_orientationCalLeftSideDone = false ;
_orientationCalRightSideDone = false ;
_orientationCalTailDownSideDone = false ;
_orientationCalNoseDownSideDone = false ;
_orientationCalDownSideInProgress = false ;
_orientationCalUpsideDownSideInProgress = false ;
_orientationCalLeftSideInProgress = false ;
_orientationCalRightSideInProgress = false ;
_orientationCalNoseDownSideInProgress = false ;
_orientationCalTailDownSideInProgress = false ;
// Reset all visibility
_orientationCalDownSideVisible = false ;
_orientationCalUpsideDownSideVisible = false ;
_orientationCalLeftSideVisible = false ;
_orientationCalRightSideVisible = false ;
_orientationCalTailDownSideVisible = false ;
_orientationCalNoseDownSideVisible = false ;
_orientationCalAreaHelpText - > setProperty ( " text " , " Place your vehicle into one of the Incomplete orientations shown below and hold it still " ) ;
if ( text = = " accel " ) {
_calTypeInProgress = CalTypeAccel ;
_orientationCalDownSideVisible = true ;
_orientationCalUpsideDownSideVisible = true ;
_orientationCalLeftSideVisible = true ;
_orientationCalRightSideVisible = true ;
_orientationCalTailDownSideVisible = true ;
_orientationCalNoseDownSideVisible = true ;
} else if ( text = = " mag " ) {
_calTypeInProgress = CalTypeOffboardCompass ;
_orientationCalDownSideVisible = true ;
_orientationCalUpsideDownSideVisible = true ;
_orientationCalLeftSideVisible = true ;
_orientationCalRightSideVisible = true ;
_orientationCalTailDownSideVisible = true ;
_orientationCalNoseDownSideVisible = true ;
} else {
Q_ASSERT ( false ) ;
}
emit orientationCalSidesDoneChanged ( ) ;
emit orientationCalSidesVisibleChanged ( ) ;
emit orientationCalSidesInProgressChanged ( ) ;
_updateAndEmitShowOrientationCalArea ( true ) ;
}
return ;
}
if ( text . endsWith ( QLatin1Literal ( " orientation detected " ) ) ) {
QString side = text . section ( " " , 0 , 0 ) ;
qDebug ( ) < < " Side started " < < side ;
if ( side = = QLatin1Literal ( " down " ) ) {
_orientationCalDownSideInProgress = true ;
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalDownSideRotate = true ;
}
} else if ( side = = QLatin1Literal ( " up " ) ) {
_orientationCalUpsideDownSideInProgress = true ;
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalUpsideDownSideRotate = true ;
}
} else if ( side = = QLatin1Literal ( " left " ) ) {
_orientationCalLeftSideInProgress = true ;
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalLeftSideRotate = true ;
}
} else if ( side = = QLatin1Literal ( " right " ) ) {
_orientationCalRightSideInProgress = true ;
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalRightSideRotate = true ;
}
} else if ( side = = QLatin1Literal ( " front " ) ) {
_orientationCalNoseDownSideInProgress = true ;
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalNoseDownSideRotate = true ;
}
} else if ( side = = QLatin1Literal ( " back " ) ) {
_orientationCalTailDownSideInProgress = true ;
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalTailDownSideRotate = true ;
}
}
if ( _calTypeInProgress = = CalTypeOffboardCompass ) {
_orientationCalAreaHelpText - > setProperty ( " text " , tr ( " Rotate the vehicle continuously as shown in the diagram until marked as Completed " ) ) ;
} else {
_orientationCalAreaHelpText - > setProperty ( " text " , tr ( " Hold still in the current orientation " ) ) ;
}
emit orientationCalSidesInProgressChanged ( ) ;
emit orientationCalSidesRotateChanged ( ) ;
return ;
}
if ( text . endsWith ( QLatin1Literal ( " side done, rotate to a different side " ) ) ) {
QString side = text . section ( " " , 0 , 0 ) ;
qDebug ( ) < < " Side finished " < < side ;
if ( side = = QLatin1Literal ( " down " ) ) {
_orientationCalDownSideInProgress = false ;
_orientationCalDownSideDone = true ;
_orientationCalDownSideRotate = false ;
} else if ( side = = QLatin1Literal ( " up " ) ) {
_orientationCalUpsideDownSideInProgress = false ;
_orientationCalUpsideDownSideDone = true ;
_orientationCalUpsideDownSideRotate = false ;
} else if ( side = = QLatin1Literal ( " left " ) ) {
_orientationCalLeftSideInProgress = false ;
_orientationCalLeftSideDone = true ;
_orientationCalLeftSideRotate = false ;
} else if ( side = = QLatin1Literal ( " right " ) ) {
_orientationCalRightSideInProgress = false ;
_orientationCalRightSideDone = true ;
_orientationCalRightSideRotate = false ;
} else if ( side = = QLatin1Literal ( " front " ) ) {
_orientationCalNoseDownSideInProgress = false ;
_orientationCalNoseDownSideDone = true ;
_orientationCalNoseDownSideRotate = false ;
} else if ( side = = QLatin1Literal ( " back " ) ) {
_orientationCalTailDownSideInProgress = false ;
_orientationCalTailDownSideDone = true ;
_orientationCalTailDownSideRotate = false ;
}
_orientationCalAreaHelpText - > setProperty ( " text " , tr ( " Place you vehicle into one of the orientations shown below and hold it still " ) ) ;
emit orientationCalSidesInProgressChanged ( ) ;
emit orientationCalSidesDoneChanged ( ) ;
emit orientationCalSidesRotateChanged ( ) ;
return ;
}
if ( text . startsWith ( QLatin1Literal ( " calibration done: " ) ) ) {
_stopCalibration ( StopCalibrationSuccess ) ;
return ;
}
if ( text . startsWith ( QLatin1Literal ( " calibration cancelled " ) ) ) {
_stopCalibration ( _waitingForCancel ? StopCalibrationCancelled : StopCalibrationFailed ) ;
return ;
}
if ( text . startsWith ( QLatin1Literal ( " calibration failed " ) ) ) {
_stopCalibration ( StopCalibrationFailed ) ;
return ;
}
# endif
}
void APMSensorsComponentController : : _refreshParams ( void )
@ -685,7 +497,7 @@ void APMSensorsComponentController::cancelCalibration(void)
@@ -685,7 +497,7 @@ void APMSensorsComponentController::cancelCalibration(void)
emit waitingForCancelChanged ( ) ;
// The firmware doesn't always allow us to cancel calibration. The best we can do is wait
// for it to timeout.
_uas - > stopCalibration ( ) ;
_vehicle - > stopCalibration ( ) ;
}
}
@ -728,36 +540,18 @@ bool APMSensorsComponentController::usingUDPLink(void)
@@ -728,36 +540,18 @@ bool APMSensorsComponentController::usingUDPLink(void)
void APMSensorsComponentController : : _handleCommandAck ( mavlink_message_t & message )
{
if ( _calTypeInProgress = = CalTypeLevelHorizon ) {
mavlink_command_ack_t commandAck ;
mavlink_msg_command_ack_decode ( & message , & commandAck ) ;
if ( commandAck . command = = MAV_CMD_PREFLIGHT_CALIBRATION ) {
switch ( commandAck . result ) {
case MAV_RESULT_ACCEPTED :
_appendStatusLog ( tr ( " Level horizon complete " ) ) ;
_stopCalibration ( StopCalibrationSuccessShowLog ) ;
break ;
default :
_appendStatusLog ( tr ( " Level horizon failed " ) ) ;
_stopCalibration ( StopCalibrationFailed ) ;
break ;
}
}
}
if ( _calTypeInProgress = = CalTypePressure ) {
if ( _calTypeInProgress = = CalTypeLevelHorizon | | _calTypeInProgress = = CalTypeGyro | | _calTypeInProgress = = CalTypePressure ) {
mavlink_command_ack_t commandAck ;
mavlink_msg_command_ack_decode ( & message , & commandAck ) ;
if ( commandAck . command = = MAV_CMD_PREFLIGHT_CALIBRATION ) {
switch ( commandAck . result ) {
case MAV_RESULT_ACCEPTED :
_appendStatusLog ( tr ( " Pressure calibration success " ) ) ;
_appendStatusLog ( tr ( " Successfully completed " ) ) ;
_stopCalibration ( StopCalibrationSuccessShowLog ) ;
break ;
default :
_appendStatusLog ( tr ( " Pressure calibration fail " ) ) ;
_appendStatusLog ( tr ( " Failed " ) ) ;
_stopCalibration ( StopCalibrationFailed ) ;
break ;
}