From fd09153877a80f5ec8f50d69f35b45e913c13190 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 27 Apr 2018 23:05:08 -0700 Subject: [PATCH] allow completion of the sensor page with a magnetometer if ATT_W_MAG is 0 --- src/AutoPilotPlugins/PX4/SensorsComponent.cc | 11 +++++++++-- src/AutoPilotPlugins/PX4/SensorsComponent.h | 3 +++ src/AutoPilotPlugins/PX4/SensorsSetup.qml | 3 ++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 7fbc76bd0..d90a71ebc 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -20,11 +20,14 @@ const char* SensorsComponent::_airspeedBreakerParam = "CBRK_AIRSPD_CHK"; const char* SensorsComponent::_airspeedDisabledParam = "FW_ARSP_MODE"; const char* SensorsComponent::_airspeedCalParam = "SENS_DPRES_OFF"; +const char* SensorsComponent::_magDisabledParam = "ATT_W_MAG"; +const char* SensorsComponent::_magCalParam = "CAL_MAG0_ID"; + SensorsComponent::SensorsComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) : VehicleComponent(vehicle, autopilot, parent), _name(tr("Sensors")) { - _deviceIds << QStringLiteral("CAL_MAG0_ID") << QStringLiteral("CAL_GYRO0_ID") << QStringLiteral("CAL_ACC0_ID"); + _deviceIds << QStringLiteral("CAL_GYRO0_ID") << QStringLiteral("CAL_ACC0_ID"); } QString SensorsComponent::name(void) const @@ -54,6 +57,10 @@ bool SensorsComponent::setupComplete(void) const return false; } } + if (_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _magDisabledParam)->rawValue().toInt() != 0 && + _vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _magCalParam)->rawValue().toFloat() == 0.0f) { + return false; + } if (_vehicle->fixedWing() || _vehicle->vtol()) { if (!_vehicle->parameterManager()->getParameter(FactSystem::defaultComponentId, _airspeedDisabledParam)->rawValue().toBool() && @@ -70,7 +77,7 @@ QStringList SensorsComponent::setupCompleteChangedTriggerList(void) const { QStringList triggers; - triggers << _deviceIds; + triggers << _deviceIds << _magCalParam << _magDisabledParam; if (_vehicle->fixedWing() || _vehicle->vtol()) { triggers << _airspeedCalParam << _airspeedBreakerParam; } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.h b/src/AutoPilotPlugins/PX4/SensorsComponent.h index 9201c5e8e..774b56c0a 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.h +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.h @@ -44,6 +44,9 @@ private: static const char* _airspeedDisabledParam; static const char* _airspeedBreakerParam; static const char* _airspeedCalParam; + + static const char* _magDisabledParam; + static const char* _magCalParam; }; #endif diff --git a/src/AutoPilotPlugins/PX4/SensorsSetup.qml b/src/AutoPilotPlugins/PX4/SensorsSetup.qml index 673c36a0a..50b3da23f 100644 --- a/src/AutoPilotPlugins/PX4/SensorsSetup.qml +++ b/src/AutoPilotPlugins/PX4/SensorsSetup.qml @@ -369,7 +369,8 @@ Item { width: _buttonWidth text: qsTr("Compass") indicatorGreen: cal_mag0_id.value !== 0 - visible: QGroundControl.corePlugin.options.showSensorCalibrationCompass && showSensorCalibrationCompass + visible: controller.getParameterFact(-1, "ATT_W_MAG").value !== 0 && + QGroundControl.corePlugin.options.showSensorCalibrationCompass && showSensorCalibrationCompass onClicked: { preCalibrationDialogType = "compass" -- 2.22.0