From 9e76f9f1749abd40a16f10d2bbd32319e2cb07de Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 6 Jun 2016 18:54:47 -0700 Subject: [PATCH 1/3] Simulate RC channels --- src/comm/MockLink.cc | 24 ++++++++++++++++++++++++ src/comm/MockLink.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/comm/MockLink.cc b/src/comm/MockLink.cc index 63f0572..a91506a 100644 --- a/src/comm/MockLink.cc +++ b/src/comm/MockLink.cc @@ -158,6 +158,7 @@ void MockLink::_run1HzTasks(void) if (_mavlinkStarted && _connected) { _sendHeartBeat(); _sendVibration(); + _sendRCChannels(); if (_sendHomePositionDelayCount > 0) { // We delay home position a bit to be more realistic _sendHomePositionDelayCount--; @@ -1026,3 +1027,26 @@ MockLink* MockLink::startAPMArduPlaneMockLink(bool sendStatusText) return _startMockLink(mockConfig); } +void MockLink::_sendRCChannels(void) +{ + mavlink_message_t msg; + + mavlink_msg_rc_channels_pack(_vehicleSystemId, + _vehicleComponentId, + &msg, + 0, // time_boot_ms + 8, // chancount + 1500, // chan1_raw + 1500, // chan2_raw + 1500, // chan3_raw + 1500, // chan4_raw + 1500, // chan5_raw + 1500, // chan6_raw + 1500, // chan7_raw + 1500, // chan8_raw + UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, UINT16_MAX, + 0); // rssi + + respondWithMavlinkMessage(msg); + +} diff --git a/src/comm/MockLink.h b/src/comm/MockLink.h index 499d761..ef6ab0a 100644 --- a/src/comm/MockLink.h +++ b/src/comm/MockLink.h @@ -173,6 +173,7 @@ private: void _sendVibration(void); void _sendStatusTextMessages(void); void _respondWithAutopilotVersion(void); + void _sendRCChannels(void); static MockLink* _startMockLink(MockConfiguration* mockConfig); From 1b7cb7bcdb6e5d4480d7c6bbf3f1b0e0d04ec1e0 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 6 Jun 2016 18:54:58 -0700 Subject: [PATCH 2/3] Small screen fixes --- src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml | 74 +++++++++++++++++------ 1 file changed, 54 insertions(+), 20 deletions(-) diff --git a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml index 94ede4f..7e43c34 100644 --- a/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml +++ b/src/AutoPilotPlugins/PX4/PX4SimpleFlightModes.qml @@ -27,8 +27,8 @@ Item { property real _margins: ScreenTools.defaultFontPixelHeight / 2 - readonly property real _flightModeComboWidth: ScreenTools.defaultFontPixelWidth * 23 - readonly property real _channelComboWidth: ScreenTools.defaultFontPixelWidth * 20 + readonly property real _flightModeComboWidth: ScreenTools.defaultFontPixelWidth * 13 + readonly property real _channelComboWidth: ScreenTools.defaultFontPixelWidth * 13 QGCPalette { id: qgcPal; colorGroupEnabled: panel.enabled } @@ -80,7 +80,7 @@ Item { QGCLabel { id: modeChannelLabel anchors.baseline: modeChannelCombo.baseline - text: qsTr("Flight mode channel:") + text: qsTr("Mode channel:") } FactComboBox { @@ -139,28 +139,62 @@ Item { anchors.top: parent.top spacing: ScreenTools.defaultFontPixelHeight - Repeater { - model: [ "RC_MAP_RETURN_SW", "RC_MAP_KILL_SW", "RC_MAP_OFFB_SW" ] + Row { + spacing: ScreenTools.defaultFontPixelWidth - Row { - spacing: ScreenTools.defaultFontPixelWidth + property Fact fact: controller.getParameterFact(-1, "RC_MAP_RETURN_SW") - property Fact fact: controller.getParameterFact(-1, modelData) + QGCLabel { + anchors.baseline: returnCombo.baseline + text: "Return switch:" + color: fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[fact.value - 1] >= 1500 ? "yellow" : qgcPal.text) + } - QGCLabel { - anchors.baseline: optCombo.baseline - text: fact.shortDescription + ":" - color: fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[fact.value - 1] >= 1500 ? "yellow" : qgcPal.text) - } + FactComboBox { + id: returnCombo + width: _channelComboWidth + fact: parent.fact + indexModel: false + } + } - FactComboBox { - id: optCombo - width: _channelComboWidth - fact: parent.fact - indexModel: false - } + Row { + spacing: ScreenTools.defaultFontPixelWidth + + property Fact fact: controller.getParameterFact(-1, "RC_MAP_KILL_SW") + + QGCLabel { + anchors.baseline: killCombo.baseline + text: "Kill switch:" + color: fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[fact.value - 1] >= 1500 ? "yellow" : qgcPal.text) + } + + FactComboBox { + id: killCombo + width: _channelComboWidth + fact: parent.fact + indexModel: false } - } // Repeater + } + + Row { + spacing: ScreenTools.defaultFontPixelWidth + + property Fact fact: controller.getParameterFact(-1, "RC_MAP_OFFB_SW") + + QGCLabel { + anchors.baseline: offboardCombo.baseline + text: "Offboard switch:" + color: fact.value == 0 ? qgcPal.text : (controller.rcChannelValues[fact.value - 1] >= 1500 ? "yellow" : qgcPal.text) + } + + FactComboBox { + id: offboardCombo + width: _channelComboWidth + fact: parent.fact + indexModel: false + } + } } // Column } // Rectangle From c2544df79c71f0d6df82630805c938810482093d Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Mon, 6 Jun 2016 19:34:55 -0700 Subject: [PATCH 3/3] No RC simulation while running unit tests --- src/comm/MockLink.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/comm/MockLink.cc b/src/comm/MockLink.cc index a91506a..f25d15b 100644 --- a/src/comm/MockLink.cc +++ b/src/comm/MockLink.cc @@ -158,7 +158,10 @@ void MockLink::_run1HzTasks(void) if (_mavlinkStarted && _connected) { _sendHeartBeat(); _sendVibration(); - _sendRCChannels(); + if (!qgcApp()->runningUnitTests()) { + // Sending RC Channels during unit test breaks RC tests which does it's own RC simulation + _sendRCChannels(); + } if (_sendHomePositionDelayCount > 0) { // We delay home position a bit to be more realistic _sendHomePositionDelayCount--;