From 0c6ae2a7a8697756023e350f1d03c5f62e4f4187 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Thu, 26 Feb 2015 09:33:24 -0800 Subject: [PATCH] Handle sensor difference for Fixed Wing --- qgroundcontrol.qrc | 1 + src/AutoPilotPlugins/PX4/SensorsComponent.cc | 23 ++++++-- .../PX4/SensorsComponentSummary.qml | 15 ++---- .../PX4/SensorsComponentSummaryFixedWing.qml | 62 ++++++++++++++++++++++ 4 files changed, 86 insertions(+), 15 deletions(-) create mode 100644 src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml diff --git a/qgroundcontrol.qrc b/qgroundcontrol.qrc index c5124d9..ce254dd 100644 --- a/qgroundcontrol.qrc +++ b/qgroundcontrol.qrc @@ -268,6 +268,7 @@ src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml + src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml src/AutoPilotPlugins/PX4/RadioComponentSummary.qml src/AutoPilotPlugins/PX4/FlightModesComponentSummary.qml src/AutoPilotPlugins/PX4/AirframeComponentSummary.qml diff --git a/src/AutoPilotPlugins/PX4/SensorsComponent.cc b/src/AutoPilotPlugins/PX4/SensorsComponent.cc index 6e57166..1f2088f 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponent.cc +++ b/src/AutoPilotPlugins/PX4/SensorsComponent.cc @@ -31,8 +31,10 @@ // These two list must be kept in sync /// @brief Parameters which signal a change in setupComplete state -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 }; +static const char* triggerParamsV1[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", NULL }; +static const char* triggerParamsV2[] = { "CAL_MAG0_ID", "CAL_GYRO0_ID", "CAL_ACC0_ID", NULL }; +static const char* triggerParamsV1FixedWing[] = { "SENS_MAG_XOFF", "SENS_GYRO_XOFF", "SENS_ACC_XOFF", "SENS_DPRES_OFF", NULL }; +static const char* triggerParamsV2FixedWing[] = { "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), @@ -102,7 +104,11 @@ QString SensorsComponent::setupStateDescription(void) const const char** SensorsComponent::setupCompleteChangedTriggerList(void) const { - return _paramsV1 ? triggerParamsV1 : triggerParamsV2; + if (_uas->getSystemType() == MAV_TYPE_FIXED_WING) { + return _paramsV1 ? triggerParamsV1FixedWing : triggerParamsV2FixedWing; + } else { + return _paramsV1 ? triggerParamsV1 : triggerParamsV2; + } } QStringList SensorsComponent::paramFilterList(void) const @@ -125,7 +131,16 @@ QWidget* SensorsComponent::setupWidget(void) const QUrl SensorsComponent::summaryQmlSource(void) const { - return QUrl::fromUserInput("qrc:/qml/SensorsComponentSummary.qml"); + QString summaryQml; + + qDebug() << _uas->getSystemType(); + if (_uas->getSystemType() == MAV_TYPE_FIXED_WING) { + summaryQml = "qrc:/qml/SensorsComponentSummaryFixedWing.qml"; + } else { + summaryQml = "qrc:/qml/SensorsComponentSummary.qml"; + } + + return QUrl::fromUserInput(summaryQml); } QString SensorsComponent::prerequisiteSetup(void) const diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml b/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml index 9c8311c..2c1f314 100644 --- a/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml +++ b/src/AutoPilotPlugins/PX4/SensorsComponentSummary.qml @@ -5,6 +5,10 @@ import QtQuick.Controls.Styles 1.2 import QGroundControl.FactSystem 1.0 import QGroundControl.Controls 1.0 +/* + IMPORTANT NOTE: Any changes made here must also be made to SensorsComponentSummaryFixedWing.qml +*/ + Column { anchors.fill: parent anchors.margins: 8 @@ -44,15 +48,4 @@ Column { text: setupRequiredValue == 0 ? "Setup required" : "Ready" } } - - Row { - width: parent.width - - QGCLabel { id: airspeed; text: "Airspeed:" } - QGCLabel { - horizontalAlignment: Text.AlignRight; - width: parent.width - airspeed.contentWidth; - text: autopilot.parameters["SENS_DPRES_OFF"].value == 0.0 ? "Setup required" : "Ready" - } - } } diff --git a/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml b/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml new file mode 100644 index 0000000..624e5e9 --- /dev/null +++ b/src/AutoPilotPlugins/PX4/SensorsComponentSummaryFixedWing.qml @@ -0,0 +1,62 @@ +import QtQuick 2.2 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles 1.2 + +import QGroundControl.FactSystem 1.0 +import QGroundControl.Controls 1.0 + +/* + IMPORTANT NOTE: Any changes made here must also be made to SensorsComponentSummary.qml +*/ + +Column { + anchors.fill: parent + anchors.margins: 8 + + Row { + width: parent.width + + QGCLabel { id: compass; text: "Compass:" } + QGCLabel { + horizontalAlignment: Text.AlignRight; + width: parent.width - compass.contentWidth; + 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" + } + } + + Row { + width: parent.width + + QGCLabel { id: gyro; text: "Gyro:" } + QGCLabel { + horizontalAlignment: Text.AlignRight; + width: parent.width - gyro.contentWidth; + 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" + } + } + + Row { + width: parent.width + + QGCLabel { id: accel; text: "Accelerometer:" } + QGCLabel { + horizontalAlignment: Text.AlignRight; + width: parent.width - accel.contentWidth; + 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" + } + } + + Row { + width: parent.width + + QGCLabel { id: airspeed; text: "Airspeed:" } + QGCLabel { + horizontalAlignment: Text.AlignRight; + width: parent.width - airspeed.contentWidth; + text: autopilot.parameters["SENS_DPRES_OFF"].value == 0.0 ? "Setup required" : "Ready" + } + } +}