diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 29b6282dc93f15fc0922922528074e3e6c7415ba..b0d5bbb9744829d3b522bbf8436ebbe16cdad46f 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -31,12 +31,17 @@ // These two list must be kept in sync /// @brief Parameters which signal a change in setupComplete state -static const char* triggerParams[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL }; +static const char* triggerParamsV1[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL }; +static const char* triggerParamsV2[] = { "CAL_MAG0_ID", "CAL_GYRO0_ID", "CAL_ACC0_ID", "SENS_DPRES_OFF", NULL }; SensorsComponent::SensorsComponent(UASInterface* uas, AutoPilotPlugin* autopilot, QObject* parent) : PX4Component(uas, autopilot, parent), _name(tr("Sensors")) { + // Determine what set of parameters are available. This is a temporary hack for now. Will need real parameter + // mapping in the future. + QVariant value; + _paramsV1 = _paramMgr->getParameterValue(_paramMgr->getDefaultComponentId(), "SENS_MAG_XOFF", value); } QString SensorsComponent::name(void) const @@ -97,14 +102,18 @@ QString SensorsComponent::setupStateDescription(void) const const char** SensorsComponent::setupCompleteChangedTriggerList(void) const { - return triggerParams; + return _paramsV1 ? triggerParamsV1 : triggerParamsV2; } QStringList SensorsComponent::paramFilterList(void) const { QStringList list; - list << "SENS_*"; + if (_paramsV1) { + list << "SENS_*"; + } else { + list << "CAL_*"; + } return list; } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index a58874986ac71c26ee156635504ee0761273b305..992a25f5ce55638e6300ce997e76b4ac490067c1 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -55,6 +55,7 @@ public: private: const QString _name; QVariantList _summaryItems; + bool _paramsV1; }; #endif diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml b/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml index be7b52d238fe20de1e4d0ec86b90018dac1db495..25f237cbd8fc58bfd149044dbe986816fa6735cc 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml @@ -15,7 +15,8 @@ Column { Text { horizontalAlignment: Text.AlignRight; width: parent.width - compass.contentWidth; - text: autopilot.parameters["SENS_MAG_XOFF"].value == 0.0 ? "Setup required" : "Ready" + property bool setupRequiredValue: autopilot.parameters["SENS_MAG_XOFF"] ? autopilot.parameters["SENS_MAG_XOFF"].value : autopilot.parameters["CAL_MAG0_ID"].value + text: setupRequiredValue == 0 ? "Setup required" : "Ready" } } @@ -26,7 +27,8 @@ Column { Text { horizontalAlignment: Text.AlignRight; width: parent.width - gyro.contentWidth; - text: autopilot.parameters["SENS_GYRO_XOFF"].value == 0.0 ? "Setup required" : "Ready" + property bool setupRequiredValue: autopilot.parameters["SENS_GYRO_XOFF"] ? autopilot.parameters["SENS_GYRO_XOFF"].value : autopilot.parameters["CAL_GYRO0_ID"].value + text: setupRequiredValue == 0 ? "Setup required" : "Ready" } } @@ -37,7 +39,8 @@ Column { Text { horizontalAlignment: Text.AlignRight; width: parent.width - accel.contentWidth; - text: autopilot.parameters["SENS_ACC_XOFF"].value == 0.0 ? "Setup required" : "Ready" + property bool setupRequiredValue: autopilot.parameters["SENS_ACC_XOFF"] ? autopilot.parameters["SENS_ACC_XOFF"].value : autopilot.parameters["CAL_ACC0_ID"].value + text: setupRequiredValue == 0 ? "Setup required" : "Ready" } } diff --git a/src/ui/px4_configuration/QGCPX4SensorCalibration.cc b/src/ui/px4_configuration/QGCPX4SensorCalibration.cc index 2107f1dc223ca9fd03648570a28c53c92bac9b6c..515ec2b16d44e08a1aa49f24971ce760b75c3109 100644 --- a/src/ui/px4_configuration/QGCPX4SensorCalibration.cc +++ b/src/ui/px4_configuration/QGCPX4SensorCalibration.cc @@ -142,7 +142,7 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p } // Check mag calibration naively - if (parameterName.contains("SENS_MAG_XOFF")) { + if (parameterName.contains("SENS_MAG_XOFF") || parameterName.contains("CAL_MAG0_ID")) { float offset = value.toFloat(); if (offset < 0.000001f && offset > -0.000001f) { // Must be zero, not good @@ -153,7 +153,7 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p } // Check gyro calibration naively - if (parameterName.contains("SENS_GYRO_XOFF")) { + if (parameterName.contains("SENS_GYRO_XOFF") || parameterName.contains("CAL_GYRO0_ID")) { float offset = value.toFloat(); if (offset < 0.000001f && offset > -0.000001f) { // Must be zero, not good @@ -164,7 +164,7 @@ void QGCPX4SensorCalibration::parameterChanged(int uas, int component, QString p } // Check accel calibration naively - if (parameterName.contains("SENS_ACC_XOFF")) { + if (parameterName.contains("SENS_ACC_XOFF") || parameterName.contains("CAL_ACC0_ID")) { float offset = value.toFloat(); if (offset < 0.000001f && offset > -0.000001f) { // Must be zero, not good @@ -354,17 +354,24 @@ void QGCPX4SensorCalibration::setActiveUAS(UASInterface* uas) // If the parameters are ready, we aren't going to get paramterChanged signals. So fake them in order to make the UI work. if (uas->getParamManager()->parametersReady()) { QVariant value; - static const char* rgParams[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF" }; + static const char* rgParamsV1[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF" }; + static const char* rgParamsV2[] = { "SENS_BOARD_ROT", "SENS_EXT_MAG_ROT", "CAL_MAG0_XOFF", "CAL_GYRO0_XOFF", "CAL_ACC0_XOFF", "SENS_DPRES_OFF" }; QGCUASParamManagerInterface* paramMgr = uas->getParamManager(); - for (size_t i=0; igetComponentForParam("SENS_MAG_XOFF").count(); + static const char** prgParamList = paramsV1 ? rgParamsV1 : rgParamsV2; + + for (size_t i=0; i compIds = paramMgr->getComponentForParam(rgParams[i]); + QList compIds = paramMgr->getComponentForParam(prgParamList[i]); Q_ASSERT(compIds.count() == 1); - paramMgr->getParameterValue(compIds[0], rgParams[i], value); - parameterChanged(uas->getUASID(), compIds[0], rgParams[i], value); + bool found = paramMgr->getParameterValue(compIds[0], prgParamList[i], value); + Q_ASSERT(found); + Q_UNUSED(found); + parameterChanged(uas->getUASID(), compIds[0], prgParamList[i], value); } } }