From 1e2e93b8c0c1eae2005678a8c1fbf0414855eabc Mon Sep 17 00:00:00 2001 From: Kevin Vertucio Date: Tue, 19 Mar 2013 10:14:50 -0400 Subject: [PATCH 01/32] OP-791 FIXED issue where Flickable web view would need to be dragged to scroll content Replaced Flickable component with ListView for the Authors list. Signed-off-by: Kevin Vertucio --- .../src/plugins/coreplugin/core.qrc | 3 +- .../plugins/coreplugin/qml/AboutDialog.qml | 58 +++--- .../plugins/coreplugin/qml/AuthorsModel.qml | 151 ++++++++++++++ .../coreplugin/qml/FlickableWebView.qml | 196 ------------------ .../coreplugin/qml/ScrollDecorator.qml | 40 ++++ 5 files changed, 223 insertions(+), 225 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml delete mode 100644 ground/openpilotgcs/src/plugins/coreplugin/qml/FlickableWebView.qml create mode 100644 ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml diff --git a/ground/openpilotgcs/src/plugins/coreplugin/core.qrc b/ground/openpilotgcs/src/plugins/coreplugin/core.qrc index 85ca549e6..268eb4808 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/core.qrc +++ b/ground/openpilotgcs/src/plugins/coreplugin/core.qrc @@ -64,7 +64,8 @@ images/tx-rx.svg qml/images/tab.png qml/AboutDialog.qml - qml/FlickableWebView.qml + qml/AuthorsModel.qml + qml/ScrollDecorator.qml qml/TabWidget.qml diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml index e9190b082..98ccf4ef3 100644 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AboutDialog.qml @@ -41,8 +41,12 @@ import QtQuick 1.1 import QtWebKit 1.0 + // This is a tabbed pane element. Add a nested Rectangle to add a tab. TabWidget { + // Define AuthorsModel as type + property AuthorsModel authors: AuthorsModel {} + id: tabs width: 640; height: 480 // This tab is for the GCS version information @@ -75,36 +79,34 @@ } } } - // This is a stub for the Plugins. - // Rectangle { - // property string title: "Plugins" - // anchors.fill: parent - // color: "#e3e3e3" - // - // Rectangle { - // anchors.fill: parent; anchors.margins: 20 - // color: "#7fff7f" - // Text { - // width: parent.width - 20 - // anchors.centerIn: parent; horizontalAlignment: Qt.AlignHCenter - // font.pixelSize: 20 - // wrapMode: Text.WordWrap - // } - // } - // } - // This tab is for the authors/contributors/credits + // This tab is for the authors/contributors/credits Rectangle { property string title: "Authors" anchors.fill: parent; color: "#e3e3e3" - Rectangle { + Rectangle { anchors.fill: parent; anchors.margins: 20 color: "#e3e3e3" - FlickableWebView { - id: webView - z: 0 - url: "../CREDITS.html" - anchors { top: parent.top; left: parent.left; right: parent.right; bottom: parent.bottom } - } - } - } - } + Text { + id: description + text: "

These people have been key contributors to the OpenPilot project. Without the work of the people in this list, OpenPilot would not be what it is today.

This list is sorted alphabetically by name

" + width: 600 + wrapMode: Text.WordWrap + + } + ListView { + id: authorsView + y: description.y + description.height + 20 + width: parent.width; height: parent.height - description.height - 20 + spacing: 3 + model: authors + delegate: Text { + text: name + } + clip: true + } + ScrollDecorator { + flickableItem: authorsView + } + } + } +} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml new file mode 100644 index 000000000..b55ee86e9 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/AuthorsModel.qml @@ -0,0 +1,151 @@ +/* +This list model was created for the AuthorsDialog. +*/ +import QtQuick 1.1 + +ListModel { + + ListElement{ name:"Connor Abbott" } + + ListElement{ name:"David Ankers" } + + ListElement{ name:"Sergiy Anikeyev" } + + ListElement{ name:"Pedro Assuncao" } + + ListElement{ name:"Fredrik Arvidsson" } + + ListElement{ name:"Werner Backes" } + + ListElement{ name:"Jose Barros" } + + ListElement{ name:"Pete Boehl" } + + ListElement{ name:"David Carlson" } + + ListElement{ name:"James Cotton" } + + ListElement{ name:"Steve Doll" } + + ListElement{ name:"Piotr Esden-Tempski" } + + ListElement{ name:"Richard Flay" } + + ListElement{ name:"Peter Farnworth" } + + ListElement{ name:"Ed Faulkner" } + + ListElement{ name:"Darren Furniss" } + + ListElement{ name:"Frederic Goddeeris" } + + ListElement{ name:"Daniel Godin" } + + ListElement{ name:"Bani Greyling" } + + ListElement{ name:"Nuno Guedes" } + + ListElement{ name:"Erik Gustavsson" } + + ListElement{ name:"Peter Gunnarsson" } + + ListElement{ name:"Dean Hall" } + + ListElement{ name:"Joe Hlebasko" } + + ListElement{ name:"Andy Honecker" } + + ListElement{ name:"Ryan Hunt" } + + ListElement{ name:"Mark James" } + + ListElement{ name:"Sami Korhonen" } + + ListElement{ name:"Thorsten Klose" } + + ListElement{ name:"Hallvard Kristiansen" } + + ListElement{ name:"Edouard Lafargue" } + + ListElement{ name:"Mike Labranche" } + + ListElement{ name:"Fredrik Larsson" } + + ListElement{ name:"Pablo Lema" } + + ListElement{ name:"David Llama" } + + ListElement{ name:"Matt Lipski" } + + ListElement{ name:"Les Newell" } + + ListElement{ name:"Ken Northup" } + + ListElement{ name:"Greg Matthews" } + + ListElement{ name:"Guy McCaldin" } + + ListElement{ name:"Gary Mortimer" } + + ListElement{ name:"Alessio Morale" } + + ListElement{ name:"Cathy Moss" } + + ListElement{ name:"Angus Peart" } + + ListElement{ name:"Dmytro Poplavskiy" } + + ListElement{ name:"Eric Price" } + + ListElement{ name:"Richard Querin" } + + ListElement{ name:"Randy Ram" } + + ListElement{ name:"Laurent Ribon" } + + ListElement{ name:"Julien Rouviere" } + + ListElement{ name:"Jackson Russell" } + + ListElement{ name:"Zik Saleeba" } + + ListElement{ name:"Professor Dale Schinstock" } + + ListElement{ name:"Professor Kenn Sebesta" } + + ListElement{ name:"Oleg Semyonov" } + + ListElement{ name:"Stacey Sheldon" } + + ListElement{ name:"Troy Schultz" } + + ListElement{ name:"Dr. Erhard Siegl" } + + ListElement{ name:"Mike Smith" } + + ListElement{ name:"Alex Sowa" } + + ListElement{ name:"Pete Stapley" } + + ListElement{ name:"Rowan Taubitz" } + + ListElement{ name:"Andrew Thoms" } + + ListElement{ name:"Jasper van Loenen" } + + ListElement{ name:"Vassilis Varveropoulos" } + + ListElement{ name:"Kevin Vertucio" } + + ListElement{ name:"Alex Vrubel" } + + ListElement{ name:"Brian Webb" } + + ListElement{ name:"Justin Welander" } + + ListElement{ name:"Mat Wellington" } + + ListElement{ name:"Kendal Wells" } + + ListElement{ name:"Dmitriy Zaitsev" } +} \ No newline at end of file diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/FlickableWebView.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/FlickableWebView.qml deleted file mode 100644 index 3043ce88a..000000000 --- a/ground/openpilotgcs/src/plugins/coreplugin/qml/FlickableWebView.qml +++ /dev/null @@ -1,196 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 1.0 -import QtWebKit 1.0 - -Flickable { - property alias title: webView.title - property alias icon: webView.icon - property alias progress: webView.progress - property alias url: webView.url - property alias back: webView.back - property alias stop: webView.stop - property alias reload: webView.reload - property alias forward: webView.forward - - id: flickable - width: parent.width - contentWidth: Math.max(parent.width,webView.width) - contentHeight: Math.max(parent.height,webView.height) - // anchors.top: headerSpace.bottom - anchors.bottom: parent.top - anchors.left: parent.left - anchors.right: parent.right - pressDelay: 200 - clip: true - - onWidthChanged : { - // Expand (but not above 1:1) if otherwise would be smaller that available width. - if (width > webView.width*webView.contentsScale && webView.contentsScale < 1.0) - webView.contentsScale = width / webView.width * webView.contentsScale; - } - - WebView { - id: webView - transformOrigin: Item.TopLeft - - function fixUrl(url) - { - if (url == "") return url - if (url[0] == "/") return "file://"+url - if (url.indexOf(":")<0) { - if (url.indexOf(".")<0 || url.indexOf(" ")>=0) { - // Fall back to a search engine; hard-code Wikipedia - return "http://en.wikipedia.org/w/index.php?search="+url - } else { - return "http://"+url - } - } - return url - } - - url: fixUrl(webBrowser.urlString) - smooth: false // We don't want smooth scaling, since we only scale during (fast) transitions - focus: true - - onAlert: console.log(message) - - function doZoom(zoom,centerX,centerY) - { - if (centerX) { - var sc = zoom*contentsScale; - scaleAnim.to = sc; - flickVX.from = flickable.contentX - flickVX.to = Math.max(0,Math.min(centerX-flickable.width/2,webView.width*sc-flickable.width)) - finalX.value = flickVX.to - flickVY.from = flickable.contentY - flickVY.to = Math.max(0,Math.min(centerY-flickable.height/2,webView.height*sc-flickable.height)) - finalY.value = flickVY.to - quickZoom.start() - } - } - - Keys.onLeftPressed: webView.contentsScale -= 0.1 - Keys.onRightPressed: webView.contentsScale += 0.1 - - preferredWidth: flickable.width - preferredHeight: flickable.height - contentsScale: 1 - onContentsSizeChanged: { - // zoom out - contentsScale = Math.min(1,flickable.width / contentsSize.width) - } - onUrlChanged: { - // got to topleft - flickable.contentX = 0 - flickable.contentY = 0 - // if (url != null) { header.editUrl = url.toString(); } - } - onDoubleClick: { - if (!heuristicZoom(clickX,clickY,2.5)) { - var zf = flickable.width / contentsSize.width - if (zf >= contentsScale) - zf = 2.0*contentsScale // zoom in (else zooming out) - doZoom(zf,clickX*zf,clickY*zf) - } - } - - SequentialAnimation { - id: quickZoom - - PropertyAction { - target: webView - property: "renderingEnabled" - value: false - } - ParallelAnimation { - NumberAnimation { - id: scaleAnim - target: webView - property: "contentsScale" - // the to property is set before calling - easing.type: Easing.Linear - duration: 200 - } - NumberAnimation { - id: flickVX - target: flickable - property: "contentX" - easing.type: Easing.Linear - duration: 200 - from: 0 // set before calling - to: 0 // set before calling - } - NumberAnimation { - id: flickVY - target: flickable - property: "contentY" - easing.type: Easing.Linear - duration: 200 - from: 0 // set before calling - to: 0 // set before calling - } - } - // Have to set the contentXY, since the above 2 - // size changes may have started a correction if - // contentsScale < 1.0. - PropertyAction { - id: finalX - target: flickable - property: "contentX" - value: 0 // set before calling - } - PropertyAction { - id: finalY - target: flickable - property: "contentY" - value: 0 // set before calling - } - PropertyAction { - target: webView - property: "renderingEnabled" - value: true - } - } - onZoomTo: doZoom(zoom,centerX,centerY) - } -} diff --git a/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml b/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml new file mode 100644 index 000000000..24c79c927 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/coreplugin/qml/ScrollDecorator.qml @@ -0,0 +1,40 @@ +import QtQuick 1.1 + +Rectangle { + id: scrollDecorator + + property Flickable flickableItem: null + + Loader { + id: scrollLoader + sourceComponent: scrollDecorator.flickableItem ? scrollBar : undefined + } + + Component.onDestruction: scrollLoader.sourceComponent = undefined + + Component { + id: scrollBar + Rectangle { + property Flickable flickable: scrollDecorator.flickableItem + + parent: flickable + anchors.right: parent.right + + smooth: true + radius: 2 + color: "gray" + border.color: "lightgray" + border.width: 1.0 + opacity: flickable.moving ? 0.8 : 0.4 + + Behavior on opacity { + NumberAnimation { duration: 500 } + } + + width: 4 + height: flickable.height * (flickable.height / flickable.contentHeight) + y: flickable.height * (flickable.contentY / flickable.contentHeight) + visible: flickable.height < flickable.contentHeight + } + } +} From 0d3e00134a4840a644eae68d311cdd9bd5746963 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 23 Mar 2013 16:53:24 +0100 Subject: [PATCH 02/32] OP-907 step 1: extract vehicle specific UIs from airframe.ui --- .../config/cfg_vehicletypes/airframe_ccpm.ui | 37 + .../cfg_vehicletypes/airframe_custom.ui | 713 ++++++++++++++ .../cfg_vehicletypes/airframe_fixedwing.ui | 530 +++++++++++ .../cfg_vehicletypes/airframe_ground.ui | 548 +++++++++++ .../cfg_vehicletypes/airframe_multirotor.ui | 868 ++++++++++++++++++ .../cfg_vehicletypes/configccpmwidget.cpp | 7 +- .../cfg_vehicletypes/configccpmwidget.h | 98 +- .../configfixedwingwidget.cpp | 20 +- .../cfg_vehicletypes/configfixedwingwidget.h | 8 +- .../configgroundvehiclewidget.cpp | 21 +- .../configgroundvehiclewidget.h | 9 +- .../configmultirotorwidget.cpp | 143 ++- .../cfg_vehicletypes/configmultirotorwidget.h | 10 +- .../config/cfg_vehicletypes/vehicleconfig.cpp | 1 - .../config/cfg_vehicletypes/vehicleconfig.h | 102 +- .../src/plugins/config/config.pro | 23 +- .../config/configvehicletypewidget.cpp | 345 ++++--- .../plugins/config/configvehicletypewidget.h | 32 +- 18 files changed, 3138 insertions(+), 377 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ccpm.ui create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ccpm.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ccpm.ui new file mode 100644 index 000000000..d9d90ebd4 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ccpm.ui @@ -0,0 +1,37 @@ + + + CcpmConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + + + + ConfigCcpmWidget + QWidget +
cfg_vehicletypes/configccpmwidget.h
+ 1 +
+
+ + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui new file mode 100644 index 000000000..684b73947 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui @@ -0,0 +1,713 @@ + + + CustomConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + + + + + 0 + 0 + + + + Curve 1 + + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + Curve 2 + + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + + + 0 + 0 + + + + true + + + 50 + + + false + + + + Type + + + + + Curve 1 + + + + + Curve 2 + + + + + Roll + + + + + Pitch + + + + + Yaw + + + + + Ch 1 + + + + + Ch 2 + + + + + Ch 3 + + + + + Ch 4 + + + + + Ch 5 + + + + + Ch 6 + + + + + Ch 7 + + + + + Ch 8 + + + + + Ch 9 + + + + + Ch 10 + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui new file mode 100644 index 000000000..9e871d695 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui @@ -0,0 +1,530 @@ + + + FixedWingConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 9 + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Airplane type: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 230 + 100 + + + + Output Channel Assignments + + + + + + Engine + + + + + + + Select output channel for the engine + + + + + + + + 60 + 0 + + + + Aileron 1 + + + + + + + Select output channel for the first aileron (or elevon) + + + + + + + false + + + + 60 + 0 + + + + Aileron 2 + + + + + + + false + + + Select output channel for the second aileron (or elevon) + + + + + + + + 67 + 0 + + + + Elevator 1 + + + + + + + Select output channel for the first elevator + + + + + + + false + + + + 67 + 0 + + + + Elevator 2 + + + + + + + false + + + Select output channel for a secondary elevator + + + + + + + Rudder 1 + + + + + + + Select output channel for the first rudder + + + + + + + Rudder 2 + + + + + + + Select output channel for a secondary rudder + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + + + 0 + 0 + + + + Elevon Mix + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 0 + 20 + + + + + + + + + + + + + 65 + 0 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Rudder % + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 50 + + + Qt::AlignCenter + + + + + + + + + + + + 50 + 0 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Pitch % + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 50 + + + Qt::AlignCenter + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 100 + + + + Throttle Curve + + + + + + + 1 + 1 + + + + + 0 + 0 + + + + + 500 + 500 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Mixer OK + + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + + + elevonSlider1 + valueChanged(int) + elevonSliderLabel1 + setNum(int) + + + 124 + 126 + + + 124 + 126 + + + + + elevonSlider2 + valueChanged(int) + elevonSliderLabel2 + setNum(int) + + + 362 + 299 + + + 124 + 126 + + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui new file mode 100644 index 000000000..8dc27404a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui @@ -0,0 +1,548 @@ + + + GroundConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Vehicle type: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 75 + true + + + + Channel Assignment + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 100 + + + + Output channel asignmets + + + + + + + 77 + 0 + + + + Engine + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Select output channel for the engine + + + + + + + + 60 + 0 + + + + Aileron 1 + + + + + + + Select output channel for the first aileron (or elevon) + + + + + + + false + + + + 60 + 0 + + + + Aileron 2 + + + + + + + false + + + Select output channel for the second aileron (or elevon) + + + + + + + + 0 + 0 + + + + Motor + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Select output channel for the first motor + + + + + + + false + + + + 47 + 0 + + + + Motor 2 + + + + + + + false + + + Select output channel for a second motor + + + + + + + Front Steering + + + + + + + Select output channel for the first steering actuator + + + + + + + Rear Steering + + + + + + + Select output channel for a second steering actuator + + + + + + + + + + true + + + + 0 + 0 + + + + Differential Steering Mix + + + + + + + + + + + 65 + 0 + + + + Left % + + + + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 50 + + + + + + + + + + + + 50 + 0 + + + + Right % + + + + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 50 + + + + + + + + + + + + + + + 0 + 100 + + + + Front throttle curve + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 500 + 500 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + 0 + 0 + + + + Rear throttle curve + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 500 + 500 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Mixer OK + + + + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + + + differentialSteeringSlider1 + valueChanged(int) + gvDiffSteering1Label + setNum(int) + + + 124 + 126 + + + 315 + 391 + + + + + differentialSteeringSlider2 + valueChanged(int) + gvDiffSteering2Label + setNum(int) + + + 124 + 126 + + + 390 + 391 + + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui new file mode 100644 index 000000000..a499cfacd --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui @@ -0,0 +1,868 @@ + + + MultiRotorConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + + 0 + + + 6 + + + + + + 10 + 10 + + + + + 16777215 + 16777215 + + + + Frame Type + + + + 12 + + + + + QLayout::SetFixedSize + + + + + Qt::Horizontal + + + + 10 + 13 + + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + 16777215 + 25 + + + + Select the Multirotor frame type here. + + + + + + + Qt::Horizontal + + + + 10 + 13 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + 0 + 0 + + + + + 10 + 10 + + + + background:transparent + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + + + + 16777215 + 16777215 + + + + Mix Level + + + + 0 + + + 12 + + + + + + + + 30 + 0 + + + + 100 + + + Qt::AlignCenter + + + + + + + + 35 + 0 + + + + Weight of Roll mixing in percent. +Typical values are 100% for + configuration and 50% for X configuration on quads. + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Roll + + + Qt::AlignCenter + + + + + + + + + + + + 0 + 0 + + + + 100 + + + Qt::AlignCenter + + + + + + + + 35 + 0 + + + + Weight of Pitch mixing in percent. +Typical values are 100% for + configuration and 50% for X configuration on quads. + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Pitch + + + Qt::AlignCenter + + + + + + + + + + + + 0 + 0 + + + + 50 + + + Qt::AlignCenter + + + + + + + + 40 + 0 + + + + Weight of Yaw mixing in percent. +Typical value is 50% for + or X configuration on quads. + + + 0 + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Yaw + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Mixer OK + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + + 10 + 10 + + + + + 16777215 + 16777215 + + + + Throttle Curve + + + + 12 + + + + + + 0 + 0 + + + + + 10 + 10 + + + + + 10 + 10 + + + + + 50 + 50 + + + + background:transparent + + + + + + + + + + + 0 + 0 + + + + + 0 + 140 + + + + Motor output channels + + + + 12 + + + + + QLayout::SetMaximumSize + + + QFormLayout::AllNonFixedFieldsGrow + + + 6 + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 1 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 2 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 3 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 4 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + + + QLayout::SetMaximumSize + + + QFormLayout::AllNonFixedFieldsGrow + + + 6 + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 5 + + + + + + + false + + + + 0 + 0 + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 6 + + + + + + + false + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 7 + + + + + + + false + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 8 + + + + + + + false + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Multirotor Motor Direction + + + Qt::AlignCenter + + + + + + + false + + + + 0 + 0 + + + + + 40 + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Tricopter Yaw Servo channel + + + Qt::AlignCenter + + + + + + + Reverse all motors + + + + + + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 4ea8dd670..69693f11b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -25,6 +25,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configccpmwidget.h" +#include "mixersettings.h" +#include "systemsettings.h" +#include "actuatorcommand.h" #include #include @@ -36,10 +39,6 @@ #include #include -#include "mixersettings.h" -#include "systemsettings.h" -#include "actuatorcommand.h" - #define Pi 3.14159265358979323846 diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index 2d52eed8f..7f091c1fb 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -27,12 +27,13 @@ #ifndef CONFIGccpmWIDGET_H #define CONFIGccpmWIDGET_H +#include "cfg_vehicletypes/vehicleconfig.h" #include "ui_ccpm.h" #include "../uavobjectwidgetutils/configtaskwidget.h" -#include "cfg_vehicletypes/vehicleconfig.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" + #include #include #include @@ -63,66 +64,67 @@ public: friend class ConfigVehicleTypeWidget; private: - Ui_ccpmWidget *m_ccpm; - QGraphicsSvgItem *SwashplateImg; - QGraphicsSvgItem *CurveImg; - QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS]; - QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS]; - QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS]; - QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS]; - QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS]; + Ui_ccpmWidget *m_ccpm; + QGraphicsSvgItem *SwashplateImg; + QGraphicsSvgItem *CurveImg; + QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS]; + QGraphicsTextItem *ServosText[CCPM_MAX_SWASH_SERVOS]; + QGraphicsLineItem *ServoLines[CCPM_MAX_SWASH_SERVOS]; + QGraphicsEllipseItem *ServosTextCircles[CCPM_MAX_SWASH_SERVOS]; + QSpinBox *SwashLvlSpinBoxes[CCPM_MAX_SWASH_SERVOS]; - QString TypeText; + QString TypeText; - bool SwashLvlConfigurationInProgress; - UAVObject::Metadata SwashLvlaccInitialData; - int SwashLvlState; - int SwashLvlServoInterlock; + bool SwashLvlConfigurationInProgress; + UAVObject::Metadata SwashLvlaccInitialData; + int SwashLvlState; + int SwashLvlServoInterlock; - SwashplateServoSettingsStruct oldSwashLvlConfiguration; - SwashplateServoSettingsStruct newSwashLvlConfiguration; + SwashplateServoSettingsStruct oldSwashLvlConfiguration; + SwashplateServoSettingsStruct newSwashLvlConfiguration; - int MixerChannelData[6]; - int ShowDisclaimer(int messageID); - virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget + int MixerChannelData[6]; + int ShowDisclaimer(int messageID); + virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget - bool updatingFromHardware; - bool updatingToHardware; + bool updatingFromHardware; + bool updatingToHardware; - virtual void ResetActuators(GUIConfigDataUnion* configData); - static QStringList getChannelDescriptions(); + virtual void ResetActuators(GUIConfigDataUnion* configData); + static QStringList getChannelDescriptions(); - QString updateConfigObjects(); - private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); - virtual bool throwConfigError(QString airframeType); + QString updateConfigObjects(); - void ccpmSwashplateUpdate(); - void ccpmSwashplateRedraw(); - void UpdateMixer(); - void UpdateType(); +private slots: + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + virtual bool throwConfigError(QString airframeType); - void SwashLvlStartButtonPressed(); - void SwashLvlNextButtonPressed(); - void SwashLvlCancelButtonPressed(); - void SwashLvlFinishButtonPressed(); + void ccpmSwashplateUpdate(); + void ccpmSwashplateRedraw(); + void UpdateMixer(); + void UpdateType(); - //void UpdateCCPMOptionsFromUI(); - //void UpdateCCPMUIFromOptions(); + void SwashLvlStartButtonPressed(); + void SwashLvlNextButtonPressed(); + void SwashLvlCancelButtonPressed(); + void SwashLvlFinishButtonPressed(); - void SetUIComponentVisibilities(); + //void UpdateCCPMOptionsFromUI(); + //void UpdateCCPMUIFromOptions(); - void enableSwashplateLevellingControl(bool state); - void setSwashplateLevel(int percent); - void SwashLvlSpinBoxChanged(int value); - virtual void refreshValues() {}; // Not used + void SetUIComponentVisibilities(); - public slots: - void getMixer(); - void setMixer(); - void saveccpmUpdate(); + void enableSwashplateLevellingControl(bool state); + void setSwashplateLevel(int percent); + void SwashLvlSpinBoxChanged(int value); + virtual void refreshValues() {}; // Not used + +public slots: + void getMixer(); + void setMixer(); + void saveccpmUpdate(); protected: void showEvent(QShowEvent *event); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index ac6d91165..27a62ec9c 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -25,8 +25,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configfixedwingwidget.h" -#include "configvehicletypewidget.h" +//#include "configvehicletypewidget.h" #include "mixersettings.h" +#include "systemsettings.h" +#include "actuatorsettings.h" +#include "actuatorcommand.h" #include #include @@ -38,16 +41,10 @@ #include #include -#include "mixersettings.h" -#include "systemsettings.h" -#include "actuatorsettings.h" -#include "actuatorcommand.h" - - /** Constructor */ -ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) +ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { m_aircraft = aircraft; } @@ -60,7 +57,6 @@ ConfigFixedWingWidget::~ConfigFixedWingWidget() // Do nothing } - /** Virtual function to setup the UI */ @@ -70,7 +66,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") { // Setup the UI - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder")); m_aircraft->fwRudder1ChannelBox->setEnabled(true); m_aircraft->fwRudder1Label->setEnabled(true); @@ -92,7 +88,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonMixBox->setHidden(true); } else if (frameType == "FixedWingElevon" || frameType == "Elevon") { - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon")); m_aircraft->fwAileron1Label->setText("Elevon 1"); m_aircraft->fwAileron2Label->setText("Elevon 2"); @@ -111,7 +107,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonLabel2->setText("Pitch"); } else if (frameType == "FixedWingVtail" || frameType == "Vtail") { - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail")); m_aircraft->fwRudder1ChannelBox->setEnabled(false); m_aircraft->fwRudder1Label->setEnabled(false); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 7897829b3..282fc3447 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -27,12 +27,14 @@ #ifndef CONFIGFIXEDWINGWIDGET_H #define CONFIGFIXEDWINGWIDGET_H -#include "ui_airframe.h" +#include "cfg_vehicletypes/vehicleconfig.h" +#include "ui_airframe_fixedwing.h" #include "../uavobjectwidgetutils/configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" #include "uavtalk/telemetrymanager.h" + #include #include #include @@ -44,13 +46,13 @@ class ConfigFixedWingWidget: public VehicleConfig Q_OBJECT public: - ConfigFixedWingWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0); + ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft = 0, QWidget *parent = 0); ~ConfigFixedWingWidget(); friend class ConfigVehicleTypeWidget; private: - Ui_AircraftWidget *m_aircraft; + Ui_FixedWingConfigWidget *m_aircraft; bool setupFrameFixedWing(QString airframeType); bool setupFrameElevon(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index a23b758df..01a7d3492 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -25,8 +25,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configgroundvehiclewidget.h" -#include "configvehicletypewidget.h" +//#include "configvehicletypewidget.h" #include "mixersettings.h" +#include "systemsettings.h" +#include "actuatorsettings.h" +#include "actuatorcommand.h" #include #include @@ -38,23 +41,11 @@ #include #include -#include "mixersettings.h" -#include "systemsettings.h" -#include "actuatorsettings.h" -#include "actuatorcommand.h" - - -/** - Constructor - */ -ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent) +ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent) { m_aircraft = aircraft; } -/** - Destructor - */ ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget() { // Do nothing @@ -68,7 +59,7 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) m_aircraft->differentialSteeringMixBox->setHidden(true); //STILL NEEDS WORK // Setup the UI - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); + //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); m_aircraft->gvEngineChannelBox->setEnabled(false); m_aircraft->gvEngineLabel->setEnabled(false); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index fb6cc48b2..804b0bfa7 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -27,12 +27,14 @@ #ifndef CONFIGGROUNDVEHICLEWIDGET_H #define CONFIGGROUNDVEHICLEWIDGET_H -#include "ui_airframe.h" +#include "cfg_vehicletypes/vehicleconfig.h" +#include "ui_airframe_ground.h" #include "../uavobjectwidgetutils/configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" #include "uavtalk/telemetrymanager.h" + #include #include #include @@ -44,13 +46,13 @@ class ConfigGroundVehicleWidget: public VehicleConfig Q_OBJECT public: - ConfigGroundVehicleWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0); + ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft = 0, QWidget *parent = 0); ~ConfigGroundVehicleWidget(); friend class ConfigVehicleTypeWidget; private: - Ui_AircraftWidget *m_aircraft; + Ui_GroundConfigWidget *m_aircraft; bool setupGroundVehicleCar(QString airframeType); bool setupGroundVehicleDifferential(QString airframeType); @@ -65,7 +67,6 @@ private slots: virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(QString airframeType); - protected: }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 7db57f5d1..678688c6b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -25,6 +25,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configmultirotorwidget.h" +#include "mixersettings.h" +#include "systemsettings.h" +#include "actuatorsettings.h" +#include "actuatorcommand.h" #include #include @@ -37,46 +41,33 @@ #include #include -#include "mixersettings.h" -#include "systemsettings.h" -#include "actuatorsettings.h" -#include "actuatorcommand.h" - - const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox"); - -/** - Constructor - */ -ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft, QWidget *parent) : VehicleConfig(parent), invertMotors(1) +ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent), invertMotors(1) { m_aircraft = aircraft; } -/** - Destructor - */ ConfigMultiRotorWidget::~ConfigMultiRotorWidget() { // Do nothing } - void ConfigMultiRotorWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); Q_ASSERT(uiowner); Q_ASSERT(quad); - int i; + qDebug() << "ConfigMultiRotorWidget::setupUI - begin"; + qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType; // set aircraftType to Multirotor, disable triyaw channel - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); + //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); m_aircraft->triYawChannelBox->setEnabled(false); // disable all motor channel boxes - for (i=1; i <=8; i++) { + for (int i = 1; i <= 8; i++) { // do it manually so we can turn off any error decorations QComboBox *combobox = qFindChild(uiowner, "multiMotorChannelBox" + QString::number(i)); if (combobox) { @@ -118,8 +109,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrPitchMixLevel->setValue(100); setYawMixLevel(50); } - else if (frameType == "Hexa" || frameType == "Hexacopter") - { + else if (frameType == "Hexa" || frameType == "Hexacopter") { setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter")); //Enable all necessary motor channel boxes... @@ -140,8 +130,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(33); } - else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") - { + else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); //Enable all necessary motor channel boxes... @@ -152,8 +141,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(66); } - else if (frameType == "Octo" || frameType == "Octocopter") - { + else if (frameType == "Octo" || frameType == "Octocopter") { setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter")); //Enable all necessary motor channel boxes @@ -163,8 +151,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrPitchMixLevel->setValue(33); setYawMixLevel(25); } - else if (frameType == "OctoV" || frameType == "Octocopter V") - { + else if (frameType == "OctoV" || frameType == "Octocopter V") { setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V")); //Enable all necessary motor channel boxes @@ -175,8 +162,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(25); } - else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") - { + else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +")); //Enable all necessary motor channel boxes @@ -187,8 +173,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(50); } - else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") - { + else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X")); //Enable all necessary motor channel boxes @@ -199,82 +184,82 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(50); } - //Draw the appropriate airframe + // Draw the appropriate airframe drawAirframe(frameType); + qDebug() << "ConfigMultiRotorWidget::setupUI - end"; } -void ConfigMultiRotorWidget::drawAirframe(QString frameType){ +void ConfigMultiRotorWidget::drawAirframe(QString frameType) +{ + qDebug() << "ConfigMultiRotorWidget::drawAirframe - begin"; + qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type:" << frameType; - invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1:1; + invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1 : 1; if (frameType == "Tri" || frameType == "Tricopter Y") { - if(invertMotors > 0) + if (invertMotors > 0) { quad->setElementId("tri"); - else + } else { quad->setElementId("tri_reverse"); - } - else if (frameType == "QuadX" || frameType == "Quad X") { - if(invertMotors > 0) + } + } else if (frameType == "QuadX" || frameType == "Quad X") { + qDebug() << "ConfigMultiRotorWidget::drawAirframe - 1"; + if (invertMotors > 0) { quad->setElementId("quad-x"); - else + } else { quad->setElementId("quad-x_reverse"); - } - else if (frameType == "QuadP" || frameType == "Quad +") { - if(invertMotors > 0) + } + qDebug() << "ConfigMultiRotorWidget::drawAirframe - 2"; + } else if (frameType == "QuadP" || frameType == "Quad +") { + if (invertMotors > 0) { quad->setElementId("quad-plus"); - else + } else { quad->setElementId("quad-plus_reverse"); - } - else if (frameType == "Hexa" || frameType == "Hexacopter") - { - if(invertMotors > 0) + } + } else if (frameType == "Hexa" || frameType == "Hexacopter") { + if (invertMotors > 0) { quad->setElementId("quad-hexa"); - else + } else { quad->setElementId("quad-hexa_reverse"); - } - else if (frameType == "HexaX" || frameType == "Hexacopter X" ) { - if(invertMotors > 0) + } + } else if (frameType == "HexaX" || frameType == "Hexacopter X") { + if (invertMotors > 0) { quad->setElementId("quad-hexa-H"); - else + } else { quad->setElementId("quad-hexa-H_reverse"); - } - else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") - { - if(invertMotors > 0) + } + } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { + if (invertMotors > 0) { quad->setElementId("hexa-coax"); - else + } else { quad->setElementId("hexa-coax_reverse"); - } - else if (frameType == "Octo" || frameType == "Octocopter") - { - if(invertMotors > 0) + } + } else if (frameType == "Octo" || frameType == "Octocopter") { + if (invertMotors > 0) { quad->setElementId("quad-octo"); - else + } else { quad->setElementId("quad-octo_reverse"); - } - else if (frameType == "OctoV" || frameType == "Octocopter V") - { - if(invertMotors > 0) + } + } else if (frameType == "OctoV" || frameType == "Octocopter V") { + if (invertMotors > 0) { quad->setElementId("quad-octo-v"); - else + } else { quad->setElementId("quad-octo-v_reverse"); - } - else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") - { - if(invertMotors > 0) + } + } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { + if (invertMotors > 0) { quad->setElementId("octo-coax-P"); - else + } else { quad->setElementId("octo-coax-P_reverse"); - - } - else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") - { - if(invertMotors > 0) + } + } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { + if (invertMotors > 0) { quad->setElementId("octo-coax-X"); - else + } else { quad->setElementId("octo-coax-X_reverse"); - + } } + qDebug() << "ConfigMultiRotorWidget::drawAirframe - end"; } void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 4ce10aae3..64b8dd388 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -27,14 +27,14 @@ #ifndef CONFIGMULTIROTORWIDGET_H #define CONFIGMULTIROTORWIDGET_H -#include "ui_airframe.h" -#include "../uavobjectwidgetutils/configtaskwidget.h" #include "cfg_vehicletypes/vehicleconfig.h" - +#include "ui_airframe_multirotor.h" +#include "../uavobjectwidgetutils/configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" #include "uavtalk/telemetrymanager.h" + #include #include #include @@ -46,13 +46,13 @@ class ConfigMultiRotorWidget: public VehicleConfig Q_OBJECT public: - ConfigMultiRotorWidget(Ui_AircraftWidget *aircraft = 0, QWidget *parent = 0); + ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft = 0, QWidget *parent = 0); ~ConfigMultiRotorWidget(); friend class ConfigVehicleTypeWidget; private: - Ui_AircraftWidget *m_aircraft; + Ui_MultiRotorConfigWidget *m_aircraft; QWidget *uiowner; QGraphicsSvgItem *quad; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 64ab037c8..ad76c1632 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -29,7 +29,6 @@ #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" #include "uavobject.h" - #include "systemsettings.h" #include diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 3b729a6dd..e8de31427 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -33,7 +33,6 @@ #include "uavobject.h" #include "actuatorcommand.h" - typedef struct { uint VTOLMotorN:4; uint VTOLMotorS:4; @@ -103,60 +102,79 @@ typedef union groundGUISettingsStruct ground; } GUIConfigDataUnion; - class VehicleConfig: public ConfigTaskWidget { - Q_OBJECT +Q_OBJECT - public: - VehicleConfig(QWidget *parent = 0); - ~VehicleConfig(); +public: + VehicleConfig(QWidget *parent = 0); + ~VehicleConfig(); - /* Enumeration options for ThrottleCurves */ - typedef enum { MIXER_THROTTLECURVE1=0, MIXER_THROTTLECURVE2=1 } MixerThrottleCurveElem; + /* Enumeration options for ThrottleCurves */ + typedef enum { + MIXER_THROTTLECURVE1 = 0, MIXER_THROTTLECURVE2 = 1 + } MixerThrottleCurveElem; - /* Enumeration options for field MixerType */ - typedef enum { MIXERTYPE_DISABLED=0, MIXERTYPE_MOTOR=1, MIXERTYPE_SERVO=2, MIXERTYPE_CAMERAROLL=3, MIXERTYPE_CAMERAPITCH=4, MIXERTYPE_CAMERAYAW=5, MIXERTYPE_ACCESSORY0=6, MIXERTYPE_ACCESSORY1=7, MIXERTYPE_ACCESSORY2=8, MIXERTYPE_ACCESSORY3=9, MIXERTYPE_ACCESSORY4=10, MIXERTYPE_ACCESSORY5=11 } MixerTypeElem; - /* Array element names for field MixerVector */ - typedef enum { MIXERVECTOR_THROTTLECURVE1=0, MIXERVECTOR_THROTTLECURVE2=1, MIXERVECTOR_ROLL=2, MIXERVECTOR_PITCH=3, MIXERVECTOR_YAW=4 } MixerVectorElem; + /* Enumeration options for field MixerType */ + typedef enum { + MIXERTYPE_DISABLED = 0, + MIXERTYPE_MOTOR = 1, + MIXERTYPE_SERVO = 2, + MIXERTYPE_CAMERAROLL = 3, + MIXERTYPE_CAMERAPITCH = 4, + MIXERTYPE_CAMERAYAW = 5, + MIXERTYPE_ACCESSORY0 = 6, + MIXERTYPE_ACCESSORY1 = 7, + MIXERTYPE_ACCESSORY2 = 8, + MIXERTYPE_ACCESSORY3 = 9, + MIXERTYPE_ACCESSORY4 = 10, + MIXERTYPE_ACCESSORY5 = 11 + } MixerTypeElem; - static GUIConfigDataUnion GetConfigData(); - static void SetConfigData(GUIConfigDataUnion configData); - static void resetField(UAVObjectField * field); - static void setComboCurrentIndex(QComboBox* box, int index); - static void enableComboBoxes(QWidget* owner, QString boxName, int boxCount, bool enable); - double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName); - void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value); - void resetMixerVector(UAVDataObject* mixer, int channel); - void resetMotorAndServoMixers(UAVDataObject* mixer); - QString getMixerType(UAVDataObject* mixer, int channel); - void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType); - double getMixerValue(UAVDataObject* mixer, QString elementName); - void setMixerValue(UAVDataObject* mixer, QString elementName, double value); - void setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList curve); - void getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList* curve); - bool isValidThrottleCurve(QList* curve); - double getCurveMin(QList* curve); - double getCurveMax(QList* curve); - virtual void ResetActuators(GUIConfigDataUnion* configData); + /* Array element names for field MixerVector */ + typedef enum { + MIXERVECTOR_THROTTLECURVE1 = 0, + MIXERVECTOR_THROTTLECURVE2 = 1, + MIXERVECTOR_ROLL = 2, + MIXERVECTOR_PITCH = 3, + MIXERVECTOR_YAW = 4 + } MixerVectorElem; - QStringList channelNames; - QStringList mixerTypes; - QStringList mixerVectors; - QStringList mixerTypeDescriptions; + static GUIConfigDataUnion GetConfigData(); + static void SetConfigData(GUIConfigDataUnion configData); + static void resetField(UAVObjectField * field); + static void setComboCurrentIndex(QComboBox* box, int index); + static void enableComboBoxes(QWidget* owner, QString boxName, int boxCount, bool enable); + double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName); + void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value); + void resetMixerVector(UAVDataObject* mixer, int channel); + void resetMotorAndServoMixers(UAVDataObject* mixer); + QString getMixerType(UAVDataObject* mixer, int channel); + void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType); + double getMixerValue(UAVDataObject* mixer, QString elementName); + void setMixerValue(UAVDataObject* mixer, QString elementName, double value); + void setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList curve); + void getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList* curve); + bool isValidThrottleCurve(QList* curve); + double getCurveMin(QList* curve); + double getCurveMax(QList* curve); + virtual void ResetActuators(GUIConfigDataUnion* configData); - static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM; + QStringList channelNames; + QStringList mixerTypes; + QStringList mixerVectors; + QStringList mixerTypeDescriptions; - private: + static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; - static UAVObjectManager* getUAVObjectManager(); +private: + static UAVObjectManager* getUAVObjectManager(); - private slots: +private slots: - public slots: +public slots: - signals: - //void ConfigurationChanged(); +signals: protected: diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index 1f9d797c4..a2032dbf7 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -18,7 +18,6 @@ HEADERS += configplugin.h \ config_cc_hw_widget.h \ configccattitudewidget.h \ configpipxtremewidget.h \ - cfg_vehicletypes/configccpmwidget.h \ configstabilizationwidget.h \ assertions.h \ calibration.h \ @@ -28,10 +27,11 @@ HEADERS += configplugin.h \ configcamerastabilizationwidget.h \ configtxpidwidget.h \ outputchannelform.h \ - cfg_vehicletypes/configmultirotorwidget.h \ - cfg_vehicletypes/configgroundvehiclewidget.h \ - cfg_vehicletypes/configfixedwingwidget.h \ cfg_vehicletypes/vehicleconfig.h \ + cfg_vehicletypes/configccpmwidget.h \ + cfg_vehicletypes/configmultirotorwidget.h \ + cfg_vehicletypes/configfixedwingwidget.h \ + cfg_vehicletypes/configgroundvehiclewidget.h \ configrevowidget.h \ config_global.h \ mixercurve.h \ @@ -60,17 +60,22 @@ SOURCES += configplugin.cpp \ configcamerastabilizationwidget.cpp \ configrevowidget.cpp \ configtxpidwidget.cpp \ - cfg_vehicletypes/configmultirotorwidget.cpp \ - cfg_vehicletypes/configgroundvehiclewidget.cpp \ - cfg_vehicletypes/configfixedwingwidget.cpp \ - cfg_vehicletypes/configccpmwidget.cpp \ - outputchannelform.cpp \ cfg_vehicletypes/vehicleconfig.cpp \ + cfg_vehicletypes/configccpmwidget.cpp \ + cfg_vehicletypes/configmultirotorwidget.cpp \ + cfg_vehicletypes/configfixedwingwidget.cpp \ + cfg_vehicletypes/configgroundvehiclewidget.cpp \ + outputchannelform.cpp \ mixercurve.cpp \ dblspindelegate.cpp \ configrevohwwidget.cpp FORMS += airframe.ui \ + cfg_vehicletypes/airframe_ccpm.ui \ + cfg_vehicletypes/airframe_fixedwing.ui \ + cfg_vehicletypes/airframe_ground.ui \ + cfg_vehicletypes/airframe_multirotor.ui \ + cfg_vehicletypes/airframe_custom.ui \ cc_hw_settings.ui \ ccpm.ui \ stabilization.ui \ diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index dd290073a..0e4c26dce 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -25,6 +25,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configvehicletypewidget.h" +#include "systemsettings.h" +#include "mixersettings.h" +#include "actuatorsettings.h" #include #include @@ -38,13 +41,9 @@ #include #include -#include "systemsettings.h" -#include "mixersettings.h" -#include "actuatorsettings.h" #include #include - /** Helper delegate for the custom mixer editor table. Taken straight from Qt examples, thanks! @@ -92,10 +91,6 @@ void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, /**********************************************************************************/ - -/** - Constructor - */ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_aircraft = new Ui_AircraftWidget(); @@ -103,8 +98,9 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi ExtensionSystem::PluginManager *pm=ExtensionSystem::PluginManager::instance(); Core::Internal::GeneralSettings * settings=pm->getObject(); - if(!settings->useExpertMode()) + if (!settings->useExpertMode()) { m_aircraft->saveAircraftToRAM->setVisible(false); + } addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD); @@ -115,49 +111,44 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi ffTuningInProgress = false; ffTuningPhase = false; - //Generate lists of mixerTypeNames, mixerVectorNames, channelNames - channelNames << "None"; - for (int i = 0; i < (int)ActuatorSettings::CHANNELADDR_NUMELEM; i++) { - - mixerTypes << QString("Mixer%1Type").arg(i+1); - mixerVectors << QString("Mixer%1Vector").arg(i+1); - channelNames << QString("Channel%1").arg(i+1); - } - QStringList airframeTypes; airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom"; m_aircraft->aircraftType->addItems(airframeTypes); - m_aircraft->aircraftType->setCurrentIndex(1); //Set default vehicle to MultiRotor - m_aircraft->airframesWidget->setCurrentIndex(1); // Force the tab index to match + + // ***************************************************************************************************************** + // FIXED WING + // ***************************************************************************************************************** + + // create and setup a FixedWing config widget + QWidget *fixedwingConfigWidget = new QWidget(); + m_fixedwingUi = new Ui_FixedWingConfigWidget(); + m_fixedwingUi->setupUi(fixedwingConfigWidget); + m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget); + + m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi); + m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() ); QStringList fixedWingTypes; fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; - m_aircraft->fixedWingType->addItems(fixedWingTypes); - m_aircraft->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder" + m_fixedwingUi->fixedWingType->addItems(fixedWingTypes); + m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder" - QStringList groundVehicleTypes; - groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; - m_aircraft->groundVehicleType->addItems(groundVehicleTypes); - m_aircraft->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)" + connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - QStringList multiRotorTypes; - multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" << - "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << - "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; - m_aircraft->multirotorFrameType->addItems(multiRotorTypes); - m_aircraft->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X" + // ***************************************************************************************************************** + // MULTIROTOR + // ***************************************************************************************************************** + // create and setup a MultiRotor config widget + qDebug() << "create multirotor ui"; + QWidget *multirotorConfigWidget = new QWidget(); + m_multirotorUi = new Ui_MultiRotorConfigWidget(); + m_multirotorUi->setupUi(multirotorConfigWidget); + m_aircraft->airframesWidget->addWidget(multirotorConfigWidget); - //NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name - // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name - foreach(QComboBox *combobox, this->findChildren(QRegExp("\\S+ChannelBo\\S+")))//FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate - { - combobox->addItems(channelNames); - } - // Setup the Multirotor picture in the Quad settings interface - m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); quad = new QGraphicsSvgItem(); @@ -166,66 +157,129 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi QGraphicsScene *scene = new QGraphicsScene(this); scene->addItem(quad); scene->setSceneRect(quad->boundingRect()); - m_aircraft->quadShape->setScene(scene); + m_multirotorUi->quadShape->setScene(scene); + + m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi); + m_multirotor->quad = quad; + m_multirotor->uiowner = this; + m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText()); + + QStringList multiRotorTypes; + multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" << + "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << + "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; + m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes); + m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X" + + connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); + + // Connect the multirotor motor reverse checkbox + connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); + + m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); + + // ***************************************************************************************************************** + // HELICOPTER + // ***************************************************************************************************************** + + // create and setup a Helicopter config widget + QWidget *ccpmConfigWidget = new QWidget(); + m_ccpmUi = new Ui_CcpmConfigWidget(); + m_ccpmUi->setupUi(ccpmConfigWidget); + m_aircraft->airframesWidget->addWidget(ccpmConfigWidget); + + m_heli = m_ccpmUi->widget_3; + m_heli->setupUI(QString("HeliCP")); + + + //mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); + + // ***************************************************************************************************************** + // GROUND + // ***************************************************************************************************************** + + // create and setup a GroundVehicle config widget + qDebug() << "create ground ui"; + QWidget *groundConfigWidget = new QWidget(); + m_groundUi = new Ui_GroundConfigWidget(); + m_groundUi->setupUi(groundConfigWidget); + m_aircraft->airframesWidget->addWidget(groundConfigWidget); + + m_groundvehicle = new ConfigGroundVehicleWidget(m_groundUi); + m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText()); + + QStringList groundVehicleTypes; + groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; + m_groundUi->groundVehicleType->addItems(groundVehicleTypes); + m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)" + + connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); + + // ***************************************************************************************************************** + // CUSTOM + // ***************************************************************************************************************** + + QWidget *customConfigWidget = new QWidget(); + m_customUi = new Ui_CustomConfigWidget(); + m_customUi->setupUi(customConfigWidget); + m_aircraft->airframesWidget->addWidget(customConfigWidget); // Put combo boxes in line one of the custom mixer table: UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); UAVObjectField* field = obj->getField(QString("Mixer1Type")); QStringList list = field->getOptions(); for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { - QComboBox* qb = new QComboBox(m_aircraft->customMixerTable); + QComboBox* qb = new QComboBox(m_customUi->customMixerTable); qb->addItems(list); - m_aircraft->customMixerTable->setCellWidget(0,i,qb); + m_customUi->customMixerTable->setCellWidget(0,i,qb); } SpinBoxDelegate *sbd = new SpinBoxDelegate(); for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { - m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); + m_customUi->customMixerTable->setItemDelegateForRow(i, sbd); } - // create and setup a MultiRotor config widget - m_multirotor = new ConfigMultiRotorWidget(m_aircraft); - m_multirotor->quad = quad; - m_multirotor->uiowner = this; - m_multirotor->setupUI(m_aircraft->multirotorFrameType->currentText()); + // ***************************************************************************************************************** - // create and setup a GroundVehicle config widget - m_groundvehicle = new ConfigGroundVehicleWidget(m_aircraft); - m_groundvehicle->setupUI(m_aircraft->groundVehicleType->currentText() ); + // Set default vehicle to MultiRotor + m_aircraft->aircraftType->setCurrentIndex(1); + // Force the tab index to match + m_aircraft->airframesWidget->setCurrentIndex(1); - // create and setup a FixedWing config widget - m_fixedwing = new ConfigFixedWingWidget(m_aircraft); - m_fixedwing->setupUI(m_aircraft->fixedWingType->currentText() ); + // Generate lists of mixerTypeNames, mixerVectorNames, channelNames + channelNames << "None"; + for (int i = 0; i < (int) ActuatorSettings::CHANNELADDR_NUMELEM; i++) { + mixerTypes << QString("Mixer%1Type").arg(i+1); + mixerVectors << QString("Mixer%1Vector").arg(i+1); + channelNames << QString("Channel%1").arg(i+1); + } - // create and setup a Helicopter config widget - m_heli = m_aircraft->widget_3; - m_heli->setupUI(QString("HeliCP")); + // NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name + // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name + // FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate + QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); + foreach(QComboBox *combobox, l) { + combobox->addItems(channelNames); + } - //Connect aircraft type selection dropbox to callback function + // Connect aircraft type selection dropbox to callback function connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); - //Connect airframe selection dropbox to callback functions - connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - //mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - - //Connect the three feed forward test checkboxes + // Connect the three feed forward test checkboxes connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); connect(m_aircraft->ffTestBox2, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); connect(m_aircraft->ffTestBox3, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); - //Connect the multirotor motor reverse checkbox - connect(m_aircraft->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); - // Connect the help pushbutton connect(m_aircraft->airframeHelp, SIGNAL(clicked()), this, SLOT(openHelp())); + enableControls(false); + refreshWidgetsValues(); + addToDirtyMonitor(); disableMouseWheelEvents(); - m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); } @@ -323,14 +377,12 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() void ConfigVehicleTypeWidget::switchAirframeType(int index) { m_aircraft->airframesWidget->setCurrentIndex(index); - m_aircraft->quadShape->setSceneRect(quad->boundingRect()); - m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); - if (m_aircraft->aircraftType->findText("Custom")) { - m_aircraft->customMixerTable->resizeColumnsToContents(); - for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { - m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()- - m_aircraft->customMixerTable->verticalHeader()->width())/10); - } + m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); + m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); + m_customUi->customMixerTable->resizeColumnsToContents(); + for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { + m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- + m_customUi->customMixerTable->verticalHeader()->width())/ 10); } } @@ -344,11 +396,11 @@ void ConfigVehicleTypeWidget::showEvent(QShowEvent *event) // Thit fitInView method should only be called now, once the // widget is shown, otherwise it cannot compute its values and // the result is usually a ahrsbargraph that is way too small. - m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); - m_aircraft->customMixerTable->resizeColumnsToContents(); + m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); + m_customUi->customMixerTable->resizeColumnsToContents(); for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { - m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()- - m_aircraft->customMixerTable->verticalHeader()->width())/ 10); + m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- + m_customUi->customMixerTable->verticalHeader()->width())/ 10); } } @@ -358,12 +410,12 @@ void ConfigVehicleTypeWidget::showEvent(QShowEvent *event) void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event) { Q_UNUSED(event); - m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); + m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); // Make the custom table columns autostretch: - m_aircraft->customMixerTable->resizeColumnsToContents(); + m_customUi->customMixerTable->resizeColumnsToContents(); for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { - m_aircraft->customMixerTable->setColumnWidth(i,(m_aircraft->customMixerTable->width()- - m_aircraft->customMixerTable->verticalHeader()->width())/ 10); + m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- + m_customUi->customMixerTable->verticalHeader()->width())/ 10); } } @@ -372,33 +424,33 @@ void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event) void ConfigVehicleTypeWidget::toggleAileron2(int index) { if (index) { - m_aircraft->fwAileron2ChannelBox->setEnabled(true); - m_aircraft->fwAileron2Label->setEnabled(true); + m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true); + m_fixedwingUi->fwAileron2Label->setEnabled(true); } else { - m_aircraft->fwAileron2ChannelBox->setEnabled(false); - m_aircraft->fwAileron2Label->setEnabled(false); + m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false); + m_fixedwingUi->fwAileron2Label->setEnabled(false); } } void ConfigVehicleTypeWidget::toggleElevator2(int index) { if (index) { - m_aircraft->fwElevator2ChannelBox->setEnabled(true); - m_aircraft->fwElevator2Label->setEnabled(true); + m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true); + m_fixedwingUi->fwElevator2Label->setEnabled(true); } else { - m_aircraft->fwElevator2ChannelBox->setEnabled(false); - m_aircraft->fwElevator2Label->setEnabled(false); + m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false); + m_fixedwingUi->fwElevator2Label->setEnabled(false); } } void ConfigVehicleTypeWidget::toggleRudder2(int index) { if (index) { - m_aircraft->fwRudder2ChannelBox->setEnabled(true); - m_aircraft->fwRudder2Label->setEnabled(true); + m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true); + m_fixedwingUi->fwRudder2Label->setEnabled(true); } else { - m_aircraft->fwRudder2ChannelBox->setEnabled(false); - m_aircraft->fwRudder2Label->setEnabled(false); + m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false); + m_fixedwingUi->fwRudder2Label->setEnabled(false); } } @@ -474,10 +526,13 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) { Q_UNUSED(o); + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin"; + if(!allObjectsUpdated()) return; - bool dirty=isDirty(); + bool dirty = isDirty(); + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty; // Get the Airframe type from the system settings: UAVDataObject* system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -488,6 +543,7 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) // At this stage, we will need to have some hardcoded settings in this code, this // is not ideal, but there you go. QString frameType = field->getValue().toString(); + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; setupAirframeUI(frameType); UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); @@ -501,33 +557,31 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) // is at least one of the curve values != 0? if (vconfig->isValidThrottleCurve(&curveValues)) { // yes, use the curve we just read from mixersettings - m_aircraft->multiThrottleCurve->initCurve(&curveValues); - m_aircraft->fixedWingThrottle->initCurve(&curveValues); - m_aircraft->groundVehicleThrottle1->initCurve(&curveValues); + m_multirotorUi->multiThrottleCurve->initCurve(&curveValues); + m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues); + m_groundUi->groundVehicleThrottle1->initCurve(&curveValues); } else { // no, init a straight curve - m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); - m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); - m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); + m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); + m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); + m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); } // Setup all Throttle2 curves for all types of airframes //AT THIS MOMENT, THAT MEANS ONLY GROUND VEHICLES vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); if (vconfig->isValidThrottleCurve(&curveValues)) { - m_aircraft->groundVehicleThrottle2->initCurve(&curveValues); + m_groundUi->groundVehicleThrottle2->initCurve(&curveValues); } else { - m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); + m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); } // Load the Settings for fixed wing frames: if (frameType.startsWith("FixedWing")) { - // Retrieve fixed wing settings m_fixedwing->refreshWidgetsValues(frameType); - } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" || frameType == "HexaCoax" || frameType == "HexaX" || @@ -538,18 +592,17 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) } else if (frameType == "HeliCP") { setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); m_heli->refreshWidgetsValues(frameType); - } else if (frameType.startsWith("GroundVehicle")) { - // Retrieve ground vehicle settings m_groundvehicle->refreshWidgetsValues(frameType); - } else if (frameType == "Custom") { setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); } updateCustomAirframeUI(); setDirty(dirty); + + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end"; } /** @@ -558,12 +611,13 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) */ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) { - bool dirty=isDirty(); - if(frameType == "FixedWing" || frameType == "Elevator aileron rudder" || - frameType == "FixedWingElevon" || frameType == "Elevon" || - frameType == "FixedWingVtail" || frameType == "Vtail"){ + qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin"; + qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType; + bool dirty = isDirty(); + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" + || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { m_fixedwing->setupUI(frameType); - } + } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" || frameType == "QuadP" || frameType == "Quad +" || @@ -588,10 +642,11 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) } //SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST??? - m_aircraft->quadShape->setSceneRect(quad->boundingRect()); - m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); + m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); + m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); setDirty(dirty); + qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; } @@ -622,19 +677,19 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() // is at least one of the curve values != 0? if (vconfig->isValidThrottleCurve(&curveValues)) { - m_aircraft->customThrottle1Curve->initCurve(&curveValues); + m_customUi->customThrottle1Curve->initCurve(&curveValues); } else { // no, init a straight curve - m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); + m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); } if (MixerSettings* mxr = qobject_cast(mixer)) { MixerSettings::DataFields mixerSettingsData = mxr->getData(); if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE) - m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); + m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); else { - m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); + m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); } } @@ -642,10 +697,10 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); if (vconfig->isValidThrottleCurve(&curveValues)) { - m_aircraft->customThrottle2Curve->initCurve(&curveValues); + m_customUi->customThrottle2Curve->initCurve(&curveValues); } else { - m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_aircraft->customThrottle2Curve->getMin()); + m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin()); } // Update the mixer table: @@ -653,22 +708,22 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); if (field) { - QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,channel); + QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); if (q) { QString s = field->getValue().toString(); setComboCurrentIndex(q, q->findText(s)); } - m_aircraft->customMixerTable->item(1,channel)->setText( + m_customUi->customMixerTable->item(1,channel)->setText( QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1))); - m_aircraft->customMixerTable->item(2,channel)->setText( + m_customUi->customMixerTable->item(2,channel)->setText( QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2))); - m_aircraft->customMixerTable->item(3,channel)->setText( + m_customUi->customMixerTable->item(3,channel)->setText( QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL))); - m_aircraft->customMixerTable->item(4,channel)->setText( + m_customUi->customMixerTable->item(4,channel)->setText( QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH))); - m_aircraft->customMixerTable->item(5,channel)->setText( + m_customUi->customMixerTable->item(5,channel)->setText( QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW))); } } @@ -715,12 +770,12 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); } else { - vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve()); - vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); + vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve()); + vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve()); // Update the table: for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) { - QComboBox* q = (QComboBox*)m_aircraft->customMixerTable->cellWidget(0,channel); + QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); if(q->currentText()=="Disabled") vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); else if(q->currentText()=="Motor") @@ -747,15 +802,15 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5); vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, - m_aircraft->customMixerTable->item(1,channel)->text().toDouble()); + m_customUi->customMixerTable->item(1,channel)->text().toDouble()); vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2, - m_aircraft->customMixerTable->item(2,channel)->text().toDouble()); + m_customUi->customMixerTable->item(2,channel)->text().toDouble()); vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL, - m_aircraft->customMixerTable->item(3,channel)->text().toDouble()); + m_customUi->customMixerTable->item(3,channel)->text().toDouble()); vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH, - m_aircraft->customMixerTable->item(4,channel)->text().toDouble()); + m_customUi->customMixerTable->item(4,channel)->text().toDouble()); vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW, - m_aircraft->customMixerTable->item(5,channel)->text().toDouble()); + m_customUi->customMixerTable->item(5,channel)->text().toDouble()); } } @@ -791,7 +846,7 @@ void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox* box, int index) } void ConfigVehicleTypeWidget::reverseMultirotorMotor(){ - QString frameType = m_aircraft->multirotorFrameType->currentText(); + QString frameType = m_multirotorUi->multirotorFrameType->currentText(); m_multirotor->drawAirframe(frameType); } @@ -801,9 +856,10 @@ void ConfigVehicleTypeWidget::reverseMultirotorMotor(){ */ void ConfigVehicleTypeWidget::addToDirtyMonitor() { - addWidget(m_aircraft->customMixerTable); - addWidget(m_aircraft->customThrottle1Curve->getCurveWidget()); - addWidget(m_aircraft->customThrottle2Curve->getCurveWidget()); + /* + addWidget(m_customUi->customMixerTable); + addWidget(m_customUi->customThrottle1Curve->getCurveWidget()); + addWidget(m_customUi->customThrottle2Curve->getCurveWidget()); addWidget(m_aircraft->multiThrottleCurve->getCurveWidget()); addWidget(m_aircraft->fixedWingThrottle->getCurveWidget()); addWidget(m_aircraft->fixedWingType); @@ -869,5 +925,6 @@ void ConfigVehicleTypeWidget::addToDirtyMonitor() addWidget(m_heli->m_ccpm->ThrottleCurve->getCurveWidget()); addWidget(m_heli->m_ccpm->PitchCurve->getCurveWidget()); addWidget(m_heli->m_ccpm->ccpmAdvancedSettingsTable); + */ } diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index e4cea4cc2..c1ad6b473 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -34,11 +34,17 @@ #include "uavobject.h" #include "uavtalk/telemetrymanager.h" +#include "cfg_vehicletypes/vehicleconfig.h" #include "cfg_vehicletypes/configccpmwidget.h" #include "cfg_vehicletypes/configfixedwingwidget.h" -#include "cfg_vehicletypes/configmultirotorwidget.h" #include "cfg_vehicletypes/configgroundvehiclewidget.h" -#include "cfg_vehicletypes/vehicleconfig.h" +#include "cfg_vehicletypes/configmultirotorwidget.h" + +#include "ui_airframe_ccpm.h" +#include "ui_airframe_fixedwing.h" +#include "ui_airframe_ground.h" +#include "ui_airframe_multirotor.h" +#include "ui_airframe_custom.h" #include #include @@ -59,6 +65,12 @@ public: private: Ui_AircraftWidget *m_aircraft; + Ui_CcpmConfigWidget *m_ccpmUi; + Ui_FixedWingConfigWidget *m_fixedwingUi; + Ui_MultiRotorConfigWidget *m_multirotorUi; + Ui_GroundConfigWidget *m_groundUi; + Ui_CustomConfigWidget *m_customUi; + ConfigCcpmWidget *m_heli; ConfigFixedWingWidget *m_fixedwing; ConfigMultiRotorWidget *m_multirotor; @@ -66,7 +78,7 @@ private: void updateCustomAirframeUI(); void addToDirtyMonitor(); - void resetField(UAVObjectField * field); + void resetField(UAVObjectField *field); //void setMixerChannel(int channelNumber, bool channelIsMotor, QList vector); @@ -81,10 +93,10 @@ private: private slots: - virtual void refreshWidgetsValues(UAVObject * o=NULL); + virtual void refreshWidgetsValues(UAVObject *o = NULL); virtual void updateObjectsFromWidgets(); - void setComboCurrentIndex(QComboBox* box, int index); + void setComboCurrentIndex(QComboBox *box, int index); void setupAirframeUI(QString type); @@ -102,6 +114,7 @@ protected: void resizeEvent(QResizeEvent *event); + }; class SpinBoxDelegate : public QItemDelegate @@ -111,15 +124,12 @@ class SpinBoxDelegate : public QItemDelegate public: SpinBoxDelegate(QObject *parent = 0); - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, - const QModelIndex &index) const; + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; - void updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &index) const; + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; }; #endif // CONFIGVEHICLETYPEWIDGET_H From b27bc03ef5877306233f6959f1fd0d190c88d49e Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 24 Mar 2013 21:41:44 +0100 Subject: [PATCH 03/32] OP-907 step 1: extract vehicle specific UIs from airframe.ui (merged next) --- .../src/plugins/config/airframe.ui | 2776 +---------------- .../{cfg_vehicletypes => }/airframe_ccpm.ui | 0 .../src/plugins/config/airframe_custom.ui | 818 +++++ .../airframe_fixedwing.ui | 2 +- .../src/plugins/config/airframe_ground.ui | 544 ++++ .../src/plugins/config/airframe_multirotor.ui | 893 ++++++ .../cfg_vehicletypes/airframe_custom.ui | 713 ----- .../cfg_vehicletypes/airframe_ground.ui | 548 ---- .../cfg_vehicletypes/airframe_multirotor.ui | 868 ------ .../src/plugins/config/config.pro | 10 +- .../config/configvehicletypewidget.cpp | 2 +- 11 files changed, 2272 insertions(+), 4902 deletions(-) rename ground/openpilotgcs/src/plugins/config/{cfg_vehicletypes => }/airframe_ccpm.ui (100%) create mode 100644 ground/openpilotgcs/src/plugins/config/airframe_custom.ui rename ground/openpilotgcs/src/plugins/config/{cfg_vehicletypes => }/airframe_fixedwing.ui (99%) create mode 100644 ground/openpilotgcs/src/plugins/config/airframe_ground.ui create mode 100644 ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui delete mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui delete mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui delete mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index e70184c17..809f07c18 100755 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -128,8 +128,8 @@ 0 0 - 852 - 518 + 850 + 525 @@ -215,2639 +215,8 @@ QFrame::NoFrame - 4 + -1 - - - true - - - false - - - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Airplane type: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - 0 - 0 - - - - - 230 - 100 - - - - Output Channel Assignments - - - - - - Engine - - - - - - - Select output channel for the engine - - - - - - - - 60 - 0 - - - - Aileron 1 - - - - - - - Select output channel for the first aileron (or elevon) - - - - - - - false - - - - 60 - 0 - - - - Aileron 2 - - - - - - - false - - - Select output channel for the second aileron (or elevon) - - - - - - - - 67 - 0 - - - - Elevator 1 - - - - - - - Select output channel for the first elevator - - - - - - - false - - - - 67 - 0 - - - - Elevator 2 - - - - - - - false - - - Select output channel for a secondary elevator - - - - - - - Rudder 1 - - - - - - - Select output channel for the first rudder - - - - - - - Rudder 2 - - - - - - - Select output channel for a secondary rudder - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - - - - 0 - 0 - - - - Elevon Mix - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 0 - 20 - - - - - - - - - - - - - 65 - 0 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Rudder % - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - 50 - - - Qt::AlignCenter - - - - - - - - - - - - 50 - 0 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Pitch % - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - 50 - - - Qt::AlignCenter - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 100 - - - - Throttle Curve - - - - - - - 1 - 1 - - - - - 0 - 0 - - - - - 500 - 500 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Mixer OK - - - - - - - - - - - - - 0 - - - 6 - - - - - - 10 - 10 - - - - - 16777215 - 16777215 - - - - Frame Type - - - - 12 - - - - - QLayout::SetFixedSize - - - - - Qt::Horizontal - - - - 10 - 13 - - - - - - - - - 0 - 0 - - - - - 25 - 25 - - - - - 16777215 - 25 - - - - Select the Multirotor frame type here. - - - - - - - Qt::Horizontal - - - - 10 - 13 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - - 0 - 0 - - - - - 10 - 10 - - - - background:transparent - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - - - - - 0 - 0 - - - - - 10 - 10 - - - - - 16777215 - 16777215 - - - - Throttle Curve - - - - 12 - - - - - - 0 - 0 - - - - - 10 - 10 - - - - - 10 - 10 - - - - - 50 - 50 - - - - background:transparent - - - - - - - - - - - 16777215 - 16777215 - - - - Mix Level - - - - 0 - - - 12 - - - - - - - - 30 - 0 - - - - 100 - - - Qt::AlignCenter - - - - - - - - 35 - 0 - - - - Weight of Roll mixing in percent. -Typical values are 100% for + configuration and 50% for X configuration on quads. - - - 100 - - - 100 - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 30 - 0 - - - - - 30 - 16777215 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Roll - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - - - - 100 - - - Qt::AlignCenter - - - - - - - - 35 - 0 - - - - Weight of Pitch mixing in percent. -Typical values are 100% for + configuration and 50% for X configuration on quads. - - - 100 - - - 100 - - - Qt::Vertical - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Pitch - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - - - - 50 - - - Qt::AlignCenter - - - - - - - - 40 - 0 - - - - Weight of Yaw mixing in percent. -Typical value is 50% for + or X configuration on quads. - - - 0 - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Yaw - - - Qt::AlignCenter - - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Mixer OK - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 140 - - - - Motor output channels - - - - 12 - - - - - QLayout::SetMaximumSize - - - QFormLayout::AllNonFixedFieldsGrow - - - 6 - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 1 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 2 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 3 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 4 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - - - QLayout::SetMaximumSize - - - QFormLayout::AllNonFixedFieldsGrow - - - 6 - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 5 - - - - - - - false - - - - 0 - 0 - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 6 - - - - - - - false - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 7 - - - - - - - false - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 8 - - - - - - - false - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Multirotor Motor Direction - - - Qt::AlignCenter - - - - - - - false - - - - 0 - 0 - - - - - 40 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Tricopter Yaw Servo channel - - - Qt::AlignCenter - - - - - - - Reverse all motors - - - - - - - - - - - - 0 - - - 0 - - - - - 0 - - - - - - - - - - - true - - - false - - - - - - true - - - - - 0 - 0 - 808 - 397 - - - - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Vehicle type: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 75 - true - - - - Channel Assignment - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 100 - - - - Output channel asignmets - - - - - - - 77 - 0 - - - - Engine - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Select output channel for the engine - - - - - - - - 60 - 0 - - - - Aileron 1 - - - - - - - Select output channel for the first aileron (or elevon) - - - - - - - false - - - - 60 - 0 - - - - Aileron 2 - - - - - - - false - - - Select output channel for the second aileron (or elevon) - - - - - - - - 0 - 0 - - - - Motor - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Select output channel for the first motor - - - - - - - false - - - - 47 - 0 - - - - Motor 2 - - - - - - - false - - - Select output channel for a second motor - - - - - - - Front Steering - - - - - - - Select output channel for the first steering actuator - - - - - - - Rear Steering - - - - - - - Select output channel for a second steering actuator - - - - - - - - - - true - - - - 0 - 0 - - - - Differential Steering Mix - - - - - - - - - - - 65 - 0 - - - - Left % - - - - - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - 50 - - - - - - - - - - - - 50 - 0 - - - - Right % - - - - - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - 50 - - - - - - - - - - - - - - - 0 - 100 - - - - Front throttle curve - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 500 - 500 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - 0 - 0 - - - - Rear throttle curve - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 500 - 500 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Mixer OK - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - Curve 1 - - - - - - - 1 - 1 - - - - - 50 - 50 - - - - - 1000 - 1000 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - Curve 2 - - - - - - - 1 - 1 - - - - - 50 - 50 - - - - - 1000 - 1000 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - - - 0 - 0 - - - - true - - - 12 - - - 50 - - - false - - - - Type - - - - - Curve 1 - - - - - Curve 2 - - - - - Roll - - - - - Pitch - - - - - Yaw - - - - - Ch 1 - - - - - Ch 2 - - - - - Ch 3 - - - - - Ch 4 - - - - - Ch 5 - - - - - Ch 6 - - - - - Ch 7 - - - - - Ch 8 - - - - - Ch 9 - - - - - Ch 10 - - - - - Ch 11 - - - - - Ch 12 - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - @@ -2950,8 +319,8 @@ margin:1px; 0 0 - 852 - 518 + 850 + 525 @@ -3334,13 +703,14 @@ p, li { white-space: pre-wrap; } <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Ubuntu'; font-size:9pt; font-weight:400; font-style:normal;"> +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> <table border="0" style="-qt-table-type: root; margin-top:4px; margin-bottom:4px; margin-left:4px; margin-right:4px;"> <tr> <td style="border: none;"> -<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD REQUIRES CAUTION</span></p> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:11pt;"><br /></p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:11pt;"><br /></span></p> +<p align="center" style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:14pt; font-weight:600; color:#ff0000;">SETTING UP FEED FORWARD REQUIRES CAUTION</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;"><br /></span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Ubuntu'; font-size:11pt;"><br /></span></p> <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Beware: Feed Forward Tuning will launch all engines around mid-throttle, you have been warned!</span></p> <p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:13pt;">Remove your props initially, and for fine-tuning, make sure your airframe is safely held in place. Wear glasses and protect your face and body.</span></p></td></tr></table></body></html> @@ -3431,20 +801,6 @@ p, li { white-space: pre-wrap; } - - - MixerCurve - QWidget -
mixercurve.h
- 1 -
- - ConfigCcpmWidget - QWidget -
cfg_vehicletypes/configccpmwidget.h
- 1 -
-
@@ -3481,117 +837,5 @@ p, li { white-space: pre-wrap; } - - elevonSlider1 - valueChanged(int) - elevonSliderLabel1 - setNum(int) - - - 124 - 126 - - - 124 - 126 - - - - - elevonSlider2 - valueChanged(int) - elevonSliderLabel2 - setNum(int) - - - 362 - 299 - - - 124 - 126 - - - - - differentialSteeringSlider1 - valueChanged(int) - gvDiffSteering1Label - setNum(int) - - - 124 - 126 - - - 315 - 391 - - - - - differentialSteeringSlider2 - valueChanged(int) - gvDiffSteering2Label - setNum(int) - - - 124 - 126 - - - 390 - 391 - - - - - mrRollMixLevel - valueChanged(int) - mrRollMixValue - setNum(int) - - - 42 - 220 - - - 43 - 171 - - - - - mrYawMixLevel - valueChanged(int) - mrYawMixValue - setNum(int) - - - 120 - 254 - - - 121 - 172 - - - - - mrPitchMixLevel - valueChanged(int) - mrPitchMixValue - setNum(int) - - - 92 - 222 - - - 92 - 151 - - - diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ccpm.ui b/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui similarity index 100% rename from ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ccpm.ui rename to ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui diff --git a/ground/openpilotgcs/src/plugins/config/airframe_custom.ui b/ground/openpilotgcs/src/plugins/config/airframe_custom.ui new file mode 100644 index 000000000..5cddb3c5f --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/airframe_custom.ui @@ -0,0 +1,818 @@ + + + CustomConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + + + 0 + 0 + + + + Curve 1 + + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + Curve 2 + + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + + + 0 + 0 + + + + true + + + 12 + + + 50 + + + false + + + + Type + + + + + Curve 1 + + + + + Curve 2 + + + + + Roll + + + + + Pitch + + + + + Yaw + + + + + Ch 1 + + + + + Ch 2 + + + + + Ch 3 + + + + + Ch 4 + + + + + Ch 5 + + + + + Ch 6 + + + + + Ch 7 + + + + + Ch 8 + + + + + Ch 9 + + + + + Ch 10 + + + + + Ch 11 + + + + + Ch 12 + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui b/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui similarity index 99% rename from ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui rename to ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui index 9e871d695..7bc50cb72 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_fixedwing.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui @@ -15,7 +15,7 @@ - 9 + 12 diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ground.ui b/ground/openpilotgcs/src/plugins/config/airframe_ground.ui new file mode 100644 index 000000000..6ca9f5088 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/airframe_ground.ui @@ -0,0 +1,544 @@ + + + GroundConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Vehicle type: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 75 + true + + + + Channel Assignment + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 100 + + + + Output channel assignments + + + + + + + 77 + 0 + + + + Engine + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Select output channel for the engine + + + + + + + + 60 + 0 + + + + Aileron 1 + + + + + + + Select output channel for the first aileron (or elevon) + + + + + + + false + + + + 60 + 0 + + + + Aileron 2 + + + + + + + false + + + Select output channel for the second aileron (or elevon) + + + + + + + + 0 + 0 + + + + Motor + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Select output channel for the first motor + + + + + + + false + + + + 47 + 0 + + + + Motor 2 + + + + + + + false + + + Select output channel for a second motor + + + + + + + Front Steering + + + + + + + Select output channel for the first steering actuator + + + + + + + Rear Steering + + + + + + + Select output channel for a second steering actuator + + + + + + + + + + true + + + + 0 + 0 + + + + Differential Steering Mix + + + + + + + + + + + 65 + 0 + + + + Left % + + + + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 50 + + + + + + + + + + + + 50 + 0 + + + + Right % + + + + + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + 50 + + + + + + + + + + + + + + + 0 + 100 + + + + Front throttle curve + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 500 + 500 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + 0 + 0 + + + + Rear throttle curve + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 500 + 500 + + + + + 10 + 10 + + + + + 300 + 350 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 75 + true + + + + Mixer OK + + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + + + differentialSteeringSlider1 + valueChanged(int) + gvDiffSteering1Label + setNum(int) + + + 124 + 126 + + + 315 + 391 + + + + + differentialSteeringSlider2 + valueChanged(int) + gvDiffSteering2Label + setNum(int) + + + 124 + 126 + + + 390 + 391 + + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui new file mode 100644 index 000000000..8f912a375 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui @@ -0,0 +1,893 @@ + + + MultiRotorConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + 10 + 10 + + + + + 16777215 + 16777215 + + + + Frame Type + + + + 12 + + + + + QLayout::SetFixedSize + + + + + Qt::Horizontal + + + + 10 + 13 + + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + 16777215 + 25 + + + + Select the Multirotor frame type here. + + + + + + + Qt::Horizontal + + + + 10 + 13 + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + 0 + 0 + + + + + 10 + 10 + + + + background:transparent + + + QFrame::NoFrame + + + QFrame::Plain + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 8 + + + + + + + + + + + + 0 + 0 + + + + + 10 + 10 + + + + + 16777215 + 16777215 + + + + Throttle Curve + + + + 12 + + + + + + 0 + 0 + + + + + 10 + 10 + + + + + 10 + 10 + + + + + 50 + 50 + + + + background:transparent + + + + + + + + + + + 16777215 + 16777215 + + + + Mix Level + + + + 0 + + + 12 + + + + + + + + 30 + 0 + + + + 100 + + + Qt::AlignCenter + + + + + + + + 35 + 0 + + + + Weight of Roll mixing in percent. +Typical values are 100% for + configuration and 50% for X configuration on quads. + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 30 + 0 + + + + + 30 + 16777215 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Roll + + + Qt::AlignCenter + + + + + + + + + + + + 0 + 0 + + + + 100 + + + Qt::AlignCenter + + + + + + + + 35 + 0 + + + + Weight of Pitch mixing in percent. +Typical values are 100% for + configuration and 50% for X configuration on quads. + + + 100 + + + 100 + + + Qt::Vertical + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Pitch + + + Qt::AlignCenter + + + + + + + + + + + + 0 + 0 + + + + 50 + + + Qt::AlignCenter + + + + + + + + 40 + 0 + + + + Weight of Yaw mixing in percent. +Typical value is 50% for + or X configuration on quads. + + + 0 + + + 100 + + + 50 + + + Qt::Vertical + + + + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Yaw + + + Qt::AlignCenter + + + + + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Mixer OK + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + + + + + + 0 + 0 + + + + + 0 + 140 + + + + Motor output channels + + + + 12 + + + + + QLayout::SetMaximumSize + + + QFormLayout::AllNonFixedFieldsGrow + + + 6 + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 1 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 2 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 3 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 4 + + + + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + + + QLayout::SetMaximumSize + + + QFormLayout::AllNonFixedFieldsGrow + + + 6 + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 5 + + + + + + + false + + + + 0 + 0 + + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 6 + + + + + + + false + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 7 + + + + + + + false + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + 8 + + + + + + + false + + + Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. + + + + + + + + + + 0 + 0 + + + + Qt::Vertical + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Multirotor Motor Direction + + + Qt::AlignCenter + + + + + + + false + + + + 0 + 0 + + + + + 40 + 0 + + + + + + + + + 0 + 0 + + + + + 0 + 16 + + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Tricopter Yaw Servo channel + + + Qt::AlignCenter + + + + + + + Reverse all motors + + + + + + + + + + + MixerCurve + QWidget +
mixercurve.h
+ 1 +
+
+ + + + + + mrRollMixLevel + valueChanged(int) + mrRollMixValue + setNum(int) + + + 42 + 220 + + + 43 + 171 + + + + + mrYawMixLevel + valueChanged(int) + mrYawMixValue + setNum(int) + + + 120 + 254 + + + 121 + 172 + + + + + mrPitchMixLevel + valueChanged(int) + mrPitchMixValue + setNum(int) + + + 92 + 222 + + + 92 + 151 + + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui deleted file mode 100644 index 684b73947..000000000 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_custom.ui +++ /dev/null @@ -1,713 +0,0 @@ - - - CustomConfigWidget - - - - 0 - 0 - 880 - 608 - - - - Form - - - - 12 - - - - - - - - - - 0 - 0 - - - - Curve 1 - - - - - - - 1 - 1 - - - - - 50 - 50 - - - - - 1000 - 1000 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - Curve 2 - - - - - - - 1 - 1 - - - - - 50 - 50 - - - - - 1000 - 1000 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - - - 0 - 0 - - - - true - - - 50 - - - false - - - - Type - - - - - Curve 1 - - - - - Curve 2 - - - - - Roll - - - - - Pitch - - - - - Yaw - - - - - Ch 1 - - - - - Ch 2 - - - - - Ch 3 - - - - - Ch 4 - - - - - Ch 5 - - - - - Ch 6 - - - - - Ch 7 - - - - - Ch 8 - - - - - Ch 9 - - - - - Ch 10 - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - - - MixerCurve - QWidget -
mixercurve.h
- 1 -
-
- - - - -
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui deleted file mode 100644 index 8dc27404a..000000000 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_ground.ui +++ /dev/null @@ -1,548 +0,0 @@ - - - GroundConfigWidget - - - - 0 - 0 - 880 - 608 - - - - Form - - - - 12 - - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Vehicle type: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 75 - true - - - - Channel Assignment - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 0 - 0 - - - - - 0 - 100 - - - - Output channel asignmets - - - - - - - 77 - 0 - - - - Engine - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Select output channel for the engine - - - - - - - - 60 - 0 - - - - Aileron 1 - - - - - - - Select output channel for the first aileron (or elevon) - - - - - - - false - - - - 60 - 0 - - - - Aileron 2 - - - - - - - false - - - Select output channel for the second aileron (or elevon) - - - - - - - - 0 - 0 - - - - Motor - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - Select output channel for the first motor - - - - - - - false - - - - 47 - 0 - - - - Motor 2 - - - - - - - false - - - Select output channel for a second motor - - - - - - - Front Steering - - - - - - - Select output channel for the first steering actuator - - - - - - - Rear Steering - - - - - - - Select output channel for a second steering actuator - - - - - - - - - - true - - - - 0 - 0 - - - - Differential Steering Mix - - - - - - - - - - - 65 - 0 - - - - Left % - - - - - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - 50 - - - - - - - - - - - - 50 - 0 - - - - Right % - - - - - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - 50 - - - - - - - - - - - - - - - 0 - 100 - - - - Front throttle curve - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 500 - 500 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - 0 - 0 - - - - Rear throttle curve - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 500 - 500 - - - - - 10 - 10 - - - - - 300 - 350 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 75 - true - - - - Mixer OK - - - - - - - - - - - - MixerCurve - QWidget -
mixercurve.h
- 1 -
-
- - - - - - differentialSteeringSlider1 - valueChanged(int) - gvDiffSteering1Label - setNum(int) - - - 124 - 126 - - - 315 - 391 - - - - - differentialSteeringSlider2 - valueChanged(int) - gvDiffSteering2Label - setNum(int) - - - 124 - 126 - - - 390 - 391 - - - - -
diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui deleted file mode 100644 index a499cfacd..000000000 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/airframe_multirotor.ui +++ /dev/null @@ -1,868 +0,0 @@ - - - MultiRotorConfigWidget - - - - 0 - 0 - 880 - 608 - - - - Form - - - - 12 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - - 0 - - - 6 - - - - - - 10 - 10 - - - - - 16777215 - 16777215 - - - - Frame Type - - - - 12 - - - - - QLayout::SetFixedSize - - - - - Qt::Horizontal - - - - 10 - 13 - - - - - - - - - 0 - 0 - - - - - 25 - 25 - - - - - 16777215 - 25 - - - - Select the Multirotor frame type here. - - - - - - - Qt::Horizontal - - - - 10 - 13 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - - 0 - 0 - - - - - 10 - 10 - - - - background:transparent - - - QFrame::NoFrame - - - QFrame::Plain - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - - - - - - - - 16777215 - 16777215 - - - - Mix Level - - - - 0 - - - 12 - - - - - - - - 30 - 0 - - - - 100 - - - Qt::AlignCenter - - - - - - - - 35 - 0 - - - - Weight of Roll mixing in percent. -Typical values are 100% for + configuration and 50% for X configuration on quads. - - - 100 - - - 100 - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 30 - 0 - - - - - 30 - 16777215 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Roll - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - - - - 100 - - - Qt::AlignCenter - - - - - - - - 35 - 0 - - - - Weight of Pitch mixing in percent. -Typical values are 100% for + configuration and 50% for X configuration on quads. - - - 100 - - - 100 - - - Qt::Vertical - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Pitch - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - - - - 50 - - - Qt::AlignCenter - - - - - - - - 40 - 0 - - - - Weight of Yaw mixing in percent. -Typical value is 50% for + or X configuration on quads. - - - 0 - - - 100 - - - 50 - - - Qt::Vertical - - - - - - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Yaw - - - Qt::AlignCenter - - - - - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Mixer OK - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - - - - - - 0 - 0 - - - - - 10 - 10 - - - - - 16777215 - 16777215 - - - - Throttle Curve - - - - 12 - - - - - - 0 - 0 - - - - - 10 - 10 - - - - - 10 - 10 - - - - - 50 - 50 - - - - background:transparent - - - - - - - - - - - 0 - 0 - - - - - 0 - 140 - - - - Motor output channels - - - - 12 - - - - - QLayout::SetMaximumSize - - - QFormLayout::AllNonFixedFieldsGrow - - - 6 - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 1 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 2 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 3 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 4 - - - - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - - - QLayout::SetMaximumSize - - - QFormLayout::AllNonFixedFieldsGrow - - - 6 - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 5 - - - - - - - false - - - - 0 - 0 - - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 6 - - - - - - - false - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 7 - - - - - - - false - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - 8 - - - - - - - false - - - Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. - - - - - - - - - - 0 - 0 - - - - Qt::Vertical - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Multirotor Motor Direction - - - Qt::AlignCenter - - - - - - - false - - - - 0 - 0 - - - - - 40 - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 16 - - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - - Tricopter Yaw Servo channel - - - Qt::AlignCenter - - - - - - - Reverse all motors - - - - - - - - - - - - - - MixerCurve - QWidget -
mixercurve.h
- 1 -
-
- - - - -
diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index a2032dbf7..d05c66252 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -71,11 +71,11 @@ SOURCES += configplugin.cpp \ configrevohwwidget.cpp FORMS += airframe.ui \ - cfg_vehicletypes/airframe_ccpm.ui \ - cfg_vehicletypes/airframe_fixedwing.ui \ - cfg_vehicletypes/airframe_ground.ui \ - cfg_vehicletypes/airframe_multirotor.ui \ - cfg_vehicletypes/airframe_custom.ui \ + airframe_ccpm.ui \ + airframe_fixedwing.ui \ + airframe_ground.ui \ + airframe_multirotor.ui \ + airframe_custom.ui \ cc_hw_settings.ui \ ccpm.ui \ stabilization.ui \ diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 0e4c26dce..c14045755 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -704,7 +704,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() } // Update the mixer table: - for (int channel=0; channel < m_aircraft->customMixerTable->columnCount(); channel++) { + for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) { UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); if (field) { From ccb285dd38b1dd5765487fa3473deb1a63b5e84b Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 1 Apr 2013 23:23:45 +0200 Subject: [PATCH 04/32] OP-907 step 1: renamed MultirotorRevMixercheckBox to MultirotorRevMixerCheckBox --- ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui index 8f912a375..f22ccd285 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui @@ -818,7 +818,7 @@ margin:1px;
- + Reverse all motors From b190b898f155f3c616164ae06dd441f411ed2719 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 1 Apr 2013 23:25:25 +0200 Subject: [PATCH 05/32] OP-907 step 1: merged ccpm.ui into airframe_ccpm.ui --- .../src/plugins/config/airframe_ccpm.ui | 3644 ++++++++++++++++- 1 file changed, 3630 insertions(+), 14 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui b/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui index d9d90ebd4..cce202e17 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui @@ -6,32 +6,3648 @@ 0 0 - 880 - 608 + 850 + 572 + + + 0 + 0 + + + + + 300 + 300 + + Form - - - 12 - - - + + false + + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + 0 + + + + + Swashplate config: + + + + + + + Select aircraft type here + + + + + + + + + + 0 + 0 + + + + + 300 + 300 + + + + #SwashplateBox,#SwashplateBox_2,#SwashplateBox_3,#SwashplateBox_4,#ccpmSwashImageBox,#SwashLvlInstructionsBox,#SwashLvlccpmSwashImageBox,#SwashLvlccpmSliderBox,#SwashLvlStatusBox,#ThrottleCurveBox,#PitchCurveBox{ +background-color: qlineargradient(spread:pad, x1:0.507, y1:0.869318, x2:0.507, y2:0.0965909, stop:0 rgba(243, 243, 243, 255), stop:1 rgba(250, 250, 250, 255)); +border: 1px outset #999; +border-radius: 3; +font:bold; +} + +QGroupBox::title { + subcontrol-origin: margin; + subcontrol-position: top center; /* position at the top center */ + padding: 0 3px; + background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, + stop: 0 #FFOECE, stop: 1 #FFFFFF); + top: 5px; + } + + + 0 + + + + Basic settings + + + + 3 + + + 0 + + + 3 + + + 3 + + + 3 + + + + + + + + 0 + 0 + + + + + 190 + 16777215 + + + + Motor outputs + + + + 3 + + + 2 + + + 3 + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Tail Rotor + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Engine + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 190 + 16777215 + + + + Swashplate outputs + + + + 3 + + + 2 + + + 3 + + + + + true + + + + 1 + 1 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Servo W + + + + + + + true + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + + + + true + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + + + + + 1 + 1 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Servo X + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + Front + + + + + Right + + + + + Rear + + + + + Left + + + + + + + + + 1 + 1 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + 1st Servo + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 100 + 16777215 + + + + + + + + + 1 + 1 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Servo Z + + + + + + + true + + + + 1 + 1 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Servo Y + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 190 + 16777215 + + + + Swashplate Servo Angles + + + + 3 + + + 2 + + + 3 + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 85 + 16777215 + + + + 0 + + + 360.000000000000000 + + + 15.000000000000000 + + + + + + + true + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Angle W + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Angle X + + + + + + + true + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Angle Y + + + + + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Angle Z + + + + + + + true + + + + 0 + 0 + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + Correction Angle + + + true + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 85 + 16777215 + + + + 0 + + + 360.000000000000000 + + + 15.000000000000000 + + + + + + + true + + + + 0 + 0 + + + + + 85 + 0 + + + + + 85 + 16777215 + + + + 0 + + + 360.000000000000000 + + + 15.000000000000000 + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 85 + 16777215 + + + + 0 + + + 360.000000000000000 + + + 15.000000000000000 + + + + + + + + 0 + 0 + + + + + 85 + 0 + + + + + 85 + 16777215 + + + + 0 + + + 360.000000000000000 + + + 15.000000000000000 + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + 0 + 0 + + + + + 190 + 16777215 + + + + CCPM Options + + + + 3 + + + 2 + + + 3 + + + + + Collective Pass through + + + + + + + Link Roll/Pitch + + + true + + + + + + + Link Cyclic/Collective + + + true + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + 0 + + + 0 + + + + + + 1 + 1 + + + + + 200 + 200 + + + + + 600 + 600 + + + + + 10 + 10 + + + + + 200 + 200 + + + + + 75 + false + true + + + + Swashplate Layout + + + Qt::AlignHCenter|Qt::AlignTop + + + false + + + false + + + + 3 + + + 3 + + + + + Qt::Vertical + + + + + 1 + 1 + + + + + 10 + 10 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 200 + 200 + + + + QFrame::Box + + + QFrame::Plain + + + 1 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + 112 + 184 + 138 + + + + + + + 127 + 127 + 127 + + + + + + 0.000000000000000 + 0.000000000000000 + 400.000000000000000 + 400.000000000000000 + + + + Qt::AlignCenter + + + QGraphicsView::AnchorViewCenter + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + + QLayout::SetNoConstraint + + + 3 + + + 3 + + + + + true + + + + 0 + 0 + + + + + 50 + 100 + + + + + 50 + 600 + + + + + 9 + 75 + true + + + + QGroupBox::title { + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; + } + + + REVO + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 7 + + + + + + + + false + + + + 7 + + + + 100% + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + false + + + + 7 + + + + 0% + + + Qt::AlignCenter + + + + + + + + + + + + + true + + + + 0 + 0 + + + + + 60 + 100 + + + + + 50 + 600 + + + + + 9 + 75 + true + + + + QGroupBox::title { + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; + } + + + CCPM + + + Qt::AlignCenter + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 7 + + + + + + + + true + + + + 7 + + + + Collective + + + true + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + true + + + + 7 + + + + Cyclic + + + Qt::AlignCenter + + + + + + + 100 + + + 5 + + + 50 + + + + + + + + + + true + + + + 0 + 0 + + + + + 70 + 100 + + + + + 50 + 600 + + + + + 9 + 75 + true + + + + QGroupBox::title { + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; + } + + + Collective + + + Qt::AlignCenter + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 7 + + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + 100 + + + 5 + + + 50 + + + + + + + + + + true + + + + 0 + 0 + + + + + 50 + 100 + + + + + 50 + 600 + + + + + 9 + 75 + true + + + + QGroupBox::title { + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; + } + + + Cyclic + + + Qt::AlignCenter + + + false + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 7 + + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + 100 + + + 5 + + + 50 + + + + + + + + + + true + + + + 0 + 0 + + + + + 50 + 100 + + + + + 50 + 600 + + + + + 9 + 75 + true + + + + QGroupBox::title { + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; + } + + + Pitch + + + Qt::AlignCenter + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 7 + + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + 100 + + + 5 + + + 50 + + + + + + + + + + true + + + + 0 + 0 + + + + + 50 + 100 + + + + + 50 + 600 + + + + + 9 + 75 + true + + + + QGroupBox::title { + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +margin:1px; + } + + + Roll + + + Qt::AlignCenter + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Minimum + + + + 20 + 7 + + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + 100 + + + 5 + + + 50 + + + + + + + + + + + + + Swashplate Levelling + + + + 3 + + + 3 + + + + + 3 + + + + + + 0 + 0 + + + + + 228 + 0 + + + + Commands + + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + 0 + + + + + + 85 + 0 + + + + + 85 + 16777215 + + + + Start + + + + + + + false + + + + 85 + 0 + + + + + 85 + 16777215 + + + + Next + + + + + + + + + + 0 + 150 + + + + + 220 + 450 + + + + Qt::ScrollBarAlwaysOff + + + true + + + + + + + + + false + + + + 170 + 0 + + + + + 170 + 16777215 + + + + Cancel + + + + + + + false + + + + 170 + 0 + + + + + 170 + 16777215 + + + + Finish + + + + + + + + + + + + + 0 + 0 + + + + + 200 + 0 + + + + Status + + + + 3 + + + 2 + + + 3 + + + + + + 220 + 0 + + + + + 190 + 125 + + + + QAbstractItemView::NoEditTriggers + + + true + + + QAbstractItemView::NoSelection + + + QAbstractItemView::SelectRows + + + + Neutral + + + + :/configgadget/images/none.png + :/configgadget/images/ok.png:/configgadget/images/none.png + + + + + Max + + + + :/configgadget/images/none.png + :/configgadget/images/ok.png:/configgadget/images/none.png + + + + + Min + + + + :/configgadget/images/none.png + :/configgadget/images/ok.png:/configgadget/images/none.png + + + ItemIsSelectable|ItemIsEnabled + + + + + Verify + + + + :/configgadget/images/none.png + :/configgadget/images/ok.png:/configgadget/images/none.png + + + ItemIsEnabled + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 0 + + + + + + + + + + true + + + + 0 + 0 + + + + + 70 + 100 + + + + + 50 + 600 + + + + Position + + + Qt::AlignCenter + + + + 0 + + + 3 + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + true + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Max + + + true + + + Qt::AlignCenter + + + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + true + + + + 0 + 0 + + + + + 0 + 100 + + + + 100 + + + 5 + + + 50 + + + Qt::Vertical + + + + + + + Qt::Horizontal + + + + 5 + 25 + + + + + + + + + + true + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Min + + + Qt::AlignCenter + + + + + + + 100 + + + 5 + + + 50 + + + + + + + + + + + 1 + 1 + + + + + 200 + 200 + + + + + 600 + 600 + + + + + 10 + 10 + + + + + 200 + 200 + + + + Swashplate Adjustment + + + Qt::AlignHCenter|Qt::AlignTop + + + false + + + false + + + + 3 + + + 3 + + + + + Qt::Vertical + + + + + 1 + 1 + + + + + 10 + 10 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 200 + 200 + + + + QFrame::Box + + + QFrame::Plain + + + 1 + + + 0 + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + + + 126 + 176 + 220 + + + + + + + 0 + 0 + 0 + + + + + + 0.000000000000000 + 0.000000000000000 + 400.000000000000000 + 400.000000000000000 + + + + Qt::AlignCenter + + + QGraphicsView::AnchorViewCenter + + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + + + Curve settings + + + + 3 + + + 3 + + + + + + + + 3 + + + + + + 1 + 1 + + + + + 100 + 100 + + + + + 10 + 10 + + + + + 100 + 100 + + + + Qt::LeftToRight + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + + 0 + + + 0 + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 200 + 200 + + + + + + + + + + + + 1 + 1 + + + + + 100 + 100 + + + + + 10 + 10 + + + + + 100 + 100 + + + + + + + + 0 + + + 0 + + + + + + 1 + 1 + + + + + 50 + 50 + + + + + 1000 + 1000 + + + + + 10 + 10 + + + + + 200 + 200 + + + + + + + + + + + + + Qt::Vertical + + + QSizePolicy::Preferred + + + + 20 + 0 + + + + + + + + + Advanced settings + + + + 3 + + + 3 + + + + + + 0 + 0 + + + + + 0 + 200 + + + + + 1000 + 300 + + + + Qt::ScrollBarAlwaysOff + + + Qt::ScrollBarAlwaysOff + + + true + + + true + + + QAbstractItemView::NoSelection + + + false + + + true + + + 75 + + + 20 + + + + Engine + + + + + Tail Rotor + + + + + Servo W + + + + + Servo X + + + + + Servo Y + + + + + Servo Z + + + + + Channel + + + + + Curve 1 + + + + + Curve 2 + + + + + Roll + + + + + Pitch + + + + + Yaw + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + + + + Qt::Vertical + + + QSizePolicy::MinimumExpanding + + + + 20 + 40 + + + + + + + + + - ConfigCcpmWidget + MixerCurve QWidget -
cfg_vehicletypes/configccpmwidget.h
+
mixercurve.h
1
- - - - + + ccpmType + TabObject + ccpmEngineChannel + ccpmTailChannel + ccpmServoWChannel + ccpmServoXChannel + ccpmServoYChannel + ccpmServoZChannel + ccpmSingleServo + ccpmAngleW + ccpmAngleX + ccpmAngleY + ccpmAngleZ + ccpmCorrectionAngle + ccpmRevoSlider + ccpmREVOspinBox + ccpmCollectiveSlider + ccpmCollectivespinBox + SwashplateImage + SwashLvlStartButton + SwashLvlNextButton + SwashLvlStepInstruction + SwashLvlCancelButton + SwashLvlFinishButton + SwashLvlStepList + SwashLvlPositionSlider + SwashLvlPositionSpinBox + SwashLvlSwashplateImage + ccpmAdvancedSettingsTable + + + + + ccpmCollectiveSlider + valueChanged(int) + ccpmCollectivespinBox + setValue(int) + + + 261 + 496 + + + 269 + 546 + + + + + ccpmCollectivespinBox + valueChanged(int) + ccpmCollectiveSlider + setValue(int) + + + 269 + 546 + + + 261 + 511 + + + + + ccpmREVOspinBox + valueChanged(int) + ccpmRevoSlider + setValue(int) + + + 216 + 546 + + + 208 + 511 + + + + + ccpmRevoSlider + valueChanged(int) + ccpmREVOspinBox + setValue(int) + + + 208 + 412 + + + 216 + 546 + + + + + SwashLvlPositionSlider + valueChanged(int) + SwashLvlPositionSpinBox + setValue(int) + + + 276 + 486 + + + 270 + 537 + + + + + SwashLvlPositionSpinBox + valueChanged(int) + SwashLvlPositionSlider + setValue(int) + + + 301 + 546 + + + 277 + 401 + + + + + ccpmCollectiveScaleBox + valueChanged(int) + ccpmCollectiveScale + setValue(int) + + + 296 + 534 + + + 306 + 480 + + + + + ccpmCollectiveScale + valueChanged(int) + ccpmCollectiveScaleBox + setValue(int) + + + 308 + 328 + + + 292 + 534 + + + + + ccpmCyclicScale + valueChanged(int) + ccpmCyclicScaleBox + setValue(int) + + + 358 + 306 + + + 355 + 538 + + + + + ccpmCyclicScaleBox + valueChanged(int) + ccpmCyclicScale + setValue(int) + + + 341 + 538 + + + 351 + 376 + + + + + ccpmPitchScale + valueChanged(int) + ccpmPitchScaleBox + setValue(int) + + + 417 + 306 + + + 406 + 531 + + + + + ccpmPitchScaleBox + valueChanged(int) + ccpmPitchScale + setValue(int) + + + 394 + 531 + + + 408 + 302 + + + + + ccpmRollScaleBox + valueChanged(int) + ccpmRollScale + setValue(int) + + + 455 + 529 + + + 458 + 466 + + + + + ccpmRollScale + valueChanged(int) + ccpmRollScaleBox + setValue(int) + + + 461 + 388 + + + 474 + 533 + + + + From 3ab96ed3ccf59c52e0ed59541c422776b5b9a673 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 1 Apr 2013 23:27:02 +0200 Subject: [PATCH 06/32] OP-907 step 2: moved vehicle specific code to respective vehicle widget --- .../src/plugins/config/airframe_ccpm_old.ui | 37 + .../plugins/config/{ccpm.ui => ccpm_old.ui} | 0 .../cfg_vehicletypes/configccpmwidget.cpp | 1081 ++++++++--------- .../cfg_vehicletypes/configccpmwidget.h | 9 +- .../cfg_vehicletypes/configcustomwidget.cpp | 293 +++++ .../cfg_vehicletypes/configcustomwidget.h | 91 ++ .../configfixedwingwidget.cpp | 83 +- .../cfg_vehicletypes/configfixedwingwidget.h | 4 +- .../configgroundvehiclewidget.cpp | 151 ++- .../configgroundvehiclewidget.h | 3 +- .../configmultirotorwidget.cpp | 297 +++-- .../cfg_vehicletypes/configmultirotorwidget.h | 8 +- .../config/cfg_vehicletypes/vehicleconfig.cpp | 95 +- .../config/cfg_vehicletypes/vehicleconfig.h | 44 +- .../src/plugins/config/config.pro | 3 +- .../config/configvehicletypewidget.cpp | 792 ++++++------ .../plugins/config/configvehicletypewidget.h | 71 +- 17 files changed, 1776 insertions(+), 1286 deletions(-) create mode 100644 ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui rename ground/openpilotgcs/src/plugins/config/{ccpm.ui => ccpm_old.ui} (100%) create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp create mode 100644 ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui b/ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui new file mode 100644 index 000000000..d9d90ebd4 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui @@ -0,0 +1,37 @@ + + + CcpmConfigWidget + + + + 0 + 0 + 880 + 608 + + + + Form + + + + 12 + + + + + + + + + ConfigCcpmWidget + QWidget +
cfg_vehicletypes/configccpmwidget.h
+ 1 +
+
+ + + + +
diff --git a/ground/openpilotgcs/src/plugins/config/ccpm.ui b/ground/openpilotgcs/src/plugins/config/ccpm_old.ui similarity index 100% rename from ground/openpilotgcs/src/plugins/config/ccpm.ui rename to ground/openpilotgcs/src/plugins/config/ccpm_old.ui diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 69693f11b..7b322f10e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -36,34 +36,38 @@ #include #include #include -#include #include -#define Pi 3.14159265358979323846 +#include +#define Pi 3.14159265358979323846 -ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) +ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : + VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget()) { - int i; - SwashLvlConfigurationInProgress=0; - SwashLvlState=0; - SwashLvlServoInterlock=0; - updatingFromHardware=FALSE; - updatingToHardware=FALSE; + m_aircraft->setupUi(this); - m_ccpm = new Ui_ccpmWidget(); - m_ccpm->setupUi(this); + //Ui_CcpmConfigWidget *m_aircraft = m_aircraft; + + SwashLvlConfigurationInProgress = 0; + SwashLvlState = 0; + SwashLvlServoInterlock = 0; + updatingFromHardware = FALSE; + updatingToHardware = FALSE; + + //m_aircraft = new Ui_ccpmWidget(); + //m_aircraft->setupUi(this); // Initialization of the swashplaye widget - m_ccpm->SwashplateImage->setScene(new QGraphicsScene(this)); + m_aircraft->SwashplateImage->setScene(new QGraphicsScene(this)); - m_ccpm->SwashLvlSwashplateImage->setScene(m_ccpm->SwashplateImage->scene()); - m_ccpm->SwashLvlSwashplateImage->setSceneRect(-50,-50,500,500); - //m_ccpm->SwashLvlSwashplateImage->scale(.85,.85); + m_aircraft->SwashLvlSwashplateImage->setScene(m_aircraft->SwashplateImage->scene()); + m_aircraft->SwashLvlSwashplateImage->setSceneRect(-50,-50,500,500); + //m_aircraft->SwashLvlSwashplateImage->scale(.85,.85); - //m_ccpm->SwashplateImage->setSceneRect(SwashplateImg->boundingRect()); - m_ccpm->SwashplateImage->setSceneRect(-50,-30,500,500); - //m_ccpm->SwashplateImage->scale(.85,.85); + //m_aircraft->SwashplateImage->setSceneRect(SwashplateImg->boundingRect()); + m_aircraft->SwashplateImage->setSceneRect(-50,-30,500,500); + //m_aircraft->SwashplateImage->scale(.85,.85); QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(QString(":/configgadget/images/ccpm_setup.svg")); @@ -74,7 +78,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) SwashplateImg->setElementId("Swashplate"); SwashplateImg->setObjectName("Swashplate"); //SwashplateImg->setScale(0.75); - m_ccpm->SwashplateImage->scene()->addItem(SwashplateImg); + m_aircraft->SwashplateImage->scene()->addItem(SwashplateImg); QFont serifFont("Times", 24, QFont::Bold); QPen pen; // creates a default pen @@ -101,14 +105,13 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) QList ServoNames; ServoNames << "ServoW" << "ServoX" << "ServoY" << "ServoZ" ; - for (i=0;iSwashLvlSwashplateImage->scene()->addLine(0,0,100*i,i*i*100,pen); + for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { + ServoLines[i] = m_aircraft->SwashLvlSwashplateImage->scene()->addLine(0,0,100*i,i*i*100,pen); Servos[i] = new QGraphicsSvgItem(); Servos[i]->setSharedRenderer(renderer); Servos[i]->setElementId(ServoNames.at(i)); - m_ccpm->SwashplateImage->scene()->addItem(Servos[i]); + m_aircraft->SwashplateImage->scene()->addItem(Servos[i]); ServosText[i] = new QGraphicsTextItem(); ServosText[i]->setDefaultTextColor(Qt::yellow); @@ -118,13 +121,13 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) ServosTextCircles[i] = new QGraphicsEllipseItem(1,1,30,30); ServosTextCircles[i]->setBrush(brush); ServosTextCircles[i]->setPen(pen2); - m_ccpm->SwashplateImage->scene()->addItem(ServosTextCircles[i]); - m_ccpm->SwashplateImage->scene()->addItem(ServosText[i]); + m_aircraft->SwashplateImage->scene()->addItem(ServosTextCircles[i]); + m_aircraft->SwashplateImage->scene()->addItem(ServosText[i]); - SwashLvlSpinBoxes[i] = new QSpinBox(m_ccpm->SwashLvlSwashplateImage); // use QGraphicsView - m_ccpm->SwashLvlSwashplateImage->scene()->addWidget(SwashLvlSpinBoxes[i]); + SwashLvlSpinBoxes[i] = new QSpinBox(m_aircraft->SwashLvlSwashplateImage); // use QGraphicsView + m_aircraft->SwashLvlSwashplateImage->scene()->addWidget(SwashLvlSpinBoxes[i]); SwashLvlSpinBoxes[i]->setMaximum(10000); SwashLvlSpinBoxes[i]->setMinimum(0); SwashLvlSpinBoxes[i]->setValue(0); @@ -133,25 +136,25 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) //initialize our two mixer curves // mixercurve defaults to mixercurve_throttle - m_ccpm->ThrottleCurve->initLinearCurve(5, 1.0, 0.0); + m_aircraft->ThrottleCurve->initLinearCurve(5, 1.0, 0.0); // tell mixercurve this is a pitch curve - m_ccpm->PitchCurve->setMixerType(MixerCurve::MIXERCURVE_PITCH); - m_ccpm->PitchCurve->initLinearCurve(5, 1.0, -1.0); + m_aircraft->PitchCurve->setMixerType(MixerCurve::MIXERCURVE_PITCH); + m_aircraft->PitchCurve->initLinearCurve(5, 1.0, -1.0); //initialize channel names - m_ccpm->ccpmEngineChannel->addItems(channelNames); - m_ccpm->ccpmEngineChannel->setCurrentIndex(0); - m_ccpm->ccpmTailChannel->addItems(channelNames); - m_ccpm->ccpmTailChannel->setCurrentIndex(0); - m_ccpm->ccpmServoWChannel->addItems(channelNames); - m_ccpm->ccpmServoWChannel->setCurrentIndex(0); - m_ccpm->ccpmServoXChannel->addItems(channelNames); - m_ccpm->ccpmServoXChannel->setCurrentIndex(0); - m_ccpm->ccpmServoYChannel->addItems(channelNames); - m_ccpm->ccpmServoYChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->addItems(channelNames); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmEngineChannel->addItems(channelNames); + m_aircraft->ccpmEngineChannel->setCurrentIndex(0); + m_aircraft->ccpmTailChannel->addItems(channelNames); + m_aircraft->ccpmTailChannel->setCurrentIndex(0); + m_aircraft->ccpmServoWChannel->addItems(channelNames); + m_aircraft->ccpmServoWChannel->setCurrentIndex(0); + m_aircraft->ccpmServoXChannel->addItems(channelNames); + m_aircraft->ccpmServoXChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->addItems(channelNames); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->addItems(channelNames); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); QStringList Types; Types << QString::fromUtf8("CCPM 2 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 90º") << QString::fromUtf8("CCPM 4 Servo 90º") << @@ -159,49 +162,47 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent) QString::fromUtf8("FP 2 Servo 90º") << QString::fromUtf8("Coax 2 Servo 90º") << QString::fromUtf8("Custom - User Angles") << QString::fromUtf8("Custom - Advanced Settings"); - m_ccpm->ccpmType->addItems(Types); - m_ccpm->ccpmType->setCurrentIndex(m_ccpm->ccpmType->count() - 1); + m_aircraft->ccpmType->addItems(Types); + m_aircraft->ccpmType->setCurrentIndex(m_aircraft->ccpmType->count() - 1); refreshWidgetsValues(QString("HeliCP")); UpdateType(); - connect(m_ccpm->ccpmAngleW, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmAngleX, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmAngleY, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmAngleZ, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmCorrectionAngle, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmServoWChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmServoXChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmServoYChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmServoZChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); - connect(m_ccpm->ccpmEngineChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer())); - connect(m_ccpm->ccpmTailChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer())); - connect(m_ccpm->ccpmRevoSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); - connect(m_ccpm->ccpmREVOspinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); - connect(m_ccpm->ccpmCollectiveSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); - connect(m_ccpm->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); - connect(m_ccpm->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); - connect(m_ccpm->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); - connect(m_ccpm->TabObject, SIGNAL(currentChanged ( QWidget * )), this, SLOT(UpdateType())); - - connect(m_ccpm->SwashLvlStartButton, SIGNAL(clicked()), this, SLOT(SwashLvlStartButtonPressed())); - connect(m_ccpm->SwashLvlNextButton, SIGNAL(clicked()), this, SLOT(SwashLvlNextButtonPressed())); - connect(m_ccpm->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed())); - connect(m_ccpm->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed())); - - connect(m_ccpm->ccpmCollectivePassthrough, SIGNAL(clicked()),this, SLOT(SetUIComponentVisibilities())); - connect(m_ccpm->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); - connect(m_ccpm->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); + connect(m_aircraft->ccpmAngleW, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmAngleX, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmAngleY, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmAngleZ, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmCorrectionAngle, SIGNAL(valueChanged(double)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmServoWChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmServoXChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmServoYChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmServoZChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(ccpmSwashplateUpdate())); + connect(m_aircraft->ccpmEngineChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer())); + connect(m_aircraft->ccpmTailChannel, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateMixer())); + connect(m_aircraft->ccpmRevoSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); + connect(m_aircraft->ccpmREVOspinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); + connect(m_aircraft->ccpmCollectiveSlider, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); + connect(m_aircraft->ccpmCollectivespinBox, SIGNAL(valueChanged(int)), this, SLOT(UpdateMixer())); + connect(m_aircraft->ccpmType, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); + connect(m_aircraft->ccpmSingleServo, SIGNAL(currentIndexChanged(int)), this, SLOT(UpdateType())); + connect(m_aircraft->TabObject, SIGNAL(currentChanged ( QWidget * )), this, SLOT(UpdateType())); + connect(m_aircraft->SwashLvlStartButton, SIGNAL(clicked()), this, SLOT(SwashLvlStartButtonPressed())); + connect(m_aircraft->SwashLvlNextButton, SIGNAL(clicked()), this, SLOT(SwashLvlNextButtonPressed())); + connect(m_aircraft->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed())); + connect(m_aircraft->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed())); + connect(m_aircraft->ccpmCollectivePassthrough, SIGNAL(clicked()),this, SLOT(SetUIComponentVisibilities())); + connect(m_aircraft->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); + connect(m_aircraft->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); - ccpmSwashplateRedraw(); + ccpmSwashplateRedraw(); } ConfigCcpmWidget::~ConfigCcpmWidget() { - // Do nothing + delete m_aircraft; } void ConfigCcpmWidget::setupUI(QString frameType) @@ -291,139 +292,139 @@ void ConfigCcpmWidget::UpdateType() SetUIComponentVisibilities(); - TypeInt = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; - TypeText = m_ccpm->ccpmType->currentText(); - SingleServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); + TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1; + TypeText = m_aircraft->ccpmType->currentText(); + SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); //set visibility of user settings - m_ccpm->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0); - m_ccpm->ccpmAdvancedSettingsTable->clearFocus();; + m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0); + m_aircraft->ccpmAdvancedSettingsTable->clearFocus();; - m_ccpm->ccpmAngleW->setEnabled(TypeInt==1); - m_ccpm->ccpmAngleX->setEnabled(TypeInt==1); - m_ccpm->ccpmAngleY->setEnabled(TypeInt==1); - m_ccpm->ccpmAngleZ->setEnabled(TypeInt==1); - m_ccpm->ccpmCorrectionAngle->setEnabled(TypeInt!=0); + m_aircraft->ccpmAngleW->setEnabled(TypeInt==1); + m_aircraft->ccpmAngleX->setEnabled(TypeInt==1); + m_aircraft->ccpmAngleY->setEnabled(TypeInt==1); + m_aircraft->ccpmAngleZ->setEnabled(TypeInt==1); + m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt!=0); - m_ccpm->ccpmServoWChannel->setEnabled(TypeInt>0); - m_ccpm->ccpmServoXChannel->setEnabled(TypeInt>0); - m_ccpm->ccpmServoYChannel->setEnabled(TypeInt>0); - m_ccpm->ccpmServoZChannel->setEnabled(TypeInt>0); - m_ccpm->ccpmSingleServo->setEnabled(TypeInt>1); + m_aircraft->ccpmServoWChannel->setEnabled(TypeInt>0); + m_aircraft->ccpmServoXChannel->setEnabled(TypeInt>0); + m_aircraft->ccpmServoYChannel->setEnabled(TypeInt>0); + m_aircraft->ccpmServoZChannel->setEnabled(TypeInt>0); + m_aircraft->ccpmSingleServo->setEnabled(TypeInt>1); - m_ccpm->ccpmEngineChannel->setEnabled(TypeInt>0); - m_ccpm->ccpmTailChannel->setEnabled(TypeInt>0); - m_ccpm->ccpmCollectiveSlider->setEnabled(TypeInt>0); - m_ccpm->ccpmCollectivespinBox->setEnabled(TypeInt>0); - m_ccpm->ccpmRevoSlider->setEnabled(TypeInt>0); - m_ccpm->ccpmREVOspinBox->setEnabled(TypeInt>0); + m_aircraft->ccpmEngineChannel->setEnabled(TypeInt>0); + m_aircraft->ccpmTailChannel->setEnabled(TypeInt>0); + m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt>0); + m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt>0); + m_aircraft->ccpmRevoSlider->setEnabled(TypeInt>0); + m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt>0); AdjustmentAngle=SingleServoIndex*90; - m_ccpm->PitchCurve->setVisible(1); + m_aircraft->PitchCurve->setVisible(1); NumServosDefined=4; //set values for pre defined heli types if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_ccpm->ccpmAngleY->setValue(0); - m_ccpm->ccpmAngleZ->setValue(0); - m_ccpm->ccpmAngleY->setEnabled(0); - m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoYChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); - m_ccpm->ccpmServoYChannel->setEnabled(0); - m_ccpm->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); NumServosDefined=2; } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); - m_ccpm->ccpmAngleZ->setValue(0); - m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); NumServosDefined=3; } else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); - m_ccpm->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360)); - m_ccpm->ccpmSingleServo->setEnabled(0); - m_ccpm->ccpmSingleServo->setCurrentIndex(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); + m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360)); + m_aircraft->ccpmSingleServo->setEnabled(0); + m_aircraft->ccpmSingleServo->setCurrentIndex(0); NumServosDefined=4; } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360)); - m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360)); - m_ccpm->ccpmAngleZ->setValue(0); - m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); NumServosDefined=3; } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360)); - m_ccpm->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360)); - m_ccpm->ccpmAngleZ->setValue(0); - m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); NumServosDefined=3; } else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_ccpm->ccpmAngleY->setValue(0); - m_ccpm->ccpmAngleZ->setValue(0); - m_ccpm->ccpmAngleY->setEnabled(0); - m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoYChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); - m_ccpm->ccpmServoYChannel->setEnabled(0); - m_ccpm->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); - m_ccpm->ccpmCollectivespinBox->setEnabled(0); - m_ccpm->ccpmCollectiveSlider->setEnabled(0); - m_ccpm->ccpmCollectivespinBox->setValue(0); - m_ccpm->ccpmCollectiveSlider->setValue(0); - m_ccpm->PitchCurve->setVisible(0); + m_aircraft->ccpmCollectivespinBox->setEnabled(0); + m_aircraft->ccpmCollectiveSlider->setEnabled(0); + m_aircraft->ccpmCollectivespinBox->setValue(0); + m_aircraft->ccpmCollectiveSlider->setValue(0); + m_aircraft->PitchCurve->setVisible(0); NumServosDefined=2; } else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_ccpm->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_ccpm->ccpmAngleY->setValue(0); - m_ccpm->ccpmAngleZ->setValue(0); - m_ccpm->ccpmAngleY->setEnabled(0); - m_ccpm->ccpmAngleZ->setEnabled(0); - m_ccpm->ccpmServoYChannel->setCurrentIndex(0); - m_ccpm->ccpmServoZChannel->setCurrentIndex(0); - m_ccpm->ccpmServoYChannel->setEnabled(0); - m_ccpm->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); - m_ccpm->ccpmCollectivespinBox->setEnabled(0); - m_ccpm->ccpmCollectiveSlider->setEnabled(0); - m_ccpm->ccpmCollectivespinBox->setValue(0); - m_ccpm->ccpmCollectiveSlider->setValue(0); - m_ccpm->PitchCurve->setVisible(0); + m_aircraft->ccpmCollectivespinBox->setEnabled(0); + m_aircraft->ccpmCollectiveSlider->setEnabled(0); + m_aircraft->ccpmCollectivespinBox->setValue(0); + m_aircraft->ccpmCollectiveSlider->setValue(0); + m_aircraft->PitchCurve->setVisible(0); NumServosDefined=2; } @@ -431,39 +432,39 @@ void ConfigCcpmWidget::UpdateType() //Set the text of the motor boxes if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmEngineLabel->setText("CW motor"); - m_ccpm->ccpmTailLabel->setText("CCW motor"); + m_aircraft->ccpmEngineLabel->setText("CW motor"); + m_aircraft->ccpmTailLabel->setText("CCW motor"); } else{ - m_ccpm->ccpmEngineLabel->setText("Engine"); - m_ccpm->ccpmTailLabel->setText("Tail rotor"); + m_aircraft->ccpmEngineLabel->setText("Engine"); + m_aircraft->ccpmTailLabel->setText("Tail rotor"); } //set the visibility of the swashplate servo selection boxes - m_ccpm->ccpmServoWLabel->setVisible(NumServosDefined>=1); - m_ccpm->ccpmServoXLabel->setVisible(NumServosDefined>=2); - m_ccpm->ccpmServoYLabel->setVisible(NumServosDefined>=3); - m_ccpm->ccpmServoZLabel->setVisible(NumServosDefined>=4); - m_ccpm->ccpmServoWChannel->setVisible(NumServosDefined>=1); - m_ccpm->ccpmServoXChannel->setVisible(NumServosDefined>=2); - m_ccpm->ccpmServoYChannel->setVisible(NumServosDefined>=3); - m_ccpm->ccpmServoZChannel->setVisible(NumServosDefined>=4); + m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined>=1); + m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined>=2); + m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined>=3); + m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined>=4); + m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined>=1); + m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined>=2); + m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined>=3); + m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined>=4); //set the visibility of the swashplate angle selection boxes - m_ccpm->ccpmServoWLabel_2->setVisible(NumServosDefined>=1); - m_ccpm->ccpmServoXLabel_2->setVisible(NumServosDefined>=2); - m_ccpm->ccpmServoYLabel_2->setVisible(NumServosDefined>=3); - m_ccpm->ccpmServoZLabel_2->setVisible(NumServosDefined>=4); - m_ccpm->ccpmAngleW->setVisible(NumServosDefined>=1); - m_ccpm->ccpmAngleX->setVisible(NumServosDefined>=2); - m_ccpm->ccpmAngleY->setVisible(NumServosDefined>=3); - m_ccpm->ccpmAngleZ->setVisible(NumServosDefined>=4); + m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined>=1); + m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined>=2); + m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined>=3); + m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined>=4); + m_aircraft->ccpmAngleW->setVisible(NumServosDefined>=1); + m_aircraft->ccpmAngleX->setVisible(NumServosDefined>=2); + m_aircraft->ccpmAngleY->setVisible(NumServosDefined>=3); + m_aircraft->ccpmAngleZ->setVisible(NumServosDefined>=4); - m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents(); + m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents(); for (int i=0;i<6;i++) { - m_ccpm->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_ccpm->ccpmAdvancedSettingsTable->width()- - m_ccpm->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); + m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()- + m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); } //update UI @@ -482,25 +483,25 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw() double scale,xscale,yscale; - size = m_ccpm->SwashplateImage->rect(); + size = m_aircraft->SwashplateImage->rect(); xscale=size.width(); yscale=size.height(); scale=xscale; if (yscaleSwashplateImage->resetTransform (); - m_ccpm->SwashplateImage->scale(scale,scale); + m_aircraft->SwashplateImage->resetTransform (); + m_aircraft->SwashplateImage->scale(scale,scale); - size = m_ccpm->SwashLvlSwashplateImage->rect(); + size = m_aircraft->SwashLvlSwashplateImage->rect(); xscale=size.width(); yscale=size.height(); scale=xscale; if (yscaleSwashLvlSwashplateImage->resetTransform (); - m_ccpm->SwashLvlSwashplateImage->scale(scale,scale); + m_aircraft->SwashLvlSwashplateImage->resetTransform (); + m_aircraft->SwashLvlSwashplateImage->scale(scale,scale); - CorrectionAngle=m_ccpm->ccpmCorrectionAngle->value(); + CorrectionAngle=m_aircraft->ccpmCorrectionAngle->value(); CenterX=200; CenterY=200; @@ -509,18 +510,18 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw() SwashplateImg->setPos(CenterX-bounds.width()/2,CenterY-bounds.height()/2); - defined[0]=(m_ccpm->ccpmServoWChannel->isEnabled()); - defined[1]=(m_ccpm->ccpmServoXChannel->isEnabled()); - defined[2]=(m_ccpm->ccpmServoYChannel->isEnabled()); - defined[3]=(m_ccpm->ccpmServoZChannel->isEnabled()); - used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled())); - used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled())); - used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled())); - used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled())); - angle[0]=(CorrectionAngle+180+m_ccpm->ccpmAngleW->value())*Pi/180.00; - angle[1]=(CorrectionAngle+180+m_ccpm->ccpmAngleX->value())*Pi/180.00; - angle[2]=(CorrectionAngle+180+m_ccpm->ccpmAngleY->value())*Pi/180.00; - angle[3]=(CorrectionAngle+180+m_ccpm->ccpmAngleZ->value())*Pi/180.00; + defined[0]=(m_aircraft->ccpmServoWChannel->isEnabled()); + defined[1]=(m_aircraft->ccpmServoXChannel->isEnabled()); + defined[2]=(m_aircraft->ccpmServoYChannel->isEnabled()); + defined[3]=(m_aircraft->ccpmServoZChannel->isEnabled()); + used[0]=((m_aircraft->ccpmServoWChannel->currentIndex()>0)&&(m_aircraft->ccpmServoWChannel->isEnabled())); + used[1]=((m_aircraft->ccpmServoXChannel->currentIndex()>0)&&(m_aircraft->ccpmServoXChannel->isEnabled())); + used[2]=((m_aircraft->ccpmServoYChannel->currentIndex()>0)&&(m_aircraft->ccpmServoYChannel->isEnabled())); + used[3]=((m_aircraft->ccpmServoZChannel->currentIndex()>0)&&(m_aircraft->ccpmServoZChannel->isEnabled())); + angle[0]=(CorrectionAngle+180+m_aircraft->ccpmAngleW->value())*Pi/180.00; + angle[1]=(CorrectionAngle+180+m_aircraft->ccpmAngleX->value())*Pi/180.00; + angle[2]=(CorrectionAngle+180+m_aircraft->ccpmAngleY->value())*Pi/180.00; + angle[3]=(CorrectionAngle+180+m_aircraft->ccpmAngleZ->value())*Pi/180.00; for (i=0;imove(m_ccpm->SwashLvlSwashplateImage->mapFromScene (x, y)); + SwashLvlSpinBoxes[i]->move(m_aircraft->SwashLvlSwashplateImage->mapFromScene (x, y)); SwashLvlSpinBoxes[i]->setVisible(used[i]!=0); radius=220; @@ -569,9 +570,9 @@ void ConfigCcpmWidget::ccpmSwashplateRedraw() ServoLines[i]->setVisible(defined[i]!=0); } - //m_ccpm->SwashplateImage->centerOn (CenterX, CenterY); + //m_aircraft->SwashplateImage->centerOn (CenterX, CenterY); - //m_ccpm->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio); + //m_aircraft->SwashplateImage->fitInView(SwashplateImg, Qt::KeepAspectRatio); } void ConfigCcpmWidget::ccpmSwashplateUpdate() @@ -620,24 +621,24 @@ void ConfigCcpmWidget::UpdateMixer() if (config.heli.SwashplateType>0) {//not advanced settings //get the channel data from the ui - MixerChannelData[0] = m_ccpm->ccpmEngineChannel->currentIndex(); - MixerChannelData[1] = m_ccpm->ccpmTailChannel->currentIndex(); - MixerChannelData[2] = m_ccpm->ccpmServoWChannel->currentIndex(); - MixerChannelData[3] = m_ccpm->ccpmServoXChannel->currentIndex(); - MixerChannelData[4] = m_ccpm->ccpmServoYChannel->currentIndex(); - MixerChannelData[5] = m_ccpm->ccpmServoZChannel->currentIndex(); + MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex(); + MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex(); + MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex(); + MixerChannelData[3] = m_aircraft->ccpmServoXChannel->currentIndex(); + MixerChannelData[4] = m_aircraft->ccpmServoYChannel->currentIndex(); + MixerChannelData[5] = m_aircraft->ccpmServoZChannel->currentIndex(); //get the angle data from the ui - ThisAngle[2] = m_ccpm->ccpmAngleW->value(); - ThisAngle[3] = m_ccpm->ccpmAngleX->value(); - ThisAngle[4] = m_ccpm->ccpmAngleY->value(); - ThisAngle[5] = m_ccpm->ccpmAngleZ->value(); + ThisAngle[2] = m_aircraft->ccpmAngleW->value(); + ThisAngle[3] = m_aircraft->ccpmAngleX->value(); + ThisAngle[4] = m_aircraft->ccpmAngleY->value(); + ThisAngle[5] = m_aircraft->ccpmAngleZ->value(); //get the angle data from the ui - ThisEnable[2] = m_ccpm->ccpmServoWChannel->isEnabled(); - ThisEnable[3] = m_ccpm->ccpmServoXChannel->isEnabled(); - ThisEnable[4] = m_ccpm->ccpmServoYChannel->isEnabled(); - ThisEnable[5] = m_ccpm->ccpmServoZChannel->isEnabled(); + ThisEnable[2] = m_aircraft->ccpmServoWChannel->isEnabled(); + ThisEnable[3] = m_aircraft->ccpmServoXChannel->isEnabled(); + ThisEnable[4] = m_aircraft->ccpmServoYChannel->isEnabled(); + ThisEnable[5] = m_aircraft->ccpmServoZChannel->isEnabled(); ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] )); ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] )); @@ -650,52 +651,52 @@ void ConfigCcpmWidget::UpdateMixer() { if ((MixerChannelData[i]>0) && ((ThisEnable[i])||(i<2))) { - m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] )); + m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] )); //Generate the mixer vector if (i==0) {//main motor-engine - m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 - m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 - m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll - m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch + m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 + m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 + m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll + m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw + m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw else - m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw + m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw } if (i==1) {//tailrotor --or-- counter-clockwise motor if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) { - m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 - m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw + m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 + m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw } else{ - m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 - m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw + m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 + m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw } - m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 - m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll - m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch + m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 + m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll + m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch } if (i>1) {//Swashplate - m_ccpm->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 - m_ccpm->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2 - m_ccpm->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll - m_ccpm->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch - m_ccpm->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw + m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 + m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2 + m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll + m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch + m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw } } else { - for (j=0;j<6;j++) m_ccpm->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-")); + for (j=0;j<6;j++) m_aircraft->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-")); } } @@ -704,7 +705,7 @@ void ConfigCcpmWidget::UpdateMixer() {//advanced settings for (i=0;i<6;i++) { - Channel =m_ccpm->ccpmAdvancedSettingsTable->item(i,0)->text(); + Channel =m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->text(); if (Channel == "-") Channel = QString("9"); MixerChannelData[i]= Channel.toInt(); } @@ -726,48 +727,48 @@ QString ConfigCcpmWidget::updateConfigObjects() GUIConfigDataUnion config = GetConfigData(); //swashplate config - config.heli.SwashplateType = m_ccpm->ccpmType->count() - m_ccpm->ccpmType->currentIndex()-1; - config.heli.FirstServoIndex = m_ccpm->ccpmSingleServo->currentIndex(); + config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1; + config.heli.FirstServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); //ccpm mixing options - config.heli.ccpmCollectivePassthroughState = m_ccpm->ccpmCollectivePassthrough->isChecked(); - config.heli.ccpmLinkCyclicState = m_ccpm->ccpmLinkCyclic->isChecked(); - config.heli.ccpmLinkRollState = m_ccpm->ccpmLinkRoll->isChecked(); + config.heli.ccpmCollectivePassthroughState = m_aircraft->ccpmCollectivePassthrough->isChecked(); + config.heli.ccpmLinkCyclicState = m_aircraft->ccpmLinkCyclic->isChecked(); + config.heli.ccpmLinkRollState = m_aircraft->ccpmLinkRoll->isChecked(); useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); useCyclic = config.heli.ccpmLinkRollState; //correction angle - config.heli.CorrectionAngle = m_ccpm->ccpmCorrectionAngle->value(); + config.heli.CorrectionAngle = m_aircraft->ccpmCorrectionAngle->value(); //update sliders if (useCCPM) { - config.heli.SliderValue0 = m_ccpm->ccpmCollectiveSlider->value(); + config.heli.SliderValue0 = m_aircraft->ccpmCollectiveSlider->value(); } else { - config.heli.SliderValue0 = m_ccpm->ccpmCollectiveScale->value(); + config.heli.SliderValue0 = m_aircraft->ccpmCollectiveScale->value(); } if (useCyclic) { - config.heli.SliderValue1 = m_ccpm->ccpmCyclicScale->value(); + config.heli.SliderValue1 = m_aircraft->ccpmCyclicScale->value(); } else { - config.heli.SliderValue1 = m_ccpm->ccpmPitchScale->value(); + config.heli.SliderValue1 = m_aircraft->ccpmPitchScale->value(); } - config.heli.SliderValue2 = m_ccpm->ccpmRollScale->value(); + config.heli.SliderValue2 = m_aircraft->ccpmRollScale->value(); //servo assignments - config.heli.ServoIndexW = m_ccpm->ccpmServoWChannel->currentIndex(); - config.heli.ServoIndexX = m_ccpm->ccpmServoXChannel->currentIndex(); - config.heli.ServoIndexY = m_ccpm->ccpmServoYChannel->currentIndex(); - config.heli.ServoIndexZ = m_ccpm->ccpmServoZChannel->currentIndex(); + config.heli.ServoIndexW = m_aircraft->ccpmServoWChannel->currentIndex(); + config.heli.ServoIndexX = m_aircraft->ccpmServoXChannel->currentIndex(); + config.heli.ServoIndexY = m_aircraft->ccpmServoYChannel->currentIndex(); + config.heli.ServoIndexZ = m_aircraft->ccpmServoZChannel->currentIndex(); //throttle - config.heli.Throttle = m_ccpm->ccpmEngineChannel->currentIndex(); + config.heli.Throttle = m_aircraft->ccpmEngineChannel->currentIndex(); //tail - config.heli.Tail = m_ccpm->ccpmTailChannel->currentIndex(); + config.heli.Tail = m_aircraft->ccpmTailChannel->currentIndex(); SetConfigData(config); @@ -791,39 +792,39 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro GUIConfigDataUnion config = GetConfigData(); //swashplate config - setComboCurrentIndex( m_ccpm->ccpmType, m_ccpm->ccpmType->count() - (config.heli.SwashplateType +1)); - setComboCurrentIndex(m_ccpm->ccpmSingleServo, config.heli.FirstServoIndex); + setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); + setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex); //ccpm mixing options - m_ccpm->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState); - m_ccpm->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState); - m_ccpm->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState); + m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState); + m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState); + m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState); //correction angle - m_ccpm->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle); + m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle); //update sliders - m_ccpm->ccpmCollectiveScale->setValue(config.heli.SliderValue0); - m_ccpm->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0); - m_ccpm->ccpmCyclicScale->setValue(config.heli.SliderValue1); - m_ccpm->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1); - m_ccpm->ccpmPitchScale->setValue(config.heli.SliderValue1); - m_ccpm->ccpmPitchScaleBox->setValue(config.heli.SliderValue1); - m_ccpm->ccpmRollScale->setValue(config.heli.SliderValue2); - m_ccpm->ccpmRollScaleBox->setValue(config.heli.SliderValue2); - m_ccpm->ccpmCollectiveSlider->setValue(config.heli.SliderValue0); - m_ccpm->ccpmCollectivespinBox->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCollectiveScale->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCyclicScale->setValue(config.heli.SliderValue1); + m_aircraft->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1); + m_aircraft->ccpmPitchScale->setValue(config.heli.SliderValue1); + m_aircraft->ccpmPitchScaleBox->setValue(config.heli.SliderValue1); + m_aircraft->ccpmRollScale->setValue(config.heli.SliderValue2); + m_aircraft->ccpmRollScaleBox->setValue(config.heli.SliderValue2); + m_aircraft->ccpmCollectiveSlider->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCollectivespinBox->setValue(config.heli.SliderValue0); //servo assignments - setComboCurrentIndex(m_ccpm->ccpmServoWChannel, config.heli.ServoIndexW); - setComboCurrentIndex( m_ccpm->ccpmServoXChannel,config.heli.ServoIndexX); - setComboCurrentIndex( m_ccpm->ccpmServoYChannel,config.heli.ServoIndexY); - setComboCurrentIndex( m_ccpm->ccpmServoZChannel,config.heli.ServoIndexZ); + setComboCurrentIndex(m_aircraft->ccpmServoWChannel, config.heli.ServoIndexW); + setComboCurrentIndex( m_aircraft->ccpmServoXChannel,config.heli.ServoIndexX); + setComboCurrentIndex( m_aircraft->ccpmServoYChannel,config.heli.ServoIndexY); + setComboCurrentIndex( m_aircraft->ccpmServoZChannel,config.heli.ServoIndexZ); //throttle - setComboCurrentIndex( m_ccpm->ccpmEngineChannel, config.heli.Throttle); + setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle); //tail - setComboCurrentIndex( m_ccpm->ccpmTailChannel, config.heli.Tail); + setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail); getMixer(); } @@ -831,30 +832,30 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro void ConfigCcpmWidget::SetUIComponentVisibilities() { - m_ccpm->ccpmRevoMixingBox->setVisible(0); + m_aircraft->ccpmRevoMixingBox->setVisible(0); - m_ccpm->ccpmPitchMixingBox->setVisible(!m_ccpm->ccpmCollectivePassthrough->isChecked() && - m_ccpm->ccpmLinkCyclic->isChecked()); + m_aircraft->ccpmPitchMixingBox->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked() && + m_aircraft->ccpmLinkCyclic->isChecked()); - m_ccpm->ccpmCollectiveScalingBox->setVisible(m_ccpm->ccpmCollectivePassthrough->isChecked() || !m_ccpm->ccpmLinkCyclic->isChecked()); + m_aircraft->ccpmCollectiveScalingBox->setVisible(m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()); - m_ccpm->ccpmLinkCyclic->setVisible(!m_ccpm->ccpmCollectivePassthrough->isChecked()); + m_aircraft->ccpmLinkCyclic->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked()); - m_ccpm->ccpmCyclicScalingBox->setVisible((m_ccpm->ccpmCollectivePassthrough->isChecked() || !m_ccpm->ccpmLinkCyclic->isChecked()) && - m_ccpm->ccpmLinkRoll->isChecked()); + m_aircraft->ccpmCyclicScalingBox->setVisible((m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) && + m_aircraft->ccpmLinkRoll->isChecked()); - if (!m_ccpm->ccpmCollectivePassthrough->checkState() && m_ccpm->ccpmLinkCyclic->isChecked()) + if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked()) { - m_ccpm->ccpmPitchScalingBox->setVisible(0); - m_ccpm->ccpmRollScalingBox->setVisible(0); - m_ccpm->ccpmLinkRoll->setVisible(0); + m_aircraft->ccpmPitchScalingBox->setVisible(0); + m_aircraft->ccpmRollScalingBox->setVisible(0); + m_aircraft->ccpmLinkRoll->setVisible(0); } else { - m_ccpm->ccpmPitchScalingBox->setVisible(!m_ccpm->ccpmLinkRoll->isChecked()); - m_ccpm->ccpmRollScalingBox->setVisible(!m_ccpm->ccpmLinkRoll->isChecked()); - m_ccpm->ccpmLinkRoll->setVisible(1); + m_aircraft->ccpmPitchScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked()); + m_aircraft->ccpmRollScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked()); + m_aircraft->ccpmLinkRoll->setVisible(1); } } /** @@ -877,20 +878,20 @@ void ConfigCcpmWidget::getMixer() // is at least one of the curve values != 0? if (vconfig->isValidThrottleCurve(&curveValues)) { - m_ccpm->ThrottleCurve->setCurve(&curveValues); + m_aircraft->ThrottleCurve->setCurve(&curveValues); } else { - m_ccpm->ThrottleCurve->ResetCurve(); + m_aircraft->ThrottleCurve->ResetCurve(); } vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); // is at least one of the curve values != 0? if (vconfig->isValidThrottleCurve(&curveValues)) { - m_ccpm->PitchCurve->setCurve(&curveValues); + m_aircraft->PitchCurve->setCurve(&curveValues); } else { - m_ccpm->PitchCurve->ResetCurve(); + m_aircraft->PitchCurve->ResetCurve(); } updatingFromHardware=FALSE; @@ -963,13 +964,13 @@ void ConfigCcpmWidget::setMixer() //Configure the vector for (j=0;j<5;j++) - mixers[MixerChannelData[i] - 1][j] = m_ccpm->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(); + mixers[MixerChannelData[i] - 1][j] = m_aircraft->ccpmAdvancedSettingsTable->item(i,j+1)->text().toInt(); } } //get the user data for the curve into the mixer settings - QList curve1 = m_ccpm->ThrottleCurve->getCurve(); - QList curve2 = m_ccpm->PitchCurve->getCurve(); + QList curve1 = m_aircraft->ThrottleCurve->getCurve(); + QList curve2 = m_aircraft->PitchCurve->getCurve(); for (i=0;i<5;i++) { mixerSettingsData.ThrottleCurve1[i] = curve1.at(i); mixerSettingsData.ThrottleCurve2[i] = curve2.at(i); @@ -978,7 +979,7 @@ void ConfigCcpmWidget::setMixer() //mapping of collective input to curve 2... //MixerSettings.Curve2Source = Throttle,Roll,Pitch,Yaw,Accessory0,Accessory1,Accessory2,Accessory3,Accessory4,Accessory5 //check if we are using throttle or directly from a channel... - if (m_ccpm->ccpmCollectivePassthrough->isChecked()) + if (m_aircraft->ccpmCollectivePassthrough->isChecked()) mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_COLLECTIVE; else mixerSettingsData.Curve2Source = MixerSettings::CURVE2SOURCE_THROTTLE; @@ -1008,10 +1009,10 @@ void ConfigCcpmWidget::resizeEvent(QResizeEvent* event) { Q_UNUSED(event); // Make the custom table columns autostretch: - m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents(); + m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents(); for (int i=0;i<6;i++) { - m_ccpm->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_ccpm->ccpmAdvancedSettingsTable->width()- - m_ccpm->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); + m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()- + m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); } ccpmSwashplateRedraw(); @@ -1019,10 +1020,10 @@ void ConfigCcpmWidget::resizeEvent(QResizeEvent* event) void ConfigCcpmWidget::showEvent(QShowEvent *event) { Q_UNUSED(event) - m_ccpm->ccpmAdvancedSettingsTable->resizeColumnsToContents(); + m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents(); for (int i=0;i<6;i++) { - m_ccpm->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_ccpm->ccpmAdvancedSettingsTable->width()- - m_ccpm->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); + m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()- + m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); } ccpmSwashplateRedraw(); } @@ -1053,15 +1054,15 @@ void ConfigCcpmWidget::SwashLvlStartButtonPressed() //remove Flight control of ActuatorCommand enableSwashplateLevellingControl(true); - m_ccpm->SwashLvlStartButton->setEnabled(false); - m_ccpm->SwashLvlNextButton->setEnabled(true); - m_ccpm->SwashLvlCancelButton->setEnabled(true); - m_ccpm->SwashLvlFinishButton->setEnabled(false); + m_aircraft->SwashLvlStartButton->setEnabled(false); + m_aircraft->SwashLvlNextButton->setEnabled(true); + m_aircraft->SwashLvlCancelButton->setEnabled(true); + m_aircraft->SwashLvlFinishButton->setEnabled(false); //clear status check boxes - m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked); - m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked); - m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked); - m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked); //download the current settings to the OP hw @@ -1086,15 +1087,15 @@ void ConfigCcpmWidget::SwashLvlStartButtonPressed() MaxField = obj->getField(QString("ChannelMax")); //channel assignments - oldSwashLvlConfiguration.ServoChannels[0]=m_ccpm->ccpmServoWChannel->currentIndex(); - oldSwashLvlConfiguration.ServoChannels[1]=m_ccpm->ccpmServoXChannel->currentIndex(); - oldSwashLvlConfiguration.ServoChannels[2]=m_ccpm->ccpmServoYChannel->currentIndex(); - oldSwashLvlConfiguration.ServoChannels[3]=m_ccpm->ccpmServoZChannel->currentIndex(); + oldSwashLvlConfiguration.ServoChannels[0]=m_aircraft->ccpmServoWChannel->currentIndex(); + oldSwashLvlConfiguration.ServoChannels[1]=m_aircraft->ccpmServoXChannel->currentIndex(); + oldSwashLvlConfiguration.ServoChannels[2]=m_aircraft->ccpmServoYChannel->currentIndex(); + oldSwashLvlConfiguration.ServoChannels[3]=m_aircraft->ccpmServoZChannel->currentIndex(); //if servos are used - oldSwashLvlConfiguration.Used[0]=((m_ccpm->ccpmServoWChannel->currentIndex()>0)&&(m_ccpm->ccpmServoWChannel->isEnabled())); - oldSwashLvlConfiguration.Used[1]=((m_ccpm->ccpmServoXChannel->currentIndex()>0)&&(m_ccpm->ccpmServoXChannel->isEnabled())); - oldSwashLvlConfiguration.Used[2]=((m_ccpm->ccpmServoYChannel->currentIndex()>0)&&(m_ccpm->ccpmServoYChannel->isEnabled())); - oldSwashLvlConfiguration.Used[3]=((m_ccpm->ccpmServoZChannel->currentIndex()>0)&&(m_ccpm->ccpmServoZChannel->isEnabled())); + oldSwashLvlConfiguration.Used[0]=((m_aircraft->ccpmServoWChannel->currentIndex()>0)&&(m_aircraft->ccpmServoWChannel->isEnabled())); + oldSwashLvlConfiguration.Used[1]=((m_aircraft->ccpmServoXChannel->currentIndex()>0)&&(m_aircraft->ccpmServoXChannel->isEnabled())); + oldSwashLvlConfiguration.Used[2]=((m_aircraft->ccpmServoYChannel->currentIndex()>0)&&(m_aircraft->ccpmServoYChannel->isEnabled())); + oldSwashLvlConfiguration.Used[3]=((m_aircraft->ccpmServoZChannel->currentIndex()>0)&&(m_aircraft->ccpmServoZChannel->isEnabled())); //min,neutral,max values for the servos for (i=0;iSwashLvlStartButton->setEnabled(true); - m_ccpm->SwashLvlNextButton->setEnabled(false); - m_ccpm->SwashLvlCancelButton->setEnabled(false); - m_ccpm->SwashLvlFinishButton->setEnabled(false); + m_aircraft->SwashLvlStartButton->setEnabled(true); + m_aircraft->SwashLvlNextButton->setEnabled(false); + m_aircraft->SwashLvlCancelButton->setEnabled(false); + m_aircraft->SwashLvlFinishButton->setEnabled(false); break; default: // should never be reached break; } - - } + void ConfigCcpmWidget::SwashLvlNextButtonPressed() { //ShowDisclaimer(2); SwashLvlState++; - int i; - - - - switch (SwashLvlState) - { + switch (SwashLvlState) { case 0: break; case 1: //Neutral levelling - m_ccpm->SwashLvlStepList->setCurrentRow(0); + m_aircraft->SwashLvlStepList->setCurrentRow(0); //set spin boxes and swashplate servos to Neutral values setSwashplateLevel(50); //disable position slider - m_ccpm->SwashLvlPositionSlider->setEnabled(false); - m_ccpm->SwashLvlPositionSpinBox->setEnabled(false); + m_aircraft->SwashLvlPositionSlider->setEnabled(false); + m_aircraft->SwashLvlPositionSpinBox->setEnabled(false); //set position slider to 50% - m_ccpm->SwashLvlPositionSlider->setValue(50); - m_ccpm->SwashLvlPositionSpinBox->setValue(50); + m_aircraft->SwashLvlPositionSlider->setValue(50); + m_aircraft->SwashLvlPositionSpinBox->setValue(50); //connect spinbox signals to slots and ebnable them - for (i=0;isetEnabled(true); } //issue user instructions - m_ccpm->SwashLvlStepInstruction->setHtml("

Neutral levelling

Using adjustment of:

  • servo horns
  • link lengths and
  • Neutral timing spinboxes to the right

ensure that the swashplate is in the center of desired travel range and is level."); + m_aircraft->SwashLvlStepInstruction->setHtml( + "

Neutral levelling

Using adjustment of:

  • servo horns
  • link lengths and
  • Neutral timing spinboxes to the right

ensure that the swashplate is in the center of desired travel range and is level."); break; case 2: //Max levelling //check Neutral status as complete - m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Checked); - m_ccpm->SwashLvlStepList->setCurrentRow(1); + m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Checked); + m_aircraft->SwashLvlStepList->setCurrentRow(1); //set spin boxes and swashplate servos to Max values setSwashplateLevel(100); //set position slider to 100% - m_ccpm->SwashLvlPositionSlider->setValue(100); - m_ccpm->SwashLvlPositionSpinBox->setValue(100); + m_aircraft->SwashLvlPositionSlider->setValue(100); + m_aircraft->SwashLvlPositionSpinBox->setValue(100); //issue user instructions - m_ccpm->SwashLvlStepInstruction->setText("

Max levelling

Using adjustment of:

  • Max timing spinboxes to the right ONLY

ensure that the swashplate is at the top of desired travel range and is level."); + m_aircraft->SwashLvlStepInstruction->setText( + "

Max levelling

Using adjustment of:

  • Max timing spinboxes to the right ONLY

ensure that the swashplate is at the top of desired travel range and is level."); break; case 3: //Min levelling //check Max status as complete - m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Checked); - m_ccpm->SwashLvlStepList->setCurrentRow(2); + m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Checked); + m_aircraft->SwashLvlStepList->setCurrentRow(2); //set spin boxes and swashplate servos to Min values setSwashplateLevel(0); //set position slider to 0% - m_ccpm->SwashLvlPositionSlider->setValue(0); - m_ccpm->SwashLvlPositionSpinBox->setValue(0); + m_aircraft->SwashLvlPositionSlider->setValue(0); + m_aircraft->SwashLvlPositionSpinBox->setValue(0); //issue user instructions - m_ccpm->SwashLvlStepInstruction->setText("

Min levelling

Using adjustment of:

  • Min timing spinboxes to the right ONLY

ensure that the swashplate is at the bottom of desired travel range and is level."); - break; + m_aircraft->SwashLvlStepInstruction->setText( + "

Min levelling

Using adjustment of:

  • Min timing spinboxes to the right ONLY

ensure that the swashplate is at the bottom of desired travel range and is level."); + break; case 4: //levelling verification //check Min status as complete - m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Checked); - m_ccpm->SwashLvlStepList->setCurrentRow(3); + m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Checked); + m_aircraft->SwashLvlStepList->setCurrentRow(3); //enable position slider - m_ccpm->SwashLvlPositionSlider->setEnabled(true); - m_ccpm->SwashLvlPositionSpinBox->setEnabled(true); + m_aircraft->SwashLvlPositionSlider->setEnabled(true); + m_aircraft->SwashLvlPositionSpinBox->setEnabled(true); //make heli respond to slider movement - connect(m_ccpm->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int))); + connect(m_aircraft->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int))); //disable spin boxes - for (i=0;isetEnabled(false); } //issue user instructions - m_ccpm->SwashLvlStepInstruction->setText("

levelling verification

Adjust the slider to the right over it's full range and observe the swashplate motion. It should remain level over the entire range of travel."); - break; + m_aircraft->SwashLvlStepInstruction->setText( + "

levelling verification

Adjust the slider to the right over it's full range and observe the swashplate motion. It should remain level over the entire range of travel."); + break; case 5: //levelling complete //check verify status as complete - m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Checked); + m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Checked); //issue user instructions - m_ccpm->SwashLvlStepInstruction->setText("

levelling complete

Press the Finish button to save these settings to the SD card

Press the cancel button to return to the pre-levelling settings"); + m_aircraft->SwashLvlStepInstruction->setText( + "

levelling complete

Press the Finish button to save these settings to the SD card

Press the cancel button to return to the pre-levelling settings"); //disable position slider - m_ccpm->SwashLvlPositionSlider->setEnabled(false); - m_ccpm->SwashLvlPositionSpinBox->setEnabled(false); + m_aircraft->SwashLvlPositionSlider->setEnabled(false); + m_aircraft->SwashLvlPositionSpinBox->setEnabled(false); //disconnect levelling slots from signals - disconnect(m_ccpm->SwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int))); - for (i=0;iSwashLvlPositionSlider, SIGNAL(valueChanged(int)), this, SLOT(setSwashplateLevel(int))); + for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { disconnect(SwashLvlSpinBoxes[i], SIGNAL(valueChanged(int)), this, SLOT(SwashLvlSpinBoxChanged(int))); } - m_ccpm->SwashLvlStartButton->setEnabled(false); - m_ccpm->SwashLvlNextButton->setEnabled(false); - m_ccpm->SwashLvlCancelButton->setEnabled(true); - m_ccpm->SwashLvlFinishButton->setEnabled(true); + m_aircraft->SwashLvlStartButton->setEnabled(false); + m_aircraft->SwashLvlNextButton->setEnabled(false); + m_aircraft->SwashLvlCancelButton->setEnabled(true); + m_aircraft->SwashLvlFinishButton->setEnabled(true); default: //restore collective/cyclic setting @@ -1230,24 +1227,24 @@ void ConfigCcpmWidget::SwashLvlNextButtonPressed() break; } } + void ConfigCcpmWidget::SwashLvlCancelButtonPressed() { - int i; - SwashLvlState=0; + SwashLvlState = 0; - UAVObjectField* MinField; - UAVObjectField* NeutralField; - UAVObjectField* MaxField; + UAVObjectField *MinField; + UAVObjectField *NeutralField; + UAVObjectField *MaxField; - m_ccpm->SwashLvlStartButton->setEnabled(true); - m_ccpm->SwashLvlNextButton->setEnabled(false); - m_ccpm->SwashLvlCancelButton->setEnabled(false); - m_ccpm->SwashLvlFinishButton->setEnabled(false); + m_aircraft->SwashLvlStartButton->setEnabled(true); + m_aircraft->SwashLvlNextButton->setEnabled(false); + m_aircraft->SwashLvlCancelButton->setEnabled(false); + m_aircraft->SwashLvlFinishButton->setEnabled(false); - m_ccpm->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked); - m_ccpm->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked); - m_ccpm->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked); - m_ccpm->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(0)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(1)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(2)->setCheckState(Qt::Unchecked); + m_aircraft->SwashLvlStepList->item(3)->setCheckState(Qt::Unchecked); //restore old Actuator Settings ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); @@ -1259,110 +1256,110 @@ void ConfigCcpmWidget::SwashLvlCancelButtonPressed() NeutralField = obj->getField(QString("ChannelNeutral")); MaxField = obj->getField(QString("ChannelMax")); - //min,neutral,max values for the servos - for (i=0;isetValue(oldSwashLvlConfiguration.Min[i],oldSwashLvlConfiguration.ServoChannels[i]); - NeutralField->setValue(oldSwashLvlConfiguration.Neutral[i],oldSwashLvlConfiguration.ServoChannels[i]); - MaxField->setValue(oldSwashLvlConfiguration.Max[i],oldSwashLvlConfiguration.ServoChannels[i]); + // min,neutral,max values for the servos + for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { + MinField->setValue(oldSwashLvlConfiguration.Min[i], oldSwashLvlConfiguration.ServoChannels[i]); + NeutralField->setValue(oldSwashLvlConfiguration.Neutral[i], oldSwashLvlConfiguration.ServoChannels[i]); + MaxField->setValue(oldSwashLvlConfiguration.Max[i], oldSwashLvlConfiguration.ServoChannels[i]); } obj->updated(); - - //restore Flight control of ActuatorCommand + // restore Flight control of ActuatorCommand enableSwashplateLevellingControl(false); - m_ccpm->SwashLvlStepInstruction->setText("

Levelling Cancelled

Previous settings have been restored."); - + m_aircraft->SwashLvlStepInstruction->setText( + "

Levelling Cancelled

Previous settings have been restored."); } void ConfigCcpmWidget::SwashLvlFinishButtonPressed() { - int i; + UAVObjectField *MinField; + UAVObjectField *NeutralField; + UAVObjectField *MaxField; - UAVObjectField* MinField; - UAVObjectField* NeutralField; - UAVObjectField* MaxField; + m_aircraft->SwashLvlStartButton->setEnabled(true); + m_aircraft->SwashLvlNextButton->setEnabled(false); + m_aircraft->SwashLvlCancelButton->setEnabled(false); + m_aircraft->SwashLvlFinishButton->setEnabled(false); - m_ccpm->SwashLvlStartButton->setEnabled(true); - m_ccpm->SwashLvlNextButton->setEnabled(false); - m_ccpm->SwashLvlCancelButton->setEnabled(false); - m_ccpm->SwashLvlFinishButton->setEnabled(false); - - //save new Actuator Settings to memory and SD card + // save new Actuator Settings to memory and SD card ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager *objManager = pm->getObject(); UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ActuatorSettings"))); Q_ASSERT(obj); - //update settings to match our changes. + + // update settings to match our changes. MinField = obj->getField(QString("ChannelMin")); NeutralField = obj->getField(QString("ChannelNeutral")); MaxField = obj->getField(QString("ChannelMax")); - //min,neutral,max values for the servos - for (i=0;isetValue(newSwashLvlConfiguration.Min[i],newSwashLvlConfiguration.ServoChannels[i]); - NeutralField->setValue(newSwashLvlConfiguration.Neutral[i],newSwashLvlConfiguration.ServoChannels[i]); - MaxField->setValue(newSwashLvlConfiguration.Max[i],newSwashLvlConfiguration.ServoChannels[i]); + // min,neutral,max values for the servos + for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { + MinField->setValue(newSwashLvlConfiguration.Min[i], newSwashLvlConfiguration.ServoChannels[i]); + NeutralField->setValue(newSwashLvlConfiguration.Neutral[i], newSwashLvlConfiguration.ServoChannels[i]); + MaxField->setValue(newSwashLvlConfiguration.Max[i], newSwashLvlConfiguration.ServoChannels[i]); } obj->updated(); saveObjectToSD(obj); - //restore Flight control of ActuatorCommand + // restore Flight control of ActuatorCommand enableSwashplateLevellingControl(false); - m_ccpm->SwashLvlStepInstruction->setText("

Levelling Completed

New settings have been saved to the SD card"); + m_aircraft->SwashLvlStepInstruction->setText( + "

Levelling Completed

New settings have been saved to the SD card"); ShowDisclaimer(0); //ShowDisclaimer(2); - } int ConfigCcpmWidget::ShowDisclaimer(int messageID) { - QMessageBox msgBox; - msgBox.setText("

Warning!!!

"); - int ret; - switch (messageID) { - case 0: - // Basic disclaimer - msgBox.setInformativeText("

This code has many configurations.

Please double check all settings before attempting flight!"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Information); - ret = msgBox.exec(); - return 0; - break; - case 1: - // Not Tested disclaimer - msgBox.setInformativeText("

The CCPM mixer code needs more testing!

Use it at your own risk!

Do you wish to continue?"); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); - msgBox.setDefaultButton(QMessageBox::Cancel); - msgBox.setIcon(QMessageBox::Warning); - ret = msgBox.exec(); - switch (ret) - { - case QMessageBox::Cancel: return -1; - case QMessageBox::Yes: return 0; - } - break; - case 2: - // DO NOT use - msgBox.setInformativeText("

The CCPM swashplate levelling code is NOT complete!

DO NOT use it for flight!"); - msgBox.setStandardButtons(QMessageBox::Ok); - msgBox.setDefaultButton(QMessageBox::Ok); - msgBox.setIcon(QMessageBox::Critical); - ret = msgBox.exec(); + QMessageBox msgBox; + msgBox.setText("

Warning!!!

"); + int ret; + switch (messageID) { + case 0: + // Basic disclaimer + msgBox.setInformativeText( + "

This code has many configurations.

Please double check all settings before attempting flight!"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Information); + ret = msgBox.exec(); + return 0; + break; + case 1: + // Not Tested disclaimer + msgBox.setInformativeText( + "

The CCPM mixer code needs more testing!

Use it at your own risk!

Do you wish to continue?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel); + msgBox.setDefaultButton(QMessageBox::Cancel); + msgBox.setIcon(QMessageBox::Warning); + ret = msgBox.exec(); + switch (ret) { + case QMessageBox::Cancel: + return -1; + case QMessageBox::Yes: return 0; - break; - default: - // should never be reached - break; } + break; + case 2: + // DO NOT use + msgBox.setInformativeText( + "

The CCPM swashplate levelling code is NOT complete!

DO NOT use it for flight!"); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.setDefaultButton(QMessageBox::Ok); + msgBox.setIcon(QMessageBox::Critical); + ret = msgBox.exec(); + return 0; + break; + default: + // should never be reached + break; + } return -1; } @@ -1378,33 +1375,30 @@ void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state) UAVDataObject* obj = dynamic_cast(objManager->getObject(QString("ActuatorCommand"))); UAVObject::Metadata mdata = obj->getMetadata(); - if (state) - { + if (state) { SwashLvlaccInitialData = mdata; UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY); UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE); UAVObject::SetGcsTelemetryAcked(mdata, false); UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_ONCHANGE); mdata.gcsTelemetryUpdatePeriod = 100; - SwashLvlConfigurationInProgress=1; - m_ccpm->TabObject->setTabEnabled(0,0); - m_ccpm->TabObject->setTabEnabled(2,0); - m_ccpm->TabObject->setTabEnabled(3,0); - m_ccpm->ccpmType->setEnabled(0); - } - else - { - mdata = SwashLvlaccInitialData; // Restore metadata - SwashLvlConfigurationInProgress=0; + SwashLvlConfigurationInProgress = 1; + m_aircraft->TabObject->setTabEnabled(0, 0); + m_aircraft->TabObject->setTabEnabled(2, 0); + m_aircraft->TabObject->setTabEnabled(3, 0); + m_aircraft->ccpmType->setEnabled(0); + } else { + // Restore metadata + mdata = SwashLvlaccInitialData; + SwashLvlConfigurationInProgress = 0; - m_ccpm->TabObject->setTabEnabled(0,1); - m_ccpm->TabObject->setTabEnabled(2,1); - m_ccpm->TabObject->setTabEnabled(3,1); - m_ccpm->ccpmType->setEnabled(1); + m_aircraft->TabObject->setTabEnabled(0, 1); + m_aircraft->TabObject->setTabEnabled(2, 1); + m_aircraft->TabObject->setTabEnabled(3, 1); + m_aircraft->ccpmType->setEnabled(1); } obj->setMetadata(mdata); - } /** @@ -1413,26 +1407,34 @@ void ConfigCcpmWidget::enableSwashplateLevellingControl(bool state) */ void ConfigCcpmWidget::setSwashplateLevel(int percent) { - if (percent<0)return;// -1; - if (percent>100)return;// -1; - if (SwashLvlConfigurationInProgress!=1)return;// -1; - int i; - double value; - double level = ((double)percent /50.00) - 1.00; + if (percent < 0) { + return; // -1; + } + if (percent > 100) { + return; // -1; + } + if (SwashLvlConfigurationInProgress != 1) { + return; // -1; + } - SwashLvlServoInterlock=1; + double level = ((double) percent / 50.00) - 1.00; - ActuatorCommand * actuatorCommand = ActuatorCommand::GetInstance(getObjectManager()); + SwashLvlServoInterlock = 1; + + ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager()); ActuatorCommand::DataFields actuatorCommandData = actuatorCommand->getData(); - for (i=0;i 0) - value = (newSwashLvlConfiguration.Max[i] - newSwashLvlConfiguration.Neutral[i])*level + newSwashLvlConfiguration.Neutral[i]; - else if (level < 0) - value = (newSwashLvlConfiguration.Neutral[i] - newSwashLvlConfiguration.Min[i])*level + newSwashLvlConfiguration.Neutral[i]; - + } else if (level > 0) { + value = (newSwashLvlConfiguration.Max[i] - newSwashLvlConfiguration.Neutral[i]) * level + + newSwashLvlConfiguration.Neutral[i]; + } else if (level < 0) { + value = (newSwashLvlConfiguration.Neutral[i] - newSwashLvlConfiguration.Min[i]) * level + + newSwashLvlConfiguration.Neutral[i]; + } actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value; SwashLvlSpinBoxes[i]->setValue(value); } @@ -1440,38 +1442,42 @@ void ConfigCcpmWidget::setSwashplateLevel(int percent) actuatorCommand->setData(actuatorCommandData); actuatorCommand->updated(); - SwashLvlServoInterlock=0; - -return; + SwashLvlServoInterlock = 0; } void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value) { Q_UNUSED(value); - int i; - if (SwashLvlServoInterlock==1)return; - ActuatorCommand * actuatorCommand = ActuatorCommand::GetInstance(getObjectManager()); + if (SwashLvlServoInterlock == 1) { + return; + } + + ActuatorCommand *actuatorCommand = ActuatorCommand::GetInstance(getObjectManager()); ActuatorCommand::DataFields actuatorCommandData = actuatorCommand->getData(); - for (i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { + for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { value = SwashLvlSpinBoxes[i]->value(); - switch (SwashLvlState) - { - case 1: //Neutral levelling - newSwashLvlConfiguration.Neutral[i]=value; + switch (SwashLvlState) { + case 1: + // Neutral levelling + newSwashLvlConfiguration.Neutral[i] = value; break; - case 2: //Max levelling + case 2: + // Max levelling newSwashLvlConfiguration.Max[i] = value; break; - case 3: //Min levelling - newSwashLvlConfiguration.Min[i]= value; + case 3: + // Min levelling + newSwashLvlConfiguration.Min[i] = value; break; - case 4: //levelling verification + case 4: + // levelling verification break; - case 5: //levelling complete + case 5: + // levelling complete break; default: break; @@ -1480,7 +1486,6 @@ void ConfigCcpmWidget::SwashLvlSpinBoxChanged(int value) actuatorCommandData.Channel[newSwashLvlConfiguration.ServoChannels[i]] = value; } - actuatorCommand->setData(actuatorCommandData); actuatorCommand->updated(); @@ -1496,63 +1501,45 @@ bool ConfigCcpmWidget::throwConfigError(QString airframeType) bool error = false; - if((m_ccpm->ccpmServoWChannel->currentIndex()==0) && (m_ccpm->ccpmServoWChannel->isEnabled())) - { - m_ccpm->ccpmServoWLabel->setText("" + m_ccpm->ccpmServoWLabel->text() + ""); + if ((m_aircraft->ccpmServoWChannel->currentIndex() == 0) && (m_aircraft->ccpmServoWChannel->isEnabled())) { + m_aircraft->ccpmServoWLabel->setText("" + m_aircraft->ccpmServoWLabel->text() + ""); error = true; - } - else - { - m_ccpm->ccpmServoWLabel->setText(QTextEdit(m_ccpm->ccpmServoWLabel->text()).toPlainText()); + } else { + m_aircraft->ccpmServoWLabel->setText(QTextEdit(m_aircraft->ccpmServoWLabel->text()).toPlainText()); } - if((m_ccpm->ccpmServoXChannel->currentIndex()==0) && (m_ccpm->ccpmServoXChannel->isEnabled())) - { - m_ccpm->ccpmServoXLabel->setText("" + m_ccpm->ccpmServoXLabel->text() + ""); + if ((m_aircraft->ccpmServoXChannel->currentIndex() == 0) && (m_aircraft->ccpmServoXChannel->isEnabled())) { + m_aircraft->ccpmServoXLabel->setText("" + m_aircraft->ccpmServoXLabel->text() + ""); error = true; - } - else - { - m_ccpm->ccpmServoXLabel->setText(QTextEdit(m_ccpm->ccpmServoXLabel->text()).toPlainText()); + } else { + m_aircraft->ccpmServoXLabel->setText(QTextEdit(m_aircraft->ccpmServoXLabel->text()).toPlainText()); } - if((m_ccpm->ccpmServoYChannel->currentIndex()==0) && (m_ccpm->ccpmServoYChannel->isEnabled())) - { - m_ccpm->ccpmServoYLabel->setText("" + m_ccpm->ccpmServoYLabel->text() + ""); + if ((m_aircraft->ccpmServoYChannel->currentIndex() == 0) && (m_aircraft->ccpmServoYChannel->isEnabled())) { + m_aircraft->ccpmServoYLabel->setText("" + m_aircraft->ccpmServoYLabel->text() + ""); error = true; - } - else - { - m_ccpm->ccpmServoYLabel->setText(QTextEdit(m_ccpm->ccpmServoYLabel->text()).toPlainText()); + } else { + m_aircraft->ccpmServoYLabel->setText(QTextEdit(m_aircraft->ccpmServoYLabel->text()).toPlainText()); } - if((m_ccpm->ccpmServoZChannel->currentIndex()==0) && (m_ccpm->ccpmServoZChannel->isEnabled())) - { - m_ccpm->ccpmServoZLabel->setText("" + m_ccpm->ccpmServoZLabel->text()+ ""); + if ((m_aircraft->ccpmServoZChannel->currentIndex() == 0) && (m_aircraft->ccpmServoZChannel->isEnabled())) { + m_aircraft->ccpmServoZLabel->setText("" + m_aircraft->ccpmServoZLabel->text() + ""); error = true; - } - else - { - m_ccpm->ccpmServoZLabel->setText(QTextEdit(m_ccpm->ccpmServoZLabel->text()).toPlainText()); + } else { + m_aircraft->ccpmServoZLabel->setText(QTextEdit(m_aircraft->ccpmServoZLabel->text()).toPlainText()); } - if((m_ccpm->ccpmEngineChannel->currentIndex()==0) && (m_ccpm->ccpmEngineChannel->isEnabled())) - { - m_ccpm->ccpmEngineLabel->setText("" + m_ccpm->ccpmEngineLabel->text() + ""); - } - else - { - m_ccpm->ccpmEngineLabel->setText(QTextEdit(m_ccpm->ccpmEngineLabel->text()).toPlainText()); + if ((m_aircraft->ccpmEngineChannel->currentIndex() == 0) && (m_aircraft->ccpmEngineChannel->isEnabled())) { + m_aircraft->ccpmEngineLabel->setText("" + m_aircraft->ccpmEngineLabel->text() + ""); + } else { + m_aircraft->ccpmEngineLabel->setText(QTextEdit(m_aircraft->ccpmEngineLabel->text()).toPlainText()); } - if((m_ccpm->ccpmTailChannel->currentIndex()==0) && (m_ccpm->ccpmTailChannel->isEnabled())) - { - m_ccpm->ccpmTailLabel->setText("" + m_ccpm->ccpmTailLabel->text() + ""); + if ((m_aircraft->ccpmTailChannel->currentIndex() == 0) && (m_aircraft->ccpmTailChannel->isEnabled())) { + m_aircraft->ccpmTailLabel->setText("" + m_aircraft->ccpmTailLabel->text() + ""); error = true; - } - else - { - m_ccpm->ccpmTailLabel->setText(QTextEdit(m_ccpm->ccpmTailLabel->text()).toPlainText()); + } else { + m_aircraft->ccpmTailLabel->setText(QTextEdit(m_aircraft->ccpmTailLabel->text()).toPlainText()); } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index 7f091c1fb..2890cffdb 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -28,7 +28,7 @@ #define CONFIGccpmWIDGET_H #include "cfg_vehicletypes/vehicleconfig.h" -#include "ui_ccpm.h" +#include "ui_airframe_ccpm.h" #include "../uavobjectwidgetutils/configtaskwidget.h" #include "extensionsystem/pluginmanager.h" #include "uavobjectmanager.h" @@ -52,7 +52,6 @@ typedef struct { int Min[CCPM_MAX_SWASH_SERVOS]; } SwashplateServoSettingsStruct; - class ConfigCcpmWidget: public VehicleConfig { Q_OBJECT @@ -64,7 +63,9 @@ public: friend class ConfigVehicleTypeWidget; private: - Ui_ccpmWidget *m_ccpm; + //Ui_ccpmWidget *m_ccpm; + Ui_CcpmConfigWidget *m_aircraft; + QGraphicsSvgItem *SwashplateImg; QGraphicsSvgItem *CurveImg; QGraphicsSvgItem *Servos[CCPM_MAX_SWASH_SERVOS]; @@ -90,7 +91,7 @@ private: bool updatingFromHardware; bool updatingToHardware; - virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual void ResetActuators(GUIConfigDataUnion *configData); static QStringList getChannelDescriptions(); QString updateConfigObjects(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp new file mode 100644 index 000000000..07c453c93 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -0,0 +1,293 @@ +/** + ****************************************************************************** + * + * @file configmultirotorwidget.cpp + * @author E. Lafargue & The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief ccpm configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#include "configcustomwidget.h" +#include "mixersettings.h" +//#include "systemsettings.h" +//#include "actuatorsettings.h" +//#include "actuatorcommand.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +//const QString ConfigCustomWidget::CHANNELBOXNAME = QString("multiMotorChannelBox"); + +ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) : + VehicleConfig(parent), m_aircraft(new Ui_CustomConfigWidget()) +{ + m_aircraft->setupUi(this); + + // Put combo boxes in line one of the custom mixer table: + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + UAVObjectField* field = mixer->getField(QString("Mixer1Type")); + QStringList list = field->getOptions(); + for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + QComboBox* qb = new QComboBox(m_aircraft->customMixerTable); + qb->addItems(list); + m_aircraft->customMixerTable->setCellWidget(0, i, qb); + } + + SpinBoxDelegate *sbd = new SpinBoxDelegate(); + for (int i = 1; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); + } +} + +ConfigCustomWidget::~ConfigCustomWidget() +{ + delete m_aircraft; +} + +void ConfigCustomWidget::setupUI(QString frameType) +{ + Q_ASSERT(m_aircraft); + + m_aircraft->customMixerTable->resizeColumnsToContents(); + + for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + m_aircraft->customMixerTable->setColumnWidth(i, + (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10); + } +} + +QStringList ConfigCustomWidget::getChannelDescriptions() +{ + QStringList channelDesc; + + for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + channelDesc.append(QString("-")); + } + + return channelDesc; +} + +/** + Helper function to update the UI widget objects + */ +QString ConfigCustomWidget::updateConfigObjectsFromWidgets() +{ + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve()); + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); + + // Update the table: + for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) { + QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel); + if (q->currentText() == "Disabled") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); + } else if (q->currentText() == "Motor") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); + } else if (q->currentText() == "Servo") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + } else if (q->currentText() == "CameraRoll") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL); + } else if (q->currentText() == "CameraPitch") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH); + } else if (q->currentText() == "CameraYaw") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW); + } else if (q->currentText() == "Accessory0") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0); + } else if (q->currentText() == "Accessory1") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1); + } else if (q->currentText() == "Accessory2") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2); + } else if (q->currentText() == "Accessory3") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3); + } else if (q->currentText() == "Accessory4") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4); + } else if (q->currentText() == "Accessory5") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5); + } + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, + m_aircraft->customMixerTable->item(1, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, + m_aircraft->customMixerTable->item(2, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, + m_aircraft->customMixerTable->item(3, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, + m_aircraft->customMixerTable->item(4, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, + m_aircraft->customMixerTable->item(5, channel)->text().toDouble()); + } + + return "Custom"; +} + +/** + Helper function to refresh the UI widget values + */ +void ConfigCustomWidget::refreshWidgetsValues(QString frameType) +{ + Q_ASSERT(m_aircraft); + + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QList curveValues; + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); + + // is at least one of the curve values != 0? + if (isValidThrottleCurve(&curveValues)) { + // yes, use the curve we just read from mixersettings + m_aircraft->customThrottle1Curve->initCurve(&curveValues); + } + else { + // no, init a straight curve + m_aircraft->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); + } + + if (MixerSettings *mxr = qobject_cast(mixer)) { + MixerSettings::DataFields mixerSettingsData = mxr->getData(); + if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE) + m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); + else { + m_aircraft->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); + } + } + + // Setup all Throttle2 curves for all types of airframes + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); + + if (isValidThrottleCurve(&curveValues)) { + m_aircraft->customThrottle2Curve->initCurve(&curveValues); + } + else { + m_aircraft->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_aircraft->customThrottle2Curve->getMin()); + } + + // Update the mixer table: + for (int channel = 0; channel < m_aircraft->customMixerTable->columnCount(); channel++) { + UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); + if (field) { + QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel); + if (q) { + QString s = field->getValue().toString(); + setComboCurrentIndex(q, q->findText(s)); + } + + m_aircraft->customMixerTable->item(1, channel)->setText( + QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1))); + m_aircraft->customMixerTable->item(2, channel)->setText( + QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2))); + m_aircraft->customMixerTable->item(3, channel)->setText( + QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL))); + m_aircraft->customMixerTable->item(4, channel)->setText( + QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH))); + m_aircraft->customMixerTable->item(5, channel)->setText( + QString::number(getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW))); + } + } +} + +/** + This function displays text and color formatting in order to help the user understand what channels have not yet been configured. + */ +bool ConfigCustomWidget::throwConfigError(int numMotors) +{ + return false; +} + +/** + WHAT DOES THIS DO??? + */ +void ConfigCustomWidget::showEvent(QShowEvent *event) +{ + Q_UNUSED(event) + m_aircraft->customMixerTable->resizeColumnsToContents(); + for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + m_aircraft->customMixerTable->setColumnWidth(i, + (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10); + } +} + +/** + Resize the GUI contents when the user changes the window size + */ +void ConfigCustomWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + // Make the custom table columns autostretch: + m_aircraft->customMixerTable->resizeColumnsToContents(); + int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM; + for (int i = 0; i < channelCount; i++) { + m_aircraft->customMixerTable->setColumnWidth(i, + (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount); + } +} + +/** + Helper delegate for the custom mixer editor table. + Taken straight from Qt examples, thanks! +*/ +SpinBoxDelegate::SpinBoxDelegate(QObject *parent) : + QItemDelegate(parent) +{ +} + +QWidget *SpinBoxDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + QSpinBox *editor = new QSpinBox(parent); + editor->setMinimum(-127); + editor->setMaximum(127); + + return editor; +} + +void SpinBoxDelegate::setEditorData(QWidget *editor, const QModelIndex &index) const +{ + int value = index.model()->data(index, Qt::EditRole).toInt(); + + QSpinBox *spinBox = static_cast(editor); + spinBox->setValue(value); +} + +void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const +{ + QSpinBox *spinBox = static_cast(editor); + spinBox->interpretText(); + int value = spinBox->value(); + + model->setData(index, value, Qt::EditRole); +} + +void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, + const QModelIndex &index) const +{ + editor->setGeometry(option.rect); +} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h new file mode 100644 index 000000000..08fcd549a --- /dev/null +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -0,0 +1,91 @@ +/** + ****************************************************************************** + * + * @file configairframetwidget.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @addtogroup GCSPlugins GCS Plugins + * @{ + * @addtogroup ConfigPlugin Config Plugin + * @{ + * @brief Airframe configuration panel + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef CONFIGCUSTOMWIDGET_H +#define CONFIGCUSTOMWIDGET_H + +#include "cfg_vehicletypes/vehicleconfig.h" +#include "ui_airframe_custom.h" +#include "../uavobjectwidgetutils/configtaskwidget.h" +#include "extensionsystem/pluginmanager.h" +#include "uavobjectmanager.h" +#include "uavobject.h" +#include "uavtalk/telemetrymanager.h" + +#include +#include +#include + +class Ui_Widget; + +class ConfigCustomWidget: public VehicleConfig +{ + Q_OBJECT + +public: + ConfigCustomWidget(QWidget *parent = 0); + ~ConfigCustomWidget(); + + friend class ConfigVehicleTypeWidget; + +private: + Ui_CustomConfigWidget *m_aircraft; + + //virtual void ResetActuators(GUIConfigDataUnion *configData); + static QStringList getChannelDescriptions(); +// static const QString CHANNELBOXNAME; + +private slots: + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + virtual bool throwConfigError(int numMotors); + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); + +signals: + void configurationChanged(); + +}; + +class SpinBoxDelegate : public QItemDelegate +{ + Q_OBJECT + +public: + SpinBoxDelegate(QObject *parent = 0); + + QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; + + void setEditorData(QWidget *editor, const QModelIndex &index) const; + void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; + + void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; +}; + +#endif // CONFIGCUSTOMWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 27a62ec9c..8c3ae1167 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -41,20 +41,24 @@ #include #include -/** - Constructor - */ -ConfigFixedWingWidget::ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent) +ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : + VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget()) { - m_aircraft = aircraft; + m_aircraft->setupUi(this); + + QStringList fixedWingTypes; + fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; + m_aircraft->fixedWingType->addItems(fixedWingTypes); + + // Set default model to "Elevator aileron rudder" + m_aircraft->fixedWingType->setCurrentIndex(0); + + connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } -/** - Destructor - */ ConfigFixedWingWidget::~ConfigFixedWingWidget() { - // Do nothing + delete m_aircraft; } /** @@ -65,7 +69,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType) Q_ASSERT(m_aircraft); if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") { - // Setup the UI //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder")); m_aircraft->fwRudder1ChannelBox->setEnabled(true); @@ -210,6 +213,30 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) { Q_ASSERT(m_aircraft); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QList curveValues; + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); + + // is at least one of the curve values != 0? + if (isValidThrottleCurve(&curveValues)) { + // yes, use the curve we just read from mixersettings + m_aircraft->fixedWingThrottle->initCurve(&curveValues); + } + else { + // no, init a straight curve + m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); + } + + + + + + + + + GUIConfigDataUnion config = GetConfigData(); fixedGUISettingsStruct fixed = config.fixedwing; @@ -222,26 +249,32 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1); setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2); - UAVDataObject* mixer= dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); + //UAVDataObject* mixer= dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + //Q_ASSERT(mixer); int channel; - if (frameType == "FixedWingElevon") { + if (frameType == "FixedWingElevon") { // If the airframe is elevon, restore the slider setting // Find the channel number for Elevon1 (FixedWingRoll1) - channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; - if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. - m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL)*100); - m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100); - } - } - if (frameType == "FixedWingVtail") { - channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; - if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. - m_aircraft->elevonSlider1->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW)*100); - m_aircraft->elevonSlider2->setValue(getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH)*100); + channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; + if (channel > -1) { + // If for some reason the actuators were incoherent, we might fail here, hence the check. + m_aircraft->elevonSlider1->setValue( + getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100); + m_aircraft->elevonSlider2->setValue( + getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); } - } + } + else if (frameType == "FixedWingVtail") { + channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1; + if (channel > -1) { + // If for some reason the actuators were incoherent, we might fail here, hence the check. + m_aircraft->elevonSlider1->setValue( + getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW) * 100); + m_aircraft->elevonSlider2->setValue( + getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); + } + } } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 282fc3447..21dff9658 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -46,7 +46,7 @@ class ConfigFixedWingWidget: public VehicleConfig Q_OBJECT public: - ConfigFixedWingWidget(Ui_FixedWingConfigWidget *aircraft = 0, QWidget *parent = 0); + ConfigFixedWingWidget(QWidget *parent = 0); ~ConfigFixedWingWidget(); friend class ConfigVehicleTypeWidget; @@ -67,10 +67,8 @@ private slots: virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(QString airframeType); - protected: }; - #endif // CONFIGFIXEDWINGWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 01a7d3492..b2e419f42 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -41,29 +41,42 @@ #include #include -ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent) +ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : + VehicleConfig(parent), m_aircraft(new Ui_GroundConfigWidget()) { - m_aircraft = aircraft; + m_aircraft->setupUi(this); + + QStringList groundVehicleTypes; + groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; + m_aircraft->groundVehicleType->addItems(groundVehicleTypes); + + // Set default model to "Turnable (car)" + m_aircraft->groundVehicleType->setCurrentIndex(0); + + setupUI(m_aircraft->groundVehicleType->currentText()); + + connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget() { - // Do nothing + delete m_aircraft; } /** Virtual function to setup the UI + TODO move to constructor or make private */ void ConfigGroundVehicleWidget::setupUI(QString frameType) { m_aircraft->differentialSteeringMixBox->setHidden(true); //STILL NEEDS WORK + // Setup the UI //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); m_aircraft->gvEngineChannelBox->setEnabled(false); m_aircraft->gvEngineLabel->setEnabled(false); - m_aircraft->gvAileron1ChannelBox->setEnabled(false); m_aircraft->gvAileron1Label->setEnabled(false); @@ -71,7 +84,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) m_aircraft->gvAileron2ChannelBox->setEnabled(false); m_aircraft->gvAileron2Label->setEnabled(false); - if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)"){ //Tank + if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") { + // Tank setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Differential (tank)")); m_aircraft->gvMotor1ChannelBox->setEnabled(true); m_aircraft->gvMotor1Label->setEnabled(true); @@ -96,7 +110,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve"); } - else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle"){ //Motorcycle + else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") { + // Motorcycle setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle")); m_aircraft->gvMotor1ChannelBox->setEnabled(false); m_aircraft->gvMotor1Label->setEnabled(false); @@ -120,7 +135,8 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve"); m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); } - else {//Car + else { + // Car setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)")); m_aircraft->gvMotor1ChannelBox->setEnabled(true); @@ -159,28 +175,28 @@ QStringList ConfigGroundVehicleWidget::getChannelDescriptions() QStringList channelDesc; // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) - { + for (i = 0; i < (int) (ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) { channelDesc.append(QString("-")); } // get the gui config data GUIConfigDataUnion configData = GetConfigData(); - if (configData.ground.GroundVehicleSteering1 > 0) - channelDesc[configData.ground.GroundVehicleSteering1-1] = QString("GroundSteering1"); - if (configData.ground.GroundVehicleSteering2 > 0) - channelDesc[configData.ground.GroundVehicleSteering2-1] = QString("GroundSteering2"); - if (configData.ground.GroundVehicleThrottle1 > 0) - channelDesc[configData.ground.GroundVehicleThrottle1-1] = QString("GroundThrottle1"); - if (configData.ground.GroundVehicleThrottle2 > 0) - channelDesc[configData.ground.GroundVehicleThrottle2-1] = QString("GroundThrottle2"); - + if (configData.ground.GroundVehicleSteering1 > 0) { + channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1"); + } + if (configData.ground.GroundVehicleSteering2 > 0) { + channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2"); + } + if (configData.ground.GroundVehicleThrottle1 > 0) { + channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundThrottle1"); + } + if (configData.ground.GroundVehicleThrottle2 > 0) { + channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundThrottle2"); + } return channelDesc; } - - /** Virtual function to update the UI widget objects */ @@ -195,33 +211,68 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() setMixerValue(mixer, "FeedForward", 0.0); // set the throttle curves - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve() ); - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve() ); + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve()); + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve()); - //All airframe types must start with "GroundVehicle" - if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)" ) { - airframeType = "GroundVehicleCar"; - setupGroundVehicleCar(airframeType); - } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { - airframeType = "GroundVehicleDifferential"; - setupGroundVehicleDifferential(airframeType); - } else { // "Motorcycle" - airframeType = "GroundVehicleMotorcycle"; - setupGroundVehicleMotorcycle(airframeType); - } + // All airframe types must start with "GroundVehicle" + if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") { + airframeType = "GroundVehicleCar"; + setupGroundVehicleCar(airframeType); + } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { + airframeType = "GroundVehicleDifferential"; + setupGroundVehicleDifferential(airframeType); + } else { // "Motorcycle" + airframeType = "GroundVehicleMotorcycle"; + setupGroundVehicleMotorcycle(airframeType); + } return airframeType; } - - /** Virtual function to refresh the UI widget values */ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { - UAVDataObject* obj; -// UAVObjectField *field; + qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType; + + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QList curveValues; + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); + + // is at least one of the curve values != 0? + if (isValidThrottleCurve(&curveValues)) { + // yes, use the curve we just read from mixersettings + m_aircraft->groundVehicleThrottle1->initCurve(&curveValues); + } + else { + // no, init a straight curve + m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); + } + + // Setup all Throttle2 curves for all types of airframes + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); + + if (isValidThrottleCurve(&curveValues)) { + m_aircraft->groundVehicleThrottle2->initCurve(&curveValues); + } + else { + m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); + } + + + + + + + + + + + //UAVDataObject *obj; + //UAVObjectField *field; GUIConfigDataUnion config = GetConfigData(); @@ -237,16 +288,18 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) // If the vehicle type is "differential", restore the slider setting // Find the channel number for Motor1 - obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(obj); - int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; - if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. - - m_aircraft->differentialSteeringSlider1->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_ROLL)*100); - m_aircraft->differentialSteeringSlider2->setValue(getMixerVectorValue(obj,channel,VehicleConfig::MIXERVECTOR_PITCH)*100); - } + //obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + //Q_ASSERT(obj); + int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; + if (channel > -1) { + // If for some reason the actuators were incoherent, we might fail here, hence the check. + m_aircraft->differentialSteeringSlider1->setValue( + getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL) * 100); + m_aircraft->differentialSteeringSlider2->setValue( + getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); + } } - if (frameType == "GroundVehicleMotorcycle") { + else if (frameType == "GroundVehicleMotorcycle") { //CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE // obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); // Q_ASSERT(obj); @@ -311,8 +364,6 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp return true; } - - /** Setup differentially steered ground vehicle. @@ -355,11 +406,8 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT m_aircraft->gvStatusLabel->setText("Mixer generated"); return true; - } - - /** Setup steerable ground vehicle. @@ -505,4 +553,3 @@ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType) } return error; } - diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 804b0bfa7..97b35c8e4 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -46,7 +46,7 @@ class ConfigGroundVehicleWidget: public VehicleConfig Q_OBJECT public: - ConfigGroundVehicleWidget(Ui_GroundConfigWidget *aircraft = 0, QWidget *parent = 0); + ConfigGroundVehicleWidget(QWidget *parent = 0); ~ConfigGroundVehicleWidget(); friend class ConfigVehicleTypeWidget; @@ -71,5 +71,4 @@ protected: }; - #endif // CONFIGGROUNDVEHICLEWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 678688c6b..f93aceba8 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -43,14 +43,50 @@ const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox"); -ConfigMultiRotorWidget::ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft, QWidget *parent) : VehicleConfig(parent), invertMotors(1) +ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : + VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1) { - m_aircraft = aircraft; + m_aircraft->setupUi(this); + + // Setup the Multirotor picture in the Quad settings interface + m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QSvgRenderer *renderer = new QSvgRenderer(); + renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); + + quad = new QGraphicsSvgItem(); + quad->setSharedRenderer(renderer); + quad->setElementId("quad-x"); + + QGraphicsScene *scene = new QGraphicsScene(this); + scene->addItem(quad); + scene->setSceneRect(quad->boundingRect()); + m_aircraft->quadShape->setScene(scene); + + //m_multirotor = new ConfigMultiRotorWidget(m_aircraft); + //m_multirotor->quad = quad; + uiowner = this; + setupUI(m_aircraft->multirotorFrameType->currentText()); + + QStringList multiRotorTypes; + multiRotorTypes << "Tricopter Y" << "Quad +" << "Quad X" << + "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << + "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; + m_aircraft->multirotorFrameType->addItems(multiRotorTypes); + // Set default model to "Quad X" + m_aircraft->multirotorFrameType->setCurrentIndex(2); + + connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); + + // Connect the multirotor motor reverse checkbox + connect(m_aircraft->MultirotorRevMixerCheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); + + //m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); } ConfigMultiRotorWidget::~ConfigMultiRotorWidget() { - // Do nothing + delete m_aircraft; } void ConfigMultiRotorWidget::setupUI(QString frameType) @@ -59,11 +95,12 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) Q_ASSERT(uiowner); Q_ASSERT(quad); - qDebug() << "ConfigMultiRotorWidget::setupUI - begin"; qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType; - // set aircraftType to Multirotor, disable triyaw channel + // set aircraftType to Multirotor //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); + + // disable triyaw channel m_aircraft->triYawChannelBox->setEnabled(false); // disable all motor channel boxes @@ -77,9 +114,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) } if (frameType == "Tri" || frameType == "Tricopter Y") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y")); - //Enable all necessary motor channel boxes... + // Enable all necessary motor channel boxes... enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true); m_aircraft->mrRollMixLevel->setValue(100); @@ -89,9 +126,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->triYawChannelBox->setEnabled(true); } else if (frameType == "QuadX" || frameType == "Quad X") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X")); - //Enable all necessary motor channel boxes... + // Enable all necessary motor channel boxes... enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true); // init mixer levels @@ -100,9 +137,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(50); } else if (frameType == "QuadP" || frameType == "Quad +") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +")); - //Enable all necessary motor channel boxes... + // Enable all necessary motor channel boxes... enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true); m_aircraft->mrRollMixLevel->setValue(100); @@ -110,9 +147,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(50); } else if (frameType == "Hexa" || frameType == "Hexacopter") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter")); - //Enable all necessary motor channel boxes... + // Enable all necessary motor channel boxes... enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true); m_aircraft->mrRollMixLevel->setValue(50); @@ -120,31 +157,31 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(33); } else if (frameType == "HexaX" || frameType == "Hexacopter X" ) { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, + m_aircraft->multirotorFrameType->findText("Hexacopter X")); - //Enable all necessary motor channel boxes... + // Enable all necessary motor channel boxes... enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true); m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(33); - } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, + m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); - //Enable all necessary motor channel boxes... + // Enable all necessary motor channel boxes... enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(66); - } else if (frameType == "Octo" || frameType == "Octocopter") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter")); - //Enable all necessary motor channel boxes + // Enable all necessary motor channel boxes enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(33); @@ -152,31 +189,30 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(25); } else if (frameType == "OctoV" || frameType == "Octocopter V") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, + m_aircraft->multirotorFrameType->findText("Octocopter V")); - //Enable all necessary motor channel boxes + // Enable all necessary motor channel boxes enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(25); m_aircraft->mrPitchMixLevel->setValue(25); setYawMixLevel(25); - } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +")); - //Enable all necessary motor channel boxes + // Enable all necessary motor channel boxes enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); setYawMixLevel(50); - } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { - setComboCurrentIndex( m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X")); + setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X")); - //Enable all necessary motor channel boxes + // Enable all necessary motor channel boxes enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(50); @@ -186,15 +222,14 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) // Draw the appropriate airframe drawAirframe(frameType); - qDebug() << "ConfigMultiRotorWidget::setupUI - end"; } void ConfigMultiRotorWidget::drawAirframe(QString frameType) { - qDebug() << "ConfigMultiRotorWidget::drawAirframe - begin"; - qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type:" << frameType; + qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType; - invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1 : 1; + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; + qDebug() << "ConfigMultiRotorWidget::drawAirframe - invert motors" << invertMotors; if (frameType == "Tri" || frameType == "Tricopter Y") { if (invertMotors > 0) { @@ -203,13 +238,11 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType) quad->setElementId("tri_reverse"); } } else if (frameType == "QuadX" || frameType == "Quad X") { - qDebug() << "ConfigMultiRotorWidget::drawAirframe - 1"; if (invertMotors > 0) { quad->setElementId("quad-x"); } else { quad->setElementId("quad-x_reverse"); } - qDebug() << "ConfigMultiRotorWidget::drawAirframe - 2"; } else if (frameType == "QuadP" || frameType == "Quad +") { if (invertMotors > 0) { quad->setElementId("quad-plus"); @@ -259,7 +292,8 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType) quad->setElementId("octo-coax-X_reverse"); } } - qDebug() << "ConfigMultiRotorWidget::drawAirframe - end"; + m_aircraft->quadShape->setSceneRect(quad->boundingRect()); + m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); } void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData) @@ -316,12 +350,12 @@ void ConfigMultiRotorWidget::setYawMixLevel(int value) if(value<0) { m_aircraft->mrYawMixLevel->setValue((-1)*value); - m_aircraft->MultirotorRevMixercheckBox->setChecked(true); + m_aircraft->MultirotorRevMixerCheckBox->setChecked(true); } else { m_aircraft->mrYawMixLevel->setValue(value); - m_aircraft->MultirotorRevMixercheckBox->setChecked(false); + m_aircraft->MultirotorRevMixerCheckBox->setChecked(false); } } @@ -337,11 +371,11 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() QString airframeType; QList motorList; - UAVDataObject* mixerObj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixerObj); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); // Curve is also common to all quads: - setThrottleCurve(mixerObj, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() ); + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() ); if (m_aircraft->multirotorFrameType->currentText() == "Quad +") { airframeType = "QuadP"; @@ -368,17 +402,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() // Motor 1 to 6, Y6 Layout: // pitch roll yaw - double mixer [8][3] = { - { 0.5, 1, -1}, - { 0.5, 1, 1}, - { 0.5, -1, -1}, - { 0.5, -1, 1}, - { -1, 0, -1}, - { -1, 0, 1}, - { 0, 0, 0}, - { 0, 0, 0} + double mixerMatrix[8][3] = { + { 0.5, 1, -1 }, + { 0.5, 1, 1 }, + { 0.5, -1, -1 }, + { 0.5, -1, 1 }, + { -1, 0, -1 }, + { -1, 0, 1 }, + { 0, 0, 0 }, + { 0, 0, 0 } }; - setupMultiRotorMixer(mixer); + setupMultiRotorMixer(mixerMatrix); m_aircraft->mrStatusLabel->setText("Configuration OK"); } else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") { @@ -394,17 +428,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() setupMotors(motorList); // Motor 1 to 8: // pitch roll yaw - double mixer [8][3] = { - { 1, 0, -1}, - { 1, -1, 1}, - { 0, -1, -1}, - { -1, -1, 1}, - { -1, 0, -1}, - { -1, 1, 1}, - { 0, 1, -1}, - { 1, 1, 1} + double mixerMatrix[8][3] = { + { 1, 0, -1 }, + { 1, -1, 1 }, + { 0, -1, -1 }, + { -1, -1, 1 }, + { -1, 0, -1 }, + { -1, 1, 1 }, + { 0, 1, -1 }, + { 1, 1, 1 } }; - setupMultiRotorMixer(mixer); + setupMultiRotorMixer(mixerMatrix); m_aircraft->mrStatusLabel->setText("Configuration OK"); } else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") { @@ -420,17 +454,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() // Motor 1 to 8: // IMPORTANT: Assumes evenly spaced engines // pitch roll yaw - double mixer [8][3] = { - { 0.33, -1, -1}, - { 1 , -1, 1}, - { -1 , -1, -1}, - { -0.33, -1, 1}, - { -0.33, 1, -1}, - { -1 , 1, 1}, - { 1 , 1, -1}, - { 0.33, 1, 1} + double mixerMatrix[8][3] = { + { 0.33, -1, -1 }, + { 1 , -1, 1 }, + { -1 , -1, -1 }, + { -0.33, -1, 1 }, + { -0.33, 1, -1 }, + { -1 , 1, 1 }, + { 1 , 1, -1 }, + { 0.33, 1, 1 } }; - setupMultiRotorMixer(mixer); + setupMultiRotorMixer(mixerMatrix); m_aircraft->mrStatusLabel->setText("Configuration OK"); } else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") { @@ -445,17 +479,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() setupMotors(motorList); // Motor 1 to 8: // pitch roll yaw - double mixer [8][3] = { - { 1, 0, -1}, - { 1, 0, 1}, - { 0, -1, -1}, - { 0, -1, 1}, - { -1, 0, -1}, - { -1, 0, 1}, - { 0, 1, -1}, - { 0, 1, 1} + double mixerMatrix[8][3] = { + { 1, 0, -1 }, + { 1, 0, 1 }, + { 0, -1, -1 }, + { 0, -1, 1 }, + { -1, 0, -1 }, + { -1, 0, 1 }, + { 0, 1, -1 }, + { 0, 1, 1 } }; - setupMultiRotorMixer(mixer); + setupMultiRotorMixer(mixerMatrix); m_aircraft->mrStatusLabel->setText("Configuration OK"); } else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") { @@ -470,17 +504,17 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() setupMotors(motorList); // Motor 1 to 8: // pitch roll yaw - double mixer [8][3] = { - { 1, 1, -1}, - { 1, 1, 1}, - { 1, -1, -1}, - { 1, -1, 1}, - { -1, -1, -1}, - { -1, -1, 1}, - { -1, 1, -1}, - { -1, 1, 1} + double mixerMatrix[8][3] = { + { 1, 1, -1 }, + { 1, 1, 1 }, + { 1, -1, -1 }, + { 1, -1, 1 }, + { -1, -1, -1 }, + { -1, -1, 1 }, + { -1, 1, -1 }, + { -1, 1, 1 } }; - setupMultiRotorMixer(mixer); + setupMultiRotorMixer(mixerMatrix); m_aircraft->mrStatusLabel->setText("Configuration OK"); } else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") { @@ -505,24 +539,24 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() // Motor 1 to 6, Y6 Layout: // pitch roll yaw - double mixer [8][3] = { - { 0.5, 1, 0}, - { 0.5, -1, 0}, - { -1, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0}, - { 0, 0, 0} + double mixerMatrix[8][3] = { + { 0.5, 1, 0 }, + { 0.5, -1, 0 }, + { -1, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 }, + { 0, 0, 0 } }; - setupMultiRotorMixer(mixer); + setupMultiRotorMixer(mixerMatrix); - //tell the mixer about tricopter yaw channel + // tell the mixer about tricopter yaw channel - int channel = m_aircraft->triYawChannelBox->currentIndex()-1; - if (channel > -1){ - setMixerType(mixerObj, channel, VehicleConfig::MIXERTYPE_SERVO); - setMixerVectorValue(mixerObj, channel, VehicleConfig::MIXERVECTOR_YAW, 127); + int channel = m_aircraft->triYawChannelBox->currentIndex() - 1; + if (channel > -1) { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); } m_aircraft->mrStatusLabel->setText(tr("Configuration OK")); @@ -532,21 +566,45 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() return airframeType; } - +void ConfigMultiRotorWidget::reverseMultirotorMotor(){ + QString frameType = m_aircraft->multirotorFrameType->currentText(); + drawAirframe(frameType); +} /** Helper function to refresh the UI widget values */ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) { + Q_ASSERT(m_aircraft); + + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QList curveValues; + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); + + // is at least one of the curve values != 0? + if (isValidThrottleCurve(&curveValues)) { + // yes, use the curve we just read from mixersettings + m_aircraft->multiThrottleCurve->initCurve(&curveValues); + } + else { + // no, init a straight curve + m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); + } + + + + int channel; double value; GUIConfigDataUnion config = GetConfigData(); multiGUISettingsStruct multi = config.multi; - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); +// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(mixer); if (frameType == "QuadP") { @@ -1022,7 +1080,7 @@ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) // and enable only the relevant channels: double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100; double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100; - invertMotors = m_aircraft->MultirotorRevMixercheckBox->isChecked() ? -1:1; + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1:1; double yFactor =invertMotors * (double)m_aircraft->mrYawMixLevel->value()/100; for (int i=0 ; i<8; i++) { if(mmList.at(i)->isEnabled()) @@ -1070,4 +1128,23 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors) return error; } +/** + WHAT DOES THIS DO??? + */ +void ConfigMultiRotorWidget::showEvent(QShowEvent *event) +{ + Q_UNUSED(event) + // Thit fitInView method should only be called now, once the + // widget is shown, otherwise it cannot compute its values and + // the result is usually a ahrsbargraph that is way too small. + m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); +} +/** + Resize the GUI contents when the user changes the window size + */ +void ConfigMultiRotorWidget::resizeEvent(QResizeEvent *event) +{ + Q_UNUSED(event); + m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); +} diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 64b8dd388..210133a48 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -46,7 +46,7 @@ class ConfigMultiRotorWidget: public VehicleConfig Q_OBJECT public: - ConfigMultiRotorWidget(Ui_MultiRotorConfigWidget *aircraft = 0, QWidget *parent = 0); + ConfigMultiRotorWidget(QWidget *parent = 0); ~ConfigMultiRotorWidget(); friend class ConfigVehicleTypeWidget; @@ -66,7 +66,7 @@ private: float invertMotors; - virtual void ResetActuators(GUIConfigDataUnion* configData); + virtual void ResetActuators(GUIConfigDataUnion *configData); static QStringList getChannelDescriptions(); static const QString CHANNELBOXNAME; void setYawMixLevel(int); @@ -79,13 +79,15 @@ private slots: virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(int numMotors); + void reverseMultirotorMotor(); protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); signals: void configurationChanged(); }; - #endif // CONFIGMULTIROTORWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index ad76c1632..caba82a7f 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -104,7 +104,22 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) { guiConfig->setValue(configData.UAVObject[i], i); } -void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData) + +void VehicleConfig::setupUI(QString frameType) +{ + +} + +QString VehicleConfig::updateConfigObjectsFromWidgets() +{ + return QString(); +} + +void VehicleConfig::refreshWidgetsValues(QString frameType) +{ +} + +void VehicleConfig::ResetActuators(GUIConfigDataUnion *configData) { } @@ -113,27 +128,30 @@ void VehicleConfig::ResetActuators(GUIConfigDataUnion* configData) Sets the current index on supplied combobox to index if it is within bounds 0 <= index < combobox.count() */ -void VehicleConfig::setComboCurrentIndex(QComboBox* box, int index) +void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index) { Q_ASSERT(box); - if (index >= 0 && index < box->count()) + if (index >= 0 && index < box->count()) { box->setCurrentIndex(index); + } } /** Helper function: enables/disables the named comboboxes within supplied uiowner */ -void VehicleConfig::enableComboBoxes(QWidget* owner, QString boxName, int boxCount, bool enable) +void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable) { for (int i = 1; i <= boxCount; i++) { QComboBox* box = qFindChild(owner, QString("%0%1").arg(boxName).arg(i)); - if (box) + if (box) { box->setEnabled(enable); + } } } -QString VehicleConfig::getMixerType(UAVDataObject* mixer, int channel) + +QString VehicleConfig::getMixerType(UAVDataObject *mixer, int channel) { Q_ASSERT(mixer); @@ -246,28 +264,22 @@ void VehicleConfig::setMixerValue(UAVDataObject* mixer, QString elementName, dou } } - -void VehicleConfig::setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList curve) +void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList curve) { QPointer field; - switch (curveType) - { - case MIXER_THROTTLECURVE1: - { - field = mixer->getField("ThrottleCurve1"); - break; - } - case MIXER_THROTTLECURVE2: - { - field = mixer->getField("ThrottleCurve2"); - break; - } + switch (curveType) { + case MIXER_THROTTLECURVE1: + field = mixer->getField("ThrottleCurve1"); + break; + case MIXER_THROTTLECURVE2: + field = mixer->getField("ThrottleCurve2"); + break; } if (field && field->getNumElements() == curve.length()) { - for (int i=0;isetValue(curve.at(i),i); + for (int i = 0; i < curve.length(); i++) { + field->setValue(curve.at(i), i); } } } @@ -279,23 +291,18 @@ void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveEle QPointer field; - switch (curveType) - { - case MIXER_THROTTLECURVE1: - { - field = mixer->getField("ThrottleCurve1"); - break; - } - case MIXER_THROTTLECURVE2: - { - field = mixer->getField("ThrottleCurve2"); - break; - } + switch (curveType) { + case MIXER_THROTTLECURVE1: + field = mixer->getField("ThrottleCurve1"); + break; + case MIXER_THROTTLECURVE2: + field = mixer->getField("ThrottleCurve2"); + break; } if (field) { curve->clear(); - for (unsigned int i=0; i < field->getNumElements(); i++) { + for (unsigned int i = 0; i < field->getNumElements(); i++) { curve->append(field->getValue(i).toDouble()); } } @@ -306,7 +313,7 @@ bool VehicleConfig::isValidThrottleCurve(QList* curve) Q_ASSERT(curve); if (curve) { - for (int i=0; i < curve->count(); i++) { + for (int i = 0; i < curve->count(); i++) { if (curve->at(i) != 0) return true; } @@ -314,21 +321,21 @@ bool VehicleConfig::isValidThrottleCurve(QList* curve) return false; } -double VehicleConfig::getCurveMin(QList* curve) +double VehicleConfig::getCurveMin(QList *curve) { double min = 0; - for (int i=0; icount(); i++) + for (int i = 0; i < curve->count(); i++) { min = std::min(min, curve->at(i)); - + } return min; } -double VehicleConfig::getCurveMax(QList* curve) +double VehicleConfig::getCurveMax(QList *curve) { double max = 0; - for (int i=0; icount(); i++) + for (int i = 0; i < curve->count(); i++) { max = std::max(max, curve->at(i)); - + } return max; } /** @@ -336,8 +343,8 @@ double VehicleConfig::getCurveMax(QList* curve) */ void VehicleConfig::resetField(UAVObjectField * field) { - for (unsigned int i=0;igetNumElements();i++) { - field->setValue(0,i); + for (unsigned int i = 0; i < field->getNumElements(); i++) { + field->setValue(0, i); } } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index e8de31427..1be3037e0 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -140,25 +140,33 @@ public: MIXERVECTOR_YAW = 4 } MixerVectorElem; + // TODO remove 1st capital static GUIConfigDataUnion GetConfigData(); static void SetConfigData(GUIConfigDataUnion configData); - static void resetField(UAVObjectField * field); - static void setComboCurrentIndex(QComboBox* box, int index); - static void enableComboBoxes(QWidget* owner, QString boxName, int boxCount, bool enable); - double getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName); - void setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value); - void resetMixerVector(UAVDataObject* mixer, int channel); - void resetMotorAndServoMixers(UAVDataObject* mixer); - QString getMixerType(UAVDataObject* mixer, int channel); - void setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType); - double getMixerValue(UAVDataObject* mixer, QString elementName); - void setMixerValue(UAVDataObject* mixer, QString elementName, double value); - void setThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList curve); - void getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList* curve); - bool isValidThrottleCurve(QList* curve); - double getCurveMin(QList* curve); - double getCurveMax(QList* curve); - virtual void ResetActuators(GUIConfigDataUnion* configData); + + static void resetField(UAVObjectField *field); + static void setComboCurrentIndex(QComboBox *box, int index); + static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable); + + virtual void setupUI(QString airframeType); + virtual QString updateConfigObjectsFromWidgets(); + virtual void refreshWidgetsValues(QString frameType); + + virtual void ResetActuators(GUIConfigDataUnion *configData); + + double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName); + void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value); + void resetMixerVector(UAVDataObject *mixer, int channel); + void resetMotorAndServoMixers(UAVDataObject *mixer); + QString getMixerType(UAVDataObject *mixer, int channel); + void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType); + double getMixerValue(UAVDataObject *mixer, QString elementName); + void setMixerValue(UAVDataObject *mixer, QString elementName, double value); + void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList curve); + void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList* curve); + bool isValidThrottleCurve(QList *curve); + double getCurveMin(QList *curve); + double getCurveMax(QList *curve); QStringList channelNames; QStringList mixerTypes; @@ -168,7 +176,7 @@ public: static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; private: - static UAVObjectManager* getUAVObjectManager(); + static UAVObjectManager *getUAVObjectManager(); private slots: diff --git a/ground/openpilotgcs/src/plugins/config/config.pro b/ground/openpilotgcs/src/plugins/config/config.pro index d05c66252..af016c2ac 100644 --- a/ground/openpilotgcs/src/plugins/config/config.pro +++ b/ground/openpilotgcs/src/plugins/config/config.pro @@ -32,6 +32,7 @@ HEADERS += configplugin.h \ cfg_vehicletypes/configmultirotorwidget.h \ cfg_vehicletypes/configfixedwingwidget.h \ cfg_vehicletypes/configgroundvehiclewidget.h \ + cfg_vehicletypes/configcustomwidget.h \ configrevowidget.h \ config_global.h \ mixercurve.h \ @@ -65,6 +66,7 @@ SOURCES += configplugin.cpp \ cfg_vehicletypes/configmultirotorwidget.cpp \ cfg_vehicletypes/configfixedwingwidget.cpp \ cfg_vehicletypes/configgroundvehiclewidget.cpp \ + cfg_vehicletypes/configcustomwidget.cpp \ outputchannelform.cpp \ mixercurve.cpp \ dblspindelegate.cpp \ @@ -77,7 +79,6 @@ FORMS += airframe.ui \ airframe_multirotor.ui \ airframe_custom.ui \ cc_hw_settings.ui \ - ccpm.ui \ stabilization.ui \ input.ui \ output.ui \ diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index c14045755..b9c98ab89 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -26,70 +26,29 @@ */ #include "configvehicletypewidget.h" #include "systemsettings.h" -#include "mixersettings.h" #include "actuatorsettings.h" +#include "cfg_vehicletypes/configccpmwidget.h" +#include "cfg_vehicletypes/configfixedwingwidget.h" +#include "cfg_vehicletypes/configgroundvehiclewidget.h" +#include "cfg_vehicletypes/configmultirotorwidget.h" +#include "cfg_vehicletypes/configcustomwidget.h" + #include #include #include #include -#include -#include -#include -#include +//#include +//#include +//#include #include #include -#include +//#include #include #include -/** - Helper delegate for the custom mixer editor table. - Taken straight from Qt examples, thanks! - */ -SpinBoxDelegate::SpinBoxDelegate(QObject *parent) - : QItemDelegate(parent) - { - } - -QWidget *SpinBoxDelegate::createEditor(QWidget *parent, - const QStyleOptionViewItem &/* option */, - const QModelIndex &/* index */) const -{ - QSpinBox *editor = new QSpinBox(parent); - editor->setMinimum(-127); - editor->setMaximum(127); - - return editor; -} - -void SpinBoxDelegate::setEditorData(QWidget *editor, - const QModelIndex &index) const -{ - int value = index.model()->data(index, Qt::EditRole).toInt(); - - QSpinBox *spinBox = static_cast(editor); - spinBox->setValue(value); -} - -void SpinBoxDelegate::setModelData(QWidget *editor, QAbstractItemModel *model, - const QModelIndex &index) const -{ - QSpinBox *spinBox = static_cast(editor); - spinBox->interpretText(); - int value = spinBox->value(); - - model->setData(index, value, Qt::EditRole); -} - -void SpinBoxDelegate::updateEditorGeometry(QWidget *editor, - const QStyleOptionViewItem &option, const QModelIndex &/* index */) const -{ - editor->setGeometry(option.rect); -} - -/**********************************************************************************/ +//#include ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent) { @@ -102,7 +61,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi m_aircraft->saveAircraftToRAM->setVisible(false); } - addApplySaveButtons(m_aircraft->saveAircraftToRAM,m_aircraft->saveAircraftToSD); + addApplySaveButtons(m_aircraft->saveAircraftToRAM, m_aircraft->saveAircraftToSD); addUAVObject("SystemSettings"); addUAVObject("MixerSettings"); @@ -120,76 +79,90 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // ***************************************************************************************************************** // create and setup a FixedWing config widget - QWidget *fixedwingConfigWidget = new QWidget(); - m_fixedwingUi = new Ui_FixedWingConfigWidget(); - m_fixedwingUi->setupUi(fixedwingConfigWidget); - m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget); + qDebug() << "create fixedwing ui"; + m_fixedwing = new ConfigFixedWingWidget(); + m_aircraft->airframesWidget->addWidget(m_fixedwing); - m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi); - m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() ); - QStringList fixedWingTypes; - fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; - m_fixedwingUi->fixedWingType->addItems(fixedWingTypes); - m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder" - connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); +// QWidget *fixedwingConfigWidget = new QWidget(); +// m_fixedwingUi = new Ui_FixedWingConfigWidget(); +// m_fixedwingUi->setupUi(fixedwingConfigWidget); +// m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget); + +// m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi); +// m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() ); + +// QStringList fixedWingTypes; +// fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; +// m_fixedwingUi->fixedWingType->addItems(fixedWingTypes); +// m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder" +// +// connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); // ***************************************************************************************************************** // MULTIROTOR // ***************************************************************************************************************** // create and setup a MultiRotor config widget - qDebug() << "create multirotor ui"; - QWidget *multirotorConfigWidget = new QWidget(); - m_multirotorUi = new Ui_MultiRotorConfigWidget(); - m_multirotorUi->setupUi(multirotorConfigWidget); - m_aircraft->airframesWidget->addWidget(multirotorConfigWidget); + m_multirotor = new ConfigMultiRotorWidget(); + m_aircraft->airframesWidget->addWidget(m_multirotor); - // Setup the Multirotor picture in the Quad settings interface - m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - QSvgRenderer *renderer = new QSvgRenderer(); - renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); - quad = new QGraphicsSvgItem(); - quad->setSharedRenderer(renderer); - quad->setElementId("quad-x"); - QGraphicsScene *scene = new QGraphicsScene(this); - scene->addItem(quad); - scene->setSceneRect(quad->boundingRect()); - m_multirotorUi->quadShape->setScene(scene); - m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi); - m_multirotor->quad = quad; - m_multirotor->uiowner = this; - m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText()); - QStringList multiRotorTypes; - multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" << - "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << - "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; - m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes); - m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X" +// qDebug() << "create multirotor ui"; +// QWidget *multirotorConfigWidget = new QWidget(); +// m_multirotorUi = new Ui_MultiRotorConfigWidget(); +// m_multirotorUi->setupUi(multirotorConfigWidget); +// m_aircraft->airframesWidget->addWidget(multirotorConfigWidget); - connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - - // Connect the multirotor motor reverse checkbox - connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); - - m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); +// // Setup the Multirotor picture in the Quad settings interface +// m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +// m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); +// QSvgRenderer *renderer = new QSvgRenderer(); +// renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); +// quad = new QGraphicsSvgItem(); +// quad->setSharedRenderer(renderer); +// quad->setElementId("quad-x"); +// QGraphicsScene *scene = new QGraphicsScene(this); +// scene->addItem(quad); +// scene->setSceneRect(quad->boundingRect()); +// m_multirotorUi->quadShape->setScene(scene); +// +// m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi); +// m_multirotor->quad = quad; +// m_multirotor->uiowner = this; +// m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText()); +// +// QStringList multiRotorTypes; +// multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" << +// "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << +// "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; +// m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes); +// m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X" +// +// connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); +// +// // Connect the multirotor motor reverse checkbox +// connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); +// +// m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); // ***************************************************************************************************************** // HELICOPTER // ***************************************************************************************************************** // create and setup a Helicopter config widget - QWidget *ccpmConfigWidget = new QWidget(); - m_ccpmUi = new Ui_CcpmConfigWidget(); - m_ccpmUi->setupUi(ccpmConfigWidget); - m_aircraft->airframesWidget->addWidget(ccpmConfigWidget); +// QWidget *ccpmConfigWidget = new QWidget(); +// m_ccpmUi = new Ui_CcpmConfigWidget(); +// m_ccpmUi->setupUi(ccpmConfigWidget); +// m_aircraft->airframesWidget->addWidget(ccpmConfigWidget); - m_heli = m_ccpmUi->widget_3; - m_heli->setupUI(QString("HeliCP")); + m_heli = new ConfigCcpmWidget(); + m_aircraft->airframesWidget->addWidget(m_heli); + + //m_heli = m_ccpmUi->widget_3; + //m_heli->setupUI(QString("HeliCP")); //mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); @@ -199,45 +172,49 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // ***************************************************************************************************************** // create and setup a GroundVehicle config widget - qDebug() << "create ground ui"; - QWidget *groundConfigWidget = new QWidget(); - m_groundUi = new Ui_GroundConfigWidget(); - m_groundUi->setupUi(groundConfigWidget); - m_aircraft->airframesWidget->addWidget(groundConfigWidget); +// QWidget *groundConfigWidget = new QWidget(); +// m_groundUi = new Ui_GroundConfigWidget(); +// m_groundUi->setupUi(groundConfigWidget); +// m_aircraft->airframesWidget->addWidget(groundConfigWidget); - m_groundvehicle = new ConfigGroundVehicleWidget(m_groundUi); - m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText()); + m_groundvehicle = new ConfigGroundVehicleWidget(); + //m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText()); + m_aircraft->airframesWidget->addWidget(m_groundvehicle); - QStringList groundVehicleTypes; - groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; - m_groundUi->groundVehicleType->addItems(groundVehicleTypes); - m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)" +// QStringList groundVehicleTypes; +// groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; +// m_groundUi->groundVehicleType->addItems(groundVehicleTypes); +// m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)" - connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); +// connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); // ***************************************************************************************************************** // CUSTOM // ***************************************************************************************************************** - QWidget *customConfigWidget = new QWidget(); - m_customUi = new Ui_CustomConfigWidget(); - m_customUi->setupUi(customConfigWidget); - m_aircraft->airframesWidget->addWidget(customConfigWidget); + m_custom = new ConfigCustomWidget(); + m_aircraft->airframesWidget->addWidget(m_custom); - // Put combo boxes in line one of the custom mixer table: - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - UAVObjectField* field = obj->getField(QString("Mixer1Type")); - QStringList list = field->getOptions(); - for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { - QComboBox* qb = new QComboBox(m_customUi->customMixerTable); - qb->addItems(list); - m_customUi->customMixerTable->setCellWidget(0,i,qb); - } - SpinBoxDelegate *sbd = new SpinBoxDelegate(); - for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { - m_customUi->customMixerTable->setItemDelegateForRow(i, sbd); - } +// QWidget *customConfigWidget = new QWidget(); +// m_customUi = new Ui_CustomConfigWidget(); +// m_customUi->setupUi(customConfigWidget); +// m_aircraft->airframesWidget->addWidget(customConfigWidget); + +// // Put combo boxes in line one of the custom mixer table: +// UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// UAVObjectField* field = obj->getField(QString("Mixer1Type")); +// QStringList list = field->getOptions(); +// for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { +// QComboBox* qb = new QComboBox(m_customUi->customMixerTable); +// qb->addItems(list); +// m_customUi->customMixerTable->setCellWidget(0,i,qb); +// } +// +// SpinBoxDelegate *sbd = new SpinBoxDelegate(); +// for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { +// m_customUi->customMixerTable->setItemDelegateForRow(i, sbd); +// } // ***************************************************************************************************************** @@ -249,9 +226,9 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // Generate lists of mixerTypeNames, mixerVectorNames, channelNames channelNames << "None"; for (int i = 0; i < (int) ActuatorSettings::CHANNELADDR_NUMELEM; i++) { - mixerTypes << QString("Mixer%1Type").arg(i+1); - mixerVectors << QString("Mixer%1Vector").arg(i+1); - channelNames << QString("Channel%1").arg(i+1); + mixerTypes << QString("Mixer%1Type").arg(i + 1); + mixerVectors << QString("Mixer%1Vector").arg(i + 1); + channelNames << QString("Channel%1").arg(i + 1); } // NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name @@ -298,73 +275,52 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() */ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() { - int i; - QStringList channelDesc; - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager * objMngr = pm->getObject(); + UAVObjectManager *objMngr = pm->getObject(); Q_ASSERT(objMngr); // get an instance of systemsettings - SystemSettings * systemSettings = SystemSettings::GetInstance(objMngr); + SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr); Q_ASSERT(systemSettings); SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - switch (systemSettingsData.AirframeType) - { + QStringList channelDesc; + switch (systemSettingsData.AirframeType) { + case SystemSettings::AIRFRAMETYPE_FIXEDWING: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: // fixed wing - case SystemSettings::AIRFRAMETYPE_FIXEDWING: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: - { - channelDesc = ConfigFixedWingWidget::getChannelDescriptions(); - } + channelDesc = ConfigFixedWingWidget::getChannelDescriptions(); break; - + case SystemSettings::AIRFRAMETYPE_HELICP: // helicp - case SystemSettings::AIRFRAMETYPE_HELICP: - { - channelDesc = ConfigCcpmWidget::getChannelDescriptions(); - } + channelDesc = ConfigCcpmWidget::getChannelDescriptions(); break; - - //multirotor - case SystemSettings::AIRFRAMETYPE_VTOL: - case SystemSettings::AIRFRAMETYPE_TRI: - case SystemSettings::AIRFRAMETYPE_QUADX: - case SystemSettings::AIRFRAMETYPE_QUADP: - case SystemSettings::AIRFRAMETYPE_OCTOV: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: - case SystemSettings::AIRFRAMETYPE_OCTO: - case SystemSettings::AIRFRAMETYPE_HEXAX: - case SystemSettings::AIRFRAMETYPE_HEXACOAX: - case SystemSettings::AIRFRAMETYPE_HEXA: - { - channelDesc = ConfigMultiRotorWidget::getChannelDescriptions(); - } + case SystemSettings::AIRFRAMETYPE_VTOL: + case SystemSettings::AIRFRAMETYPE_TRI: + case SystemSettings::AIRFRAMETYPE_QUADX: + case SystemSettings::AIRFRAMETYPE_QUADP: + case SystemSettings::AIRFRAMETYPE_OCTOV: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: + case SystemSettings::AIRFRAMETYPE_OCTO: + case SystemSettings::AIRFRAMETYPE_HEXAX: + case SystemSettings::AIRFRAMETYPE_HEXACOAX: + case SystemSettings::AIRFRAMETYPE_HEXA: + // multirotor + channelDesc = ConfigMultiRotorWidget::getChannelDescriptions(); break; - + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: // ground - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: - { - channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions(); - } + channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions(); break; - - default: - { - for (i=0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) - channelDesc.append(QString("-")); - } + default: + channelDesc = ConfigCustomWidget::getChannelDescriptions(); break; } -// for (i=0; i < channelDesc.count(); i++) -// qDebug() << QString("Channel %0 = %1").arg(i).arg(channelDesc[i]); - return channelDesc; } @@ -376,83 +332,83 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() */ void ConfigVehicleTypeWidget::switchAirframeType(int index) { + //m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); + //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); +// m_customUi->customMixerTable->resizeColumnsToContents(); +// for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { +// m_customUi->customMixerTable->setColumnWidth(i, +// (m_customUi->customMixerTable->width() - m_customUi->customMixerTable->verticalHeader()->width()) / 10); +// } + m_aircraft->airframesWidget->setCurrentIndex(index); - m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); - m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); - m_customUi->customMixerTable->resizeColumnsToContents(); - for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { - m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- - m_customUi->customMixerTable->verticalHeader()->width())/ 10); - } } /** WHAT DOES THIS DO??? */ -void ConfigVehicleTypeWidget::showEvent(QShowEvent *event) -{ - Q_UNUSED(event) - // Thit fitInView method should only be called now, once the - // widget is shown, otherwise it cannot compute its values and - // the result is usually a ahrsbargraph that is way too small. - m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); - m_customUi->customMixerTable->resizeColumnsToContents(); - for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { - m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- - m_customUi->customMixerTable->verticalHeader()->width())/ 10); - } -} +//void ConfigVehicleTypeWidget::showEvent(QShowEvent *event) +//{ +// Q_UNUSED(event) +// // Thit fitInView method should only be called now, once the +// // widget is shown, otherwise it cannot compute its values and +// // the result is usually a ahrsbargraph that is way too small. +// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); +//// m_customUi->customMixerTable->resizeColumnsToContents(); +//// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { +//// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- +//// m_customUi->customMixerTable->verticalHeader()->width())/ 10); +//// } +//} /** Resize the GUI contents when the user changes the window size */ -void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent* event) -{ - Q_UNUSED(event); - m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); - // Make the custom table columns autostretch: - m_customUi->customMixerTable->resizeColumnsToContents(); - for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { - m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- - m_customUi->customMixerTable->verticalHeader()->width())/ 10); - } +//void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent *event) +//{ +// Q_UNUSED(event); +// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); +// // Make the custom table columns autostretch: +// m_customUi->customMixerTable->resizeColumnsToContents(); +// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { +// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- +// m_customUi->customMixerTable->verticalHeader()->width())/ 10); +// } +// +//} -} +//void ConfigVehicleTypeWidget::toggleAileron2(int index) +//{ +// if (index) { +// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true); +// m_fixedwingUi->fwAileron2Label->setEnabled(true); +// } else { +// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false); +// m_fixedwingUi->fwAileron2Label->setEnabled(false); +// } +//} +//void ConfigVehicleTypeWidget::toggleElevator2(int index) +//{ +// if (index) { +// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true); +// m_fixedwingUi->fwElevator2Label->setEnabled(true); +// } else { +// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false); +// m_fixedwingUi->fwElevator2Label->setEnabled(false); +// } +//} -void ConfigVehicleTypeWidget::toggleAileron2(int index) -{ - if (index) { - m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true); - m_fixedwingUi->fwAileron2Label->setEnabled(true); - } else { - m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false); - m_fixedwingUi->fwAileron2Label->setEnabled(false); - } -} - -void ConfigVehicleTypeWidget::toggleElevator2(int index) -{ - if (index) { - m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true); - m_fixedwingUi->fwElevator2Label->setEnabled(true); - } else { - m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false); - m_fixedwingUi->fwElevator2Label->setEnabled(false); - } -} - -void ConfigVehicleTypeWidget::toggleRudder2(int index) -{ - if (index) { - m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true); - m_fixedwingUi->fwRudder2Label->setEnabled(true); - } else { - m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false); - m_fixedwingUi->fwRudder2Label->setEnabled(false); - } -} +//void ConfigVehicleTypeWidget::toggleRudder2(int index) +//{ +// if (index) { +// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true); +// m_fixedwingUi->fwRudder2Label->setEnabled(true); +// } else { +// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false); +// m_fixedwingUi->fwRudder2Label->setEnabled(false); +// } +//} ///////////////////////////////////////////////////////// /// Feed Forward Testing @@ -522,81 +478,84 @@ void ConfigVehicleTypeWidget::enableFFTest() /** Refreshes the current value of the SystemSettings which holds the aircraft type */ -void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject * o) +void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) { Q_UNUSED(o); qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin"; - if(!allObjectsUpdated()) + if (!allObjectsUpdated()) { return; + } bool dirty = isDirty(); qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty; // Get the Airframe type from the system settings: - UAVDataObject* system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); Q_ASSERT(system); UAVObjectField *field = system->getField(QString("AirframeType")); Q_ASSERT(field); + // At this stage, we will need to have some hardcoded settings in this code, this // is not ideal, but there you go. QString frameType = field->getValue().toString(); qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; setupAirframeUI(frameType); - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - QPointer vconfig = new VehicleConfig(); - - QList curveValues; - vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); +// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(mixer); +// +// QPointer vconfig = new VehicleConfig(); +// +// QList curveValues; +// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); // is at least one of the curve values != 0? - if (vconfig->isValidThrottleCurve(&curveValues)) { - // yes, use the curve we just read from mixersettings - m_multirotorUi->multiThrottleCurve->initCurve(&curveValues); - m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues); - m_groundUi->groundVehicleThrottle1->initCurve(&curveValues); - } - else { - // no, init a straight curve - m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); - m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); - m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); - } +// if (vconfig->isValidThrottleCurve(&curveValues)) { +// // yes, use the curve we just read from mixersettings +// //m_multirotorUi->multiThrottleCurve->initCurve(&curveValues); +// //m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues); +// //m_groundUi->groundVehicleThrottle1->initCurve(&curveValues); +// } +// else { +// // no, init a straight curve +// //m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); +// //m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); +// //m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); +// } // Setup all Throttle2 curves for all types of airframes //AT THIS MOMENT, THAT MEANS ONLY GROUND VEHICLES - vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); +// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); +// +// if (vconfig->isValidThrottleCurve(&curveValues)) { +// m_groundUi->groundVehicleThrottle2->initCurve(&curveValues); +// } +// else { +// m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); +// } - if (vconfig->isValidThrottleCurve(&curveValues)) { - m_groundUi->groundVehicleThrottle2->initCurve(&curveValues); - } - else { - m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); - } - - // Load the Settings for fixed wing frames: if (frameType.startsWith("FixedWing")) { // Retrieve fixed wing settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); m_fixedwing->refreshWidgetsValues(frameType); - } else if (frameType == "Tri" || - frameType == "QuadX" || frameType == "QuadP" || - frameType == "Hexa" || frameType == "HexaCoax" || frameType == "HexaX" || - frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP" || frameType == "OctoCoaxX" ) { - - // Retrieve multirotor settings - m_multirotor->refreshWidgetsValues(frameType); + } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" + || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV" + || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") { + // Retrieve multirotor settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); + m_multirotor->refreshWidgetsValues(frameType); } else if (frameType == "HeliCP") { setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); m_heli->refreshWidgetsValues(frameType); } else if (frameType.startsWith("GroundVehicle")) { // Retrieve ground vehicle settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); m_groundvehicle->refreshWidgetsValues(frameType); } else if (frameType == "Custom") { setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); + m_custom->refreshWidgetsValues(frameType); } updateCustomAirframeUI(); @@ -614,36 +573,31 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin"; qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType; bool dirty = isDirty(); + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { m_fixedwing->setupUI(frameType); - } - else if (frameType == "Tri" || frameType == "Tricopter Y" || - frameType == "QuadX" || frameType == "Quad X" || - frameType == "QuadP" || frameType == "Quad +" || - frameType == "Hexa" || frameType == "Hexacopter" || - frameType == "HexaX" || frameType == "Hexacopter X" || - frameType == "HexaCoax" || frameType == "Hexacopter Y6" || - frameType == "Octo" || frameType == "Octocopter" || - frameType == "OctoV" || frameType == "Octocopter V" || - frameType == "OctoCoaxP" || frameType == "Octo Coax +" || - frameType == "OctoCoaxX" || frameType == "Octo Coax X" ) { - - //Call multi-rotor setup UI - m_multirotor->setupUI(frameType); - } - else if (frameType == "HeliCP") { + } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" + || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" + || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax" + || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV" + || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" + || frameType == "OctoCoaxX" || frameType == "Octo Coax X") { + + m_multirotor->setupUI(frameType); + } else if (frameType == "HeliCP") { m_heli->setupUI(frameType); - } - else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" || - frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" || - frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { + } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" + || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" + || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { m_groundvehicle->setupUI(frameType); + } else { + m_custom->setupUI(frameType); } - + //SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST??? - m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); - m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); + //m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); + //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); setDirty(dirty); qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; @@ -655,8 +609,8 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) */ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field) { - for (unsigned int i=0;igetNumElements();i++) { - field->setValue(0,i); + for (unsigned int i = 0; i < field->getNumElements(); i++) { + field->setValue(0, i); } } @@ -665,6 +619,7 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field) Note: does NOT ask for an object refresh itself! */ +// TODO rename to FF void ConfigVehicleTypeWidget::updateCustomAirframeUI() { UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); @@ -672,61 +627,61 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() QPointer vconfig = new VehicleConfig(); - QList curveValues; - vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); - - // is at least one of the curve values != 0? - if (vconfig->isValidThrottleCurve(&curveValues)) { - m_customUi->customThrottle1Curve->initCurve(&curveValues); - } - else { - // no, init a straight curve - m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); - } - - if (MixerSettings* mxr = qobject_cast(mixer)) { - MixerSettings::DataFields mixerSettingsData = mxr->getData(); - if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE) - m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); - else { - m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); - } - } - - // Setup all Throttle2 curves for all types of airframes - vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); - - if (vconfig->isValidThrottleCurve(&curveValues)) { - m_customUi->customThrottle2Curve->initCurve(&curveValues); - } - else { - m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin()); - } - - // Update the mixer table: - for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) { - UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); - if (field) - { - QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); - if (q) - { - QString s = field->getValue().toString(); - setComboCurrentIndex(q, q->findText(s)); - } - - m_customUi->customMixerTable->item(1,channel)->setText( - QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1))); - m_customUi->customMixerTable->item(2,channel)->setText( - QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2))); - m_customUi->customMixerTable->item(3,channel)->setText( - QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL))); - m_customUi->customMixerTable->item(4,channel)->setText( - QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH))); - m_customUi->customMixerTable->item(5,channel)->setText( - QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW))); - } - } +// QList curveValues; +// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); +// +// // is at least one of the curve values != 0? +// if (vconfig->isValidThrottleCurve(&curveValues)) { +// m_customUi->customThrottle1Curve->initCurve(&curveValues); +// } +// else { +// // no, init a straight curve +// m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); +// } +// +// if (MixerSettings* mxr = qobject_cast(mixer)) { +// MixerSettings::DataFields mixerSettingsData = mxr->getData(); +// if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE) +// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); +// else { +// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); +// } +// } +// +// // Setup all Throttle2 curves for all types of airframes +// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); +// +// if (vconfig->isValidThrottleCurve(&curveValues)) { +// m_customUi->customThrottle2Curve->initCurve(&curveValues); +// } +// else { +// m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin()); +// } +// +// // Update the mixer table: +// for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) { +// UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); +// if (field) +// { +// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); +// if (q) +// { +// QString s = field->getValue().toString(); +// setComboCurrentIndex(q, q->findText(s)); +// } +// +// m_customUi->customMixerTable->item(1,channel)->setText( +// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1))); +// m_customUi->customMixerTable->item(2,channel)->setText( +// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2))); +// m_customUi->customMixerTable->item(3,channel)->setText( +// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL))); +// m_customUi->customMixerTable->item(4,channel)->setText( +// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH))); +// m_customUi->customMixerTable->item(5,channel)->setText( +// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW))); +// } +// } // Update feed forward settings m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer,"FeedForward") * 100); @@ -745,7 +700,7 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() */ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() { - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); QPointer vconfig = new VehicleConfig(); @@ -756,7 +711,8 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - QString airframeType = "Custom"; //Sets airframe type default to "Custom" + // Sets airframe type default to "Custom" + QString airframeType = "Custom"; if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { airframeType = m_fixedwing->updateConfigObjectsFromWidgets(); } @@ -770,57 +726,59 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); } else { - vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve()); - vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve()); - - // Update the table: - for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) { - QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); - if(q->currentText()=="Disabled") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); - else if(q->currentText()=="Motor") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); - else if(q->currentText()=="Servo") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); - else if(q->currentText()=="CameraRoll") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL); - else if(q->currentText()=="CameraPitch") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH); - else if(q->currentText()=="CameraYaw") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW); - else if(q->currentText()=="Accessory0") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0); - else if(q->currentText()=="Accessory1") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1); - else if(q->currentText()=="Accessory2") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2); - else if(q->currentText()=="Accessory3") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3); - else if(q->currentText()=="Accessory4") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4); - else if(q->currentText()=="Accessory5") - vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5); - - vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, - m_customUi->customMixerTable->item(1,channel)->text().toDouble()); - vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2, - m_customUi->customMixerTable->item(2,channel)->text().toDouble()); - vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL, - m_customUi->customMixerTable->item(3,channel)->text().toDouble()); - vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH, - m_customUi->customMixerTable->item(4,channel)->text().toDouble()); - vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW, - m_customUi->customMixerTable->item(5,channel)->text().toDouble()); - } + airframeType = m_custom->updateConfigObjectsFromWidgets(); +// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve()); +// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve()); +// +// // Update the table: +// for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) { +// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); +// if(q->currentText()=="Disabled") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); +// else if(q->currentText()=="Motor") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); +// else if(q->currentText()=="Servo") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); +// else if(q->currentText()=="CameraRoll") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL); +// else if(q->currentText()=="CameraPitch") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH); +// else if(q->currentText()=="CameraYaw") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW); +// else if(q->currentText()=="Accessory0") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0); +// else if(q->currentText()=="Accessory1") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1); +// else if(q->currentText()=="Accessory2") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2); +// else if(q->currentText()=="Accessory3") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3); +// else if(q->currentText()=="Accessory4") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4); +// else if(q->currentText()=="Accessory5") +// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5); +// +// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, +// m_customUi->customMixerTable->item(1,channel)->text().toDouble()); +// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2, +// m_customUi->customMixerTable->item(2,channel)->text().toDouble()); +// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL, +// m_customUi->customMixerTable->item(3,channel)->text().toDouble()); +// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH, +// m_customUi->customMixerTable->item(4,channel)->text().toDouble()); +// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW, +// m_customUi->customMixerTable->item(5,channel)->text().toDouble()); +// } } // set the airframe type - UAVDataObject* system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); Q_ASSERT(system); QPointer field = system->getField(QString("AirframeType")); - if (field) + if (field) { field->setValue(airframeType); + } updateCustomAirframeUI(); } @@ -830,7 +788,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() */ void ConfigVehicleTypeWidget::openHelp() { - QDesktopServices::openUrl( QUrl("http://wiki.openpilot.org/x/44Cf", QUrl::StrictMode) ); } @@ -841,16 +798,11 @@ void ConfigVehicleTypeWidget::openHelp() */ void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox* box, int index) { - if (index >= 0 && index < box->count()) + if (index >= 0 && index < box->count()) { box->setCurrentIndex(index); + } } -void ConfigVehicleTypeWidget::reverseMultirotorMotor(){ - QString frameType = m_multirotorUi->multirotorFrameType->currentText(); - m_multirotor->drawAirframe(frameType); -} - - /** WHAT DOES THIS DO??? */ diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index c1ad6b473..2a4bb867e 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -28,29 +28,14 @@ #define CONFIGVEHICLETYPEWIDGET_H #include "ui_airframe.h" -#include "../uavobjectwidgetutils/configtaskwidget.h" -#include "extensionsystem/pluginmanager.h" -#include "uavobjectmanager.h" -#include "uavobject.h" -#include "uavtalk/telemetrymanager.h" - #include "cfg_vehicletypes/vehicleconfig.h" -#include "cfg_vehicletypes/configccpmwidget.h" -#include "cfg_vehicletypes/configfixedwingwidget.h" -#include "cfg_vehicletypes/configgroundvehiclewidget.h" -#include "cfg_vehicletypes/configmultirotorwidget.h" +#include "uavobject.h" +#include "../uavobjectwidgetutils/configtaskwidget.h" -#include "ui_airframe_ccpm.h" -#include "ui_airframe_fixedwing.h" -#include "ui_airframe_ground.h" -#include "ui_airframe_multirotor.h" -#include "ui_airframe_custom.h" - -#include -#include -#include - -class Ui_Widget; +#include +#include +#include +#include class ConfigVehicleTypeWidget: public ConfigTaskWidget { @@ -65,16 +50,11 @@ public: private: Ui_AircraftWidget *m_aircraft; - Ui_CcpmConfigWidget *m_ccpmUi; - Ui_FixedWingConfigWidget *m_fixedwingUi; - Ui_MultiRotorConfigWidget *m_multirotorUi; - Ui_GroundConfigWidget *m_groundUi; - Ui_CustomConfigWidget *m_customUi; - - ConfigCcpmWidget *m_heli; - ConfigFixedWingWidget *m_fixedwing; - ConfigMultiRotorWidget *m_multirotor; - ConfigGroundVehicleWidget *m_groundvehicle; + VehicleConfig *m_heli; + VehicleConfig *m_fixedwing; + VehicleConfig *m_multirotor; + VehicleConfig *m_groundvehicle; + VehicleConfig *m_custom; void updateCustomAirframeUI(); void addToDirtyMonitor(); @@ -86,7 +66,6 @@ private: QStringList mixerTypes; QStringList mixerVectors; - QGraphicsSvgItem *quad; bool ffTuningInProgress; bool ffTuningPhase; UAVObject::Metadata accInitialData; @@ -100,36 +79,14 @@ private slots: void setupAirframeUI(QString type); - void toggleAileron2(int index); - void toggleElevator2(int index); - void toggleRudder2(int index); +// void toggleAileron2(int index); +// void toggleElevator2(int index); +// void toggleRudder2(int index); void switchAirframeType(int index); void enableFFTest(); void openHelp(); - void reverseMultirotorMotor(); -protected: - void showEvent(QShowEvent *event); - void resizeEvent(QResizeEvent *event); - - - -}; - -class SpinBoxDelegate : public QItemDelegate -{ - Q_OBJECT - -public: - SpinBoxDelegate(QObject *parent = 0); - - QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const; - - void setEditorData(QWidget *editor, const QModelIndex &index) const; - void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const; - - void updateEditorGeometry(QWidget *editor, const QStyleOptionViewItem &option, const QModelIndex &index) const; }; #endif // CONFIGVEHICLETYPEWIDGET_H From 90b0c5ca219c7c1ebcb9149d0b10e6894510ab44 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 3 Apr 2013 01:42:42 +0200 Subject: [PATCH 07/32] OP-907 step 3: cleaned up vehicleconfig.h + related cleanups --- .../cfg_vehicletypes/configccpmwidget.cpp | 596 +++++++++--------- .../cfg_vehicletypes/configccpmwidget.h | 40 +- .../cfg_vehicletypes/configcustomwidget.cpp | 5 + .../cfg_vehicletypes/configcustomwidget.h | 26 +- .../configfixedwingwidget.cpp | 8 +- .../cfg_vehicletypes/configfixedwingwidget.h | 15 +- .../configgroundvehiclewidget.cpp | 10 +- .../configgroundvehiclewidget.h | 14 +- .../configmultirotorwidget.cpp | 4 +- .../cfg_vehicletypes/configmultirotorwidget.h | 28 +- .../config/cfg_vehicletypes/vehicleconfig.cpp | 13 +- .../config/cfg_vehicletypes/vehicleconfig.h | 16 +- 12 files changed, 381 insertions(+), 394 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 7b322f10e..02cb3894a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -42,6 +42,71 @@ #define Pi 3.14159265358979323846 +QStringList ConfigCcpmWidget::getChannelDescriptions() +{ + int i; + QStringList channelDesc; + + // init a channel_numelem list of channel desc defaults + for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++) + { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + heliGUISettingsStruct heli = configData.heli; + + if (heli.Throttle > 0) + channelDesc[heli.Throttle - 1] = QString("Throttle"); + if (heli.Tail > 0) + channelDesc[heli.Tail - 1] = QString("Tail"); + + switch(heli.FirstServoIndex) + { + case 0: //front + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + break; + + case 1: //right + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + break; + + case 2: //rear + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + break; + + case 3: //left + if (heli.ServoIndexW > 0) + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + if (heli.ServoIndexX > 0) + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + if (heli.ServoIndexY > 0) + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + break; + + } + if (heli.ServoIndexZ > 0) + channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); + + return channelDesc; +} + ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget()) { @@ -210,7 +275,7 @@ void ConfigCcpmWidget::setupUI(QString frameType) Q_UNUSED(frameType); } -void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigCcpmWidget::resetActuators(GUIConfigDataUnion *configData) { configData->heli.Throttle = 0; configData->heli.Tail = 0; @@ -220,197 +285,96 @@ void ConfigCcpmWidget::ResetActuators(GUIConfigDataUnion* configData) configData->heli.ServoIndexZ = 0; } -QStringList ConfigCcpmWidget::getChannelDescriptions() -{ - int i; - QStringList channelDesc; - - // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++) - { - channelDesc.append(QString("-")); - } - - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - heliGUISettingsStruct heli = configData.heli; - - if (heli.Throttle > 0) - channelDesc[heli.Throttle - 1] = QString("Throttle"); - if (heli.Tail > 0) - channelDesc[heli.Tail - 1] = QString("Tail"); - - switch(heli.FirstServoIndex) - { - case 0: //front - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); - break; - - case 1: //right - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); - break; - - case 2: //rear - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); - break; - - case 3: //left - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); - break; - - } - if (heli.ServoIndexZ > 0) - channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); - - return channelDesc; -} - void ConfigCcpmWidget::UpdateType() { - int TypeInt,SingleServoIndex,NumServosDefined; - double AdjustmentAngle=0; + int TypeInt, SingleServoIndex, NumServosDefined; + double AdjustmentAngle = 0; SetUIComponentVisibilities(); - - TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1; + + TypeInt = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1; TypeText = m_aircraft->ccpmType->currentText(); SingleServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); //set visibility of user settings - m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt==0); - m_aircraft->ccpmAdvancedSettingsTable->clearFocus();; + m_aircraft->ccpmAdvancedSettingsTable->setEnabled(TypeInt == 0); + m_aircraft->ccpmAdvancedSettingsTable->clearFocus(); - m_aircraft->ccpmAngleW->setEnabled(TypeInt==1); - m_aircraft->ccpmAngleX->setEnabled(TypeInt==1); - m_aircraft->ccpmAngleY->setEnabled(TypeInt==1); - m_aircraft->ccpmAngleZ->setEnabled(TypeInt==1); - m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt!=0); + m_aircraft->ccpmAngleW->setEnabled(TypeInt == 1); + m_aircraft->ccpmAngleX->setEnabled(TypeInt == 1); + m_aircraft->ccpmAngleY->setEnabled(TypeInt == 1); + m_aircraft->ccpmAngleZ->setEnabled(TypeInt == 1); + m_aircraft->ccpmCorrectionAngle->setEnabled(TypeInt != 0); - m_aircraft->ccpmServoWChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmServoXChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmServoYChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmServoZChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmSingleServo->setEnabled(TypeInt>1); + m_aircraft->ccpmServoWChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmServoXChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmServoYChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmServoZChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmSingleServo->setEnabled(TypeInt > 1); - m_aircraft->ccpmEngineChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmTailChannel->setEnabled(TypeInt>0); - m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt>0); - m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt>0); - m_aircraft->ccpmRevoSlider->setEnabled(TypeInt>0); - m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt>0); + m_aircraft->ccpmEngineChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmTailChannel->setEnabled(TypeInt > 0); + m_aircraft->ccpmCollectiveSlider->setEnabled(TypeInt > 0); + m_aircraft->ccpmCollectivespinBox->setEnabled(TypeInt > 0); + m_aircraft->ccpmRevoSlider->setEnabled(TypeInt > 0); + m_aircraft->ccpmREVOspinBox->setEnabled(TypeInt > 0); - AdjustmentAngle=SingleServoIndex*90; + AdjustmentAngle = SingleServoIndex * 90; m_aircraft->PitchCurve->setVisible(1); - NumServosDefined=4; + NumServosDefined = 4; //set values for pre defined heli types - if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(0); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleY->setEnabled(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoYChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoYChannel->setEnabled(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=2; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=3; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180,360)); - m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270,360)); - m_aircraft->ccpmSingleServo->setEnabled(0); - m_aircraft->ccpmSingleServo->setCurrentIndex(0); - NumServosDefined=4; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240,360)); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=3; - - } - else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140,360)); - m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220,360)); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - NumServosDefined=3; - - } - else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); - m_aircraft->ccpmAngleY->setValue(0); - m_aircraft->ccpmAngleZ->setValue(0); - m_aircraft->ccpmAngleY->setEnabled(0); - m_aircraft->ccpmAngleZ->setEnabled(0); - m_aircraft->ccpmServoYChannel->setCurrentIndex(0); - m_aircraft->ccpmServoZChannel->setCurrentIndex(0); - m_aircraft->ccpmServoYChannel->setEnabled(0); - m_aircraft->ccpmServoZChannel->setEnabled(0); - - m_aircraft->ccpmCollectivespinBox->setEnabled(0); - m_aircraft->ccpmCollectiveSlider->setEnabled(0); - m_aircraft->ccpmCollectivespinBox->setValue(0); - m_aircraft->ccpmCollectiveSlider->setValue(0); - m_aircraft->PitchCurve->setVisible(0); - NumServosDefined=2; - } - else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - { + if (TypeText.compare(QString::fromUtf8("CCPM 2 Servo 90º"), Qt::CaseInsensitive) == 0) { m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); - m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90,360)); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 2; + } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 3; + } else if (TypeText.compare(QString::fromUtf8("CCPM 4 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 180, 360)); + m_aircraft->ccpmAngleZ->setValue(fmod(AdjustmentAngle + 270, 360)); + m_aircraft->ccpmSingleServo->setEnabled(0); + m_aircraft->ccpmSingleServo->setCurrentIndex(0); + NumServosDefined = 4; + } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 120º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 120, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 240, 360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 3; + } else if (TypeText.compare(QString::fromUtf8("CCPM 3 Servo 140º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 140, 360)); + m_aircraft->ccpmAngleY->setValue(fmod(AdjustmentAngle + 220, 360)); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + NumServosDefined = 3; + } else if (TypeText.compare(QString::fromUtf8("FP 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); m_aircraft->ccpmAngleY->setValue(0); m_aircraft->ccpmAngleZ->setValue(0); m_aircraft->ccpmAngleY->setEnabled(0); @@ -425,55 +389,66 @@ void ConfigCcpmWidget::UpdateType() m_aircraft->ccpmCollectivespinBox->setValue(0); m_aircraft->ccpmCollectiveSlider->setValue(0); m_aircraft->PitchCurve->setVisible(0); - NumServosDefined=2; + NumServosDefined = 2; + } else if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + m_aircraft->ccpmAngleW->setValue(AdjustmentAngle + 0); + m_aircraft->ccpmAngleX->setValue(fmod(AdjustmentAngle + 90, 360)); + m_aircraft->ccpmAngleY->setValue(0); + m_aircraft->ccpmAngleZ->setValue(0); + m_aircraft->ccpmAngleY->setEnabled(0); + m_aircraft->ccpmAngleZ->setEnabled(0); + m_aircraft->ccpmServoYChannel->setCurrentIndex(0); + m_aircraft->ccpmServoZChannel->setCurrentIndex(0); + m_aircraft->ccpmServoYChannel->setEnabled(0); + m_aircraft->ccpmServoZChannel->setEnabled(0); + m_aircraft->ccpmCollectivespinBox->setEnabled(0); + m_aircraft->ccpmCollectiveSlider->setEnabled(0); + m_aircraft->ccpmCollectivespinBox->setValue(0); + m_aircraft->ccpmCollectiveSlider->setValue(0); + m_aircraft->PitchCurve->setVisible(0); + NumServosDefined = 2; } //Set the text of the motor boxes - if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - { + if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { m_aircraft->ccpmEngineLabel->setText("CW motor"); m_aircraft->ccpmTailLabel->setText("CCW motor"); - } - else{ + } else { m_aircraft->ccpmEngineLabel->setText("Engine"); m_aircraft->ccpmTailLabel->setText("Tail rotor"); } //set the visibility of the swashplate servo selection boxes - m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined>=1); - m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined>=2); - m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined>=3); - m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined>=4); - m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined>=1); - m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined>=2); - m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined>=3); - m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined>=4); - - //set the visibility of the swashplate angle selection boxes - m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined>=1); - m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined>=2); - m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined>=3); - m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined>=4); - m_aircraft->ccpmAngleW->setVisible(NumServosDefined>=1); - m_aircraft->ccpmAngleX->setVisible(NumServosDefined>=2); - m_aircraft->ccpmAngleY->setVisible(NumServosDefined>=3); - m_aircraft->ccpmAngleZ->setVisible(NumServosDefined>=4); - + m_aircraft->ccpmServoWLabel->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmServoXLabel->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmServoYLabel->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmServoZLabel->setVisible(NumServosDefined >= 4); + m_aircraft->ccpmServoWChannel->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmServoXChannel->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmServoYChannel->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmServoZChannel->setVisible(NumServosDefined >= 4); - m_aircraft->ccpmAdvancedSettingsTable->resizeColumnsToContents(); - for (int i=0;i<6;i++) { - m_aircraft->ccpmAdvancedSettingsTable->setColumnWidth(i,(m_aircraft->ccpmAdvancedSettingsTable->width()- - m_aircraft->ccpmAdvancedSettingsTable->verticalHeader()->width())/6); + //set the visibility of the swashplate angle selection boxes + m_aircraft->ccpmServoWLabel_2->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmServoXLabel_2->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmServoYLabel_2->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmServoZLabel_2->setVisible(NumServosDefined >= 4); + m_aircraft->ccpmAngleW->setVisible(NumServosDefined >= 1); + m_aircraft->ccpmAngleX->setVisible(NumServosDefined >= 2); + m_aircraft->ccpmAngleY->setVisible(NumServosDefined >= 3); + m_aircraft->ccpmAngleZ->setVisible(NumServosDefined >= 4); + + QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; + table->resizeColumnsToContents(); + for (int i = 0; i < 6; i++) { + table->setColumnWidth(i, (table->width() - table->verticalHeader()->width()) / 6); } //update UI ccpmSwashplateUpdate(); - } - - void ConfigCcpmWidget::ccpmSwashplateRedraw() { double angle[CCPM_MAX_SWASH_SERVOS],CorrectionAngle,x,y,w,h,radius,CenterX,CenterY; @@ -586,8 +561,9 @@ void ConfigCcpmWidget::UpdateMixer() { bool useCCPM; bool useCyclic; - int i,j,ThisEnable[6]; - float CollectiveConstant,PitchConstant,RollConstant,ThisAngle[6]; + int ThisEnable[6]; + float CollectiveConstant, PitchConstant, RollConstant; + float ThisAngle[6]; QString Channel; if (throwConfigError(QString("HeliCP"))) @@ -598,29 +574,24 @@ void ConfigCcpmWidget::UpdateMixer() useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); useCyclic = config.heli.ccpmLinkRollState; - CollectiveConstant = (float)config.heli.SliderValue0 / 100.00; + CollectiveConstant = (float) config.heli.SliderValue0 / 100.00; - if (useCCPM) - {//cyclic = 1 - collective - PitchConstant = 1-CollectiveConstant; + if (useCCPM) { //cyclic = 1 - collective + PitchConstant = 1 - CollectiveConstant; RollConstant = PitchConstant; - } - else - { - PitchConstant = (float)config.heli.SliderValue1 / 100.00;; - if (useCyclic) - { + } else { + PitchConstant = (float) config.heli.SliderValue1 / 100.00; + ; + if (useCyclic) { RollConstant = PitchConstant; - } - else - { - RollConstant = (float)config.heli.SliderValue2 / 100.00;; - } + } else { + RollConstant = (float) config.heli.SliderValue2 / 100.00; + ; + } } - if (config.heli.SwashplateType>0) - {//not advanced settings - //get the channel data from the ui + if (config.heli.SwashplateType > 0) { //not advanced settings + //get the channel data from the ui MixerChannelData[0] = m_aircraft->ccpmEngineChannel->currentIndex(); MixerChannelData[1] = m_aircraft->ccpmTailChannel->currentIndex(); MixerChannelData[2] = m_aircraft->ccpmServoWChannel->currentIndex(); @@ -640,78 +611,92 @@ void ConfigCcpmWidget::UpdateMixer() ThisEnable[4] = m_aircraft->ccpmServoYChannel->isEnabled(); ThisEnable[5] = m_aircraft->ccpmServoZChannel->isEnabled(); - ServosText[0]->setPlainText(QString("%1").arg( MixerChannelData[2] )); - ServosText[1]->setPlainText(QString("%1").arg( MixerChannelData[3] )); - ServosText[2]->setPlainText(QString("%1").arg( MixerChannelData[4] )); - ServosText[3]->setPlainText(QString("%1").arg( MixerChannelData[5] )); - + ServosText[0]->setPlainText(QString("%1").arg(MixerChannelData[2])); + ServosText[1]->setPlainText(QString("%1").arg(MixerChannelData[3])); + ServosText[2]->setPlainText(QString("%1").arg(MixerChannelData[4])); + ServosText[3]->setPlainText(QString("%1").arg(MixerChannelData[5])); //go through the user data and update the mixer matrix - for (i=0;i<6;i++) - { - if ((MixerChannelData[i]>0) && ((ThisEnable[i])||(i<2))) - { - m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->setText(QString("%1").arg( MixerChannelData[i] )); + QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; + for (int i = 0; i < 6; i++) { + if ((MixerChannelData[i] > 0) && ((ThisEnable[i]) || (i < 2))) { + table->item(i, 0)->setText(QString("%1").arg(MixerChannelData[i])); //Generate the mixer vector - if (i==0) - {//main motor-engine - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 - m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll - m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch + if (i == 0) { //main motor-engine + table->item(i, 1)->setText(QString("%1").arg(127)); //ThrottleCurve1 + table->item(i, 2)->setText(QString("%1").arg(0)); //ThrottleCurve2 + table->item(i, 3)->setText(QString("%1").arg(0)); //Roll + table->item(i, 4)->setText(QString("%1").arg(0)); //Pitch - if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(-127));//Yaw - else - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw - - } - if (i==1) - {//tailrotor --or-- counter-clockwise motor - if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive)==0) - { - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(127));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw - } - else{ - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(127));//Yaw + if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + // Yaw + table->item(i, 5)->setText(QString("%1").arg(-127)); + } else { + // Yaw + table->item(i, 5)->setText(QString("%1").arg(0)); } - m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg(0));//ThrottleCurve2 - m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg(0));//Roll - m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg(0));//Pitch + } + if (i == 1) { + // tailrotor --or-- counter-clockwise motor + if (TypeText.compare(QString::fromUtf8("Coax 2 Servo 90º"), Qt::CaseInsensitive) == 0) { + // ThrottleCurve1 + table->item(i, 1)->setText(QString("%1").arg(127)); + // Yaw + table->item(i, 5)->setText(QString("%1").arg(127)); + } else { + // ThrottleCurve1 + table->item(i, 1)->setText(QString("%1").arg(0)); + // Yaw + table->item(i, 5)->setText(QString("%1").arg(127)); + } + //ThrottleCurve2 + table->item(i, 2)->setText(QString("%1").arg(0)); + // Roll + table->item(i, 3)->setText(QString("%1").arg(0)); + // Pitch + table->item(i, 4)->setText(QString("%1").arg(0)); } - if (i>1) - {//Swashplate - m_aircraft->ccpmAdvancedSettingsTable->item(i,1)->setText(QString("%1").arg(0));//ThrottleCurve1 - m_aircraft->ccpmAdvancedSettingsTable->item(i,2)->setText(QString("%1").arg((int)(127.0*CollectiveConstant)));//ThrottleCurve2 - m_aircraft->ccpmAdvancedSettingsTable->item(i,3)->setText(QString("%1").arg((int)(127.0*(RollConstant)*sin((180+config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Roll - m_aircraft->ccpmAdvancedSettingsTable->item(i,4)->setText(QString("%1").arg((int)(127.0*(PitchConstant)*cos((config.heli.CorrectionAngle + ThisAngle[i])*Pi/180.00))));//Pitch - m_aircraft->ccpmAdvancedSettingsTable->item(i,5)->setText(QString("%1").arg(0));//Yaw + if (i > 1) { + // Swashplate + //ThrottleCurve1 + table->item(i, 1)->setText(QString("%1").arg(0)); + //ThrottleCurve2 + table->item(i, 2)->setText(QString("%1").arg((int) (127.0 * CollectiveConstant))); + table->item(i, 3)->setText( + QString("%1").arg( + (int) (127.0 * (RollConstant) + * sin((180 + config.heli.CorrectionAngle + ThisAngle[i]) * Pi / 180.00)))); //Roll + table->item(i, 4)->setText( + QString("%1").arg( + (int) (127.0 * (PitchConstant) + * cos((config.heli.CorrectionAngle + ThisAngle[i]) * Pi / 180.00)))); //Pitch + // Yaw + table->item(i, 5)->setText(QString("%1").arg(0)); } - } - else - { - for (j=0;j<6;j++) m_aircraft->ccpmAdvancedSettingsTable->item(i,j)->setText(QString("-")); + } else { + for (int j = 0; j < 6; j++) { + table->item(i, j)->setText(QString("-")); + } } } + } else { + // advanced settings + QTableWidget *table = m_aircraft->ccpmAdvancedSettingsTable; + for (int i = 0; i < 6; i++) { + Channel = table->item(i, 0)->text(); + if (Channel == "-") { + Channel = QString("9"); + } + MixerChannelData[i] = Channel.toInt(); + } } - else - {//advanced settings - for (i=0;i<6;i++) - { - Channel =m_aircraft->ccpmAdvancedSettingsTable->item(i,0)->text(); - if (Channel == "-") Channel = QString("9"); - MixerChannelData[i]= Channel.toInt(); - } - } - } + QString ConfigCcpmWidget::updateConfigObjects() { QString airframeType = "HeliCP"; @@ -719,7 +704,8 @@ QString ConfigCcpmWidget::updateConfigObjects() bool useCCPM; bool useCyclic; - if (updatingFromHardware == TRUE) return airframeType; + if (updatingFromHardware == TRUE) + return airframeType; updatingFromHardware = TRUE; @@ -727,7 +713,7 @@ QString ConfigCcpmWidget::updateConfigObjects() GUIConfigDataUnion config = GetConfigData(); //swashplate config - config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex()-1; + config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1; config.heli.FirstServoIndex = m_aircraft->ccpmSingleServo->currentIndex(); //ccpm mixing options @@ -741,20 +727,14 @@ QString ConfigCcpmWidget::updateConfigObjects() config.heli.CorrectionAngle = m_aircraft->ccpmCorrectionAngle->value(); //update sliders - if (useCCPM) - { + if (useCCPM) { config.heli.SliderValue0 = m_aircraft->ccpmCollectiveSlider->value(); - } - else - { + } else { config.heli.SliderValue0 = m_aircraft->ccpmCollectiveScale->value(); } - if (useCyclic) - { + if (useCyclic) { config.heli.SliderValue1 = m_aircraft->ccpmCyclicScale->value(); - } - else - { + } else { config.heli.SliderValue1 = m_aircraft->ccpmPitchScale->value(); } config.heli.SliderValue2 = m_aircraft->ccpmRollScale->value(); @@ -776,7 +756,7 @@ QString ConfigCcpmWidget::updateConfigObjects() return airframeType; } -QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFromUI() +QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() { QString airframeType = updateConfigObjects(); @@ -785,7 +765,7 @@ QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() //UpdateCCPMOptionsFr return airframeType; } -void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFromOptions() +void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) { Q_UNUSED(frameType); @@ -829,35 +809,34 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) //UpdateCCPMUIFro getMixer(); } - void ConfigCcpmWidget::SetUIComponentVisibilities() { m_aircraft->ccpmRevoMixingBox->setVisible(0); - - m_aircraft->ccpmPitchMixingBox->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked() && - m_aircraft->ccpmLinkCyclic->isChecked()); - m_aircraft->ccpmCollectiveScalingBox->setVisible(m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()); + m_aircraft->ccpmPitchMixingBox->setVisible( + !m_aircraft->ccpmCollectivePassthrough->isChecked() && m_aircraft->ccpmLinkCyclic->isChecked()); + + m_aircraft->ccpmCollectiveScalingBox->setVisible( + m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()); m_aircraft->ccpmLinkCyclic->setVisible(!m_aircraft->ccpmCollectivePassthrough->isChecked()); - m_aircraft->ccpmCyclicScalingBox->setVisible((m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) && - m_aircraft->ccpmLinkRoll->isChecked()); + m_aircraft->ccpmCyclicScalingBox->setVisible( + (m_aircraft->ccpmCollectivePassthrough->isChecked() || !m_aircraft->ccpmLinkCyclic->isChecked()) + && m_aircraft->ccpmLinkRoll->isChecked()); - if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked()) - { + if (!m_aircraft->ccpmCollectivePassthrough->checkState() && m_aircraft->ccpmLinkCyclic->isChecked()) { m_aircraft->ccpmPitchScalingBox->setVisible(0); m_aircraft->ccpmRollScalingBox->setVisible(0); m_aircraft->ccpmLinkRoll->setVisible(0); - } - else - { + } else { m_aircraft->ccpmPitchScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked()); m_aircraft->ccpmRollScalingBox->setVisible(!m_aircraft->ccpmLinkRoll->isChecked()); m_aircraft->ccpmLinkRoll->setVisible(1); } } + /** Request the current value of the SystemSettings which holds the ccpm type */ @@ -899,7 +878,6 @@ void ConfigCcpmWidget::getMixer() ccpmSwashplateUpdate(); } - /** Sends the config to the board (ccpm type) */ diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index 2890cffdb..c11146071 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -57,13 +57,28 @@ class ConfigCcpmWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + ConfigCcpmWidget(QWidget *parent = 0); ~ConfigCcpmWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + +public slots: + void getMixer(); + void setMixer(); + void saveccpmUpdate(); + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); private: - //Ui_ccpmWidget *m_ccpm; + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_CcpmConfigWidget *m_aircraft; QGraphicsSvgItem *SwashplateImg; @@ -86,20 +101,16 @@ private: int MixerChannelData[6]; int ShowDisclaimer(int messageID); - virtual void enableControls(bool enable) { Q_UNUSED(enable)}; // Not used by this widget + virtual void enableControls(bool enable) { Q_UNUSED(enable) }; // Not used by this widget bool updatingFromHardware; bool updatingToHardware; - virtual void ResetActuators(GUIConfigDataUnion *configData); - static QStringList getChannelDescriptions(); - + // TODO ? QString updateConfigObjects(); private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); + // TODO ? virtual bool throwConfigError(QString airframeType); void ccpmSwashplateUpdate(); @@ -120,17 +131,8 @@ private slots: void enableSwashplateLevellingControl(bool state); void setSwashplateLevel(int percent); void SwashLvlSpinBoxChanged(int value); + // TODO ? virtual void refreshValues() {}; // Not used - -public slots: - void getMixer(); - void setMixer(); - void saveccpmUpdate(); - -protected: - void showEvent(QShowEvent *event); - void resizeEvent(QResizeEvent *event); - }; #endif // CONFIGccpmWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 07c453c93..6181589cc 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -94,6 +94,11 @@ QStringList ConfigCustomWidget::getChannelDescriptions() return channelDesc; } +void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData) +{ + +} + /** Helper function to update the UI widget objects */ diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h index 08fcd549a..4b0409421 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -46,30 +46,30 @@ class ConfigCustomWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + ConfigCustomWidget(QWidget *parent = 0); ~ConfigCustomWidget(); - friend class ConfigVehicleTypeWidget; - -private: - Ui_CustomConfigWidget *m_aircraft; - - //virtual void ResetActuators(GUIConfigDataUnion *configData); - static QStringList getChannelDescriptions(); -// static const QString CHANNELBOXNAME; - -private slots: virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); - virtual bool throwConfigError(int numMotors); protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); -signals: - void configurationChanged(); +private: + virtual void resetActuators(GUIConfigDataUnion *configData); + + Ui_CustomConfigWidget *m_aircraft; + +private slots: + virtual bool throwConfigError(int numMotors); + +//signals: +// void configurationChanged(); }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 8c3ae1167..c464b56ec 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -130,7 +130,7 @@ void ConfigFixedWingWidget::setupUI(QString frameType) } } -void ConfigFixedWingWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData) { configData->fixedwing.FixedWingPitch1 = 0; configData->fixedwing.FixedWingPitch2 = 0; @@ -297,7 +297,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); @@ -369,7 +369,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) } GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); @@ -441,7 +441,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) } GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); config.fixedwing.FixedWingPitch2 = m_aircraft->fwElevator2ChannelBox->currentIndex(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 21dff9658..f7007302c 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -46,25 +46,26 @@ class ConfigFixedWingWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + ConfigFixedWingWidget(QWidget *parent = 0); ~ConfigFixedWingWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); private: + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_FixedWingConfigWidget *m_aircraft; bool setupFrameFixedWing(QString airframeType); bool setupFrameElevon(QString airframeType); bool setupFrameVtail(QString airframeType); - virtual void ResetActuators(GUIConfigDataUnion* configData); - static QStringList getChannelDescriptions(); - private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(QString airframeType); protected: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index b2e419f42..2b04a3c63 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -161,7 +161,7 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) } } -void ConfigGroundVehicleWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) { configData->ground.GroundVehicleSteering1 = 0; configData->ground.GroundVehicleSteering2 = 0; @@ -330,7 +330,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); @@ -379,14 +379,14 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); SetConfigData((config)); - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); @@ -423,7 +423,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); - ResetActuators(&config); + resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 97b35c8e4..2b38d58ea 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -46,25 +46,25 @@ class ConfigGroundVehicleWidget: public VehicleConfig Q_OBJECT public: + static QStringList getChannelDescriptions(); + ConfigGroundVehicleWidget(QWidget *parent = 0); ~ConfigGroundVehicleWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); private: + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_GroundConfigWidget *m_aircraft; bool setupGroundVehicleCar(QString airframeType); bool setupGroundVehicleDifferential(QString airframeType); bool setupGroundVehicleMotorcycle(QString airframeType); - virtual void ResetActuators(GUIConfigDataUnion* configData); - static QStringList getChannelDescriptions(); - private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(QString airframeType); protected: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index f93aceba8..4e4180dcf 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -296,7 +296,7 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType) m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); } -void ConfigMultiRotorWidget::ResetActuators(GUIConfigDataUnion* configData) +void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) { configData->multi.VTOLMotorN = 0; configData->multi.VTOLMotorNE = 0; @@ -893,7 +893,7 @@ void ConfigMultiRotorWidget::setupMotors(QList motorList) << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; GUIConfigDataUnion configData = GetConfigData(); - ResetActuators(&configData); + resetActuators(&configData); int index; foreach (QString motor, motorList) { diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 210133a48..12b9d102b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -46,12 +46,24 @@ class ConfigMultiRotorWidget: public VehicleConfig Q_OBJECT public: + + static QStringList getChannelDescriptions(); + static const QString CHANNELBOXNAME; + ConfigMultiRotorWidget(QWidget *parent = 0); ~ConfigMultiRotorWidget(); - friend class ConfigVehicleTypeWidget; + virtual void setupUI(QString airframeType); + virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); + +protected: + void showEvent(QShowEvent *event); + void resizeEvent(QResizeEvent *event); private: + virtual void resetActuators(GUIConfigDataUnion *configData); + Ui_MultiRotorConfigWidget *m_aircraft; QWidget *uiowner; @@ -66,28 +78,14 @@ private: float invertMotors; - virtual void ResetActuators(GUIConfigDataUnion *configData); - static QStringList getChannelDescriptions(); - static const QString CHANNELBOXNAME; void setYawMixLevel(int); void drawAirframe(QString multiRotorType); private slots: - virtual void setupUI(QString airframeType); - virtual void refreshWidgetsValues(QString frameType); - virtual QString updateConfigObjectsFromWidgets(); virtual bool throwConfigError(int numMotors); void reverseMultirotorMotor(); - -protected: - void showEvent(QShowEvent *event); - void resizeEvent(QResizeEvent *event); - -signals: - void configurationChanged(); - }; #endif // CONFIGMULTIROTORWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index caba82a7f..d9e5cbf00 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -35,7 +35,7 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) { - //Generate lists of mixerTypeNames, mixerVectorNames, channelNames + // Generate lists of mixerTypeNames, mixerVectorNames, channelNames channelNames << "None"; for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) { mixerTypes << QString("Mixer%1Type").arg(i+1); @@ -50,7 +50,7 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) // This is needed because new style tries to compact things as much as possible in grid // and on OSX the widget sizes of PushButtons is reported incorrectly: // https://bugreports.qt-project.org/browse/QTBUG-14591 - foreach( QPushButton * btn, findChildren() ) { + foreach(QPushButton *btn, findChildren()) { btn->setAttribute(Qt::WA_LayoutUsesWidgetRect); } } @@ -107,7 +107,6 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) { void VehicleConfig::setupUI(QString frameType) { - } QString VehicleConfig::updateConfigObjectsFromWidgets() @@ -119,7 +118,7 @@ void VehicleConfig::refreshWidgetsValues(QString frameType) { } -void VehicleConfig::ResetActuators(GUIConfigDataUnion *configData) +void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) { } @@ -277,7 +276,7 @@ void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveEle break; } - if (field && field->getNumElements() == curve.length()) { + if (field && (field->getNumElements() == (unsigned int) curve.length())) { for (int i = 0; i < curve.length(); i++) { field->setValue(curve.at(i), i); } @@ -338,6 +337,7 @@ double VehicleConfig::getCurveMax(QList *curve) } return max; } + /** Reset the contents of a field */ @@ -348,12 +348,11 @@ void VehicleConfig::resetField(UAVObjectField * field) } } - /** * Util function to get a pointer to the object manager * @return pointer to the UAVObjectManager */ -UAVObjectManager* VehicleConfig::getUAVObjectManager() { +UAVObjectManager *VehicleConfig::getUAVObjectManager() { ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); UAVObjectManager * objMngr = pm->getObject(); Q_ASSERT(objMngr); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 1be3037e0..1569c2db3 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -107,8 +107,6 @@ class VehicleConfig: public ConfigTaskWidget Q_OBJECT public: - VehicleConfig(QWidget *parent = 0); - ~VehicleConfig(); /* Enumeration options for ThrottleCurves */ typedef enum { @@ -140,6 +138,8 @@ public: MIXERVECTOR_YAW = 4 } MixerVectorElem; + static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; + // TODO remove 1st capital static GUIConfigDataUnion GetConfigData(); static void SetConfigData(GUIConfigDataUnion configData); @@ -148,12 +148,15 @@ public: static void setComboCurrentIndex(QComboBox *box, int index); static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable); + // VehicleConfig class + VehicleConfig(QWidget *parent = 0); + ~VehicleConfig(); + virtual void setupUI(QString airframeType); virtual QString updateConfigObjectsFromWidgets(); virtual void refreshWidgetsValues(QString frameType); - virtual void ResetActuators(GUIConfigDataUnion *configData); - + // TODO move to separate class double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName); void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value); void resetMixerVector(UAVDataObject *mixer, int channel); @@ -168,16 +171,17 @@ public: double getCurveMin(QList *curve); double getCurveMax(QList *curve); +protected: QStringList channelNames; QStringList mixerTypes; QStringList mixerVectors; QStringList mixerTypeDescriptions; - static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; - private: static UAVObjectManager *getUAVObjectManager(); + virtual void resetActuators(GUIConfigDataUnion *configData); + private slots: public slots: From 2d1af680a0beab3e0d5290fa15de1e2d6fd8ffda Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 3 Apr 2013 02:26:45 +0200 Subject: [PATCH 08/32] OP-907 step 3: cleaned up configvehicletypewidget.cpp + related cleanups --- .../cfg_vehicletypes/configccpmwidget.h | 2 +- .../cfg_vehicletypes/configcustomwidget.cpp | 8 +- .../cfg_vehicletypes/configcustomwidget.h | 4 +- .../cfg_vehicletypes/configfixedwingwidget.h | 4 +- .../configgroundvehiclewidget.h | 6 +- .../cfg_vehicletypes/configmultirotorwidget.h | 4 +- .../config/cfg_vehicletypes/vehicleconfig.h | 4 +- .../config/configvehicletypewidget.cpp | 494 +++--------------- .../plugins/config/configvehicletypewidget.h | 10 +- 9 files changed, 85 insertions(+), 451 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index c11146071..f2548789b 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -63,11 +63,11 @@ public: ConfigCcpmWidget(QWidget *parent = 0); ~ConfigCcpmWidget(); - virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); public slots: + virtual void setupUI(QString airframeType); void getMixer(); void setMixer(); void saveccpmUpdate(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 6181589cc..838baa619 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -232,11 +232,13 @@ bool ConfigCustomWidget::throwConfigError(int numMotors) */ void ConfigCustomWidget::showEvent(QShowEvent *event) { - Q_UNUSED(event) + Q_UNUSED(event); + // Make the custom table columns autostretch: m_aircraft->customMixerTable->resizeColumnsToContents(); - for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM; + for (int i = 0; i < channelCount; i++) { m_aircraft->customMixerTable->setColumnWidth(i, - (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10); + (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount); } } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h index 4b0409421..791667895 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -52,10 +52,12 @@ public: ConfigCustomWidget(QWidget *parent = 0); ~ConfigCustomWidget(); - virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); +public slots: + virtual void setupUI(QString airframeType); + protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index f7007302c..37df2470c 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -52,10 +52,12 @@ public: ConfigFixedWingWidget(QWidget *parent = 0); ~ConfigFixedWingWidget(); - virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); +public slots: + virtual void setupUI(QString airframeType); + private: virtual void resetActuators(GUIConfigDataUnion *configData); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 2b38d58ea..73f97cc6e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -51,10 +51,12 @@ public: ConfigGroundVehicleWidget(QWidget *parent = 0); ~ConfigGroundVehicleWidget(); - virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); +public slots: + virtual void setupUI(QString airframeType); + private: virtual void resetActuators(GUIConfigDataUnion *configData); @@ -67,8 +69,6 @@ private: private slots: virtual bool throwConfigError(QString airframeType); -protected: - }; #endif // CONFIGGROUNDVEHICLEWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 12b9d102b..e1d7c0a00 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -53,10 +53,12 @@ public: ConfigMultiRotorWidget(QWidget *parent = 0); ~ConfigMultiRotorWidget(); - virtual void setupUI(QString airframeType); virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); +public slots: + virtual void setupUI(QString airframeType); + protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 1569c2db3..6973c2507 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -152,7 +152,6 @@ public: VehicleConfig(QWidget *parent = 0); ~VehicleConfig(); - virtual void setupUI(QString airframeType); virtual QString updateConfigObjectsFromWidgets(); virtual void refreshWidgetsValues(QString frameType); @@ -171,6 +170,9 @@ public: double getCurveMin(QList *curve); double getCurveMax(QList *curve); +public slots: + virtual void setupUI(QString airframeType); + protected: QStringList channelNames; QStringList mixerTypes; diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index b9c98ab89..d590df28a 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -38,18 +38,12 @@ #include #include #include -//#include -//#include -//#include #include #include -//#include #include #include -//#include - ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_aircraft = new Ui_AircraftWidget(); @@ -74,8 +68,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom"; m_aircraft->aircraftType->addItems(airframeTypes); - // ***************************************************************************************************************** - // FIXED WING // ***************************************************************************************************************** // create and setup a FixedWing config widget @@ -83,139 +75,22 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi m_fixedwing = new ConfigFixedWingWidget(); m_aircraft->airframesWidget->addWidget(m_fixedwing); - - -// QWidget *fixedwingConfigWidget = new QWidget(); -// m_fixedwingUi = new Ui_FixedWingConfigWidget(); -// m_fixedwingUi->setupUi(fixedwingConfigWidget); -// m_aircraft->airframesWidget->addWidget(fixedwingConfigWidget); - -// m_fixedwing = new ConfigFixedWingWidget(m_fixedwingUi); -// m_fixedwing->setupUI(m_fixedwingUi->fixedWingType->currentText() ); - -// QStringList fixedWingTypes; -// fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; -// m_fixedwingUi->fixedWingType->addItems(fixedWingTypes); -// m_fixedwingUi->fixedWingType->setCurrentIndex(0); //Set default model to "Elevator aileron rudder" -// -// connect(m_fixedwingUi->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - - // ***************************************************************************************************************** - // MULTIROTOR - // ***************************************************************************************************************** - // create and setup a MultiRotor config widget m_multirotor = new ConfigMultiRotorWidget(); m_aircraft->airframesWidget->addWidget(m_multirotor); - - -// qDebug() << "create multirotor ui"; -// QWidget *multirotorConfigWidget = new QWidget(); -// m_multirotorUi = new Ui_MultiRotorConfigWidget(); -// m_multirotorUi->setupUi(multirotorConfigWidget); -// m_aircraft->airframesWidget->addWidget(multirotorConfigWidget); - -// // Setup the Multirotor picture in the Quad settings interface -// m_multirotorUi->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -// m_multirotorUi->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); -// QSvgRenderer *renderer = new QSvgRenderer(); -// renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); -// quad = new QGraphicsSvgItem(); -// quad->setSharedRenderer(renderer); -// quad->setElementId("quad-x"); -// QGraphicsScene *scene = new QGraphicsScene(this); -// scene->addItem(quad); -// scene->setSceneRect(quad->boundingRect()); -// m_multirotorUi->quadShape->setScene(scene); -// -// m_multirotor = new ConfigMultiRotorWidget(m_multirotorUi); -// m_multirotor->quad = quad; -// m_multirotor->uiowner = this; -// m_multirotor->setupUI(m_multirotorUi->multirotorFrameType->currentText()); -// -// QStringList multiRotorTypes; -// multiRotorTypes << "Tricopter Y"<< "Quad +" << "Quad X" << -// "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << -// "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; -// m_multirotorUi->multirotorFrameType->addItems(multiRotorTypes); -// m_multirotorUi->multirotorFrameType->setCurrentIndex(2); //Set default model to "Quad X" -// -// connect(m_multirotorUi->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); -// -// // Connect the multirotor motor reverse checkbox -// connect(m_multirotorUi->MultirotorRevMixercheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); -// -// m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); - - // ***************************************************************************************************************** - // HELICOPTER - // ***************************************************************************************************************** - // create and setup a Helicopter config widget -// QWidget *ccpmConfigWidget = new QWidget(); -// m_ccpmUi = new Ui_CcpmConfigWidget(); -// m_ccpmUi->setupUi(ccpmConfigWidget); -// m_aircraft->airframesWidget->addWidget(ccpmConfigWidget); - m_heli = new ConfigCcpmWidget(); m_aircraft->airframesWidget->addWidget(m_heli); - //m_heli = m_ccpmUi->widget_3; - //m_heli->setupUI(QString("HeliCP")); - - - //mdl connect(m_heli->m_ccpm->ccpmType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - - // ***************************************************************************************************************** - // GROUND - // ***************************************************************************************************************** - // create and setup a GroundVehicle config widget -// QWidget *groundConfigWidget = new QWidget(); -// m_groundUi = new Ui_GroundConfigWidget(); -// m_groundUi->setupUi(groundConfigWidget); -// m_aircraft->airframesWidget->addWidget(groundConfigWidget); - m_groundvehicle = new ConfigGroundVehicleWidget(); - //m_groundvehicle->setupUI(m_groundUi->groundVehicleType->currentText()); m_aircraft->airframesWidget->addWidget(m_groundvehicle); -// QStringList groundVehicleTypes; -// groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; -// m_groundUi->groundVehicleType->addItems(groundVehicleTypes); -// m_groundUi->groundVehicleType->setCurrentIndex(0); //Set default model to "Turnable (car)" - -// connect(m_groundUi->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupAirframeUI(QString))); - - // ***************************************************************************************************************** - // CUSTOM - // ***************************************************************************************************************** - + // create and setup a custom config widget m_custom = new ConfigCustomWidget(); m_aircraft->airframesWidget->addWidget(m_custom); - -// QWidget *customConfigWidget = new QWidget(); -// m_customUi = new Ui_CustomConfigWidget(); -// m_customUi->setupUi(customConfigWidget); -// m_aircraft->airframesWidget->addWidget(customConfigWidget); - -// // Put combo boxes in line one of the custom mixer table: -// UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// UAVObjectField* field = obj->getField(QString("Mixer1Type")); -// QStringList list = field->getOptions(); -// for (int i=0; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { -// QComboBox* qb = new QComboBox(m_customUi->customMixerTable); -// qb->addItems(list); -// m_customUi->customMixerTable->setCellWidget(0,i,qb); -// } -// -// SpinBoxDelegate *sbd = new SpinBoxDelegate(); -// for (int i=1; i<(int)(VehicleConfig::CHANNEL_NUMELEM); i++) { -// m_customUi->customMixerTable->setItemDelegateForRow(i, sbd); -// } - // ***************************************************************************************************************** // Set default vehicle to MultiRotor @@ -254,8 +129,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi refreshWidgetsValues(); - addToDirtyMonitor(); - disableMouseWheelEvents(); } @@ -332,87 +205,13 @@ QStringList ConfigVehicleTypeWidget::getChannelDescriptions() */ void ConfigVehicleTypeWidget::switchAirframeType(int index) { - //m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); - //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); -// m_customUi->customMixerTable->resizeColumnsToContents(); -// for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { -// m_customUi->customMixerTable->setColumnWidth(i, -// (m_customUi->customMixerTable->width() - m_customUi->customMixerTable->verticalHeader()->width()) / 10); -// } - m_aircraft->airframesWidget->setCurrentIndex(index); } - -/** - WHAT DOES THIS DO??? - */ -//void ConfigVehicleTypeWidget::showEvent(QShowEvent *event) -//{ -// Q_UNUSED(event) -// // Thit fitInView method should only be called now, once the -// // widget is shown, otherwise it cannot compute its values and -// // the result is usually a ahrsbargraph that is way too small. -// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); -//// m_customUi->customMixerTable->resizeColumnsToContents(); -//// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { -//// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- -//// m_customUi->customMixerTable->verticalHeader()->width())/ 10); -//// } -//} - -/** - Resize the GUI contents when the user changes the window size - */ -//void ConfigVehicleTypeWidget::resizeEvent(QResizeEvent *event) -//{ -// Q_UNUSED(event); -// //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); -// // Make the custom table columns autostretch: -// m_customUi->customMixerTable->resizeColumnsToContents(); -// for (int i=0;i<(int)(VehicleConfig::CHANNEL_NUMELEM);i++) { -// m_customUi->customMixerTable->setColumnWidth(i,(m_customUi->customMixerTable->width()- -// m_customUi->customMixerTable->verticalHeader()->width())/ 10); -// } -// -//} - -//void ConfigVehicleTypeWidget::toggleAileron2(int index) -//{ -// if (index) { -// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(true); -// m_fixedwingUi->fwAileron2Label->setEnabled(true); -// } else { -// m_fixedwingUi->fwAileron2ChannelBox->setEnabled(false); -// m_fixedwingUi->fwAileron2Label->setEnabled(false); -// } -//} - -//void ConfigVehicleTypeWidget::toggleElevator2(int index) -//{ -// if (index) { -// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(true); -// m_fixedwingUi->fwElevator2Label->setEnabled(true); -// } else { -// m_fixedwingUi->fwElevator2ChannelBox->setEnabled(false); -// m_fixedwingUi->fwElevator2Label->setEnabled(false); -// } -//} - -//void ConfigVehicleTypeWidget::toggleRudder2(int index) -//{ -// if (index) { -// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(true); -// m_fixedwingUi->fwRudder2Label->setEnabled(true); -// } else { -// m_fixedwingUi->fwRudder2ChannelBox->setEnabled(false); -// m_fixedwingUi->fwRudder2Label->setEnabled(false); -// } -//} - ///////////////////////////////////////////////////////// /// Feed Forward Testing ///////////////////////////////////////////////////////// + /** Enables and runs feed forward testing */ @@ -475,6 +274,7 @@ void ConfigVehicleTypeWidget::enableFFTest() /************************** * Aircraft settings **************************/ + /** Refreshes the current value of the SystemSettings which holds the aircraft type */ @@ -504,61 +304,29 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; setupAirframeUI(frameType); -// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(mixer); -// -// QPointer vconfig = new VehicleConfig(); -// -// QList curveValues; -// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); - - // is at least one of the curve values != 0? -// if (vconfig->isValidThrottleCurve(&curveValues)) { -// // yes, use the curve we just read from mixersettings -// //m_multirotorUi->multiThrottleCurve->initCurve(&curveValues); -// //m_fixedwingUi->fixedWingThrottle->initCurve(&curveValues); -// //m_groundUi->groundVehicleThrottle1->initCurve(&curveValues); -// } -// else { -// // no, init a straight curve -// //m_multirotorUi->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); -// //m_fixedwingUi->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); -// //m_groundUi->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); -// } - - // Setup all Throttle2 curves for all types of airframes //AT THIS MOMENT, THAT MEANS ONLY GROUND VEHICLES -// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); -// -// if (vconfig->isValidThrottleCurve(&curveValues)) { -// m_groundUi->groundVehicleThrottle2->initCurve(&curveValues); -// } -// else { -// m_groundUi->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); -// } - - if (frameType.startsWith("FixedWing")) { + QString category = frameCategory1(frameType); + if (category == "FixedWing") { // Retrieve fixed wing settings setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); m_fixedwing->refreshWidgetsValues(frameType); - } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" - || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV" - || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") { + } else if (category == "Multirotor") { // Retrieve multirotor settings setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); m_multirotor->refreshWidgetsValues(frameType); - } else if (frameType == "HeliCP") { + } else if (category == "Helicopter") { setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); m_heli->refreshWidgetsValues(frameType); - } else if (frameType.startsWith("GroundVehicle")) { + } else if (category == "Ground") { // Retrieve ground vehicle settings setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); m_groundvehicle->refreshWidgetsValues(frameType); - } else if (frameType == "Custom") { + } else if (category == "Custom") { + // Retrieve custom settings setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); m_custom->refreshWidgetsValues(frameType); } - updateCustomAirframeUI(); + updateFeedForwardUI(); setDirty(dirty); qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end"; @@ -574,33 +342,66 @@ void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType; bool dirty = isDirty(); + QString category = frameCategory2(frameType); + if (category == "FixedWing") { + m_fixedwing->setupUI(frameType); + } else if (category == "Multirotor") { + m_multirotor->setupUI(frameType); + } else if (category == "Helicopter") { + m_heli->setupUI(frameType); + } else if (category == "Ground") { + m_groundvehicle->setupUI(frameType); + } else if (category == "Custom") { + m_custom->setupUI(frameType); + } + + setDirty(dirty); + qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; +} + +QString ConfigVehicleTypeWidget::frameCategory1(QString frameType) +{ + QString category; + if (frameType.startsWith("FixedWing")) { + category = "FixedWing"; + } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" + || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV" + || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") { + category = "Multirotor"; + } else if (frameType == "HeliCP") { + category = "Helicopter"; + } else if (frameType.startsWith("GroundVehicle")) { + category = "Ground"; + } else { + category = "Custom"; + } + return category; +} + + +QString ConfigVehicleTypeWidget::frameCategory2(QString frameType) +{ + QString category; if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { - m_fixedwing->setupUI(frameType); + category = "FixedWing"; } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax" || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV" || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" || frameType == "OctoCoaxX" || frameType == "Octo Coax X") { - - m_multirotor->setupUI(frameType); + category = "Multirotor"; } else if (frameType == "HeliCP") { - m_heli->setupUI(frameType); + category = "Helicopter"; } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { - m_groundvehicle->setupUI(frameType); + category = "Ground"; } else { - m_custom->setupUI(frameType); + category = "Custom"; } - - //SHOULDN'T THIS BE DONE ONLY IN QUAD SETUP, AND NOT ALL THE REST??? - //m_multirotorUi->quadShape->setSceneRect(quad->boundingRect()); - //m_multirotorUi->quadShape->fitInView(quad, Qt::KeepAspectRatio); - - setDirty(dirty); - qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; + return category; } @@ -620,69 +421,13 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field) Note: does NOT ask for an object refresh itself! */ // TODO rename to FF -void ConfigVehicleTypeWidget::updateCustomAirframeUI() +void ConfigVehicleTypeWidget::updateFeedForwardUI() { UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); QPointer vconfig = new VehicleConfig(); -// QList curveValues; -// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); -// -// // is at least one of the curve values != 0? -// if (vconfig->isValidThrottleCurve(&curveValues)) { -// m_customUi->customThrottle1Curve->initCurve(&curveValues); -// } -// else { -// // no, init a straight curve -// m_customUi->customThrottle1Curve->initLinearCurve(curveValues.count(), 1.0); -// } -// -// if (MixerSettings* mxr = qobject_cast(mixer)) { -// MixerSettings::DataFields mixerSettingsData = mxr->getData(); -// if (mixerSettingsData.Curve2Source == MixerSettings::CURVE2SOURCE_THROTTLE) -// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_THROTTLE); -// else { -// m_customUi->customThrottle2Curve->setMixerType(MixerCurve::MIXERCURVE_PITCH); -// } -// } -// -// // Setup all Throttle2 curves for all types of airframes -// vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); -// -// if (vconfig->isValidThrottleCurve(&curveValues)) { -// m_customUi->customThrottle2Curve->initCurve(&curveValues); -// } -// else { -// m_customUi->customThrottle2Curve->initLinearCurve(curveValues.count(), 1.0, m_customUi->customThrottle2Curve->getMin()); -// } -// -// // Update the mixer table: -// for (int channel=0; channel < m_customUi->customMixerTable->columnCount(); channel++) { -// UAVObjectField* field = mixer->getField(mixerTypes.at(channel)); -// if (field) -// { -// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); -// if (q) -// { -// QString s = field->getValue().toString(); -// setComboCurrentIndex(q, q->findText(s)); -// } -// -// m_customUi->customMixerTable->item(1,channel)->setText( -// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1))); -// m_customUi->customMixerTable->item(2,channel)->setText( -// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2))); -// m_customUi->customMixerTable->item(3,channel)->setText( -// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL))); -// m_customUi->customMixerTable->item(4,channel)->setText( -// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH))); -// m_customUi->customMixerTable->item(5,channel)->setText( -// QString::number(vconfig->getMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW))); -// } -// } - // Update feed forward settings m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer,"FeedForward") * 100); m_aircraft->accelTime->setValue(vconfig->getMixerValue(mixer,"AccelTime")); @@ -690,7 +435,6 @@ void ConfigVehicleTypeWidget::updateCustomAirframeUI() m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer,"MaxAccel")); } - /** Sends the config to the board (airframe type) @@ -727,48 +471,6 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() } else { airframeType = m_custom->updateConfigObjectsFromWidgets(); -// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_customUi->customThrottle1Curve->getCurve()); -// vconfig->setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_customUi->customThrottle2Curve->getCurve()); -// -// // Update the table: -// for (int channel=0; channel<(int)(VehicleConfig::CHANNEL_NUMELEM); channel++) { -// QComboBox* q = (QComboBox*)m_customUi->customMixerTable->cellWidget(0,channel); -// if(q->currentText()=="Disabled") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_DISABLED); -// else if(q->currentText()=="Motor") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); -// else if(q->currentText()=="Servo") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); -// else if(q->currentText()=="CameraRoll") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAROLL); -// else if(q->currentText()=="CameraPitch") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAPITCH); -// else if(q->currentText()=="CameraYaw") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_CAMERAYAW); -// else if(q->currentText()=="Accessory0") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY0); -// else if(q->currentText()=="Accessory1") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY1); -// else if(q->currentText()=="Accessory2") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY2); -// else if(q->currentText()=="Accessory3") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY3); -// else if(q->currentText()=="Accessory4") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY4); -// else if(q->currentText()=="Accessory5") -// vconfig->setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_ACCESSORY5); -// -// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, -// m_customUi->customMixerTable->item(1,channel)->text().toDouble()); -// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE2, -// m_customUi->customMixerTable->item(2,channel)->text().toDouble()); -// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_ROLL, -// m_customUi->customMixerTable->item(3,channel)->text().toDouble()); -// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_PITCH, -// m_customUi->customMixerTable->item(4,channel)->text().toDouble()); -// vconfig->setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_YAW, -// m_customUi->customMixerTable->item(5,channel)->text().toDouble()); -// } } // set the airframe type @@ -780,7 +482,7 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() field->setValue(airframeType); } - updateCustomAirframeUI(); + updateFeedForwardUI(); } /** @@ -802,81 +504,3 @@ void ConfigVehicleTypeWidget::setComboCurrentIndex(QComboBox* box, int index) box->setCurrentIndex(index); } } - -/** - WHAT DOES THIS DO??? - */ -void ConfigVehicleTypeWidget::addToDirtyMonitor() -{ - /* - addWidget(m_customUi->customMixerTable); - addWidget(m_customUi->customThrottle1Curve->getCurveWidget()); - addWidget(m_customUi->customThrottle2Curve->getCurveWidget()); - addWidget(m_aircraft->multiThrottleCurve->getCurveWidget()); - addWidget(m_aircraft->fixedWingThrottle->getCurveWidget()); - addWidget(m_aircraft->fixedWingType); - addWidget(m_aircraft->groundVehicleThrottle1->getCurveWidget()); - addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget()); - addWidget(m_aircraft->groundVehicleType); - addWidget(m_aircraft->feedForwardSlider); - addWidget(m_aircraft->accelTime); - addWidget(m_aircraft->decelTime); - addWidget(m_aircraft->maxAccelSlider); - addWidget(m_aircraft->multirotorFrameType); - addWidget(m_aircraft->multiMotorChannelBox1); - addWidget(m_aircraft->multiMotorChannelBox2); - addWidget(m_aircraft->multiMotorChannelBox3); - addWidget(m_aircraft->multiMotorChannelBox4); - addWidget(m_aircraft->multiMotorChannelBox5); - addWidget(m_aircraft->multiMotorChannelBox6); - addWidget(m_aircraft->multiMotorChannelBox7); - addWidget(m_aircraft->multiMotorChannelBox8); - addWidget(m_aircraft->mrPitchMixLevel); - addWidget(m_aircraft->mrRollMixLevel); - addWidget(m_aircraft->mrYawMixLevel); - addWidget(m_aircraft->triYawChannelBox); - addWidget(m_aircraft->aircraftType); - addWidget(m_aircraft->fwEngineChannelBox); - addWidget(m_aircraft->fwAileron1ChannelBox); - addWidget(m_aircraft->fwAileron2ChannelBox); - addWidget(m_aircraft->fwElevator1ChannelBox); - addWidget(m_aircraft->fwElevator2ChannelBox); - addWidget(m_aircraft->fwRudder1ChannelBox); - addWidget(m_aircraft->fwRudder2ChannelBox); - addWidget(m_aircraft->elevonSlider1); - addWidget(m_aircraft->elevonSlider2); - addWidget(m_heli->m_ccpm->ccpmType); - addWidget(m_heli->m_ccpm->ccpmTailChannel); - addWidget(m_heli->m_ccpm->ccpmEngineChannel); - addWidget(m_heli->m_ccpm->ccpmServoWChannel); - addWidget(m_heli->m_ccpm->ccpmServoXChannel); - addWidget(m_heli->m_ccpm->ccpmServoYChannel); - addWidget(m_heli->m_ccpm->ccpmSingleServo); - addWidget(m_heli->m_ccpm->ccpmServoZChannel); - addWidget(m_heli->m_ccpm->ccpmAngleW); - addWidget(m_heli->m_ccpm->ccpmAngleX); - addWidget(m_heli->m_ccpm->ccpmCorrectionAngle); - addWidget(m_heli->m_ccpm->ccpmAngleZ); - addWidget(m_heli->m_ccpm->ccpmAngleY); - addWidget(m_heli->m_ccpm->ccpmCollectivePassthrough); - addWidget(m_heli->m_ccpm->ccpmLinkRoll); - addWidget(m_heli->m_ccpm->ccpmLinkCyclic); - addWidget(m_heli->m_ccpm->ccpmRevoSlider); - addWidget(m_heli->m_ccpm->ccpmREVOspinBox); - addWidget(m_heli->m_ccpm->ccpmCollectiveSlider); - addWidget(m_heli->m_ccpm->ccpmCollectivespinBox); - addWidget(m_heli->m_ccpm->ccpmCollectiveScale); - addWidget(m_heli->m_ccpm->ccpmCollectiveScaleBox); - addWidget(m_heli->m_ccpm->ccpmCyclicScale); - addWidget(m_heli->m_ccpm->ccpmPitchScale); - addWidget(m_heli->m_ccpm->ccpmPitchScaleBox); - addWidget(m_heli->m_ccpm->ccpmRollScale); - addWidget(m_heli->m_ccpm->ccpmRollScaleBox); - addWidget(m_heli->m_ccpm->SwashLvlPositionSlider); - addWidget(m_heli->m_ccpm->SwashLvlPositionSpinBox); - addWidget(m_heli->m_ccpm->ThrottleCurve->getCurveWidget()); - addWidget(m_heli->m_ccpm->PitchCurve->getCurveWidget()); - addWidget(m_heli->m_ccpm->ccpmAdvancedSettingsTable); - */ -} - diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index 2a4bb867e..f249b0155 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -42,11 +42,11 @@ class ConfigVehicleTypeWidget: public ConfigTaskWidget Q_OBJECT public: + static QStringList getChannelDescriptions(); + ConfigVehicleTypeWidget(QWidget *parent = 0); ~ConfigVehicleTypeWidget(); - static QStringList getChannelDescriptions(); - private: Ui_AircraftWidget *m_aircraft; @@ -56,11 +56,11 @@ private: VehicleConfig *m_groundvehicle; VehicleConfig *m_custom; - void updateCustomAirframeUI(); - void addToDirtyMonitor(); + void updateFeedForwardUI(); void resetField(UAVObjectField *field); - //void setMixerChannel(int channelNumber, bool channelIsMotor, QList vector); + QString frameCategory1(QString frameType); + QString frameCategory2(QString frameType); QStringList channelNames; QStringList mixerTypes; From e141e75e9f792ec7a0eeeac9a3ab2c89c6162997 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 3 Apr 2013 03:00:30 +0200 Subject: [PATCH 09/32] OP-907 step 3: cleaned up configvehicletypewidget.cpp + related cleanups --- .../src/plugins/config/cfg_vehicletypes/vehicleconfig.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 6973c2507..774aea259 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -184,14 +184,6 @@ private: virtual void resetActuators(GUIConfigDataUnion *configData); -private slots: - -public slots: - -signals: - -protected: - }; #endif // GUIVEHICLECONFIG_H From 14a0da076d97191ee5ee04b1e8d3453a9318ecbd Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 3 Apr 2013 04:15:30 +0200 Subject: [PATCH 10/32] OP-907 step 3: cleaned up configvehicletypewidget.cpp + related cleanups --- .../src/plugins/config/configvehicletypewidget.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index f249b0155..cdc64fed3 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -78,10 +78,7 @@ private slots: void setComboCurrentIndex(QComboBox *box, int index); void setupAirframeUI(QString type); - -// void toggleAileron2(int index); -// void toggleElevator2(int index); -// void toggleRudder2(int index); + // TODO ? void switchAirframeType(int index); void enableFFTest(); From 3520a7c0554b28e62fbc868ae6802d079f256449 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 7 Apr 2013 17:55:59 +0200 Subject: [PATCH 11/32] OP-907 step 3: more vehicle config code cleanups --- .../cfg_vehicletypes/configccpmwidget.cpp | 108 +-- .../cfg_vehicletypes/configccpmwidget.h | 11 +- .../cfg_vehicletypes/configcustomwidget.cpp | 147 ++-- .../cfg_vehicletypes/configcustomwidget.h | 14 +- .../configfixedwingwidget.cpp | 75 +- .../cfg_vehicletypes/configfixedwingwidget.h | 11 +- .../configgroundvehiclewidget.cpp | 173 ++-- .../configgroundvehiclewidget.h | 8 +- .../configmultirotorwidget.cpp | 812 +++++++++--------- .../cfg_vehicletypes/configmultirotorwidget.h | 16 +- .../config/cfg_vehicletypes/vehicleconfig.cpp | 2 +- .../config/cfg_vehicletypes/vehicleconfig.h | 35 +- .../config/configvehicletypewidget.cpp | 510 ++++++----- .../plugins/config/configvehicletypewidget.h | 19 +- 14 files changed, 934 insertions(+), 1007 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 02cb3894a..19ed4bcfe 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -285,6 +285,61 @@ void ConfigCcpmWidget::resetActuators(GUIConfigDataUnion *configData) configData->heli.ServoIndexZ = 0; } +void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) +{ + Q_UNUSED(frameType); + + setupUI(frameType); + + GUIConfigDataUnion config = GetConfigData(); + + //swashplate config + setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); + setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex); + + //ccpm mixing options + m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState); + m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState); + m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState); + + //correction angle + m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle); + + //update sliders + m_aircraft->ccpmCollectiveScale->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCyclicScale->setValue(config.heli.SliderValue1); + m_aircraft->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1); + m_aircraft->ccpmPitchScale->setValue(config.heli.SliderValue1); + m_aircraft->ccpmPitchScaleBox->setValue(config.heli.SliderValue1); + m_aircraft->ccpmRollScale->setValue(config.heli.SliderValue2); + m_aircraft->ccpmRollScaleBox->setValue(config.heli.SliderValue2); + m_aircraft->ccpmCollectiveSlider->setValue(config.heli.SliderValue0); + m_aircraft->ccpmCollectivespinBox->setValue(config.heli.SliderValue0); + + //servo assignments + setComboCurrentIndex(m_aircraft->ccpmServoWChannel, config.heli.ServoIndexW); + setComboCurrentIndex( m_aircraft->ccpmServoXChannel,config.heli.ServoIndexX); + setComboCurrentIndex( m_aircraft->ccpmServoYChannel,config.heli.ServoIndexY); + setComboCurrentIndex( m_aircraft->ccpmServoZChannel,config.heli.ServoIndexZ); + + //throttle + setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle); + //tail + setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail); + + getMixer(); +} + +QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() +{ + QString airframeType = updateConfigObjects(); + + setMixer(); + + return airframeType; +} + void ConfigCcpmWidget::UpdateType() { int TypeInt, SingleServoIndex, NumServosDefined; @@ -756,59 +811,6 @@ QString ConfigCcpmWidget::updateConfigObjects() return airframeType; } -QString ConfigCcpmWidget::updateConfigObjectsFromWidgets() -{ - QString airframeType = updateConfigObjects(); - - setMixer(); - - return airframeType; -} - -void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) -{ - Q_UNUSED(frameType); - - GUIConfigDataUnion config = GetConfigData(); - - //swashplate config - setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); - setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex); - - //ccpm mixing options - m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState); - m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState); - m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState); - - //correction angle - m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle); - - //update sliders - m_aircraft->ccpmCollectiveScale->setValue(config.heli.SliderValue0); - m_aircraft->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0); - m_aircraft->ccpmCyclicScale->setValue(config.heli.SliderValue1); - m_aircraft->ccpmCyclicScaleBox->setValue(config.heli.SliderValue1); - m_aircraft->ccpmPitchScale->setValue(config.heli.SliderValue1); - m_aircraft->ccpmPitchScaleBox->setValue(config.heli.SliderValue1); - m_aircraft->ccpmRollScale->setValue(config.heli.SliderValue2); - m_aircraft->ccpmRollScaleBox->setValue(config.heli.SliderValue2); - m_aircraft->ccpmCollectiveSlider->setValue(config.heli.SliderValue0); - m_aircraft->ccpmCollectivespinBox->setValue(config.heli.SliderValue0); - - //servo assignments - setComboCurrentIndex(m_aircraft->ccpmServoWChannel, config.heli.ServoIndexW); - setComboCurrentIndex( m_aircraft->ccpmServoXChannel,config.heli.ServoIndexX); - setComboCurrentIndex( m_aircraft->ccpmServoYChannel,config.heli.ServoIndexY); - setComboCurrentIndex( m_aircraft->ccpmServoZChannel,config.heli.ServoIndexZ); - - //throttle - setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle); - //tail - setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail); - - getMixer(); -} - void ConfigCcpmWidget::SetUIComponentVisibilities() { m_aircraft->ccpmRevoMixingBox->setVisible(0); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index f2548789b..e2f0e8c08 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -57,7 +57,6 @@ class ConfigCcpmWidget: public VehicleConfig Q_OBJECT public: - static QStringList getChannelDescriptions(); ConfigCcpmWidget(QWidget *parent = 0); @@ -67,7 +66,6 @@ public: virtual QString updateConfigObjectsFromWidgets(); public slots: - virtual void setupUI(QString airframeType); void getMixer(); void setMixer(); void saveccpmUpdate(); @@ -77,8 +75,6 @@ protected: void resizeEvent(QResizeEvent *event); private: - virtual void resetActuators(GUIConfigDataUnion *configData); - Ui_CcpmConfigWidget *m_aircraft; QGraphicsSvgItem *SwashplateImg; @@ -100,17 +96,19 @@ private: SwashplateServoSettingsStruct newSwashLvlConfiguration; int MixerChannelData[6]; + + virtual void resetActuators(GUIConfigDataUnion *configData); + int ShowDisclaimer(int messageID); virtual void enableControls(bool enable) { Q_UNUSED(enable) }; // Not used by this widget bool updatingFromHardware; bool updatingToHardware; - // TODO ? QString updateConfigObjects(); private slots: - // TODO ? + virtual void setupUI(QString airframeType); virtual bool throwConfigError(QString airframeType); void ccpmSwashplateUpdate(); @@ -131,7 +129,6 @@ private slots: void enableSwashplateLevellingControl(bool state); void setSwashplateLevel(int percent); void SwashLvlSpinBoxChanged(int value); - // TODO ? virtual void refreshValues() {}; // Not used }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 838baa619..2a62bc5df 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -26,9 +26,6 @@ */ #include "configcustomwidget.h" #include "mixersettings.h" -//#include "systemsettings.h" -//#include "actuatorsettings.h" -//#include "actuatorcommand.h" #include #include @@ -41,7 +38,14 @@ #include #include -//const QString ConfigCustomWidget::CHANNELBOXNAME = QString("multiMotorChannelBox"); +QStringList ConfigCustomWidget::getChannelDescriptions() +{ + QStringList channelDesc; + for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + channelDesc.append(QString("-")); + } + return channelDesc; +} ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_CustomConfigWidget()) @@ -74,83 +78,10 @@ ConfigCustomWidget::~ConfigCustomWidget() void ConfigCustomWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); - - m_aircraft->customMixerTable->resizeColumnsToContents(); - - for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { - m_aircraft->customMixerTable->setColumnWidth(i, - (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / 10); - } -} - -QStringList ConfigCustomWidget::getChannelDescriptions() -{ - QStringList channelDesc; - - for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { - channelDesc.append(QString("-")); - } - - return channelDesc; } void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData) { - -} - -/** - Helper function to update the UI widget objects - */ -QString ConfigCustomWidget::updateConfigObjectsFromWidgets() -{ - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve()); - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); - - // Update the table: - for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) { - QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel); - if (q->currentText() == "Disabled") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); - } else if (q->currentText() == "Motor") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); - } else if (q->currentText() == "Servo") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); - } else if (q->currentText() == "CameraRoll") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL); - } else if (q->currentText() == "CameraPitch") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH); - } else if (q->currentText() == "CameraYaw") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW); - } else if (q->currentText() == "Accessory0") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0); - } else if (q->currentText() == "Accessory1") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1); - } else if (q->currentText() == "Accessory2") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2); - } else if (q->currentText() == "Accessory3") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3); - } else if (q->currentText() == "Accessory4") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4); - } else if (q->currentText() == "Accessory5") { - setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5); - } - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, - m_aircraft->customMixerTable->item(1, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, - m_aircraft->customMixerTable->item(2, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, - m_aircraft->customMixerTable->item(3, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, - m_aircraft->customMixerTable->item(4, channel)->text().toDouble()); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, - m_aircraft->customMixerTable->item(5, channel)->text().toDouble()); - } - - return "Custom"; } /** @@ -160,6 +91,8 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType) { Q_ASSERT(m_aircraft); + setupUI(frameType); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -219,6 +152,60 @@ void ConfigCustomWidget::refreshWidgetsValues(QString frameType) } } +/** + Helper function to + */ +QString ConfigCustomWidget::updateConfigObjectsFromWidgets() +{ + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->customThrottle1Curve->getCurve()); + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); + + // Update the table: + for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) { + QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel); + if (q->currentText() == "Disabled") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); + } else if (q->currentText() == "Motor") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); + } else if (q->currentText() == "Servo") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + } else if (q->currentText() == "CameraRoll") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAROLL); + } else if (q->currentText() == "CameraPitch") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAPITCH); + } else if (q->currentText() == "CameraYaw") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_CAMERAYAW); + } else if (q->currentText() == "Accessory0") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY0); + } else if (q->currentText() == "Accessory1") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY1); + } else if (q->currentText() == "Accessory2") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY2); + } else if (q->currentText() == "Accessory3") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY3); + } else if (q->currentText() == "Accessory4") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY4); + } else if (q->currentText() == "Accessory5") { + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_ACCESSORY5); + } + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, + m_aircraft->customMixerTable->item(1, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, + m_aircraft->customMixerTable->item(2, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, + m_aircraft->customMixerTable->item(3, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, + m_aircraft->customMixerTable->item(4, channel)->text().toDouble()); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, + m_aircraft->customMixerTable->item(5, channel)->text().toDouble()); + } + + return "Custom"; +} + /** This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ @@ -238,7 +225,8 @@ void ConfigCustomWidget::showEvent(QShowEvent *event) int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM; for (int i = 0; i < channelCount; i++) { m_aircraft->customMixerTable->setColumnWidth(i, - (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount); + (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) + / channelCount); } } @@ -253,7 +241,8 @@ void ConfigCustomWidget::resizeEvent(QResizeEvent *event) int channelCount = (int) VehicleConfig::CHANNEL_NUMELEM; for (int i = 0; i < channelCount; i++) { m_aircraft->customMixerTable->setColumnWidth(i, - (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) / channelCount); + (m_aircraft->customMixerTable->width() - m_aircraft->customMixerTable->verticalHeader()->width()) + / channelCount); } } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h index 791667895..1debb9a41 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -46,7 +46,6 @@ class ConfigCustomWidget: public VehicleConfig Q_OBJECT public: - static QStringList getChannelDescriptions(); ConfigCustomWidget(QWidget *parent = 0); @@ -55,23 +54,18 @@ public: virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); -public slots: - virtual void setupUI(QString airframeType); - protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); private: - virtual void resetActuators(GUIConfigDataUnion *configData); - Ui_CustomConfigWidget *m_aircraft; -private slots: - virtual bool throwConfigError(int numMotors); + virtual void resetActuators(GUIConfigDataUnion *configData); -//signals: -// void configurationChanged(); +private slots: + virtual void setupUI(QString airframeType); + virtual bool throwConfigError(int numMotors); }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index c464b56ec..cd0ea1598 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -25,7 +25,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configfixedwingwidget.h" -//#include "configvehicletypewidget.h" #include "mixersettings.h" #include "systemsettings.h" #include "actuatorsettings.h" @@ -41,6 +40,41 @@ #include #include +QStringList ConfigFixedWingWidget::getChannelDescriptions() +{ + // init a channel_numelem list of channel desc defaults + QStringList channelDesc; + for (int i = 0; i < (int) (ConfigFixedWingWidget::CHANNEL_NUMELEM); i++) { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + + if (configData.fixedwing.FixedWingPitch1 > 0) { + channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1"); + } + if (configData.fixedwing.FixedWingPitch2 > 0) { + channelDesc[configData.fixedwing.FixedWingPitch2 - 1] = QString("FixedWingPitch2"); + } + if (configData.fixedwing.FixedWingRoll1 > 0) { + channelDesc[configData.fixedwing.FixedWingRoll1 - 1] = QString("FixedWingRoll1"); + } + if (configData.fixedwing.FixedWingRoll2 > 0) { + channelDesc[configData.fixedwing.FixedWingRoll2 - 1] = QString("FixedWingRoll2"); + } + if (configData.fixedwing.FixedWingYaw1 > 0) { + channelDesc[configData.fixedwing.FixedWingYaw1 - 1] = QString("FixedWingYaw1"); + } + if (configData.fixedwing.FixedWingYaw2 > 0) { + channelDesc[configData.fixedwing.FixedWingYaw2 - 1] = QString("FixedWingYaw2"); + } + if (configData.fixedwing.FixedWingThrottle > 0) { + channelDesc[configData.fixedwing.FixedWingThrottle - 1] = QString("FixedWingThrottle"); + } + return channelDesc; +} + ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_FixedWingConfigWidget()) { @@ -51,7 +85,9 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : m_aircraft->fixedWingType->addItems(fixedWingTypes); // Set default model to "Elevator aileron rudder" - m_aircraft->fixedWingType->setCurrentIndex(0); + m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); + + setupUI(m_aircraft->fixedWingType->currentText()); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } @@ -141,38 +177,6 @@ void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData) configData->fixedwing.FixedWingThrottle = 0; } -QStringList ConfigFixedWingWidget::getChannelDescriptions() -{ - int i; - QStringList channelDesc; - - // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(ConfigFixedWingWidget::CHANNEL_NUMELEM); i++) - { - channelDesc.append(QString("-")); - } - - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - - if (configData.fixedwing.FixedWingPitch1 > 0) - channelDesc[configData.fixedwing.FixedWingPitch1-1] = QString("FixedWingPitch1"); - if (configData.fixedwing.FixedWingPitch2 > 0) - channelDesc[configData.fixedwing.FixedWingPitch2-1] = QString("FixedWingPitch2"); - if (configData.fixedwing.FixedWingRoll1 > 0) - channelDesc[configData.fixedwing.FixedWingRoll1-1] = QString("FixedWingRoll1"); - if (configData.fixedwing.FixedWingRoll2 > 0) - channelDesc[configData.fixedwing.FixedWingRoll2-1] = QString("FixedWingRoll2"); - if (configData.fixedwing.FixedWingYaw1 > 0) - channelDesc[configData.fixedwing.FixedWingYaw1-1] = QString("FixedWingYaw1"); - if (configData.fixedwing.FixedWingYaw2 > 0) - channelDesc[configData.fixedwing.FixedWingYaw2-1] = QString("FixedWingYaw2"); - if (configData.fixedwing.FixedWingThrottle > 0) - channelDesc[configData.fixedwing.FixedWingThrottle-1] = QString("FixedWingThrottle"); - - return channelDesc; -} - /** Virtual function to update the UI widget objects */ @@ -205,7 +209,6 @@ QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() return airframeType; } - /** Virtual function to refresh the UI widget values */ @@ -213,6 +216,8 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) { Q_ASSERT(m_aircraft); + setupUI(frameType); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 37df2470c..26f5c282e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -46,7 +46,6 @@ class ConfigFixedWingWidget: public VehicleConfig Q_OBJECT public: - static QStringList getChannelDescriptions(); ConfigFixedWingWidget(QWidget *parent = 0); @@ -55,23 +54,19 @@ public: virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); -public slots: - virtual void setupUI(QString airframeType); - private: - virtual void resetActuators(GUIConfigDataUnion *configData); - Ui_FixedWingConfigWidget *m_aircraft; + virtual void resetActuators(GUIConfigDataUnion *configData); + bool setupFrameFixedWing(QString airframeType); bool setupFrameElevon(QString airframeType); bool setupFrameVtail(QString airframeType); private slots: + virtual void setupUI(QString airframeType); virtual bool throwConfigError(QString airframeType); -protected: - }; #endif // CONFIGFIXEDWINGWIDGET_H diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 2b04a3c63..9704cce75 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -41,6 +41,32 @@ #include #include +QStringList ConfigGroundVehicleWidget::getChannelDescriptions() +{ + // init a channel_numelem list of channel desc defaults + QStringList channelDesc; + for (int i = 0; i < (int) (ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + + if (configData.ground.GroundVehicleSteering1 > 0) { + channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1"); + } + if (configData.ground.GroundVehicleSteering2 > 0) { + channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2"); + } + if (configData.ground.GroundVehicleThrottle1 > 0) { + channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundThrottle1"); + } + if (configData.ground.GroundVehicleThrottle2 > 0) { + channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundThrottle2"); + } + return channelDesc; +} + ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_GroundConfigWidget()) { @@ -51,7 +77,7 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : m_aircraft->groundVehicleType->addItems(groundVehicleTypes); // Set default model to "Turnable (car)" - m_aircraft->groundVehicleType->setCurrentIndex(0); + m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)")); setupUI(m_aircraft->groundVehicleType->currentText()); @@ -169,66 +195,6 @@ void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) configData->ground.GroundVehicleThrottle2 = 0; } -QStringList ConfigGroundVehicleWidget::getChannelDescriptions() -{ - int i; - QStringList channelDesc; - - // init a channel_numelem list of channel desc defaults - for (i = 0; i < (int) (ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) { - channelDesc.append(QString("-")); - } - - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - - if (configData.ground.GroundVehicleSteering1 > 0) { - channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1"); - } - if (configData.ground.GroundVehicleSteering2 > 0) { - channelDesc[configData.ground.GroundVehicleSteering2 - 1] = QString("GroundSteering2"); - } - if (configData.ground.GroundVehicleThrottle1 > 0) { - channelDesc[configData.ground.GroundVehicleThrottle1 - 1] = QString("GroundThrottle1"); - } - if (configData.ground.GroundVehicleThrottle2 > 0) { - channelDesc[configData.ground.GroundVehicleThrottle2 - 1] = QString("GroundThrottle2"); - } - return channelDesc; -} - -/** - Virtual function to update the UI widget objects - */ -QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() -{ - QString airframeType = "GroundVehicleCar"; - - // Save the curve (common to all ground vehicle frames) - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - - // Remove Feed Forward, it is pointless on a ground vehicle: - setMixerValue(mixer, "FeedForward", 0.0); - - // set the throttle curves - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve()); - setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve()); - - // All airframe types must start with "GroundVehicle" - if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") { - airframeType = "GroundVehicleCar"; - setupGroundVehicleCar(airframeType); - } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { - airframeType = "GroundVehicleDifferential"; - setupGroundVehicleDifferential(airframeType); - } else { // "Motorcycle" - airframeType = "GroundVehicleMotorcycle"; - setupGroundVehicleMotorcycle(airframeType); - } - - return airframeType; -} - /** Virtual function to refresh the UI widget values */ @@ -236,6 +202,8 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType; + setupUI(frameType); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -271,25 +239,25 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) - //UAVDataObject *obj; + //UAVDataObject *obj; //UAVObjectField *field; - + GUIConfigDataUnion config = GetConfigData(); - //THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE - // Retrieve channel setup values + //THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE + // Retrieve channel setup values setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1); setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2); setComboCurrentIndex(m_aircraft->gvSteering1ChannelBox, config.ground.GroundVehicleSteering1); setComboCurrentIndex(m_aircraft->gvSteering2ChannelBox, config.ground.GroundVehicleSteering2); - if (frameType == "GroundVehicleDifferential") { - //CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE - // If the vehicle type is "differential", restore the slider setting - - // Find the channel number for Motor1 - //obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - //Q_ASSERT(obj); + if (frameType == "GroundVehicleDifferential") { + //CURRENTLY BROKEN UNTIL WE DECIDE HOW DIFFERENTIAL SHOULD BEHAVE + // If the vehicle type is "differential", restore the slider setting + + // Find the channel number for Motor1 + //obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + //Q_ASSERT(obj); int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. @@ -298,23 +266,54 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) m_aircraft->differentialSteeringSlider2->setValue( getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); } - } - else if (frameType == "GroundVehicleMotorcycle") { - //CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE -// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(obj); -// int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; -// if (chMixerNumber >=0) { -// field = obj->getField(mixerVectors.at(chMixerNumber)); -// int ti = field->getElementNames().indexOf("Yaw"); -// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100); -// -// ti = field->getElementNames().indexOf("Pitch"); -// m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100); -// } - } + } + else if (frameType == "GroundVehicleMotorcycle") { + //CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE +// obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(obj); +// int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; +// if (chMixerNumber >=0) { +// field = obj->getField(mixerVectors.at(chMixerNumber)); +// int ti = field->getElementNames().indexOf("Yaw"); +// m_aircraft->differentialSteeringSlider1->setValue(field->getDouble(ti)*100); +// +// ti = field->getElementNames().indexOf("Pitch"); +// m_aircraft->differentialSteeringSlider2->setValue(field->getDouble(ti)*100); +// } + } } +/** + Virtual function to update the UI widget objects + */ +QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() +{ + QString airframeType = "GroundVehicleCar"; + + // Save the curve (common to all ground vehicle frames) + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + + // Remove Feed Forward, it is pointless on a ground vehicle: + setMixerValue(mixer, "FeedForward", 0.0); + + // set the throttle curves + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->groundVehicleThrottle1->getCurve()); + setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->groundVehicleThrottle2->getCurve()); + + // All airframe types must start with "GroundVehicle" + if (m_aircraft->groundVehicleType->currentText() == "Turnable (car)") { + airframeType = "GroundVehicleCar"; + setupGroundVehicleCar(airframeType); + } else if (m_aircraft->groundVehicleType->currentText() == "Differential (tank)") { + airframeType = "GroundVehicleDifferential"; + setupGroundVehicleDifferential(airframeType); + } else { // "Motorcycle" + airframeType = "GroundVehicleMotorcycle"; + setupGroundVehicleMotorcycle(airframeType); + } + + return airframeType; +} /** Setup balancing ground vehicle. diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 73f97cc6e..3f8abea37 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -54,19 +54,17 @@ public: virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); -public slots: - virtual void setupUI(QString airframeType); - private: - virtual void resetActuators(GUIConfigDataUnion *configData); - Ui_GroundConfigWidget *m_aircraft; + virtual void resetActuators(GUIConfigDataUnion *configData); + bool setupGroundVehicleCar(QString airframeType); bool setupGroundVehicleDifferential(QString airframeType); bool setupGroundVehicleMotorcycle(QString airframeType); private slots: + virtual void setupUI(QString airframeType); virtual bool throwConfigError(QString airframeType); }; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 4e4180dcf..bef60e9a2 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -43,6 +43,50 @@ const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox"); + +QStringList ConfigMultiRotorWidget::getChannelDescriptions() +{ + // init a channel_numelem list of channel desc defaults + QStringList channelDesc; + for (int i = 0; i < (int) (ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++) { + channelDesc.append(QString("-")); + } + + // get the gui config data + GUIConfigDataUnion configData = GetConfigData(); + multiGUISettingsStruct multi = configData.multi; + + if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorN - 1] = QString("VTOLMotorN"); + } + if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorNE - 1] = QString("VTOLMotorNE"); + } + if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorNW - 1] = QString("VTOLMotorNW"); + } + if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorS - 1] = QString("VTOLMotorS"); + } + if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorSE - 1] = QString("VTOLMotorSE"); + } + if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorSW - 1] = QString("VTOLMotorSW"); + } + if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorW - 1] = QString("VTOLMotorW"); + } + if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.VTOLMotorE - 1] = QString("VTOLMotorE"); + } + if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { + channelDesc[multi.TRIYaw - 1] = QString("Tri-Yaw"); + } + return channelDesc; +} + + ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1) { @@ -58,30 +102,30 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : quad->setSharedRenderer(renderer); quad->setElementId("quad-x"); - QGraphicsScene *scene = new QGraphicsScene(this); + QGraphicsScene *scene = new QGraphicsScene(); scene->addItem(quad); scene->setSceneRect(quad->boundingRect()); m_aircraft->quadShape->setScene(scene); //m_multirotor = new ConfigMultiRotorWidget(m_aircraft); //m_multirotor->quad = quad; - uiowner = this; - setupUI(m_aircraft->multirotorFrameType->currentText()); + //setupUI(m_aircraft->multirotorFrameType->currentText()); QStringList multiRotorTypes; multiRotorTypes << "Tricopter Y" << "Quad +" << "Quad X" << "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; m_aircraft->multirotorFrameType->addItems(multiRotorTypes); + // Set default model to "Quad X" - m_aircraft->multirotorFrameType->setCurrentIndex(2); + m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X")); + + setupUI(m_aircraft->multirotorFrameType->currentText()); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); // Connect the multirotor motor reverse checkbox connect(m_aircraft->MultirotorRevMixerCheckBox, SIGNAL(clicked(bool)), this, SLOT(reverseMultirotorMotor())); - - //m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); } ConfigMultiRotorWidget::~ConfigMultiRotorWidget() @@ -92,7 +136,6 @@ ConfigMultiRotorWidget::~ConfigMultiRotorWidget() void ConfigMultiRotorWidget::setupUI(QString frameType) { Q_ASSERT(m_aircraft); - Q_ASSERT(uiowner); Q_ASSERT(quad); qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType; @@ -106,7 +149,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) // disable all motor channel boxes for (int i = 1; i <= 8; i++) { // do it manually so we can turn off any error decorations - QComboBox *combobox = qFindChild(uiowner, "multiMotorChannelBox" + QString::number(i)); + QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i)); if (combobox) { combobox->setEnabled(false); combobox->setItemData(0, 0, Qt::DecorationRole); @@ -117,7 +160,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Tricopter Y")); // Enable all necessary motor channel boxes... - enableComboBoxes(uiowner, CHANNELBOXNAME, 3, true); + enableComboBoxes(this, CHANNELBOXNAME, 3, true); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); @@ -129,7 +172,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X")); // Enable all necessary motor channel boxes... - enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true); + enableComboBoxes(this, CHANNELBOXNAME, 4, true); // init mixer levels m_aircraft->mrRollMixLevel->setValue(50); @@ -140,7 +183,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +")); // Enable all necessary motor channel boxes... - enableComboBoxes(uiowner, CHANNELBOXNAME, 4, true); + enableComboBoxes(this, CHANNELBOXNAME, 4, true); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); @@ -150,7 +193,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter")); // Enable all necessary motor channel boxes... - enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true); + enableComboBoxes(this, CHANNELBOXNAME, 6, true); m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(33); @@ -161,7 +204,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->multirotorFrameType->findText("Hexacopter X")); // Enable all necessary motor channel boxes... - enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true); + enableComboBoxes(this, CHANNELBOXNAME, 6, true); m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(50); @@ -172,7 +215,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); // Enable all necessary motor channel boxes... - enableComboBoxes(uiowner, CHANNELBOXNAME, 6, true); + enableComboBoxes(this, CHANNELBOXNAME, 6, true); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(50); @@ -182,7 +225,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter")); // Enable all necessary motor channel boxes - enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); + enableComboBoxes(this, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(33); @@ -193,7 +236,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->multirotorFrameType->findText("Octocopter V")); // Enable all necessary motor channel boxes - enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); + enableComboBoxes(this, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(25); m_aircraft->mrPitchMixLevel->setValue(25); @@ -203,7 +246,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +")); // Enable all necessary motor channel boxes - enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); + enableComboBoxes(this, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); @@ -213,7 +256,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X")); // Enable all necessary motor channel boxes - enableComboBoxes(uiowner, CHANNELBOXNAME, 8, true); + enableComboBoxes(this, CHANNELBOXNAME, 8, true); m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(50); @@ -221,79 +264,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) } // Draw the appropriate airframe - drawAirframe(frameType); -} - -void ConfigMultiRotorWidget::drawAirframe(QString frameType) -{ - qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType; - - invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; - qDebug() << "ConfigMultiRotorWidget::drawAirframe - invert motors" << invertMotors; - - if (frameType == "Tri" || frameType == "Tricopter Y") { - if (invertMotors > 0) { - quad->setElementId("tri"); - } else { - quad->setElementId("tri_reverse"); - } - } else if (frameType == "QuadX" || frameType == "Quad X") { - if (invertMotors > 0) { - quad->setElementId("quad-x"); - } else { - quad->setElementId("quad-x_reverse"); - } - } else if (frameType == "QuadP" || frameType == "Quad +") { - if (invertMotors > 0) { - quad->setElementId("quad-plus"); - } else { - quad->setElementId("quad-plus_reverse"); - } - } else if (frameType == "Hexa" || frameType == "Hexacopter") { - if (invertMotors > 0) { - quad->setElementId("quad-hexa"); - } else { - quad->setElementId("quad-hexa_reverse"); - } - } else if (frameType == "HexaX" || frameType == "Hexacopter X") { - if (invertMotors > 0) { - quad->setElementId("quad-hexa-H"); - } else { - quad->setElementId("quad-hexa-H_reverse"); - } - } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { - if (invertMotors > 0) { - quad->setElementId("hexa-coax"); - } else { - quad->setElementId("hexa-coax_reverse"); - } - } else if (frameType == "Octo" || frameType == "Octocopter") { - if (invertMotors > 0) { - quad->setElementId("quad-octo"); - } else { - quad->setElementId("quad-octo_reverse"); - } - } else if (frameType == "OctoV" || frameType == "Octocopter V") { - if (invertMotors > 0) { - quad->setElementId("quad-octo-v"); - } else { - quad->setElementId("quad-octo-v_reverse"); - } - } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { - if (invertMotors > 0) { - quad->setElementId("octo-coax-P"); - } else { - quad->setElementId("octo-coax-P_reverse"); - } - } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { - if (invertMotors > 0) { - quad->setElementId("octo-coax-X"); - } else { - quad->setElementId("octo-coax-X_reverse"); - } - } - m_aircraft->quadShape->setSceneRect(quad->boundingRect()); - m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); + // drawAirframe(frameType); } void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) @@ -309,60 +280,298 @@ void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) configData->multi.TRIYaw = 0; } -QStringList ConfigMultiRotorWidget::getChannelDescriptions() +/** + Helper function to refresh the UI widget values + */ +void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) { - QStringList channelDesc; + Q_ASSERT(m_aircraft); - // init a channel_numelem list of channel desc defaults - for (int i=0; i < (int)(ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++) - { - channelDesc.append(QString("-")); + setupUI(frameType); + + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QList curveValues; + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); + + // is at least one of the curve values != 0? + if (isValidThrottleCurve(&curveValues)) { + // yes, use the curve we just read from mixersettings + m_aircraft->multiThrottleCurve->initCurve(&curveValues); + } + else { + // no, init a straight curve + m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); } - // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); - multiGUISettingsStruct multi = configData.multi; - if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorN-1] = QString("VTOLMotorN"); - if (multi.VTOLMotorNE > 0 && multi.VTOLMotorNE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorNE-1] = QString("VTOLMotorNE"); - if (multi.VTOLMotorNW > 0 && multi.VTOLMotorNW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorNW-1] = QString("VTOLMotorNW"); - if (multi.VTOLMotorS > 0 && multi.VTOLMotorS <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorS-1] = QString("VTOLMotorS"); - if (multi.VTOLMotorSE > 0 && multi.VTOLMotorSE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorSE-1] = QString("VTOLMotorSE"); - if (multi.VTOLMotorSW > 0 && multi.VTOLMotorSW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorSW-1] = QString("VTOLMotorSW"); - if (multi.VTOLMotorW > 0 && multi.VTOLMotorW <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorW-1] = QString("VTOLMotorW"); - if (multi.VTOLMotorE > 0 && multi.VTOLMotorE <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.VTOLMotorE-1] = QString("VTOLMotorE"); - if (multi.TRIYaw > 0 && multi.TRIYaw <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) - channelDesc[multi.TRIYaw-1] = QString("Tri-Yaw"); - return channelDesc; + + int channel; + double value; + + GUIConfigDataUnion config = GetConfigData(); + multiGUISettingsStruct multi = config.multi; + +// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); +// Q_ASSERT(mixer); + + if (frameType == "QuadP") + { + // Motors 1/2/3/4 are: N / E / S / W + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27)); + + } + } + else if (frameType == "QuadX") + { + // Motors 1/2/3/4 are: NW / NE / SE / SW + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27)); + + } + + } + else if (frameType == "Hexa") + { + // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + //change channels + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + + } + + + } + else if (frameType == "HexaX") + { + // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + } + } + else if (frameType == "HexaCoax") + { + // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) ); + + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); + } + } + else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") + { + // Motors 1 to 8 are N / NE / E / etc + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + if (frameType == "Octo") { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + //change channels + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + } + else if (frameType == "OctoV") { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + //change channels + channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + } + else if (frameType == "OctoCoaxP") { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + //change channels + channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1; + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + } + + } + } + else if (frameType == "OctoCoaxX") + { + // Motors 1 to 8 are N / NE / E / etc + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW); + + // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. + // This assumes that all vectors are identical - if not, the user should use the + // "custom" setting. + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); + setYawMixLevel( -qRound(value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); + } + } + else if (frameType == "Tri") + { + // Motors 1 to 8 are N / NE / E / etc + + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->triYawChannelBox,multi.TRIYaw); + + channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) + { + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) ); + + value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); + m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); + + } + } + + drawAirframe(frameType); } -void ConfigMultiRotorWidget::setYawMixLevel(int value) -{ - if(value<0) - { - m_aircraft->mrYawMixLevel->setValue((-1)*value); - m_aircraft->MultirotorRevMixerCheckBox->setChecked(true); - } - else - { - m_aircraft->mrYawMixLevel->setValue(value); - m_aircraft->MultirotorRevMixerCheckBox->setChecked(false); - } - -} - - - - /** Helper function to update the UI widget objects */ @@ -566,303 +775,62 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() return airframeType; } +void ConfigMultiRotorWidget::setYawMixLevel(int value) +{ + if (value < 0) { + m_aircraft->mrYawMixLevel->setValue(-value); + m_aircraft->MultirotorRevMixerCheckBox->setChecked(true); + } else { + m_aircraft->mrYawMixLevel->setValue(value); + m_aircraft->MultirotorRevMixerCheckBox->setChecked(false); + } + +} + void ConfigMultiRotorWidget::reverseMultirotorMotor(){ QString frameType = m_aircraft->multirotorFrameType->currentText(); drawAirframe(frameType); } -/** - Helper function to refresh the UI widget values - */ -void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) +void ConfigMultiRotorWidget::drawAirframe(QString frameType) { - Q_ASSERT(m_aircraft); + qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType; - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - QList curveValues; - getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); - - // is at least one of the curve values != 0? - if (isValidThrottleCurve(&curveValues)) { - // yes, use the curve we just read from mixersettings - m_aircraft->multiThrottleCurve->initCurve(&curveValues); - } - else { - // no, init a straight curve - m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); + QString elementId; + if (frameType == "Tri" || frameType == "Tricopter Y") { + elementId = "tri"; + } else if (frameType == "QuadX" || frameType == "Quad X") { + elementId = "quad-x"; + } else if (frameType == "QuadP" || frameType == "Quad +") { + elementId = "quad-plus"; + } else if (frameType == "Hexa" || frameType == "Hexacopter") { + elementId = "quad-hexa"; + } else if (frameType == "HexaX" || frameType == "Hexacopter X") { + elementId = "quad-hexa-H"; + } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { + elementId = "hexa-coax"; + } else if (frameType == "Octo" || frameType == "Octocopter") { + elementId = "quad-octo"; + } else if (frameType == "OctoV" || frameType == "Octocopter V") { + elementId = "quad-octo-v"; + } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { + elementId = "octo-coax-P"; + } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { + elementId = "octo-coax-X"; } - - - - int channel; - double value; - - GUIConfigDataUnion config = GetConfigData(); - multiGUISettingsStruct multi = config.multi; - -// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(mixer); - - if (frameType == "QuadP") - { - // Motors 1/2/3/4 are: N / E / S / W - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorW); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27)); - - } - } - else if (frameType == "QuadX") - { - // Motors 1/2/3/4 are: NW / NE / SE / SW - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27)); - - } - - } - else if (frameType == "Hexa") - { - // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - //change channels - channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - - } - - - } - else if (frameType == "HexaX") - { - // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - } - } - else if (frameType == "HexaCoax") - { - // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) ); - - channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); - } - } - else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") - { - // Motors 1 to 8 are N / NE / E / etc - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - if (frameType == "Octo") { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - //change channels - channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - } - else if (frameType == "OctoV") { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - //change channels - channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - } - else if (frameType == "OctoCoaxP") { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - //change channels - channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1; - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - } - - } - } - else if (frameType == "OctoCoaxX") - { - // Motors 1 to 8 are N / NE / E / etc - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW); - - // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); - } - } - else if (frameType == "Tri") - { - // Motors 1 to 8 are N / NE / E / etc - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->triYawChannelBox,multi.TRIYaw); - - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) ); - - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); - - } + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; + if (invertMotors <= 0) { + elementId += "_reverse"; } - drawAirframe(frameType); + if (elementId != "" && elementId != quad->elementId()) { + quad->setElementId(elementId); + m_aircraft->quadShape->setSceneRect(quad->boundingRect()); + m_aircraft->quadShape->fitInView(quad, Qt::KeepAspectRatio); + } } - - /** Helper function: setupQuadMotor */ @@ -1106,7 +1074,7 @@ bool ConfigMultiRotorWidget::throwConfigError(int numMotors) //Iterate through all instances of multiMotorChannelBox for (int i=0; i(uiowner, "multiMotorChannelBox" + QString::number(i+1)); + QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i+1)); if (combobox){ if (combobox->currentText() == "None") { int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index e1d7c0a00..2b2844fad 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -46,9 +46,8 @@ class ConfigMultiRotorWidget: public VehicleConfig Q_OBJECT public: - - static QStringList getChannelDescriptions(); static const QString CHANNELBOXNAME; + static QStringList getChannelDescriptions(); ConfigMultiRotorWidget(QWidget *parent = 0); ~ConfigMultiRotorWidget(); @@ -56,20 +55,16 @@ public: virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); -public slots: - virtual void setupUI(QString airframeType); - protected: void showEvent(QShowEvent *event); void resizeEvent(QResizeEvent *event); private: - virtual void resetActuators(GUIConfigDataUnion *configData); - Ui_MultiRotorConfigWidget *m_aircraft; - - QWidget *uiowner; QGraphicsSvgItem *quad; + float invertMotors; + + virtual void resetActuators(GUIConfigDataUnion *configData); bool setupQuad(bool pLayout); bool setupHexa(bool pLayout); @@ -78,13 +73,12 @@ private: void setupMotors(QList motorList); void setupQuadMotor(int channel, double roll, double pitch, double yaw); - float invertMotors; - void setYawMixLevel(int); void drawAirframe(QString multiRotorType); private slots: + virtual void setupUI(QString airframeType); virtual bool throwConfigError(int numMotors); void reverseMultirotorMotor(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index d9e5cbf00..543de1cba 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -138,7 +138,7 @@ void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index) /** Helper function: - enables/disables the named comboboxes within supplied uiowner + enables/disables the named comboboxes within supplied owner */ void VehicleConfig::enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable) { diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index 774aea259..ba28d8977 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -41,11 +41,11 @@ typedef struct { uint VTOLMotorNW:4; uint VTOLMotorNE:4; uint VTOLMotorSW:4; - uint VTOLMotorSE:4; //32bits + uint VTOLMotorSE:4; // 32 bits uint TRIYaw:4; - quint32 padding:28; //64bits + quint32 padding:28; // 64 bits quint32 padding1; - quint32 padding2; //128bits + quint32 padding2; // 128 bits } __attribute__((packed)) multiGUISettingsStruct; typedef struct { @@ -57,15 +57,15 @@ typedef struct { uint ccpmLinkRollState:1; uint SliderValue0:7; uint SliderValue1:7; - uint SliderValue2:7;//41bits + uint SliderValue2:7; // 41 bits uint ServoIndexW:4; uint ServoIndexX:4; uint ServoIndexY:4; - uint ServoIndexZ:4;//57bits + uint ServoIndexZ:4; // 57 bits uint Throttle:4; - uint Tail:4; //65bits - quint32 padding:31; //96bits - quint32 padding1; //128bits + uint Tail:4; // 65bits + quint32 padding:31; // 96 bits + quint32 padding1; // 128 bits } __attribute__((packed)) heliGUISettingsStruct; typedef struct { @@ -76,10 +76,10 @@ typedef struct { uint FixedWingPitch2:4; uint FixedWingYaw1:4; uint FixedWingYaw2:4; - uint padding:4; //32bits + uint padding:4; // 32 bits quint32 padding1; quint32 padding2; - quint32 padding3; //128bits + quint32 padding3; // 128 bits } __attribute__((packed)) fixedGUISettingsStruct; typedef struct { @@ -87,16 +87,16 @@ typedef struct { uint GroundVehicleThrottle2:4; uint GroundVehicleSteering1:4; uint GroundVehicleSteering2:4; - uint padding:16; //32bits + uint padding:16; // 32 bits quint32 padding1; quint32 padding2; - quint32 padding3; //128bits + quint32 padding3; // 128 bits } __attribute__((packed)) groundGUISettingsStruct; typedef union { - uint UAVObject[4]; //32bits * 4 - heliGUISettingsStruct heli; //128bits + uint UAVObject[4]; // 32 bits * 4 + heliGUISettingsStruct heli; // 128 bits fixedGUISettingsStruct fixedwing; multiGUISettingsStruct multi; groundGUISettingsStruct ground; @@ -145,6 +145,7 @@ public: static void SetConfigData(GUIConfigDataUnion configData); static void resetField(UAVObjectField *field); + static void setComboCurrentIndex(QComboBox *box, int index); static void enableComboBoxes(QWidget *owner, QString boxName, int boxCount, bool enable); @@ -170,9 +171,6 @@ public: double getCurveMin(QList *curve); double getCurveMax(QList *curve); -public slots: - virtual void setupUI(QString airframeType); - protected: QStringList channelNames; QStringList mixerTypes; @@ -184,6 +182,9 @@ private: virtual void resetActuators(GUIConfigDataUnion *configData); +private slots: + virtual void setupUI(QString airframeType); + }; #endif // GUIVEHICLECONFIG_H diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index d590df28a..283ae16a3 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -44,6 +44,62 @@ #include #include +/** + Static function to get currently assigned channelDescriptions + for all known vehicle types; instantiates the appropriate object + then asks it to supply channel descs + */ +QStringList ConfigVehicleTypeWidget::getChannelDescriptions() +{ + ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); + UAVObjectManager *objMngr = pm->getObject(); + Q_ASSERT(objMngr); + + // get an instance of systemsettings + SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr); + Q_ASSERT(systemSettings); + SystemSettings::DataFields systemSettingsData = systemSettings->getData(); + + QStringList channelDesc; + switch (systemSettingsData.AirframeType) { + case SystemSettings::AIRFRAMETYPE_FIXEDWING: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: + case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: + // fixed wing + channelDesc = ConfigFixedWingWidget::getChannelDescriptions(); + break; + case SystemSettings::AIRFRAMETYPE_HELICP: + // helicp + channelDesc = ConfigCcpmWidget::getChannelDescriptions(); + break; + case SystemSettings::AIRFRAMETYPE_VTOL: + case SystemSettings::AIRFRAMETYPE_TRI: + case SystemSettings::AIRFRAMETYPE_QUADX: + case SystemSettings::AIRFRAMETYPE_QUADP: + case SystemSettings::AIRFRAMETYPE_OCTOV: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: + case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: + case SystemSettings::AIRFRAMETYPE_OCTO: + case SystemSettings::AIRFRAMETYPE_HEXAX: + case SystemSettings::AIRFRAMETYPE_HEXACOAX: + case SystemSettings::AIRFRAMETYPE_HEXA: + // multirotor + channelDesc = ConfigMultiRotorWidget::getChannelDescriptions(); + break; + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: + case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: + // ground + channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions(); + break; + default: + channelDesc = ConfigCustomWidget::getChannelDescriptions(); + break; + } + + return channelDesc; +} + ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWidget(parent) { m_aircraft = new Ui_AircraftWidget(); @@ -115,7 +171,7 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi } // Connect aircraft type selection dropbox to callback function - connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); + connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), m_aircraft->airframesWidget, SLOT(setCurrentIndex(int))); // Connect the three feed forward test checkboxes connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); @@ -132,7 +188,6 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi disableMouseWheelEvents(); } - /** Destructor */ @@ -141,76 +196,207 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() // Do nothing } -/** - Static function to get currently assigned channelDescriptions - for all known vehicle types; instantiates the appropriate object - then asks it to supply channel descs - */ -QStringList ConfigVehicleTypeWidget::getChannelDescriptions() -{ - ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager *objMngr = pm->getObject(); - Q_ASSERT(objMngr); - - // get an instance of systemsettings - SystemSettings *systemSettings = SystemSettings::GetInstance(objMngr); - Q_ASSERT(systemSettings); - SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - - QStringList channelDesc; - switch (systemSettingsData.AirframeType) { - case SystemSettings::AIRFRAMETYPE_FIXEDWING: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGELEVON: - case SystemSettings::AIRFRAMETYPE_FIXEDWINGVTAIL: - // fixed wing - channelDesc = ConfigFixedWingWidget::getChannelDescriptions(); - break; - case SystemSettings::AIRFRAMETYPE_HELICP: - // helicp - channelDesc = ConfigCcpmWidget::getChannelDescriptions(); - break; - case SystemSettings::AIRFRAMETYPE_VTOL: - case SystemSettings::AIRFRAMETYPE_TRI: - case SystemSettings::AIRFRAMETYPE_QUADX: - case SystemSettings::AIRFRAMETYPE_QUADP: - case SystemSettings::AIRFRAMETYPE_OCTOV: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXX: - case SystemSettings::AIRFRAMETYPE_OCTOCOAXP: - case SystemSettings::AIRFRAMETYPE_OCTO: - case SystemSettings::AIRFRAMETYPE_HEXAX: - case SystemSettings::AIRFRAMETYPE_HEXACOAX: - case SystemSettings::AIRFRAMETYPE_HEXA: - // multirotor - channelDesc = ConfigMultiRotorWidget::getChannelDescriptions(); - break; - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLECAR: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEDIFFERENTIAL: - case SystemSettings::AIRFRAMETYPE_GROUNDVEHICLEMOTORCYCLE: - // ground - channelDesc = ConfigGroundVehicleWidget::getChannelDescriptions(); - break; - default: - channelDesc = ConfigCustomWidget::getChannelDescriptions(); - break; - } - - return channelDesc; -} - - /** Slot for switching the airframe type. We do it explicitely rather than a signal in the UI, because we want to force a fitInView of the quad shapes. This is because this method (fitinview) only works when the widget is shown. */ -void ConfigVehicleTypeWidget::switchAirframeType(int index) +//void ConfigVehicleTypeWidget::switchAirframeType(int index) +//{ +// m_aircraft->airframesWidget->setCurrentIndex(index); +//} + +/** + \brief Sets up the mixer depending on Airframe type. Accepts either system settings or + combo box entry from airframe type, as those do not overlap. + */ +//void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) +//{ +// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin"; +// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType; +// +// bool dirty = isDirty(); +// +// QString category = frameCategory2(frameType); +// if (category == "FixedWing") { +// m_fixedwing->setupUI(frameType); +// } else if (category == "Multirotor") { +// m_multirotor->setupUI(frameType); +// } else if (category == "Helicopter") { +// m_heli->setupUI(frameType); +// } else if (category == "Ground") { +// m_groundvehicle->setupUI(frameType); +// } else if (category == "Custom") { +// m_custom->setupUI(frameType); +// } +// +// setDirty(dirty); +// +// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; +//} + +/** + Refreshes the current value of the SystemSettings which holds the aircraft type + */ +void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) { - m_aircraft->airframesWidget->setCurrentIndex(index); + Q_UNUSED(o); + + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin"; + + if (!allObjectsUpdated()) { + return; + } + + bool dirty = isDirty(); + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty; + + // Get the Airframe type from the system settings: + UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + Q_ASSERT(system); + + UAVObjectField *field = system->getField(QString("AirframeType")); + Q_ASSERT(field); + + // At this stage, we will need to have some hardcoded settings in this code, this + // is not ideal, but there you go. + QString frameType = field->getValue().toString(); + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; + //setupAirframeUI(frameType); + + QString category = "FixedWing";//frameCategory(frameType); + if (category == "FixedWing") { + // Retrieve fixed wing settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); + m_fixedwing->refreshWidgetsValues(frameType); + } else if (category == "Multirotor") { + // Retrieve multirotor settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); + m_multirotor->refreshWidgetsValues(frameType); + } else if (category == "Helicopter") { + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); + m_heli->refreshWidgetsValues(frameType); + } else if (category == "Ground") { + // Retrieve ground vehicle settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); + m_groundvehicle->refreshWidgetsValues(frameType); + } else if (category == "Custom") { + // Retrieve custom settings + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); + m_custom->refreshWidgetsValues(frameType); + } + + updateFeedForwardUI(); + + setDirty(dirty); + + qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end"; } -///////////////////////////////////////////////////////// -/// Feed Forward Testing -///////////////////////////////////////////////////////// +//QString ConfigVehicleTypeWidget::frameCategory1(QString frameType) +//{ +// QString category; +// if (frameType.startsWith("FixedWing")) { +// category = "FixedWing"; +// } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" +// || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV" +// || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") { +// category = "Multirotor"; +// } else if (frameType == "HeliCP") { +// category = "Helicopter"; +// } else if (frameType.startsWith("GroundVehicle")) { +// category = "Ground"; +// } else { +// category = "Custom"; +// } +// return category; +//} + + +QString ConfigVehicleTypeWidget::frameCategory(QString frameType) +{ + QString category; + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" + || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { + category = "FixedWing"; + } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" + || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" + || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax" + || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV" + || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" + || frameType == "OctoCoaxX" || frameType == "Octo Coax X") { + category = "Multirotor"; + } else if (frameType == "HeliCP") { + category = "Helicopter"; + } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" + || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" + || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { + category = "Ground"; + } else { + category = "Custom"; + } + return category; +} + +/** + Sends the config to the board (airframe type) + + We do all the tasks common to all airframes, or family of airframes, and + we call additional methods for specific frames, so that we do not have a code + that is too heavy. +*/ +void ConfigVehicleTypeWidget::updateObjectsFromWidgets() +{ + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QPointer vconfig = new VehicleConfig(); + + // Update feed forward settings + vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0); + vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value()); + vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); + vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); + + // Sets airframe type default to "Custom" + QString airframeType = "Custom"; + if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { + airframeType = m_fixedwing->updateConfigObjectsFromWidgets(); + } + else if (m_aircraft->aircraftType->currentText() == "Multirotor") { + airframeType = m_multirotor->updateConfigObjectsFromWidgets(); + } + else if (m_aircraft->aircraftType->currentText() == "Helicopter") { + airframeType = m_heli->updateConfigObjectsFromWidgets(); + } + else if (m_aircraft->aircraftType->currentText() == "Ground") { + airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); + } + else { + airframeType = m_custom->updateConfigObjectsFromWidgets(); + } + + // set the airframe type + UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); + Q_ASSERT(system); + + QPointer field = system->getField(QString("AirframeType")); + if (field) { + field->setValue(airframeType); + } + + updateFeedForwardUI(); +} + +/** + Reset the contents of a field + */ +//void ConfigVehicleTypeWidget::resetField(UAVObjectField *field) +//{ +// for (unsigned int i = 0; i < field->getNumElements(); i++) { +// field->setValue(0, i); +// } +//} /** Enables and runs feed forward testing @@ -271,150 +457,6 @@ void ConfigVehicleTypeWidget::enableFFTest() } } -/************************** - * Aircraft settings - **************************/ - -/** - Refreshes the current value of the SystemSettings which holds the aircraft type - */ -void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) -{ - Q_UNUSED(o); - - qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin"; - - if (!allObjectsUpdated()) { - return; - } - - bool dirty = isDirty(); - qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty; - - // Get the Airframe type from the system settings: - UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - Q_ASSERT(system); - - UAVObjectField *field = system->getField(QString("AirframeType")); - Q_ASSERT(field); - - // At this stage, we will need to have some hardcoded settings in this code, this - // is not ideal, but there you go. - QString frameType = field->getValue().toString(); - qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; - setupAirframeUI(frameType); - - QString category = frameCategory1(frameType); - if (category == "FixedWing") { - // Retrieve fixed wing settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); - m_fixedwing->refreshWidgetsValues(frameType); - } else if (category == "Multirotor") { - // Retrieve multirotor settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); - m_multirotor->refreshWidgetsValues(frameType); - } else if (category == "Helicopter") { - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); - m_heli->refreshWidgetsValues(frameType); - } else if (category == "Ground") { - // Retrieve ground vehicle settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); - m_groundvehicle->refreshWidgetsValues(frameType); - } else if (category == "Custom") { - // Retrieve custom settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); - m_custom->refreshWidgetsValues(frameType); - } - - updateFeedForwardUI(); - setDirty(dirty); - - qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end"; -} - -/** - \brief Sets up the mixer depending on Airframe type. Accepts either system settings or - combo box entry from airframe type, as those do not overlap. - */ -void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) -{ - qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin"; - qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType; - bool dirty = isDirty(); - - QString category = frameCategory2(frameType); - if (category == "FixedWing") { - m_fixedwing->setupUI(frameType); - } else if (category == "Multirotor") { - m_multirotor->setupUI(frameType); - } else if (category == "Helicopter") { - m_heli->setupUI(frameType); - } else if (category == "Ground") { - m_groundvehicle->setupUI(frameType); - } else if (category == "Custom") { - m_custom->setupUI(frameType); - } - - setDirty(dirty); - qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; -} - -QString ConfigVehicleTypeWidget::frameCategory1(QString frameType) -{ - QString category; - if (frameType.startsWith("FixedWing")) { - category = "FixedWing"; - } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" - || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV" - || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") { - category = "Multirotor"; - } else if (frameType == "HeliCP") { - category = "Helicopter"; - } else if (frameType.startsWith("GroundVehicle")) { - category = "Ground"; - } else { - category = "Custom"; - } - return category; -} - - -QString ConfigVehicleTypeWidget::frameCategory2(QString frameType) -{ - QString category; - if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" - || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { - category = "FixedWing"; - } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" - || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" - || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax" - || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV" - || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" - || frameType == "OctoCoaxX" || frameType == "Octo Coax X") { - category = "Multirotor"; - } else if (frameType == "HeliCP") { - category = "Helicopter"; - } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" - || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" - || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { - category = "Ground"; - } else { - category = "Custom"; - } - return category; -} - - -/** - Reset the contents of a field - */ -void ConfigVehicleTypeWidget::resetField(UAVObjectField * field) -{ - for (unsigned int i = 0; i < field->getNumElements(); i++) { - field->setValue(0, i); - } -} - /** Updates the custom airframe settings based on the current airframe. @@ -422,7 +464,7 @@ void ConfigVehicleTypeWidget::resetField(UAVObjectField * field) */ // TODO rename to FF void ConfigVehicleTypeWidget::updateFeedForwardUI() -{ +{ UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -435,56 +477,6 @@ void ConfigVehicleTypeWidget::updateFeedForwardUI() m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer,"MaxAccel")); } -/** - Sends the config to the board (airframe type) - - We do all the tasks common to all airframes, or family of airframes, and - we call additional methods for specific frames, so that we do not have a code - that is too heavy. -*/ -void ConfigVehicleTypeWidget::updateObjectsFromWidgets() -{ - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - QPointer vconfig = new VehicleConfig(); - - // Update feed forward settings - vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0); - vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value()); - vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); - vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - - // Sets airframe type default to "Custom" - QString airframeType = "Custom"; - if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { - airframeType = m_fixedwing->updateConfigObjectsFromWidgets(); - } - else if (m_aircraft->aircraftType->currentText() == "Multirotor") { - airframeType = m_multirotor->updateConfigObjectsFromWidgets(); - } - else if (m_aircraft->aircraftType->currentText() == "Helicopter") { - airframeType = m_heli->updateConfigObjectsFromWidgets(); - } - else if (m_aircraft->aircraftType->currentText() == "Ground") { - airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); - } - else { - airframeType = m_custom->updateConfigObjectsFromWidgets(); - } - - // set the airframe type - UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); - Q_ASSERT(system); - - QPointer field = system->getField(QString("AirframeType")); - if (field) { - field->setValue(airframeType); - } - - updateFeedForwardUI(); -} - /** Opens the wiki from the user's default browser */ diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index cdc64fed3..880a10650 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -43,10 +43,15 @@ class ConfigVehicleTypeWidget: public ConfigTaskWidget public: static QStringList getChannelDescriptions(); + static void setComboCurrentIndex(QComboBox *box, int index); ConfigVehicleTypeWidget(QWidget *parent = 0); ~ConfigVehicleTypeWidget(); +public slots: + virtual void refreshWidgetsValues(UAVObject *o = NULL); + virtual void updateObjectsFromWidgets(); + private: Ui_AircraftWidget *m_aircraft; @@ -57,10 +62,8 @@ private: VehicleConfig *m_custom; void updateFeedForwardUI(); - void resetField(UAVObjectField *field); - QString frameCategory1(QString frameType); - QString frameCategory2(QString frameType); + QString frameCategory(QString frameType); QStringList channelNames; QStringList mixerTypes; @@ -71,16 +74,6 @@ private: UAVObject::Metadata accInitialData; private slots: - - virtual void refreshWidgetsValues(UAVObject *o = NULL); - virtual void updateObjectsFromWidgets(); - - void setComboCurrentIndex(QComboBox *box, int index); - - void setupAirframeUI(QString type); - // TODO ? - void switchAirframeType(int index); - void enableFFTest(); void openHelp(); From 80b658cebf141591302c9a6a8a68a228fa2db2e1 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sat, 13 Apr 2013 17:37:34 +0200 Subject: [PATCH 12/32] OP-907 step 3: vehicle config code formatting cleanups --- .../cfg_vehicletypes/configccpmwidget.cpp | 178 +++---- .../cfg_vehicletypes/configcustomwidget.cpp | 8 +- .../configfixedwingwidget.cpp | 360 ++++++------- .../configgroundvehiclewidget.cpp | 447 ++++++++-------- .../configmultirotorwidget.cpp | 487 +++++++----------- .../config/cfg_vehicletypes/vehicleconfig.cpp | 60 +-- .../config/configvehicletypewidget.cpp | 38 +- 7 files changed, 706 insertions(+), 872 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 19ed4bcfe..219ad53d2 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -44,12 +44,9 @@ QStringList ConfigCcpmWidget::getChannelDescriptions() { - int i; - QStringList channelDesc; - // init a channel_numelem list of channel desc defaults - for (i=0; i < (int)(ConfigCcpmWidget::CHANNEL_NUMELEM); i++) - { + QStringList channelDesc; + for (int i = 0; i < (int) ConfigCcpmWidget::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } @@ -57,87 +54,94 @@ QStringList ConfigCcpmWidget::getChannelDescriptions() GUIConfigDataUnion configData = GetConfigData(); heliGUISettingsStruct heli = configData.heli; - if (heli.Throttle > 0) + if (heli.Throttle > 0) { channelDesc[heli.Throttle - 1] = QString("Throttle"); - if (heli.Tail > 0) - channelDesc[heli.Tail - 1] = QString("Tail"); - - switch(heli.FirstServoIndex) - { - case 0: //front - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); - break; - - case 1: //right - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); - break; - - case 2: //rear - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); - break; - - case 3: //left - if (heli.ServoIndexW > 0) - channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); - if (heli.ServoIndexX > 0) - channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); - if (heli.ServoIndexY > 0) - channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); - break; - } - if (heli.ServoIndexZ > 0) - channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); + if (heli.Tail > 0) { + channelDesc[heli.Tail - 1] = QString("Tail"); + } + switch (heli.FirstServoIndex) { + case 0: + // front + if (heli.ServoIndexW > 0) { + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + } + if (heli.ServoIndexX > 0) { + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + } + if (heli.ServoIndexY > 0) { + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + } + break; + case 1: + // right + if (heli.ServoIndexW > 0) { + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + } + if (heli.ServoIndexX > 0) { + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + } + if (heli.ServoIndexY > 0) { + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + } + break; + case 2: + // rear + if (heli.ServoIndexW > 0) { + channelDesc[heli.ServoIndexW - 1] = QString("Elevator"); + } + if (heli.ServoIndexX > 0) { + channelDesc[heli.ServoIndexX - 1] = QString("Roll1"); + } + if (heli.ServoIndexY > 0) { + channelDesc[heli.ServoIndexY - 1] = QString("Roll2"); + } + break; + case 3: + // left + if (heli.ServoIndexW > 0) { + channelDesc[heli.ServoIndexW - 1] = QString("ServoW"); + } + if (heli.ServoIndexX > 0) { + channelDesc[heli.ServoIndexX - 1] = QString("ServoX"); + } + if (heli.ServoIndexY > 0) { + channelDesc[heli.ServoIndexY - 1] = QString("ServoY"); + } + break; + } + if (heli.ServoIndexZ > 0) { + channelDesc[heli.ServoIndexZ - 1] = QString("ServoZ"); + } return channelDesc; } ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : - VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget()) + VehicleConfig(parent), m_aircraft(new Ui_CcpmConfigWidget()) { m_aircraft->setupUi(this); - //Ui_CcpmConfigWidget *m_aircraft = m_aircraft; - SwashLvlConfigurationInProgress = 0; SwashLvlState = 0; SwashLvlServoInterlock = 0; updatingFromHardware = FALSE; updatingToHardware = FALSE; - //m_aircraft = new Ui_ccpmWidget(); - //m_aircraft->setupUi(this); - // Initialization of the swashplaye widget m_aircraft->SwashplateImage->setScene(new QGraphicsScene(this)); m_aircraft->SwashLvlSwashplateImage->setScene(m_aircraft->SwashplateImage->scene()); - m_aircraft->SwashLvlSwashplateImage->setSceneRect(-50,-50,500,500); + m_aircraft->SwashLvlSwashplateImage->setSceneRect(-50, -50, 500, 500); //m_aircraft->SwashLvlSwashplateImage->scale(.85,.85); //m_aircraft->SwashplateImage->setSceneRect(SwashplateImg->boundingRect()); - m_aircraft->SwashplateImage->setSceneRect(-50,-30,500,500); + m_aircraft->SwashplateImage->setSceneRect(-50, -30, 500, 500); //m_aircraft->SwashplateImage->scale(.85,.85); QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(QString(":/configgadget/images/ccpm_setup.svg")); - SwashplateImg = new QGraphicsSvgItem(); SwashplateImg->setSharedRenderer(renderer); SwashplateImg->setElementId("Swashplate"); @@ -146,7 +150,8 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : m_aircraft->SwashplateImage->scene()->addItem(SwashplateImg); QFont serifFont("Times", 24, QFont::Bold); - QPen pen; // creates a default pen + // creates a default pen + QPen pen; pen.setStyle(Qt::DotLine); pen.setWidth(2); @@ -154,24 +159,23 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : pen.setCapStyle(Qt::RoundCap); pen.setJoinStyle(Qt::RoundJoin); - QBrush brush(Qt::darkBlue); - QPen pen2; // creates a default pen - + // creates a default pen + QPen pen2; + //pen2.setStyle(Qt::DotLine); pen2.setWidth(1); pen2.setBrush(Qt::blue); //pen2.setCapStyle(Qt::RoundCap); //pen2.setJoinStyle(Qt::RoundJoin); - - - //brush.setStyle(Qt::RadialGradientPattern); - + + //brush.setStyle(Qt::RadialGradientPattern); + QList ServoNames; - ServoNames << "ServoW" << "ServoX" << "ServoY" << "ServoZ" ; + ServoNames << "ServoW" << "ServoX" << "ServoY" << "ServoZ"; for (int i = 0; i < CCPM_MAX_SWASH_SERVOS; i++) { - ServoLines[i] = m_aircraft->SwashLvlSwashplateImage->scene()->addLine(0,0,100*i,i*i*100,pen); + ServoLines[i] = m_aircraft->SwashLvlSwashplateImage->scene()->addLine(0, 0, 100 * i, i * i * 100, pen); Servos[i] = new QGraphicsSvgItem(); Servos[i]->setSharedRenderer(renderer); @@ -182,14 +186,12 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : ServosText[i]->setDefaultTextColor(Qt::yellow); ServosText[i]->setPlainText(QString("-")); ServosText[i]->setFont(serifFont); - - ServosTextCircles[i] = new QGraphicsEllipseItem(1,1,30,30); + + ServosTextCircles[i] = new QGraphicsEllipseItem(1, 1, 30, 30); ServosTextCircles[i]->setBrush(brush); ServosTextCircles[i]->setPen(pen2); m_aircraft->SwashplateImage->scene()->addItem(ServosTextCircles[i]); m_aircraft->SwashplateImage->scene()->addItem(ServosText[i]); - - SwashLvlSpinBoxes[i] = new QSpinBox(m_aircraft->SwashLvlSwashplateImage); // use QGraphicsView m_aircraft->SwashLvlSwashplateImage->scene()->addWidget(SwashLvlSpinBoxes[i]); @@ -199,7 +201,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : } - //initialize our two mixer curves + // initialize our two mixer curves // mixercurve defaults to mixercurve_throttle m_aircraft->ThrottleCurve->initLinearCurve(5, 1.0, 0.0); @@ -207,7 +209,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : m_aircraft->PitchCurve->setMixerType(MixerCurve::MIXERCURVE_PITCH); m_aircraft->PitchCurve->initLinearCurve(5, 1.0, -1.0); - //initialize channel names + // initialize channel names m_aircraft->ccpmEngineChannel->addItems(channelNames); m_aircraft->ccpmEngineChannel->setCurrentIndex(0); m_aircraft->ccpmTailChannel->addItems(channelNames); @@ -222,11 +224,11 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : m_aircraft->ccpmServoZChannel->setCurrentIndex(0); QStringList Types; - Types << QString::fromUtf8("CCPM 2 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 90º") << QString::fromUtf8("CCPM 4 Servo 90º") << - QString::fromUtf8("CCPM 3 Servo 120º") << QString::fromUtf8("CCPM 3 Servo 140º") << - QString::fromUtf8("FP 2 Servo 90º") << - QString::fromUtf8("Coax 2 Servo 90º") << - QString::fromUtf8("Custom - User Angles") << QString::fromUtf8("Custom - Advanced Settings"); + Types << QString::fromUtf8("CCPM 2 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 90º") + << QString::fromUtf8("CCPM 4 Servo 90º") << QString::fromUtf8("CCPM 3 Servo 120º") + << QString::fromUtf8("CCPM 3 Servo 140º") << QString::fromUtf8("FP 2 Servo 90º") + << QString::fromUtf8("Coax 2 Servo 90º") << QString::fromUtf8("Custom - User Angles") + << QString::fromUtf8("Custom - Advanced Settings"); m_aircraft->ccpmType->addItems(Types); m_aircraft->ccpmType->setCurrentIndex(m_aircraft->ccpmType->count() - 1); @@ -258,10 +260,10 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : connect(m_aircraft->SwashLvlCancelButton, SIGNAL(clicked()), this, SLOT(SwashLvlCancelButtonPressed())); connect(m_aircraft->SwashLvlFinishButton, SIGNAL(clicked()), this, SLOT(SwashLvlFinishButtonPressed())); - connect(m_aircraft->ccpmCollectivePassthrough, SIGNAL(clicked()),this, SLOT(SetUIComponentVisibilities())); + connect(m_aircraft->ccpmCollectivePassthrough, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); connect(m_aircraft->ccpmLinkCyclic, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); connect(m_aircraft->ccpmLinkRoll, SIGNAL(clicked()), this, SLOT(SetUIComponentVisibilities())); - + ccpmSwashplateRedraw(); } @@ -293,19 +295,19 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) GUIConfigDataUnion config = GetConfigData(); - //swashplate config + // swashplate config setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex); - //ccpm mixing options + // ccpm mixing options m_aircraft->ccpmCollectivePassthrough->setChecked(config.heli.ccpmCollectivePassthroughState); m_aircraft->ccpmLinkCyclic->setChecked(config.heli.ccpmLinkCyclicState); m_aircraft->ccpmLinkRoll->setChecked(config.heli.ccpmLinkRollState); - //correction angle + // correction angle m_aircraft->ccpmCorrectionAngle->setValue(config.heli.CorrectionAngle); - //update sliders + // update sliders m_aircraft->ccpmCollectiveScale->setValue(config.heli.SliderValue0); m_aircraft->ccpmCollectiveScaleBox->setValue(config.heli.SliderValue0); m_aircraft->ccpmCyclicScale->setValue(config.heli.SliderValue1); @@ -317,15 +319,15 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) m_aircraft->ccpmCollectiveSlider->setValue(config.heli.SliderValue0); m_aircraft->ccpmCollectivespinBox->setValue(config.heli.SliderValue0); - //servo assignments + // servo assignments setComboCurrentIndex(m_aircraft->ccpmServoWChannel, config.heli.ServoIndexW); setComboCurrentIndex( m_aircraft->ccpmServoXChannel,config.heli.ServoIndexX); setComboCurrentIndex( m_aircraft->ccpmServoYChannel,config.heli.ServoIndexY); setComboCurrentIndex( m_aircraft->ccpmServoZChannel,config.heli.ServoIndexZ); - //throttle + // throttle setComboCurrentIndex( m_aircraft->ccpmEngineChannel, config.heli.Throttle); - //tail + // tail setComboCurrentIndex( m_aircraft->ccpmTailChannel, config.heli.Tail); getMixer(); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 2a62bc5df..6d0aa91b5 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -41,7 +41,7 @@ QStringList ConfigCustomWidget::getChannelDescriptions() { QStringList channelDesc; - for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } return channelDesc; @@ -58,14 +58,14 @@ ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) : UAVObjectField* field = mixer->getField(QString("Mixer1Type")); QStringList list = field->getOptions(); - for (int i = 0; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) { QComboBox* qb = new QComboBox(m_aircraft->customMixerTable); qb->addItems(list); m_aircraft->customMixerTable->setCellWidget(0, i, qb); } SpinBoxDelegate *sbd = new SpinBoxDelegate(); - for (int i = 1; i < (int) (VehicleConfig::CHANNEL_NUMELEM); i++) { + for (int i = 1; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) { m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } } @@ -164,7 +164,7 @@ QString ConfigCustomWidget::updateConfigObjectsFromWidgets() setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, m_aircraft->customThrottle2Curve->getCurve()); // Update the table: - for (int channel = 0; channel < (int) (VehicleConfig::CHANNEL_NUMELEM); channel++) { + for (int channel = 0; channel < (int) VehicleConfig::CHANNEL_NUMELEM; channel++) { QComboBox* q = (QComboBox*) m_aircraft->customMixerTable->cellWidget(0, channel); if (q->currentText() == "Disabled") { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index cd0ea1598..9bdc792c8 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -44,7 +44,7 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults QStringList channelDesc; - for (int i = 0; i < (int) (ConfigFixedWingWidget::CHANNEL_NUMELEM); i++) { + for (int i = 0; i < (int) ConfigFixedWingWidget::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } @@ -105,7 +105,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType) Q_ASSERT(m_aircraft); if (frameType == "FixedWing" || frameType == "Elevator aileron rudder") { - //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevator aileron rudder")); m_aircraft->fwRudder1ChannelBox->setEnabled(true); m_aircraft->fwRudder1Label->setEnabled(true); @@ -127,7 +126,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonMixBox->setHidden(true); } else if (frameType == "FixedWingElevon" || frameType == "Elevon") { - //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Elevon")); m_aircraft->fwAileron1Label->setText("Elevon 1"); m_aircraft->fwAileron2Label->setText("Elevon 2"); @@ -146,7 +144,6 @@ void ConfigFixedWingWidget::setupUI(QString frameType) m_aircraft->elevonLabel2->setText("Pitch"); } else if (frameType == "FixedWingVtail" || frameType == "Vtail") { - //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); setComboCurrentIndex(m_aircraft->fixedWingType, m_aircraft->fixedWingType->findText("Vtail")); m_aircraft->fwRudder1ChannelBox->setEnabled(false); m_aircraft->fwRudder1Label->setEnabled(false); @@ -177,38 +174,6 @@ void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData) configData->fixedwing.FixedWingThrottle = 0; } -/** - Virtual function to update the UI widget objects - */ -QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() -{ - QString airframeType = "FixedWing"; - - // Save the curve (common to all Fixed wing frames) - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - // Remove Feed Forward, it is pointless on a plane: - setMixerValue(mixer, "FeedForward", 0.0); - - // Set the throttle curve - setThrottleCurve(mixer,VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->fixedWingThrottle->getCurve()); - - //All airframe types must start with "FixedWing" - if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) { - airframeType = "FixedWing"; - setupFrameFixedWing( airframeType ); - } else if (m_aircraft->fixedWingType->currentText() == "Elevon") { - airframeType = "FixedWingElevon"; - setupFrameElevon( airframeType ); - } else { // "Vtail" - airframeType = "FixedWingVtail"; - setupFrameVtail( airframeType ); - } - - return airframeType; -} - /** Virtual function to refresh the UI widget values */ @@ -234,14 +199,6 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); } - - - - - - - - GUIConfigDataUnion config = GetConfigData(); fixedGUISettingsStruct fixed = config.fixedwing; @@ -254,14 +211,10 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) setComboCurrentIndex(m_aircraft->fwRudder1ChannelBox, fixed.FixedWingYaw1); setComboCurrentIndex(m_aircraft->fwRudder2ChannelBox, fixed.FixedWingYaw2); - //UAVDataObject* mixer= dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - //Q_ASSERT(mixer); - - int channel; if (frameType == "FixedWingElevon") { // If the airframe is elevon, restore the slider setting // Find the channel number for Elevon1 (FixedWingRoll1) - channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; + int channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. m_aircraft->elevonSlider1->setValue( @@ -271,7 +224,7 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) } } else if (frameType == "FixedWingVtail") { - channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1; + int channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1; if (channel > -1) { // If for some reason the actuators were incoherent, we might fail here, hence the check. m_aircraft->elevonSlider1->setValue( @@ -282,7 +235,37 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) } } +/** + Virtual function to update the UI widget objects + */ +QString ConfigFixedWingWidget::updateConfigObjectsFromWidgets() +{ + QString airframeType = "FixedWing"; + // Save the curve (common to all Fixed wing frames) + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + // Remove Feed Forward, it is pointless on a plane: + setMixerValue(mixer, "FeedForward", 0.0); + + // Set the throttle curve + setThrottleCurve(mixer,VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->fixedWingThrottle->getCurve()); + + // All airframe types must start with "FixedWing" + if (m_aircraft->fixedWingType->currentText() == "Elevator aileron rudder" ) { + airframeType = "FixedWing"; + setupFrameFixedWing( airframeType ); + } else if (m_aircraft->fixedWingType->currentText() == "Elevon") { + airframeType = "FixedWingElevon"; + setupFrameElevon( airframeType ); + } else { // "Vtail" + airframeType = "FixedWingVtail"; + setupFrameVtail( airframeType ); + } + + return airframeType; +} /** Setup Elevator/Aileron/Rudder airframe. @@ -294,13 +277,12 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) { // Check coherence: - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(airframeType)) { - return false; - } + return false; + } // Now setup the channels: - GUIConfigDataUnion config = GetConfigData(); resetActuators(&config); @@ -312,7 +294,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); SetConfigData(config); - + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); @@ -323,56 +305,54 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) // 1. Assign the servo/motor/none for each channel - //motor - int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); - setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + // motor + int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); - //rudder - channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + // rudder + channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); - //ailerons - channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; + // ailerons + channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; if (channel > -1) { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); - channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); } - //elevators - channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; + // elevators + channel = m_aircraft->fwElevator1ChannelBox->currentIndex() - 1; if (channel > -1) { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127); - channel = m_aircraft->fwElevator2ChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + channel = m_aircraft->fwElevator2ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, 127); } m_aircraft->fwStatusLabel->setText("Mixer generated"); - + return true; } - - /** Setup Elevon */ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) { // Check coherence: - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(airframeType)) { return false; } - + GUIConfigDataUnion config = GetConfigData(); resetActuators(&config); @@ -383,7 +363,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); SetConfigData(config); - + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); @@ -397,34 +377,34 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) double value; - //motor - int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); - setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); + // motor + int channel = m_aircraft->fwEngineChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_MOTOR); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); - //rudders - channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + // rudders + channel = m_aircraft->fwRudder1ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); - channel = m_aircraft->fwRudder2ChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); + channel = m_aircraft->fwRudder2ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - //ailerons - channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; + // ailerons + channel = m_aircraft->fwAileron1ChannelBox->currentIndex() - 1; if (channel > -1) { - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); - value = (double)(m_aircraft->elevonSlider2->value()*1.27); + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + value = (double) (m_aircraft->elevonSlider2->value() * 1.27); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); - value = (double)(m_aircraft->elevonSlider1->value()*1.27); + value = (double) (m_aircraft->elevonSlider1->value() * 1.27); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, value); - channel = m_aircraft->fwAileron2ChannelBox->currentIndex()-1; - setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); - value = (double)(m_aircraft->elevonSlider2->value()*1.27); + channel = m_aircraft->fwAileron2ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); + value = (double) (m_aircraft->elevonSlider2->value() * 1.27); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); - value = (double)(m_aircraft->elevonSlider1->value()*1.27); + value = (double) (m_aircraft->elevonSlider1->value() * 1.27); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -value); } @@ -432,15 +412,13 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) return true; } - - /** Setup VTail */ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) { // Check coherence: - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(airframeType)) { return false; } @@ -467,14 +445,12 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) // 1. Assign the servo/motor/none for each channel - double value; - - //motor + // motor int channel = m_aircraft->fwEngineChannelBox->currentIndex()-1; setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_MOTOR); setMixerVectorValue(mixer,channel,VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); - //rudders + // rudders channel = m_aircraft->fwRudder1ChannelBox->currentIndex()-1; setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); @@ -483,7 +459,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - //ailerons + // ailerons channel = m_aircraft->fwAileron1ChannelBox->currentIndex()-1; if (channel > -1) { setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); @@ -494,11 +470,11 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -127); } - //vtail + // vtail channel = m_aircraft->fwElevator1ChannelBox->currentIndex()-1; if (channel > -1) { setMixerType(mixer,channel,VehicleConfig::MIXERTYPE_SERVO); - value = (double)(m_aircraft->elevonSlider2->value()*1.27); + double value = (double)(m_aircraft->elevonSlider2->value()*1.27); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, value); value = (double)(m_aircraft->elevonSlider1->value()*1.27); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, value); @@ -520,96 +496,88 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) */ bool ConfigFixedWingWidget::throwConfigError(QString airframeType) { - //Initialize configuration error flag - bool error=false; - - //Create a red block. All combo boxes are the same size, so any one should do as a model - int size = m_aircraft->fwEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize); - QPixmap pixmap(size,size); - pixmap.fill(QColor("red")); - - if (airframeType == "FixedWing" ) { - if (m_aircraft->fwEngineChannelBox->currentText() == "None"){ - m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if (m_aircraft->fwElevator1ChannelBox->currentText() == "None"){ - m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if ((m_aircraft->fwAileron1ChannelBox->currentText() == "None") && (m_aircraft->fwRudder1ChannelBox->currentText() == "None")) { - pixmap.fill(QColor("green")); - m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - m_aircraft->fwRudder1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - m_aircraft->fwRudder1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - } else if (airframeType == "FixedWingElevon"){ - if (m_aircraft->fwEngineChannelBox->currentText() == "None"){ - m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if(m_aircraft->fwAileron1ChannelBox->currentText() == "None"){ - m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if (m_aircraft->fwAileron2ChannelBox->currentText() == "None"){ - m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwAileron2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - } else if ( airframeType == "FixedWingVtail"){ - if (m_aircraft->fwEngineChannelBox->currentText() == "None"){ - m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if(m_aircraft->fwElevator1ChannelBox->currentText() == "None"){ - m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if(m_aircraft->fwElevator2ChannelBox->currentText() == "None"){ - m_aircraft->fwElevator2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->fwElevator2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - } - - if (error){ - m_aircraft->fwStatusLabel->setText(QString("ERROR: Assign all necessary channels")); - } + // Initialize configuration error flag + bool error = false; + + // Create a red block. All combo boxes are the same size, so any one should do as a model + int size = m_aircraft->fwEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize); + QPixmap pixmap(size, size); + pixmap.fill(QColor("red")); + + if (airframeType == "FixedWing") { + if (m_aircraft->fwEngineChannelBox->currentText() == "None") { + m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (m_aircraft->fwElevator1ChannelBox->currentText() == "None") { + m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if ((m_aircraft->fwAileron1ChannelBox->currentText() == "None") + && (m_aircraft->fwRudder1ChannelBox->currentText() == "None")) { + pixmap.fill(QColor("green")); + m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + m_aircraft->fwRudder1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + m_aircraft->fwRudder1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + } else if (airframeType == "FixedWingElevon") { + if (m_aircraft->fwEngineChannelBox->currentText() == "None") { + m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (m_aircraft->fwAileron1ChannelBox->currentText() == "None") { + m_aircraft->fwAileron1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwAileron1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (m_aircraft->fwAileron2ChannelBox->currentText() == "None") { + m_aircraft->fwAileron2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwAileron2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + } else if (airframeType == "FixedWingVtail") { + if (m_aircraft->fwEngineChannelBox->currentText() == "None") { + m_aircraft->fwEngineChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwEngineChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (m_aircraft->fwElevator1ChannelBox->currentText() == "None") { + m_aircraft->fwElevator1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwElevator1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (m_aircraft->fwElevator2ChannelBox->currentText() == "None") { + m_aircraft->fwElevator2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->fwElevator2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + } + + if (error) { + m_aircraft->fwStatusLabel->setText(QString("ERROR: Assign all necessary channels")); + } return error; } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 9704cce75..12caf4932 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -25,7 +25,6 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include "configgroundvehiclewidget.h" -//#include "configvehicletypewidget.h" #include "mixersettings.h" #include "systemsettings.h" #include "actuatorsettings.h" @@ -38,14 +37,15 @@ #include #include #include -#include #include +#include + QStringList ConfigGroundVehicleWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults QStringList channelDesc; - for (int i = 0; i < (int) (ConfigGroundVehicleWidget::CHANNEL_NUMELEM); i++) { + for (int i = 0; i < (int) ConfigGroundVehicleWidget::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } @@ -91,100 +91,97 @@ ConfigGroundVehicleWidget::~ConfigGroundVehicleWidget() /** Virtual function to setup the UI - TODO move to constructor or make private */ void ConfigGroundVehicleWidget::setupUI(QString frameType) { - m_aircraft->differentialSteeringMixBox->setHidden(true); - //STILL NEEDS WORK + m_aircraft->differentialSteeringMixBox->setHidden(true); + //STILL NEEDS WORK - // Setup the UI - //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); - - m_aircraft->gvEngineChannelBox->setEnabled(false); - m_aircraft->gvEngineLabel->setEnabled(false); - - m_aircraft->gvAileron1ChannelBox->setEnabled(false); - m_aircraft->gvAileron1Label->setEnabled(false); - - m_aircraft->gvAileron2ChannelBox->setEnabled(false); - m_aircraft->gvAileron2Label->setEnabled(false); - - if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") { - // Tank - setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Differential (tank)")); - m_aircraft->gvMotor1ChannelBox->setEnabled(true); - m_aircraft->gvMotor1Label->setEnabled(true); - - m_aircraft->gvMotor2ChannelBox->setEnabled(true); - m_aircraft->gvMotor2Label->setEnabled(true); + // Setup the UI - m_aircraft->gvMotor1Label->setText("Left motor"); - m_aircraft->gvMotor2Label->setText("Right motor"); + m_aircraft->gvEngineChannelBox->setEnabled(false); + m_aircraft->gvEngineLabel->setEnabled(false); - m_aircraft->gvSteering1ChannelBox->setEnabled(false); - m_aircraft->gvSteering1Label->setEnabled(false); - - m_aircraft->gvSteering2ChannelBox->setEnabled(false); - m_aircraft->gvSteering2Label->setEnabled(false); + m_aircraft->gvAileron1ChannelBox->setEnabled(false); + m_aircraft->gvAileron1Label->setEnabled(false); - m_aircraft->gvSteering2Label->setText("Rear steering"); + m_aircraft->gvAileron2ChannelBox->setEnabled(false); + m_aircraft->gvAileron2Label->setEnabled(false); - m_aircraft->differentialSteeringMixBox->setHidden(false); + if (frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)") { + // Tank + setComboCurrentIndex(m_aircraft->groundVehicleType, + m_aircraft->groundVehicleType->findText("Differential (tank)")); + m_aircraft->gvMotor1ChannelBox->setEnabled(true); + m_aircraft->gvMotor1Label->setEnabled(true); - m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve"); - m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve"); + m_aircraft->gvMotor2ChannelBox->setEnabled(true); + m_aircraft->gvMotor2Label->setEnabled(true); - } - else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") { - // Motorcycle + m_aircraft->gvMotor1Label->setText("Left motor"); + m_aircraft->gvMotor2Label->setText("Right motor"); + + m_aircraft->gvSteering1ChannelBox->setEnabled(false); + m_aircraft->gvSteering1Label->setEnabled(false); + + m_aircraft->gvSteering2ChannelBox->setEnabled(false); + m_aircraft->gvSteering2Label->setEnabled(false); + + m_aircraft->gvSteering2Label->setText("Rear steering"); + + m_aircraft->differentialSteeringMixBox->setHidden(false); + + m_aircraft->gvThrottleCurve1GroupBox->setTitle("Left throttle curve"); + m_aircraft->gvThrottleCurve2GroupBox->setTitle("Right throttle curve"); + + } else if (frameType == "GroundVehicleMotorcycle" || frameType == "Motorcycle") { + // Motorcycle setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Motorcycle")); - m_aircraft->gvMotor1ChannelBox->setEnabled(false); - m_aircraft->gvMotor1Label->setEnabled(false); + m_aircraft->gvMotor1ChannelBox->setEnabled(false); + m_aircraft->gvMotor1Label->setEnabled(false); - m_aircraft->gvMotor2ChannelBox->setEnabled(true); - m_aircraft->gvMotor2Label->setEnabled(true); + m_aircraft->gvMotor2ChannelBox->setEnabled(true); + m_aircraft->gvMotor2Label->setEnabled(true); - m_aircraft->gvMotor1Label->setText("Front motor"); - m_aircraft->gvMotor2Label->setText("Rear motor"); + m_aircraft->gvMotor1Label->setText("Front motor"); + m_aircraft->gvMotor2Label->setText("Rear motor"); - m_aircraft->gvSteering1ChannelBox->setEnabled(true); - m_aircraft->gvSteering1Label->setEnabled(true); - - m_aircraft->gvSteering2ChannelBox->setEnabled(true); - m_aircraft->gvSteering2Label->setEnabled(true); + m_aircraft->gvSteering1ChannelBox->setEnabled(true); + m_aircraft->gvSteering1Label->setEnabled(true); - m_aircraft->gvSteering2Label->setText("Balancing"); + m_aircraft->gvSteering2ChannelBox->setEnabled(true); + m_aircraft->gvSteering2Label->setEnabled(true); - m_aircraft->differentialSteeringMixBox->setHidden(true); - - m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve"); - m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); - } - else { - // Car + m_aircraft->gvSteering2Label->setText("Balancing"); + + m_aircraft->differentialSteeringMixBox->setHidden(true); + + m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve"); + m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); + } else { + // Car setComboCurrentIndex(m_aircraft->groundVehicleType, m_aircraft->groundVehicleType->findText("Turnable (car)")); - - m_aircraft->gvMotor1ChannelBox->setEnabled(true); - m_aircraft->gvMotor1Label->setEnabled(true); - m_aircraft->gvMotor2ChannelBox->setEnabled(true); - m_aircraft->gvMotor2Label->setEnabled(true); - - m_aircraft->gvMotor1Label->setText("Front motor"); - m_aircraft->gvMotor2Label->setText("Rear motor"); - - m_aircraft->gvSteering1ChannelBox->setEnabled(true); - m_aircraft->gvSteering1Label->setEnabled(true); - - m_aircraft->gvSteering2ChannelBox->setEnabled(true); - m_aircraft->gvSteering2Label->setEnabled(true); - - m_aircraft->differentialSteeringMixBox->setHidden(true); - - m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve"); - m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); - } + m_aircraft->gvMotor1ChannelBox->setEnabled(true); + m_aircraft->gvMotor1Label->setEnabled(true); + + m_aircraft->gvMotor2ChannelBox->setEnabled(true); + m_aircraft->gvMotor2Label->setEnabled(true); + + m_aircraft->gvMotor1Label->setText("Front motor"); + m_aircraft->gvMotor2Label->setText("Rear motor"); + + m_aircraft->gvSteering1ChannelBox->setEnabled(true); + m_aircraft->gvSteering1Label->setEnabled(true); + + m_aircraft->gvSteering2ChannelBox->setEnabled(true); + m_aircraft->gvSteering2Label->setEnabled(true); + + m_aircraft->differentialSteeringMixBox->setHidden(true); + + m_aircraft->gvThrottleCurve1GroupBox->setTitle("Front throttle curve"); + m_aircraft->gvThrottleCurve2GroupBox->setTitle("Rear throttle curve"); + } } void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) @@ -214,8 +211,7 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) if (isValidThrottleCurve(&curveValues)) { // yes, use the curve we just read from mixersettings m_aircraft->groundVehicleThrottle1->initCurve(&curveValues); - } - else { + } else { // no, init a straight curve m_aircraft->groundVehicleThrottle1->initLinearCurve(curveValues.count(), 1.0); } @@ -225,26 +221,12 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) if (isValidThrottleCurve(&curveValues)) { m_aircraft->groundVehicleThrottle2->initCurve(&curveValues); - } - else { + } else { m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); } - - - - - - - - - - - //UAVDataObject *obj; - //UAVObjectField *field; - GUIConfigDataUnion config = GetConfigData(); - //THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE + // THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE // Retrieve channel setup values setComboCurrentIndex(m_aircraft->gvMotor1ChannelBox, config.ground.GroundVehicleThrottle1); setComboCurrentIndex(m_aircraft->gvMotor2ChannelBox, config.ground.GroundVehicleThrottle2); @@ -266,9 +248,8 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) m_aircraft->differentialSteeringSlider2->setValue( getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH) * 100); } - } - else if (frameType == "GroundVehicleMotorcycle") { - //CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE + } else if (frameType == "GroundVehicleMotorcycle") { + // CURRENTLY BROKEN UNTIL WE DECIDE HOW MOTORCYCLE SHOULD BEHAVE // obj = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); // Q_ASSERT(obj); // int chMixerNumber = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; @@ -288,12 +269,12 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) */ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() { - QString airframeType = "GroundVehicleCar"; + QString airframeType = "GroundVehicleCar"; - // Save the curve (common to all ground vehicle frames) + // Save the curve (common to all ground vehicle frames) UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - // Remove Feed Forward, it is pointless on a ground vehicle: + // Remove Feed Forward, it is pointless on a ground vehicle: setMixerValue(mixer, "FeedForward", 0.0); // set the throttle curves @@ -312,7 +293,7 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() setupGroundVehicleMotorcycle(airframeType); } - return airframeType; + return airframeType; } /** @@ -320,14 +301,15 @@ QString ConfigGroundVehicleWidget::updateConfigObjectsFromWidgets() Returns False if impossible to create the mixer. */ -bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeType){ - // Check coherence: - //Show any config errors in GUI +bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeType) +{ + // Check coherence: + // Show any config errors in GUI if (throwConfigError(airframeType)) { - return false; - } + return false; + } - // Now setup the channels: + // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); resetActuators(&config); @@ -335,31 +317,31 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); SetConfigData(config); - + UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); - //motor - int channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; + // motor + int channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); - //steering - channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; + // steering + channel = m_aircraft->gvSteering1ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, -127); - //balance - channel = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; + // balance + channel = m_aircraft->gvSteering2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, 127); - m_aircraft->gvStatusLabel->setText("Mixer generated"); - + m_aircraft->gvStatusLabel->setText("Mixer generated"); + return true; } @@ -368,42 +350,43 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp Returns False if impossible to create the mixer. */ -bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeType){ - // Check coherence: - //Show any config errors in GUI +bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeType) +{ + // Check coherence: + // Show any config errors in GUI if (throwConfigError(airframeType)) { - return false; - } + return false; + } // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); resetActuators(&config); - + config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); SetConfigData((config)); - + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); - //left motor - int channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; + // left motor + int channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); - //right motor - channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; + // right motor + channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1; setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - //Output success message - m_aircraft->gvStatusLabel->setText("Mixer generated"); - + // Output success message + m_aircraft->gvStatusLabel->setText("Mixer generated"); + return true; } @@ -415,15 +398,15 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) { // Check coherence: - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(airframeType)) { - return false; - } + return false; + } // Now setup the channels: GUIConfigDataUnion config = GetConfigData(); resetActuators(&config); - + config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex(); @@ -435,25 +418,25 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); - int channel = m_aircraft->gvSteering1ChannelBox->currentIndex()-1; - setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + int channel = m_aircraft->gvSteering1ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, 127); - channel = m_aircraft->gvSteering2ChannelBox->currentIndex()-1; - setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + channel = m_aircraft->gvSteering2ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, -127); - channel = m_aircraft->gvMotor1ChannelBox->currentIndex()-1; - setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + channel = m_aircraft->gvMotor1ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); - channel = m_aircraft->gvMotor2ChannelBox->currentIndex()-1; - setMixerType(mixer,channel, VehicleConfig::MIXERTYPE_SERVO); + channel = m_aircraft->gvMotor2ChannelBox->currentIndex() - 1; + setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_SERVO); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 127); - //Output success message + // Output success message m_aircraft->gvStatusLabel->setText("Mixer generated"); - + return true; } @@ -462,93 +445,91 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) */ bool ConfigGroundVehicleWidget::throwConfigError(QString airframeType) { - //Initialize configuration error flag - bool error=false; + // Initialize configuration error flag + bool error = false; - - //Create a red block. All combo boxes are the same size, so any one should do as a model - int size = m_aircraft->gvEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize); - QPixmap pixmap(size,size); - pixmap.fill(QColor("red")); - - if (airframeType == "GroundVehicleCar" ) { //Car - if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None"){ - pixmap.fill(QColor("green")); - m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes -// m_aircraft->gvMotor1Label->setText("" + m_aircraft->gvMotor1Label->text() + ""); -// m_aircraft->gvMotor2Label->setText("" + m_aircraft->gvMotor2Label->text() + ""); - error=true; + // Create a red block. All combo boxes are the same size, so any one should do as a model + int size = m_aircraft->gvEngineChannelBox->style()->pixelMetric(QStyle::PM_SmallIconSize); + QPixmap pixmap(size, size); + pixmap.fill(QColor("red")); - } - else{ - m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes -// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvMotor1Label->setText(htmlText->toPlainText()); -// delete htmlText; -// -// htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvMotor2Label->setText(htmlText->toPlainText()); - } - - if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" && m_aircraft->gvSteering2ChannelBox->currentText() == "None") { - m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes -// m_aircraft->gvStatusLabel->setText("ERROR: check steering channel assignment"); -// m_aircraft->gvSteering1Label->setText("" + m_aircraft->gvSteering1Label->text() + ""); -// m_aircraft->gvSteering2Label->setText("" + m_aircraft->gvSteering2Label->text() + ""); - error=true; - } - else{ - m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes -// QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvSteering1Label->setText(htmlText->toPlainText()); -// delete htmlText; -// -// htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags. -// m_aircraft->gvSteering2Label->setText(htmlText->toPlainText()); - } - - } else if (airframeType == "GroundVehicleDifferential"){ //Tank - if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" || m_aircraft->gvMotor2ChannelBox->currentText() == "None"){ - m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - //Always reset - m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } else if ( airframeType == "GroundVehicleMotorcycle"){ //Motorcycle - if(m_aircraft->gvMotor1ChannelBox->currentText() == "None" && m_aircraft->gvMotor2ChannelBox->currentText() == "None"){ - m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" && m_aircraft->gvSteering2ChannelBox->currentText() == "None") { - m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else{ - m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - //Always reset - m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes - } - - if (error){ - m_aircraft->gvStatusLabel->setText(QString("ERROR: Assign all necessary channels")); - } + if (airframeType == "GroundVehicleCar") { //Car + if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" + && m_aircraft->gvMotor2ChannelBox->currentText() == "None") { + pixmap.fill(QColor("green")); + m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + //m_aircraft->gvMotor1Label->setText("" + m_aircraft->gvMotor1Label->text() + ""); + //m_aircraft->gvMotor2Label->setText("" + m_aircraft->gvMotor2Label->text() + ""); + error = true; + + } else { + m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + //QTextEdit* htmlText=new QTextEdit(m_aircraft->gvMotor1Label->text()); // HtmlText is any QString with html tags. + //m_aircraft->gvMotor1Label->setText(htmlText->toPlainText()); + //delete htmlText; + + //htmlText=new QTextEdit(m_aircraft->gvMotor2Label->text()); // HtmlText is any QString with html tags. + //m_aircraft->gvMotor2Label->setText(htmlText->toPlainText()); + } + + if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" + && m_aircraft->gvSteering2ChannelBox->currentText() == "None") { + m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + m_aircraft->gvSteering2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + //m_aircraft->gvStatusLabel->setText("ERROR: check steering channel assignment"); + //m_aircraft->gvSteering1Label->setText("" + m_aircraft->gvSteering1Label->text() + ""); + //m_aircraft->gvSteering2Label->setText("" + m_aircraft->gvSteering2Label->text() + ""); + error = true; + } else { + m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + //QTextEdit* htmlText=new QTextEdit(m_aircraft->gvSteering1Label->text()); // HtmlText is any QString with html tags. + //m_aircraft->gvSteering1Label->setText(htmlText->toPlainText()); + //delete htmlText; + + //htmlText=new QTextEdit(m_aircraft->gvSteering2Label->text()); // HtmlText is any QString with html tags. + //m_aircraft->gvSteering2Label->setText(htmlText->toPlainText()); + } + } else if (airframeType == "GroundVehicleDifferential") { //Tank + if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" + || m_aircraft->gvMotor2ChannelBox->currentText() == "None") { + m_aircraft->gvMotor1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + // Always reset + m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } else if (airframeType == "GroundVehicleMotorcycle") { //Motorcycle + if (m_aircraft->gvMotor1ChannelBox->currentText() == "None" + && m_aircraft->gvMotor2ChannelBox->currentText() == "None") { + m_aircraft->gvMotor2ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->gvMotor2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (m_aircraft->gvSteering1ChannelBox->currentText() == "None" + && m_aircraft->gvSteering2ChannelBox->currentText() == "None") { + m_aircraft->gvSteering1ChannelBox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + m_aircraft->gvSteering1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + // Always reset + m_aircraft->gvMotor1ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + m_aircraft->gvSteering2ChannelBox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes + } + + if (error) { + m_aircraft->gvStatusLabel->setText(QString("ERROR: Assign all necessary channels")); + } return error; } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index bef60e9a2..056c0e846 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -43,12 +43,11 @@ const QString ConfigMultiRotorWidget::CHANNELBOXNAME = QString("multiMotorChannelBox"); - QStringList ConfigMultiRotorWidget::getChannelDescriptions() { // init a channel_numelem list of channel desc defaults QStringList channelDesc; - for (int i = 0; i < (int) (ConfigMultiRotorWidget::CHANNEL_NUMELEM); i++) { + for (int i = 0; i < (int) ConfigMultiRotorWidget::CHANNEL_NUMELEM; i++) { channelDesc.append(QString("-")); } @@ -86,7 +85,6 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions() return channelDesc; } - ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1) { @@ -107,14 +105,9 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : scene->setSceneRect(quad->boundingRect()); m_aircraft->quadShape->setScene(scene); - //m_multirotor = new ConfigMultiRotorWidget(m_aircraft); - //m_multirotor->quad = quad; - //setupUI(m_aircraft->multirotorFrameType->currentText()); - QStringList multiRotorTypes; - multiRotorTypes << "Tricopter Y" << "Quad +" << "Quad X" << - "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" << - "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X" ; + multiRotorTypes << "Tricopter Y" << "Quad +" << "Quad X" << "Hexacopter" << "Hexacopter X" << "Hexacopter Y6" + << "Octocopter" << "Octocopter V" << "Octo Coax +" << "Octo Coax X"; m_aircraft->multirotorFrameType->addItems(multiRotorTypes); // Set default model to "Quad X" @@ -140,9 +133,6 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType; - // set aircraftType to Multirotor - //setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); - // disable triyaw channel m_aircraft->triYawChannelBox->setEnabled(false); @@ -167,8 +157,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) setYawMixLevel(50); m_aircraft->triYawChannelBox->setEnabled(true); - } - else if (frameType == "QuadX" || frameType == "Quad X") { + } else if (frameType == "QuadX" || frameType == "Quad X") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad X")); // Enable all necessary motor channel boxes... @@ -178,8 +167,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(50); - } - else if (frameType == "QuadP" || frameType == "Quad +") { + } else if (frameType == "QuadP" || frameType == "Quad +") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Quad +")); // Enable all necessary motor channel boxes... @@ -188,8 +176,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); setYawMixLevel(50); - } - else if (frameType == "Hexa" || frameType == "Hexacopter") { + } else if (frameType == "Hexa" || frameType == "Hexacopter") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter")); // Enable all necessary motor channel boxes... @@ -198,8 +185,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(50); m_aircraft->mrPitchMixLevel->setValue(33); setYawMixLevel(33); - } - else if (frameType == "HexaX" || frameType == "Hexacopter X" ) { + } else if (frameType == "HexaX" || frameType == "Hexacopter X") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter X")); @@ -209,8 +195,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(33); - } - else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { + } else if (frameType == "HexaCoax" || frameType == "Hexacopter Y6") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Hexacopter Y6")); @@ -220,8 +205,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(66); - } - else if (frameType == "Octo" || frameType == "Octocopter") { + } else if (frameType == "Octo" || frameType == "Octocopter") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter")); // Enable all necessary motor channel boxes @@ -230,8 +214,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(33); m_aircraft->mrPitchMixLevel->setValue(33); setYawMixLevel(25); - } - else if (frameType == "OctoV" || frameType == "Octocopter V") { + } else if (frameType == "OctoV" || frameType == "Octocopter V") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octocopter V")); @@ -241,8 +224,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(25); m_aircraft->mrPitchMixLevel->setValue(25); setYawMixLevel(25); - } - else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { + } else if (frameType == "OctoCoaxP" || frameType == "Octo Coax +") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax +")); // Enable all necessary motor channel boxes @@ -251,8 +233,7 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrRollMixLevel->setValue(100); m_aircraft->mrPitchMixLevel->setValue(100); setYawMixLevel(50); - } - else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { + } else if (frameType == "OctoCoaxX" || frameType == "Octo Coax X") { setComboCurrentIndex(m_aircraft->multirotorFrameType, m_aircraft->multirotorFrameType->findText("Octo Coax X")); // Enable all necessary motor channel boxes @@ -262,9 +243,8 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(50); } - // Draw the appropriate airframe - // drawAirframe(frameType); + //drawAirframe(frameType); } void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) @@ -299,272 +279,223 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) if (isValidThrottleCurve(&curveValues)) { // yes, use the curve we just read from mixersettings m_aircraft->multiThrottleCurve->initCurve(&curveValues); - } - else { + } else { // no, init a straight curve m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); } - - - - int channel; - double value; - GUIConfigDataUnion config = GetConfigData(); multiGUISettingsStruct multi = config.multi; -// UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); -// Q_ASSERT(mixer); - - if (frameType == "QuadP") - { + if (frameType == "QuadP") { // Motors 1/2/3/4 are: N / E / S / W - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorW); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. - // This assumes that all vectors are identical - if not, the user should use the - // "custom" setting. + // This assumes that all vectors are identical - if not, the user should use the "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27)); - + m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27)); } - } - else if (frameType == "QuadX") - { + } else if (frameType == "QuadX") { // Motors 1/2/3/4 are: NW / NE / SE / SW - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorSW); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27)); - + m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27)); } - - } - else if (frameType == "Hexa") - { + } else if (frameType == "Hexa") { // Motors 1/2/3 4/5/6 are: N / NE / SE / S / SW / NW - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorNW); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); //change channels channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - + m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27)); } - - - } - else if (frameType == "HexaX") - { + } else if (frameType == "HexaX") { // Motors 1/2/3 4/5/6 are: NE / E / SE / SW / W / NW - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorNW); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27)); } - } - else if (frameType == "HexaCoax") - { + } else if (frameType == "HexaCoax") { // Motors 1/2/3 4/5/6 are: NW/W NE/E S/SE - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorSE); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(2 * value / 1.27)); channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( qRound(value/1.27) ); + setYawMixLevel(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27)); } - } - else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") - { + } else if (frameType == "Octo" || frameType == "OctoV" || frameType == "OctoCoaxP") { // Motors 1 to 8 are N / NE / E / etc - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox7, multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox8, multi.VTOLMotorNW); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { if (frameType == "Octo") { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); //change channels channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - } - else if (frameType == "OctoV") { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27)); + } else if (frameType == "OctoV") { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); //change channels channel = m_aircraft->multiMotorChannelBox2->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); - } - else if (frameType == "OctoCoaxP") { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27)); + } else if (frameType == "OctoCoaxP") { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); //change channels channel = m_aircraft->multiMotorChannelBox3->currentIndex() - 1; value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( -qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(-qRound(value / 1.27)); } - } - } - else if (frameType == "OctoCoaxX") - { + } else if (frameType == "OctoCoaxX") { // Motors 1 to 8 are N / NE / E / etc - - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorN); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox5,multi.VTOLMotorSE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox6,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox7,multi.VTOLMotorSW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox8,multi.VTOLMotorW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorN); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox5, multi.VTOLMotorSE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox6, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox7, multi.VTOLMotorSW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox8, multi.VTOLMotorW); // Now, read the 1st mixer R/P/Y levels and initialize the mix sliders. // This assumes that all vectors are identical - if not, the user should use the // "custom" setting. - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW); - setYawMixLevel( -qRound(value/1.27) ); + setYawMixLevel(-qRound(value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27)); } - } - else if (frameType == "Tri") - { + } else if (frameType == "Tri") { // Motors 1 to 8 are N / NE / E / etc + setComboCurrentIndex(m_aircraft->multiMotorChannelBox1, multi.VTOLMotorNW); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox2, multi.VTOLMotorNE); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox3, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->multiMotorChannelBox4, multi.VTOLMotorS); + setComboCurrentIndex(m_aircraft->triYawChannelBox, multi.TRIYaw); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox1,multi.VTOLMotorNW); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox2,multi.VTOLMotorNE); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox3,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->multiMotorChannelBox4,multi.VTOLMotorS); - setComboCurrentIndex(m_aircraft->triYawChannelBox,multi.TRIYaw); - - channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; - if (channel > -1) - { - value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); - m_aircraft->mrPitchMixLevel->setValue( qRound(2*value/1.27) ); + int channel = m_aircraft->multiMotorChannelBox1->currentIndex() - 1; + if (channel > -1) { + double value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH); + m_aircraft->mrPitchMixLevel->setValue(qRound(2 * value / 1.27)); value = getMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL); - m_aircraft->mrRollMixLevel->setValue( qRound(value/1.27) ); + m_aircraft->mrRollMixLevel->setValue(qRound(value / 1.27)); } } @@ -577,15 +508,14 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) */ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() { - QString airframeType; - QList motorList; - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); // Curve is also common to all quads: setThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, m_aircraft->multiThrottleCurve->getCurve() ); + QString airframeType; + QList motorList; if (m_aircraft->multirotorFrameType->currentText() == "Quad +") { airframeType = "QuadP"; setupQuad(true); @@ -601,12 +531,11 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() } else if (m_aircraft->multirotorFrameType->currentText() == "Hexacopter Y6") { airframeType = "HexaCoax"; - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(6)) { return airframeType; } - motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE" - << "VTOLMotorS" << "VTOLMotorSE"; + motorList << "VTOLMotorNW" << "VTOLMotorW" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorS" << "VTOLMotorSE"; setupMotors(motorList); // Motor 1 to 6, Y6 Layout: @@ -627,13 +556,13 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() } else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter") { airframeType = "Octo"; - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(8)) { return airframeType; } - motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" - << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW"; + motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" + << "VTOLMotorW" << "VTOLMotorNW"; setupMotors(motorList); // Motor 1 to 8: // pitch roll yaw @@ -653,12 +582,12 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() } else if (m_aircraft->multirotorFrameType->currentText() == "Octocopter V") { airframeType = "OctoV"; - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(8)) { return airframeType; } - motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" - << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW"; + motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" + << "VTOLMotorW" << "VTOLMotorNW"; setupMotors(motorList); // Motor 1 to 8: // IMPORTANT: Assumes evenly spaced engines @@ -679,12 +608,12 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() } else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax +") { airframeType = "OctoCoaxP"; - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(8)) { return airframeType; } - motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" - << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW"; + motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" + << "VTOLMotorW" << "VTOLMotorNW"; setupMotors(motorList); // Motor 1 to 8: // pitch roll yaw @@ -704,12 +633,12 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() } else if (m_aircraft->multirotorFrameType->currentText() == "Octo Coax X") { airframeType = "OctoCoaxX"; - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(8)) { return airframeType; } - motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" - << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorW"; + motorList << "VTOLMotorNW" << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorS" + << "VTOLMotorSW" << "VTOLMotorW"; setupMotors(motorList); // Motor 1 to 8: // pitch roll yaw @@ -729,7 +658,7 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() } else if (m_aircraft->multirotorFrameType->currentText() == "Tricopter Y") { airframeType = "Tri"; - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(3)) { return airframeType; @@ -745,7 +674,6 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex(); SetConfigData(config); - // Motor 1 to 6, Y6 Layout: // pitch roll yaw double mixerMatrix[8][3] = { @@ -843,54 +771,49 @@ void ConfigMultiRotorWidget::setupQuadMotor(int channel, double pitch, double ro setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE1, 127); setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_THROTTLECURVE2, 0); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll*127); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch*127); - setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw*127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_ROLL, roll * 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_PITCH, pitch * 127); + setMixerVectorValue(mixer, channel, VehicleConfig::MIXERVECTOR_YAW, yaw * 127); } - - /** Helper function: setup motors. Takes a list of channel names in input. */ void ConfigMultiRotorWidget::setupMotors(QList motorList) { QList mmList; - mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3 - << m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 - << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; + mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 + << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 + << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 + << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; GUIConfigDataUnion configData = GetConfigData(); resetActuators(&configData); - int index; - foreach (QString motor, motorList) { - - index = mmList.takeFirst()->currentIndex(); - - if (motor == QString("VTOLMotorN")) + foreach (QString motor, motorList) + { + int index = mmList.takeFirst()->currentIndex(); + if (motor == QString("VTOLMotorN")) { configData.multi.VTOLMotorN = index; - else if (motor == QString("VTOLMotorNE")) + } else if (motor == QString("VTOLMotorNE")) { configData.multi.VTOLMotorNE = index; - else if (motor == QString("VTOLMotorE")) + } else if (motor == QString("VTOLMotorE")) { configData.multi.VTOLMotorE = index; - else if (motor == QString("VTOLMotorSE")) + } else if (motor == QString("VTOLMotorSE")) { configData.multi.VTOLMotorSE = index; - else if (motor == QString( "VTOLMotorS")) + } else if (motor == QString("VTOLMotorS")) { configData.multi.VTOLMotorS = index; - else if (motor == QString( "VTOLMotorSW")) + } else if (motor == QString("VTOLMotorSW")) { configData.multi.VTOLMotorSW = index; - else if (motor == QString( "VTOLMotorW")) + } else if (motor == QString("VTOLMotorW")) { configData.multi.VTOLMotorW = index; - else if (motor == QString( "VTOLMotorNW")) + } else if (motor == QString("VTOLMotorNW")) { configData.multi.VTOLMotorNW = index; + } } SetConfigData(configData); - } - - /** Set up a Quad-X or Quad-P mixer */ @@ -898,19 +821,16 @@ bool ConfigMultiRotorWidget::setupQuad(bool pLayout) { // Check coherence: - //Show any config errors in GUI + // Show any config errors in GUI if (throwConfigError(4)) { return false; } - QList motorList; if (pLayout) { - motorList << "VTOLMotorN" << "VTOLMotorE" << "VTOLMotorS" - << "VTOLMotorW"; + motorList << "VTOLMotorN" << "VTOLMotorE" << "VTOLMotorS" << "VTOLMotorW"; } else { - motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorSE" - << "VTOLMotorSW"; + motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorSE" << "VTOLMotorSW"; } setupMotors(motorList); @@ -931,7 +851,7 @@ bool ConfigMultiRotorWidget::setupQuad(bool pLayout) { 0, 0, 0}, { 0, 0, 0} }; - // + // Motor 1 to 4, P Layout: // pitch roll yaw // {1 ,0 ,-0.5 //Front motor (CW) @@ -958,25 +878,22 @@ bool ConfigMultiRotorWidget::setupQuad(bool pLayout) return true; } - - /** Set up a Hexa-X or Hexa-P mixer */ bool ConfigMultiRotorWidget::setupHexa(bool pLayout) { // Check coherence: - //Show any config errors in GUI - if (throwConfigError(6)) + // Show any config errors in GUI + if (throwConfigError(6)) { return false; + } QList motorList; if (pLayout) { - motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorSE" - << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorNW"; + motorList << "VTOLMotorN" << "VTOLMotorNE" << "VTOLMotorSE" << "VTOLMotorS" << "VTOLMotorSW" << "VTOLMotorNW"; } else { - motorList << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" - << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW"; + motorList << "VTOLMotorNE" << "VTOLMotorE" << "VTOLMotorSE" << "VTOLMotorSW" << "VTOLMotorW" << "VTOLMotorNW"; } setupMotors(motorList); @@ -990,7 +907,6 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout) // 4 {-0.3 , 0 , 0.3 // S CCW // 5 {-0.3 , 0.5 ,-0.3 // SW CW // 6 { 0.3 , 0.5 , 0.3 // NW CCW - double pMixer [8][3] = { { 1, 0, -1}, { 1, -1, 1}, @@ -1002,7 +918,6 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout) { 0, 0, 0} }; - // // Motor 1 to 6, X Layout: // 1 [ 0.5, -0.3, -0.3 ] NE // 2 [ 0 , -0.3, 0.3 ] E @@ -1037,61 +952,59 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout) bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) { QList mmList; - mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 << m_aircraft->multiMotorChannelBox3 - << m_aircraft->multiMotorChannelBox4 << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 - << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; + mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 + << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 + << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 + << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); // and enable only the relevant channels: - double pFactor = (double)m_aircraft->mrPitchMixLevel->value()/100; - double rFactor = (double)m_aircraft->mrRollMixLevel->value()/100; - invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1:1; - double yFactor =invertMotors * (double)m_aircraft->mrYawMixLevel->value()/100; - for (int i=0 ; i<8; i++) { - if(mmList.at(i)->isEnabled()) - { - int channel = mmList.at(i)->currentIndex()-1; + double pFactor = (double) m_aircraft->mrPitchMixLevel->value() / 100; + double rFactor = (double) m_aircraft->mrRollMixLevel->value() / 100; + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; + double yFactor = invertMotors * (double) m_aircraft->mrYawMixLevel->value() / 100; + for (int i = 0; i < 8; i++) { + if (mmList.at(i)->isEnabled()) { + int channel = mmList.at(i)->currentIndex() - 1; if (channel > -1) - setupQuadMotor(channel, mixerFactors[i][0]*pFactor, - rFactor*mixerFactors[i][1], yFactor*mixerFactors[i][2]); + setupQuadMotor(channel, mixerFactors[i][0] * pFactor, rFactor * mixerFactors[i][1], + yFactor * mixerFactors[i][2]); } } return true; } - /** This function displays text and color formatting in order to help the user understand what channels have not yet been configured. */ bool ConfigMultiRotorWidget::throwConfigError(int numMotors) -{ - //Initialize configuration error flag - bool error=false; +{ + // Initialize configuration error flag + bool error = false; - //Iterate through all instances of multiMotorChannelBox - for (int i=0; i(this, "multiMotorChannelBox" + QString::number(i+1)); - if (combobox){ + QComboBox *combobox = qFindChild(this, "multiMotorChannelBox" + QString::number(i + 1)); + if (combobox) { if (combobox->currentText() == "None") { int size = combobox->style()->pixelMetric(QStyle::PM_SmallIconSize); - QPixmap pixmap(size,size); + QPixmap pixmap(size, size); pixmap.fill(QColor("red")); - combobox->setItemData(0, pixmap, Qt::DecorationRole);//Set color palettes - error=true; - } - else { - combobox->setItemData(0, 0, Qt::DecorationRole);//Reset color palettes + combobox->setItemData(0, pixmap, Qt::DecorationRole); //Set color palettes + error = true; + } else { + combobox->setItemData(0, 0, Qt::DecorationRole); //Reset color palettes } } } - - if (error){ - m_aircraft->mrStatusLabel->setText(QString("ERROR: Assign all %1 motor channels").arg(numMotors)); + if (error) { + m_aircraft->mrStatusLabel->setText( + QString("ERROR: Assign all %1 motor channels").arg(numMotors)); } return error; } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 543de1cba..8efdb752f 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -37,7 +37,7 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) { // Generate lists of mixerTypeNames, mixerVectorNames, channelNames channelNames << "None"; - for (int i = 0; i < (int)(VehicleConfig::CHANNEL_NUMELEM); i++) { + for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) { mixerTypes << QString("Mixer%1Type").arg(i+1); mixerVectors << QString("Mixer%1Vector").arg(i+1); channelNames << QString("Channel%1").arg(i+1); @@ -60,8 +60,8 @@ VehicleConfig::~VehicleConfig() // Do nothing } -GUIConfigDataUnion VehicleConfig::GetConfigData() { - +GUIConfigDataUnion VehicleConfig::GetConfigData() +{ int i; GUIConfigDataUnion configData; @@ -81,13 +81,10 @@ GUIConfigDataUnion VehicleConfig::GetConfigData() { return configData; } -void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) { - - int i; - +void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) +{ // sanity check - Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == - (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); + Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); // get an instance of systemsettings SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); @@ -96,15 +93,16 @@ void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) { UAVObjectField* guiConfig = systemSettings->getField("GUIConfigData"); Q_ASSERT(guiConfig); - if(!guiConfig) + if (!guiConfig) { return; + } // copy parameter configData -> systemsettings - for (i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) + for (int i = 0; i < (int) (SystemSettings::GUICONFIGDATA_NUMELEM); i++) { guiConfig->setValue(configData.UAVObject[i], i); + } } - void VehicleConfig::setupUI(QString frameType) { } @@ -154,20 +152,22 @@ QString VehicleConfig::getMixerType(UAVDataObject *mixer, int channel) { Q_ASSERT(mixer); - QString mixerType = mixerTypeDescriptions[0]; //default to disabled + // default to disabled + QString mixerType = mixerTypeDescriptions[0]; if (channel >= 0 && channel < mixerTypes.count()) { UAVObjectField *field = mixer->getField(mixerTypes.at(channel)); Q_ASSERT(field); - if (field) - mixerType = field->getValue().toString(); + if (field) { + mixerType = field->getValue().toString(); + } } return mixerType; } -void VehicleConfig::setMixerType(UAVDataObject* mixer, int channel, MixerTypeElem mixerType) +void VehicleConfig::setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType) { Q_ASSERT(mixer); @@ -176,15 +176,14 @@ void VehicleConfig::setMixerType(UAVDataObject* mixer, int channel, MixerTypeEle Q_ASSERT(field); if (field) { - if (mixerType >= 0 && mixerType < mixerTypeDescriptions.count()) - { + if (mixerType >= 0 && mixerType < mixerTypeDescriptions.count()) { field->setValue(mixerTypeDescriptions[mixerType]); } } } } -void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel) +void VehicleConfig::resetMixerVector(UAVDataObject *mixer, int channel) { Q_ASSERT(mixer); @@ -200,7 +199,7 @@ void VehicleConfig::resetMixerVector(UAVDataObject* mixer, int channel) // Disable all servo/motor mixers (but keep camera and accessory ones) void VehicleConfig::resetMotorAndServoMixers(UAVDataObject *mixer) { - for (int channel = 0; channel < (int)VehicleConfig::CHANNEL_NUMELEM; channel++) { + for (int channel = 0; channel < (int) VehicleConfig::CHANNEL_NUMELEM; channel++) { QString type = getMixerType(mixer, channel); if ((type == "Disabled") || (type == "Motor") || (type == "Servo")) { setMixerType(mixer, channel, VehicleConfig::MIXERTYPE_DISABLED); @@ -209,12 +208,10 @@ void VehicleConfig::resetMotorAndServoMixers(UAVDataObject *mixer) } } -double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName) +double VehicleConfig::getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName) { Q_ASSERT(mixer); - double value = 0; - if (channel >= 0 && channel < mixerVectors.count()) { UAVObjectField *field = mixer->getField(mixerVectors.at(channel)); Q_ASSERT(field); @@ -226,7 +223,7 @@ double VehicleConfig::getMixerVectorValue(UAVDataObject* mixer, int channel, Mix return value; } -void VehicleConfig::setMixerVectorValue(UAVDataObject* mixer, int channel, MixerVectorElem elementName, double value) +void VehicleConfig::setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value) { Q_ASSERT(mixer); @@ -240,7 +237,7 @@ void VehicleConfig::setMixerVectorValue(UAVDataObject* mixer, int channel, Mixer } } -double VehicleConfig::getMixerValue(UAVDataObject* mixer, QString elementName) +double VehicleConfig::getMixerValue(UAVDataObject *mixer, QString elementName) { Q_ASSERT(mixer); @@ -253,7 +250,7 @@ double VehicleConfig::getMixerValue(UAVDataObject* mixer, QString elementName) return value; } -void VehicleConfig::setMixerValue(UAVDataObject* mixer, QString elementName, double value) +void VehicleConfig::setMixerValue(UAVDataObject *mixer, QString elementName, double value) { Q_ASSERT(mixer); @@ -283,7 +280,7 @@ void VehicleConfig::setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveEle } } -void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveElem curveType, QList* curve) +void VehicleConfig::getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList *curve) { Q_ASSERT(mixer); Q_ASSERT(curve); @@ -307,7 +304,7 @@ void VehicleConfig::getThrottleCurve(UAVDataObject* mixer, MixerThrottleCurveEle } } -bool VehicleConfig::isValidThrottleCurve(QList* curve) +bool VehicleConfig::isValidThrottleCurve(QList *curve) { Q_ASSERT(curve); @@ -322,6 +319,7 @@ bool VehicleConfig::isValidThrottleCurve(QList* curve) double VehicleConfig::getCurveMin(QList *curve) { + // TODO initialize to max double double min = 0; for (int i = 0; i < curve->count(); i++) { min = std::min(min, curve->at(i)); @@ -331,6 +329,7 @@ double VehicleConfig::getCurveMin(QList *curve) double VehicleConfig::getCurveMax(QList *curve) { + // TODO initialize to min double double max = 0; for (int i = 0; i < curve->count(); i++) { max = std::max(max, curve->at(i)); @@ -352,9 +351,10 @@ void VehicleConfig::resetField(UAVObjectField * field) * Util function to get a pointer to the object manager * @return pointer to the UAVObjectManager */ -UAVObjectManager *VehicleConfig::getUAVObjectManager() { +UAVObjectManager *VehicleConfig::getUAVObjectManager() +{ ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance(); - UAVObjectManager * objMngr = pm->getObject(); + UAVObjectManager *objMngr = pm->getObject(); Q_ASSERT(objMngr); return objMngr; } diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 283ae16a3..8b8282f6c 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -206,35 +206,6 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() // m_aircraft->airframesWidget->setCurrentIndex(index); //} -/** - \brief Sets up the mixer depending on Airframe type. Accepts either system settings or - combo box entry from airframe type, as those do not overlap. - */ -//void ConfigVehicleTypeWidget::setupAirframeUI(QString frameType) -//{ -// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - begin"; -// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - frame type" << frameType; -// -// bool dirty = isDirty(); -// -// QString category = frameCategory2(frameType); -// if (category == "FixedWing") { -// m_fixedwing->setupUI(frameType); -// } else if (category == "Multirotor") { -// m_multirotor->setupUI(frameType); -// } else if (category == "Helicopter") { -// m_heli->setupUI(frameType); -// } else if (category == "Ground") { -// m_groundvehicle->setupUI(frameType); -// } else if (category == "Custom") { -// m_custom->setupUI(frameType); -// } -// -// setDirty(dirty); -// -// qDebug() << "ConfigVehicleTypeWidget::setupAirframeUI - end"; -//} - /** Refreshes the current value of the SystemSettings which holds the aircraft type */ @@ -462,7 +433,6 @@ void ConfigVehicleTypeWidget::enableFFTest() Note: does NOT ask for an object refresh itself! */ -// TODO rename to FF void ConfigVehicleTypeWidget::updateFeedForwardUI() { UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); @@ -471,10 +441,10 @@ void ConfigVehicleTypeWidget::updateFeedForwardUI() QPointer vconfig = new VehicleConfig(); // Update feed forward settings - m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer,"FeedForward") * 100); - m_aircraft->accelTime->setValue(vconfig->getMixerValue(mixer,"AccelTime")); - m_aircraft->decelTime->setValue(vconfig->getMixerValue(mixer,"DecelTime")); - m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer,"MaxAccel")); + m_aircraft->feedForwardSlider->setValue(vconfig->getMixerValue(mixer, "FeedForward") * 100); + m_aircraft->accelTime->setValue(vconfig->getMixerValue(mixer, "AccelTime")); + m_aircraft->decelTime->setValue(vconfig->getMixerValue(mixer, "DecelTime")); + m_aircraft->maxAccelSlider->setValue(vconfig->getMixerValue(mixer, "MaxAccel")); } /** From 357f36a06d5a9017bc54dc19e5cc99192d8b0d9a Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 7 Apr 2013 17:56:33 +0200 Subject: [PATCH 13/32] OP-907 step 4: vehicle config UI cleanups --- .../src/plugins/config/airframe.ui | 160 +- .../src/plugins/config/airframe_ccpm.ui | 420 +---- .../src/plugins/config/airframe_custom.ui | 1383 +++++++++-------- .../src/plugins/config/airframe_fixedwing.ui | 113 +- .../src/plugins/config/airframe_ground.ui | 113 +- .../src/plugins/config/airframe_multirotor.ui | 321 ++-- 6 files changed, 1111 insertions(+), 1399 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index 809f07c18..da2f1898c 100755 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -17,27 +17,96 @@ 12 + + + + + 0 + 0 + + + + + + + + 9 + + + + + + 0 + 0 + + + + + 75 + true + + + + Vehicle type: + + + + + + + + 0 + 0 + + + + + 50 + false + + + + Select aircraft type here + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 2 + 20 + + + + + + + 0 - + true Mixer Settings - - - 0 - + - 0 + 9 - - + + 0 @@ -128,75 +197,14 @@ 0 0 - 850 - 525 + 832 + 461 - 12 + 0 - - - - - - - - 12 - - - - - QLayout::SetFixedSize - - - - - - 0 - 0 - - - - - 75 - true - - - - Vehicle type: - - - - - - - Select aircraft type here - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 2 - 20 - - - - - - - - - @@ -225,7 +233,7 @@ - + true @@ -319,8 +327,8 @@ 0 0 - 850 - 525 + 223 + 269 @@ -725,7 +733,7 @@ p, li { white-space: pre-wrap; } - + 4 diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui b/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui index cce202e17..c9942dc3a 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_ccpm.ui @@ -29,30 +29,49 @@ false + + 0 + - - - QFormLayout::AllNonFixedFieldsGrow - + 0 - + + + + 75 + true + + Swashplate config: - + Select aircraft type here + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -86,28 +105,25 @@ QGroupBox::title { top: 5px; } + + QTabWidget::Rounded + 0 + + false + Basic settings - - 3 - - - 0 - - - 3 - - - 3 + + 9 - 3 + 6 @@ -1231,22 +1247,6 @@ margin:1px; 3 - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 7 - - - - @@ -1267,26 +1267,13 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -1308,19 +1295,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -1398,22 +1372,6 @@ margin:1px; 3 - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 7 - - - - @@ -1437,26 +1395,13 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -1481,19 +1426,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -1581,44 +1513,15 @@ margin:1px; 3 - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 7 - - - - - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -1643,19 +1546,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -1728,44 +1618,15 @@ margin:1px; 3 - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 7 - - - - - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -1790,19 +1651,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -1872,44 +1720,15 @@ margin:1px; 3 - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 7 - - - - - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -1934,19 +1753,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -2016,44 +1822,15 @@ margin:1px; 3 - - - - Qt::Vertical - - - QSizePolicy::Minimum - - - - 20 - 7 - - - - - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -2078,19 +1855,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -2119,10 +1883,10 @@ margin:1px; - 3 + 9 - 3 + 6 @@ -2502,26 +2266,13 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - true - + 0 0 @@ -2546,19 +2297,6 @@ margin:1px; - - - - Qt::Horizontal - - - - 5 - 25 - - - - @@ -2764,10 +2502,10 @@ margin:1px; - 3 + 9 - 3 + 6 @@ -2958,10 +2696,10 @@ margin:1px; - 3 + 9 - 3 + 6 @@ -3553,38 +3291,6 @@ margin:1px; - - ccpmCyclicScale - valueChanged(int) - ccpmCyclicScaleBox - setValue(int) - - - 358 - 306 - - - 355 - 538 - - - - - ccpmCyclicScaleBox - valueChanged(int) - ccpmCyclicScale - setValue(int) - - - 341 - 538 - - - 351 - 376 - - - ccpmPitchScale valueChanged(int) @@ -3649,5 +3355,37 @@ margin:1px; + + ccpmCyclicScale + valueChanged(int) + ccpmCyclicScaleBox + setValue(int) + + + 358 + 306 + + + 355 + 538 + + + + + ccpmCyclicScaleBox + valueChanged(int) + ccpmCyclicScale + setValue(int) + + + 341 + 538 + + + 351 + 376 + + + diff --git a/ground/openpilotgcs/src/plugins/config/airframe_custom.ui b/ground/openpilotgcs/src/plugins/config/airframe_custom.ui index 5cddb3c5f..189356db1 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_custom.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_custom.ui @@ -15,10 +15,13 @@ - 12 + 0 + + 0 + @@ -114,692 +117,702 @@ - - - - 0 - 0 - + + + 0 - - true + + 0 - - 12 - - - 50 - - - false - - - - Type - - - - - Curve 1 - - - - - Curve 2 - - - - - Roll - - - - - Pitch - - - - - Yaw - - - - - Ch 1 - - - - - Ch 2 - - - - - Ch 3 - - - - - Ch 4 - - - - - Ch 5 - - - - - Ch 6 - - - - - Ch 7 - - - - - Ch 8 - - - - - Ch 9 - - - - - Ch 10 - - - - - Ch 11 - - - - - Ch 12 - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - - - - - - - AlignHCenter|AlignVCenter|AlignCenter - - - + + + + + 0 + 0 + + + + true + + + 12 + + + 50 + + + false + + + + Type + + + + + Curve 1 + + + + + Curve 2 + + + + + Roll + + + + + Pitch + + + + + Yaw + + + + + Ch 1 + + + + + Ch 2 + + + + + Ch 3 + + + + + Ch 4 + + + + + Ch 5 + + + + + Ch 6 + + + + + Ch 7 + + + + + Ch 8 + + + + + Ch 9 + + + + + Ch 10 + + + + + Ch 11 + + + + + Ch 12 + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + - + + + AlignHCenter|AlignVCenter|AlignCenter + + + + + diff --git a/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui b/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui index 7bc50cb72..1b42f042d 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_fixedwing.ui @@ -15,10 +15,10 @@ - 12 + 0 - + @@ -58,8 +58,11 @@ + + 0 + - + 0 @@ -76,21 +79,24 @@ Output Channel Assignments - + + QFormLayout::AllNonFixedFieldsGrow + + Engine - + Select output channel for the engine - + @@ -103,17 +109,17 @@ - + Select output channel for the first aileron (or elevon) - + - false + true @@ -126,17 +132,17 @@ - + - false + true Select output channel for the second aileron (or elevon) - + @@ -149,17 +155,17 @@ - + Select output channel for the first elevator - + - false + true @@ -172,57 +178,44 @@ - + - false + true Select output channel for a secondary elevator - + Rudder 1 - + Select output channel for the first rudder - + Rudder 2 - + Select output channel for a secondary rudder - - - - Qt::Vertical - - - - 20 - 20 - - - - @@ -238,22 +231,6 @@ Elevon Mix - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 0 - 20 - - - - @@ -284,7 +261,7 @@ margin:1px; - + 0 0 @@ -318,7 +295,7 @@ margin:1px; - 50 + 65 0 @@ -340,7 +317,7 @@ margin:1px; - + 0 0 @@ -374,20 +351,7 @@ margin:1px; - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + 0 @@ -435,6 +399,19 @@ margin:1px; + + + + Qt::Horizontal + + + + 0 + 20 + + + + @@ -451,7 +428,7 @@ margin:1px; - + diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ground.ui b/ground/openpilotgcs/src/plugins/config/airframe_ground.ui index 6ca9f5088..80b28af42 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_ground.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_ground.ui @@ -15,10 +15,16 @@ - 12 + 0 - + + + 0 + + + 0 + @@ -56,38 +62,11 @@ - - - - - - - 75 - true - - - - Channel Assignment - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - + + 0 + @@ -99,7 +78,7 @@ 0 - 100 + 0 @@ -118,7 +97,7 @@ Engine - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter @@ -152,7 +131,7 @@ - false + true @@ -168,7 +147,7 @@ - false + true Select output channel for the second aileron (or elevon) @@ -201,7 +180,7 @@ - false + true @@ -217,7 +196,7 @@ - false + true Select output channel for a second motor @@ -282,13 +261,28 @@ 0 + + + 50 + false + + Left % + + Qt::AlignCenter + + + + 0 + 0 + + 100 @@ -305,6 +299,9 @@ 50 + + Qt::AlignCenter + @@ -315,17 +312,26 @@ - 50 + 65 0 Right % + + Qt::AlignCenter + + + + 0 + 0 + + 100 @@ -342,6 +348,9 @@ 50 + + Qt::AlignCenter + @@ -379,20 +388,20 @@ - 500 - 500 + 16777215 + 16777215 - 10 - 10 + 0 + 0 - 300 - 350 + 0 + 0 @@ -428,20 +437,20 @@ - 500 - 500 + 16777215 + 16777215 - 10 - 10 + 0 + 0 - 300 - 350 + 0 + 0 @@ -452,7 +461,7 @@ - + Qt::Vertical diff --git a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui index f22ccd285..fa82a2558 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui @@ -15,7 +15,7 @@ - 12 + 0 @@ -32,90 +32,16 @@ - Frame Type + Frame - + - 12 + 9 - - - - QLayout::SetFixedSize - - - - - Qt::Horizontal - - - - 10 - 13 - - - - - - - - - 0 - 0 - - - - - 25 - 25 - - - - - 16777215 - 25 - - - - Select the Multirotor frame type here. - - - - - - - Qt::Horizontal - - - - 10 - 13 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - - + 0 0 @@ -137,22 +63,6 @@ - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 8 - - - - @@ -181,7 +91,7 @@ - 12 + 9 @@ -233,7 +143,7 @@ 0 - 12 + 9 @@ -241,7 +151,7 @@ - 30 + 40 0 @@ -257,7 +167,7 @@ - 35 + 40 0 @@ -286,13 +196,13 @@ Typical values are 100% for + configuration and 50% for X configuration on quads - 30 + 40 0 - 30 + 16777215 16777215 @@ -319,7 +229,7 @@ margin:1px; - 0 + 40 0 @@ -335,7 +245,7 @@ margin:1px; - 35 + 40 0 @@ -356,6 +266,12 @@ Typical values are 100% for + configuration and 50% for X configuration on quads + + + 40 + 0 + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -379,7 +295,7 @@ margin:1px; - 0 + 40 0 @@ -419,6 +335,12 @@ Typical value is 50% for + or X configuration on quads. + + + 40 + 0 + + false @@ -439,63 +361,108 @@ margin:1px; - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 75 - true - - - - Mixer OK - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop - - - - - - - Qt::Horizontal - - - - 10 - 20 - - - - - - + + + + QLayout::SetFixedSize + + + + + + 75 + true + + + + Frame Type: + + + + + + + + 0 + 0 + + + + + 25 + 25 + + + + + 16777215 + 25 + + + + Select the Multirotor frame type here. + + + + + + + Qt::Horizontal + + + + 10 + 13 + + + + + + + + + + + + Qt::Horizontal + + + + 10 + 20 + + + + + + + + + 0 + 0 + + + + + 75 + true + + + + Mixer OK + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + - + 0 @@ -511,12 +478,12 @@ margin:1px; Motor output channels - + - 12 + 9 - + QLayout::SetMaximumSize @@ -527,7 +494,7 @@ margin:1px; 6 - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -548,7 +515,7 @@ margin:1px; - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -569,7 +536,7 @@ margin:1px; - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -590,7 +557,7 @@ margin:1px; - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -613,7 +580,7 @@ margin:1px; - + QLayout::SetMaximumSize @@ -624,7 +591,7 @@ margin:1px; 6 - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -640,7 +607,7 @@ margin:1px; - false + true @@ -654,7 +621,7 @@ margin:1px; - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -670,7 +637,7 @@ margin:1px; - false + true Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. @@ -678,7 +645,7 @@ margin:1px; - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -694,7 +661,7 @@ margin:1px; - false + true Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. @@ -702,7 +669,7 @@ margin:1px; - + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); color: rgb(255, 255, 255); @@ -718,7 +685,7 @@ margin:1px; - false + true Assign your motor output channels using the drawing above as a reference. Respect propeller rotation. @@ -728,7 +695,7 @@ margin:1px; - + 0 @@ -741,7 +708,7 @@ margin:1px; - + 0 @@ -772,7 +739,7 @@ margin:1px; - false + true @@ -789,7 +756,7 @@ margin:1px; - + 0 From 782913590bc3328e6926f1e81bd22656ababa4fc Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 7 Apr 2013 17:57:53 +0200 Subject: [PATCH 14/32] OP-907 step 4: vehicle config UI cleanups --- .../src/plugins/config/airframe_ccpm_old.ui | 37 ------------------- 1 file changed, 37 deletions(-) delete mode 100644 ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui b/ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui deleted file mode 100644 index d9d90ebd4..000000000 --- a/ground/openpilotgcs/src/plugins/config/airframe_ccpm_old.ui +++ /dev/null @@ -1,37 +0,0 @@ - - - CcpmConfigWidget - - - - 0 - 0 - 880 - 608 - - - - Form - - - - 12 - - - - - - - - - ConfigCcpmWidget - QWidget -

cfg_vehicletypes/configccpmwidget.h
- 1 - - - - - - - From 81da5303f2b5e709520c448aeb40dac2dbae6779 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Sun, 14 Apr 2013 22:12:15 +0200 Subject: [PATCH 15/32] OP-907 step 3: more vehicle config code cleanups --- .../cfg_vehicletypes/configccpmwidget.cpp | 23 ++++---- .../configfixedwingwidget.cpp | 18 +++--- .../configgroundvehiclewidget.cpp | 18 +++--- .../configmultirotorwidget.cpp | 18 +++--- .../config/cfg_vehicletypes/vehicleconfig.cpp | 46 +++++++++------- .../config/cfg_vehicletypes/vehicleconfig.h | 51 ++++++++--------- .../config/configvehicletypewidget.cpp | 55 ++++++------------- .../plugins/config/configvehicletypewidget.h | 5 +- 8 files changed, 111 insertions(+), 123 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 219ad53d2..e11281754 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -51,7 +51,7 @@ QStringList ConfigCcpmWidget::getChannelDescriptions() } // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); + GUIConfigDataUnion configData = getConfigData(); heliGUISettingsStruct heli = configData.heli; if (heli.Throttle > 0) { @@ -293,7 +293,7 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) setupUI(frameType); - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); // swashplate config setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); @@ -626,7 +626,7 @@ void ConfigCcpmWidget::UpdateMixer() if (throwConfigError(QString("HeliCP"))) return; - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); useCCPM = !(config.heli.ccpmCollectivePassthroughState || !config.heli.ccpmLinkCyclicState); useCyclic = config.heli.ccpmLinkRollState; @@ -767,7 +767,7 @@ QString ConfigCcpmWidget::updateConfigObjects() updatingFromHardware = TRUE; //get the user options - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); //swashplate config config.heli.SwashplateType = m_aircraft->ccpmType->count() - m_aircraft->ccpmType->currentIndex() - 1; @@ -807,7 +807,7 @@ QString ConfigCcpmWidget::updateConfigObjects() //tail config.heli.Tail = m_aircraft->ccpmTailChannel->currentIndex(); - SetConfigData(config); + setConfigData(config); updatingFromHardware = FALSE; return airframeType; @@ -849,28 +849,25 @@ void ConfigCcpmWidget::getMixer() if (SwashLvlConfigurationInProgress)return; if (updatingToHardware)return; - updatingFromHardware=TRUE; + updatingFromHardware = TRUE; UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); - QPointer vconfig = new VehicleConfig(); - QList curveValues; - vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE1, &curveValues); // is at least one of the curve values != 0? - if (vconfig->isValidThrottleCurve(&curveValues)) { + if (isValidThrottleCurve(&curveValues)) { m_aircraft->ThrottleCurve->setCurve(&curveValues); } else { m_aircraft->ThrottleCurve->ResetCurve(); } - - vconfig->getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); + getThrottleCurve(mixer, VehicleConfig::MIXER_THROTTLECURVE2, &curveValues); // is at least one of the curve values != 0? - if (vconfig->isValidThrottleCurve(&curveValues)) { + if (isValidThrottleCurve(&curveValues)) { m_aircraft->PitchCurve->setCurve(&curveValues); } else { diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 9bdc792c8..6d385c0a4 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -49,7 +49,7 @@ QStringList ConfigFixedWingWidget::getChannelDescriptions() } // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); + GUIConfigDataUnion configData = getConfigData(); if (configData.fixedwing.FixedWingPitch1 > 0) { channelDesc[configData.fixedwing.FixedWingPitch1 - 1] = QString("FixedWingPitch1"); @@ -80,6 +80,8 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : { m_aircraft->setupUi(this); + populateChannelComboBoxes(); + QStringList fixedWingTypes; fixedWingTypes << "Elevator aileron rudder" << "Elevon" << "Vtail"; m_aircraft->fixedWingType->addItems(fixedWingTypes); @@ -199,7 +201,7 @@ void ConfigFixedWingWidget::refreshWidgetsValues(QString frameType) m_aircraft->fixedWingThrottle->initLinearCurve(curveValues.count(), 1.0); } - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); fixedGUISettingsStruct fixed = config.fixedwing; // Then retrieve how channels are setup @@ -283,7 +285,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) } // Now setup the channels: - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); @@ -293,7 +295,7 @@ bool ConfigFixedWingWidget::setupFrameFixedWing(QString airframeType) config.fixedwing.FixedWingYaw1 = m_aircraft->fwRudder1ChannelBox->currentIndex(); config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - SetConfigData(config); + setConfigData(config); UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -353,7 +355,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) return false; } - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.fixedwing.FixedWingRoll1 = m_aircraft->fwAileron1ChannelBox->currentIndex(); @@ -362,7 +364,7 @@ bool ConfigFixedWingWidget::setupFrameElevon(QString airframeType) config.fixedwing.FixedWingYaw2 = m_aircraft->fwRudder2ChannelBox->currentIndex(); config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - SetConfigData(config); + setConfigData(config); UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -423,7 +425,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) return false; } - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.fixedwing.FixedWingPitch1 = m_aircraft->fwElevator1ChannelBox->currentIndex(); @@ -432,7 +434,7 @@ bool ConfigFixedWingWidget::setupFrameVtail(QString airframeType) config.fixedwing.FixedWingRoll2 = m_aircraft->fwAileron2ChannelBox->currentIndex(); config.fixedwing.FixedWingThrottle = m_aircraft->fwEngineChannelBox->currentIndex(); - SetConfigData(config); + setConfigData(config); UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 12caf4932..4b1e265b8 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -50,7 +50,7 @@ QStringList ConfigGroundVehicleWidget::getChannelDescriptions() } // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); + GUIConfigDataUnion configData = getConfigData(); if (configData.ground.GroundVehicleSteering1 > 0) { channelDesc[configData.ground.GroundVehicleSteering1 - 1] = QString("GroundSteering1"); @@ -72,6 +72,8 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : { m_aircraft->setupUi(this); + populateChannelComboBoxes(); + QStringList groundVehicleTypes; groundVehicleTypes << "Turnable (car)" << "Differential (tank)" << "Motorcycle"; m_aircraft->groundVehicleType->addItems(groundVehicleTypes); @@ -224,7 +226,7 @@ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) } else { m_aircraft->groundVehicleThrottle2->initLinearCurve(curveValues.count(), 1.0); } - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); // THIS SECTION STILL NEEDS WORK. FOR THE MOMENT, USE THE FIXED-WING ONBOARD SETTING IN ORDER TO MINIMIZE CHANCES OF BOLLOXING REAL CODE // Retrieve channel setup values @@ -310,13 +312,13 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleMotorcycle(QString airframeTyp } // Now setup the channels: - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); - SetConfigData(config); + setConfigData(config); UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -360,13 +362,13 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleDifferential(QString airframeT } // Now setup the channels: - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); config.ground.GroundVehicleThrottle2 = m_aircraft->gvMotor2ChannelBox->currentIndex(); - SetConfigData((config)); + setConfigData(config); UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); @@ -404,7 +406,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) } // Now setup the channels: - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); resetActuators(&config); config.ground.GroundVehicleThrottle1 = m_aircraft->gvMotor1ChannelBox->currentIndex(); @@ -412,7 +414,7 @@ bool ConfigGroundVehicleWidget::setupGroundVehicleCar(QString airframeType) config.ground.GroundVehicleSteering1 = m_aircraft->gvSteering1ChannelBox->currentIndex(); config.ground.GroundVehicleSteering2 = m_aircraft->gvSteering2ChannelBox->currentIndex(); - SetConfigData(config); + setConfigData(config); UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 056c0e846..2b412c977 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -52,7 +52,7 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions() } // get the gui config data - GUIConfigDataUnion configData = GetConfigData(); + GUIConfigDataUnion configData = getConfigData(); multiGUISettingsStruct multi = configData.multi; if (multi.VTOLMotorN > 0 && multi.VTOLMotorN <= ConfigMultiRotorWidget::CHANNEL_NUMELEM) { @@ -90,9 +90,12 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : { m_aircraft->setupUi(this); + populateChannelComboBoxes(); + // Setup the Multirotor picture in the Quad settings interface m_aircraft->quadShape->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); m_aircraft->quadShape->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + QSvgRenderer *renderer = new QSvgRenderer(); renderer->load(QString(":/configgadget/images/multirotor-shapes.svg")); @@ -284,7 +287,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) m_aircraft->multiThrottleCurve->initLinearCurve(curveValues.count(), 0.9); } - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); multiGUISettingsStruct multi = config.multi; if (frameType == "QuadP") { @@ -670,9 +673,9 @@ QString ConfigMultiRotorWidget::updateConfigObjectsFromWidgets() motorList << "VTOLMotorNW" << "VTOLMotorNE" << "VTOLMotorS"; setupMotors(motorList); - GUIConfigDataUnion config = GetConfigData(); + GUIConfigDataUnion config = getConfigData(); config.multi.TRIYaw = m_aircraft->triYawChannelBox->currentIndex(); - SetConfigData(config); + setConfigData(config); // Motor 1 to 6, Y6 Layout: // pitch roll yaw @@ -787,11 +790,10 @@ void ConfigMultiRotorWidget::setupMotors(QList motorList) << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; - GUIConfigDataUnion configData = GetConfigData(); + GUIConfigDataUnion configData = getConfigData(); resetActuators(&configData); - foreach (QString motor, motorList) - { + foreach (QString motor, motorList) { int index = mmList.takeFirst()->currentIndex(); if (motor == QString("VTOLMotorN")) { configData.multi.VTOLMotorN = index; @@ -811,7 +813,7 @@ void ConfigMultiRotorWidget::setupMotors(QList motorList) configData.multi.VTOLMotorNW = index; } } - SetConfigData(configData); + setConfigData(configData); } /** diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 8efdb752f..d488744ed 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -38,14 +38,13 @@ VehicleConfig::VehicleConfig(QWidget *parent) : ConfigTaskWidget(parent) // Generate lists of mixerTypeNames, mixerVectorNames, channelNames channelNames << "None"; for (int i = 0; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) { - mixerTypes << QString("Mixer%1Type").arg(i+1); - mixerVectors << QString("Mixer%1Vector").arg(i+1); - channelNames << QString("Channel%1").arg(i+1); + mixerTypes << QString("Mixer%1Type").arg(i + 1); + mixerVectors << QString("Mixer%1Vector").arg(i + 1); + channelNames << QString("Channel%1").arg(i + 1); } - mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch" - << "CameraYaw" << "Accessory0" << "Accessory1" << "Accessory2" - << "Accessory3" << "Accessory4" << "Accessory5"; + mixerTypeDescriptions << "Disabled" << "Motor" << "Servo" << "CameraRoll" << "CameraPitch" << "CameraYaw" + << "Accessory0" << "Accessory1" << "Accessory2" << "Accessory3" << "Accessory4" << "Accessory5"; // This is needed because new style tries to compact things as much as possible in grid // and on OSX the widget sizes of PushButtons is reported incorrectly: @@ -60,45 +59,43 @@ VehicleConfig::~VehicleConfig() // Do nothing } -GUIConfigDataUnion VehicleConfig::GetConfigData() +GUIConfigDataUnion VehicleConfig::getConfigData() { - int i; - GUIConfigDataUnion configData; - // get an instance of systemsettings - SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); + SystemSettings *systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); Q_ASSERT(systemSettings); SystemSettings::DataFields systemSettingsData = systemSettings->getData(); // copy systemsettings -> local configData - for(i = 0; i < (int)(SystemSettings::GUICONFIGDATA_NUMELEM); i++) - configData.UAVObject[i]=systemSettingsData.GUIConfigData[i]; + GUIConfigDataUnion configData; + for (int i = 0; i < (int) SystemSettings::GUICONFIGDATA_NUMELEM; i++) { + configData.UAVObject[i] = systemSettingsData.GUIConfigData[i]; + } // sanity check - Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == - (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); + Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); return configData; } -void VehicleConfig::SetConfigData(GUIConfigDataUnion configData) +void VehicleConfig::setConfigData(GUIConfigDataUnion configData) { // sanity check Q_ASSERT(SystemSettings::GUICONFIGDATA_NUMELEM == (sizeof(configData.UAVObject) / sizeof(configData.UAVObject[0]))); // get an instance of systemsettings - SystemSettings * systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); + SystemSettings *systemSettings = SystemSettings::GetInstance(getUAVObjectManager()); Q_ASSERT(systemSettings); SystemSettings::DataFields systemSettingsData = systemSettings->getData(); - UAVObjectField* guiConfig = systemSettings->getField("GUIConfigData"); + UAVObjectField *guiConfig = systemSettings->getField("GUIConfigData"); Q_ASSERT(guiConfig); if (!guiConfig) { return; } // copy parameter configData -> systemsettings - for (int i = 0; i < (int) (SystemSettings::GUICONFIGDATA_NUMELEM); i++) { + for (int i = 0; i < (int) SystemSettings::GUICONFIGDATA_NUMELEM; i++) { guiConfig->setValue(configData.UAVObject[i], i); } } @@ -120,6 +117,17 @@ void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) { } +// NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name +// The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name +// FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate +void VehicleConfig::populateChannelComboBoxes() +{ + QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); + foreach(QComboBox *combobox, l) { + combobox->addItems(channelNames); + } +} + /** Helper function: Sets the current index on supplied combobox to index diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index ba28d8977..e9aa55175 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -24,8 +24,8 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef GUIVEHICLECONFIG_H -#define GUIVEHICLECONFIG_H +#ifndef VEHICLECONFIG_H +#define VEHICLECONFIG_H #include "../uavobjectwidgetutils/configtaskwidget.h" #include "extensionsystem/pluginmanager.h" @@ -95,10 +95,10 @@ typedef struct { typedef union { - uint UAVObject[4]; // 32 bits * 4 - heliGUISettingsStruct heli; // 128 bits - fixedGUISettingsStruct fixedwing; - multiGUISettingsStruct multi; + uint UAVObject[4]; // 32 bits * 4 + heliGUISettingsStruct heli; // 128 bits + fixedGUISettingsStruct fixedwing; + multiGUISettingsStruct multi; groundGUISettingsStruct ground; } GUIConfigDataUnion; @@ -140,9 +140,8 @@ public: static const quint32 CHANNEL_NUMELEM = ActuatorCommand::CHANNEL_NUMELEM;; - // TODO remove 1st capital - static GUIConfigDataUnion GetConfigData(); - static void SetConfigData(GUIConfigDataUnion configData); + static GUIConfigDataUnion getConfigData(); + static void setConfigData(GUIConfigDataUnion configData); static void resetField(UAVObjectField *field); @@ -153,23 +152,11 @@ public: VehicleConfig(QWidget *parent = 0); ~VehicleConfig(); - virtual QString updateConfigObjectsFromWidgets(); virtual void refreshWidgetsValues(QString frameType); + virtual QString updateConfigObjectsFromWidgets(); - // TODO move to separate class - double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName); - void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value); - void resetMixerVector(UAVDataObject *mixer, int channel); - void resetMotorAndServoMixers(UAVDataObject *mixer); - QString getMixerType(UAVDataObject *mixer, int channel); - void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType); - double getMixerValue(UAVDataObject *mixer, QString elementName); - void setMixerValue(UAVDataObject *mixer, QString elementName, double value); - void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList curve); - void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList* curve); - bool isValidThrottleCurve(QList *curve); - double getCurveMin(QList *curve); - double getCurveMax(QList *curve); + double getMixerValue(UAVDataObject *mixer, QString elementName); + void setMixerValue(UAVDataObject *mixer, QString elementName, double value); protected: QStringList channelNames; @@ -177,6 +164,20 @@ protected: QStringList mixerVectors; QStringList mixerTypeDescriptions; + void populateChannelComboBoxes(); + + double getMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName); + void setMixerVectorValue(UAVDataObject *mixer, int channel, MixerVectorElem elementName, double value); + void resetMixerVector(UAVDataObject *mixer, int channel); + void resetMotorAndServoMixers(UAVDataObject *mixer); + QString getMixerType(UAVDataObject *mixer, int channel); + void setMixerType(UAVDataObject *mixer, int channel, MixerTypeElem mixerType); + void setThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList curve); + void getThrottleCurve(UAVDataObject *mixer, MixerThrottleCurveElem curveType, QList* curve); + bool isValidThrottleCurve(QList *curve); + double getCurveMin(QList *curve); + double getCurveMax(QList *curve); + private: static UAVObjectManager *getUAVObjectManager(); @@ -187,4 +188,4 @@ private slots: }; -#endif // GUIVEHICLECONFIG_H +#endif // VEHICLECONFIG_H diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 8b8282f6c..085e31262 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -154,24 +154,8 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi // Force the tab index to match m_aircraft->airframesWidget->setCurrentIndex(1); - // Generate lists of mixerTypeNames, mixerVectorNames, channelNames - channelNames << "None"; - for (int i = 0; i < (int) ActuatorSettings::CHANNELADDR_NUMELEM; i++) { - mixerTypes << QString("Mixer%1Type").arg(i + 1); - mixerVectors << QString("Mixer%1Vector").arg(i + 1); - channelNames << QString("Channel%1").arg(i + 1); - } - - // NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name - // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name - // FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate - QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); - foreach(QComboBox *combobox, l) { - combobox->addItems(channelNames); - } - // Connect aircraft type selection dropbox to callback function - connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), m_aircraft->airframesWidget, SLOT(setCurrentIndex(int))); + connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); // Connect the three feed forward test checkboxes connect(m_aircraft->ffTestBox1, SIGNAL(clicked(bool)), this, SLOT(enableFFTest())); @@ -196,15 +180,10 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() // Do nothing } -/** - Slot for switching the airframe type. We do it explicitely - rather than a signal in the UI, because we want to force a fitInView of the quad shapes. - This is because this method (fitinview) only works when the widget is shown. - */ -//void ConfigVehicleTypeWidget::switchAirframeType(int index) -//{ -// m_aircraft->airframesWidget->setCurrentIndex(index); -//} +void ConfigVehicleTypeWidget::switchAirframeType(int index) +{ + m_aircraft->airframesWidget->setCurrentIndex(index); +} /** Refreshes the current value of the SystemSettings which holds the aircraft type @@ -233,9 +212,8 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) // is not ideal, but there you go. QString frameType = field->getValue().toString(); qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; - //setupAirframeUI(frameType); - QString category = "FixedWing";//frameCategory(frameType); + QString category = frameCategory(frameType); if (category == "FixedWing") { // Retrieve fixed wing settings setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); @@ -378,13 +356,12 @@ void ConfigVehicleTypeWidget::enableFFTest() // - Check if all three checkboxes are checked // - Every other timer event: toggle engine from 45% to 55% // - Every other time event: send FF settings to flight FW - if (m_aircraft->ffTestBox1->isChecked() && - m_aircraft->ffTestBox2->isChecked() && - m_aircraft->ffTestBox3->isChecked()) { - if (!ffTuningInProgress) - { + if (m_aircraft->ffTestBox1->isChecked() && m_aircraft->ffTestBox2->isChecked() + && m_aircraft->ffTestBox3->isChecked()) { + if (!ffTuningInProgress) { // Initiate tuning: - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject( + QString("ManualControlCommand"))); UAVObject::Metadata mdata = obj->getMetadata(); accInitialData = mdata; UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READONLY); @@ -404,9 +381,10 @@ void ConfigVehicleTypeWidget::enableFFTest() vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); mixer->updated(); - } else { + } else { // Toggle motor state - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject( + QString("ManualControlCommand"))); double value = obj->getField("Throttle")->getDouble(); double target = (value < 0.5) ? 0.55 : 0.45; obj->getField("Throttle")->setValue(target); @@ -420,7 +398,8 @@ void ConfigVehicleTypeWidget::enableFFTest() // Disarm! if (ffTuningInProgress) { ffTuningInProgress = false; - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject(QString("ManualControlCommand"))); + UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject( + QString("ManualControlCommand"))); UAVObject::Metadata mdata = obj->getMetadata(); mdata = accInitialData; // Restore metadata obj->setMetadata(mdata); @@ -435,7 +414,7 @@ void ConfigVehicleTypeWidget::enableFFTest() */ void ConfigVehicleTypeWidget::updateFeedForwardUI() { - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); QPointer vconfig = new VehicleConfig(); diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index 880a10650..7ce980449 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -65,15 +65,12 @@ private: QString frameCategory(QString frameType); - QStringList channelNames; - QStringList mixerTypes; - QStringList mixerVectors; - bool ffTuningInProgress; bool ffTuningPhase; UAVObject::Metadata accInitialData; private slots: + void switchAirframeType(int index); void enableFFTest(); void openHelp(); From c331a143ae3802fb1db023b95d1fba129bc86e37 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 15 Apr 2013 21:43:04 +0200 Subject: [PATCH 16/32] OP-907 moved mixer curve background svg file (curve-bg.svg) to src/plugins/uavobjectwidgetutils as it is used from mixercurvewidget.cpp located in that directory --- ground/openpilotgcs/src/plugins/config/configgadget.qrc | 1 - .../{config => uavobjectwidgetutils}/images/curve-bg.svg | 0 .../src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp | 2 +- .../plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro | 6 +++++- .../plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc | 5 +++++ 5 files changed, 11 insertions(+), 3 deletions(-) rename ground/openpilotgcs/src/plugins/{config => uavobjectwidgetutils}/images/curve-bg.svg (100%) create mode 100644 ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc diff --git a/ground/openpilotgcs/src/plugins/config/configgadget.qrc b/ground/openpilotgcs/src/plugins/config/configgadget.qrc index a5b006745..adffc9568 100644 --- a/ground/openpilotgcs/src/plugins/config/configgadget.qrc +++ b/ground/openpilotgcs/src/plugins/config/configgadget.qrc @@ -3,7 +3,6 @@ images/help2.png images/ahrs-calib.svg images/paper-plane.svg - images/curve-bg.svg images/multirotor-shapes.svg images/ccpm_setup.svg images/PipXtreme.png diff --git a/ground/openpilotgcs/src/plugins/config/images/curve-bg.svg b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg similarity index 100% rename from ground/openpilotgcs/src/plugins/config/images/curve-bg.svg rename to ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp index 63e388a28..4c52d1afb 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/mixercurvewidget.cpp @@ -64,7 +64,7 @@ MixerCurveWidget::MixerCurveWidget(QWidget *parent) : QGraphicsView(parent) QGraphicsScene *scene = new QGraphicsScene(this); QSvgRenderer *renderer = new QSvgRenderer(); plot = new QGraphicsSvgItem(); - renderer->load(QString(":/configgadget/images/curve-bg.svg")); + renderer->load(QString(":/uavobjectwidgetutils/images/curve-bg.svg")); plot->setSharedRenderer(renderer); //plot->setElementId("map"); scene->addItem(plot); diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro index cedaed7c3..b75b019ce 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.pro @@ -2,16 +2,19 @@ TEMPLATE = lib TARGET = UAVObjectWidgetUtils DEFINES += UAVOBJECTWIDGETUTILS_LIBRARY QT += svg + include(../../openpilotgcsplugin.pri) include(uavobjectwidgetutils_dependencies.pri) + HEADERS += uavobjectwidgetutils_global.h \ uavobjectwidgetutilsplugin.h \ configtaskwidget.h \ mixercurvewidget.h \ mixercurvepoint.h \ mixercurveline.h \ - smartsavebutton.h \ + smartsavebutton.h \ popupwidget.h + SOURCES += uavobjectwidgetutilsplugin.cpp \ configtaskwidget.cpp \ mixercurvewidget.cpp \ @@ -20,6 +23,7 @@ SOURCES += uavobjectwidgetutilsplugin.cpp \ smartsavebutton.cpp \ popupwidget.cpp +RESOURCES += uavobjectwidgetutils.qrc OTHER_FILES += UAVObjectWidgetUtils.pluginspec diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc new file mode 100644 index 000000000..9cbc86131 --- /dev/null +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/uavobjectwidgetutils.qrc @@ -0,0 +1,5 @@ + + + images/curve-bg.svg + + From 70177a82d72b21a6875a902d579be81673acf6d0 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 15 Apr 2013 21:47:28 +0200 Subject: [PATCH 17/32] OP-907 changed grid lines of curve-bg.svg from dashed to solid to fix rendering artefacts cause by dashed lines --- .../uavobjectwidgetutils/images/curve-bg.svg | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg index d8194ec7a..492db9174 100644 --- a/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg +++ b/ground/openpilotgcs/src/plugins/uavobjectwidgetutils/images/curve-bg.svg @@ -14,7 +14,7 @@ height="253" id="svg2" version="1.1" - inkscape:version="0.48.2 r9819" + inkscape:version="0.48.4 r9939" sodipodi:docname="curve-bg.svg"> @@ -55,15 +55,15 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="1.9966906" - inkscape:cx="181.06787" + inkscape:cx="102.93859" inkscape:cy="89.329853" inkscape:document-units="px" inkscape:current-layer="layer1" showgrid="false" inkscape:window-width="1440" inkscape:window-height="878" - inkscape:window-x="1695" - inkscape:window-y="97" + inkscape:window-x="148" + inkscape:window-y="40" inkscape:window-maximized="0" /> @@ -101,49 +101,49 @@ + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:5.30000019;stroke-opacity:0.28888890000000000;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" /> + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:5.30000019;stroke-opacity:0.28888890000000000;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" /> + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:5.30000019;stroke-opacity:0.28888890000000000;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020;marker-start:none" /> + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.28888890000000000;stroke-miterlimit:5.30000019;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" /> + style="fill:none;stroke:#000000;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:0.28888890000000000;stroke-miterlimit:5.30000019;stroke-dasharray:none;stroke-dashoffset:3.70000000000000020" /> From dc060de5dacfe5b8e3732f1e8af5d5d314c71e70 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 15 Apr 2013 21:58:01 +0200 Subject: [PATCH 18/32] OP-907 fixed minor spacing issue with multirotor mixer status line --- ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui index fa82a2558..7043696c2 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui @@ -440,7 +440,7 @@ margin:1px; - + 0 0 @@ -455,7 +455,7 @@ margin:1px; Mixer OK - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter From 3bb80977d58c51b06101fd989297f89d315caca8 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 15 Apr 2013 21:59:11 +0200 Subject: [PATCH 19/32] OP-907 changed vehicle config widget margin --- ground/openpilotgcs/src/plugins/config/airframe.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index da2f1898c..ad91b79ff 100755 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -15,7 +15,7 @@ - 12 + 9 @@ -197,8 +197,8 @@ 0 0 - 832 - 461 + 838 + 467 From 0deb4d4a8f6a42576a177ce334dd8bd57306c6be Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Tue, 16 Apr 2013 00:13:08 +0200 Subject: [PATCH 20/32] OP-907 vehicle config widgets now have consistent labels for mixer sliders --- .../src/plugins/config/airframe_ground.ui | 24 ++- .../src/plugins/config/airframe_multirotor.ui | 174 +++++++++--------- 2 files changed, 107 insertions(+), 91 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe_ground.ui b/ground/openpilotgcs/src/plugins/config/airframe_ground.ui index 80b28af42..de21f3ad2 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_ground.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_ground.ui @@ -252,7 +252,7 @@ - + @@ -263,10 +263,19 @@ - 50 - false + -1 + 75 + false + true + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + Left % @@ -307,7 +316,7 @@ - + @@ -316,6 +325,13 @@ 0 + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + Right % diff --git a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui index 7043696c2..a8e038f74 100644 --- a/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe_multirotor.ui @@ -128,7 +128,7 @@ - + 16777215 @@ -146,47 +146,8 @@ 9 - - - - - - 40 - 0 - - - - 100 - - - Qt::AlignCenter - - - - - - - - 40 - 0 - - - - Weight of Roll mixing in percent. -Typical values are 100% for + configuration and 50% for X configuration on quads. - - - 100 - - - 100 - - - Qt::Vertical - - - - + + @@ -221,28 +182,8 @@ margin:1px; - - - - - - - - - 40 - 0 - - - - 100 - - - Qt::AlignCenter - - - - - + + 40 @@ -250,21 +191,41 @@ margin:1px; - Weight of Pitch mixing in percent. + Weight of Roll mixing in percent. Typical values are 100% for + configuration and 50% for X configuration on quads. 100 - 100 + 50 Qt::Vertical - + + + + + 40 + 0 + + + + 50 + + + Qt::AlignCenter + + + + + + + + @@ -287,12 +248,31 @@ margin:1px; - - - - - - + + + + + 40 + 0 + + + + Weight of Pitch mixing in percent. +Typical values are 100% for + configuration and 50% for X configuration on quads. + + + 100 + + + 50 + + + Qt::Vertical + + + + + 40 @@ -307,7 +287,37 @@ margin:1px; - + + + + + + + + + 40 + 0 + + + + false + + + background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); +color: rgb(255, 255, 255); +border-radius: 5; +font: bold 12px; +margin:1px; + + + Yaw + + + Qt::AlignCenter + + + + @@ -333,26 +343,16 @@ Typical value is 50% for + or X configuration on quads. - - + + 40 0 - - false - - - background-color: qlineargradient(spread:reflect, x1:0.507, y1:0, x2:0.507, y2:0.772, stop:0.208955 rgba(74, 74, 74, 255), stop:0.78607 rgba(36, 36, 36, 255)); -color: rgb(255, 255, 255); -border-radius: 5; -font: bold 12px; -margin:1px; - - Yaw + 50 Qt::AlignCenter From b03ebbaf3a17d266108399dcf802ea64615cedc1 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Thu, 18 Apr 2013 03:51:47 +0200 Subject: [PATCH 21/32] OP-907 step 4: added lazy creation of vehicle config widget --- .../config/configvehicletypewidget.cpp | 176 +++++++----------- .../plugins/config/configvehicletypewidget.h | 18 +- 2 files changed, 77 insertions(+), 117 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 085e31262..52ef16629 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -124,35 +124,8 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi airframeTypes << "Fixed Wing" << "Multirotor" << "Helicopter" << "Ground" << "Custom"; m_aircraft->aircraftType->addItems(airframeTypes); - // ***************************************************************************************************************** - - // create and setup a FixedWing config widget - qDebug() << "create fixedwing ui"; - m_fixedwing = new ConfigFixedWingWidget(); - m_aircraft->airframesWidget->addWidget(m_fixedwing); - - // create and setup a MultiRotor config widget - m_multirotor = new ConfigMultiRotorWidget(); - m_aircraft->airframesWidget->addWidget(m_multirotor); - - // create and setup a Helicopter config widget - m_heli = new ConfigCcpmWidget(); - m_aircraft->airframesWidget->addWidget(m_heli); - - // create and setup a GroundVehicle config widget - m_groundvehicle = new ConfigGroundVehicleWidget(); - m_aircraft->airframesWidget->addWidget(m_groundvehicle); - - // create and setup a custom config widget - m_custom = new ConfigCustomWidget(); - m_aircraft->airframesWidget->addWidget(m_custom); - - // ***************************************************************************************************************** - // Set default vehicle to MultiRotor - m_aircraft->aircraftType->setCurrentIndex(1); - // Force the tab index to match - m_aircraft->airframesWidget->setCurrentIndex(1); + //m_aircraft->aircraftType->setCurrentIndex(3); // Connect aircraft type selection dropbox to callback function connect(m_aircraft->aircraftType, SIGNAL(currentIndexChanged(int)), this, SLOT(switchAirframeType(int))); @@ -182,7 +155,9 @@ ConfigVehicleTypeWidget::~ConfigVehicleTypeWidget() void ConfigVehicleTypeWidget::switchAirframeType(int index) { - m_aircraft->airframesWidget->setCurrentIndex(index); + // TODO not safe w/r to translation!!! + QString frameCategory = m_aircraft->aircraftType->currentText(); + m_aircraft->airframesWidget->setCurrentWidget(getVehicleConfigWidget(frameCategory)); } /** @@ -214,26 +189,10 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - frame type:" << frameType; QString category = frameCategory(frameType); - if (category == "FixedWing") { - // Retrieve fixed wing settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Fixed Wing")); - m_fixedwing->refreshWidgetsValues(frameType); - } else if (category == "Multirotor") { - // Retrieve multirotor settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Multirotor")); - m_multirotor->refreshWidgetsValues(frameType); - } else if (category == "Helicopter") { - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Helicopter")); - m_heli->refreshWidgetsValues(frameType); - } else if (category == "Ground") { - // Retrieve ground vehicle settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Ground")); - m_groundvehicle->refreshWidgetsValues(frameType); - } else if (category == "Custom") { - // Retrieve custom settings - setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText("Custom")); - m_custom->refreshWidgetsValues(frameType); - } + setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText(category)); + + VehicleConfig *vehicleConfig = getVehicleConfigWidget(category); + vehicleConfig->refreshWidgetsValues(frameType); updateFeedForwardUI(); @@ -242,51 +201,6 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - end"; } -//QString ConfigVehicleTypeWidget::frameCategory1(QString frameType) -//{ -// QString category; -// if (frameType.startsWith("FixedWing")) { -// category = "FixedWing"; -// } else if (frameType == "Tri" || frameType == "QuadX" || frameType == "QuadP" || frameType == "Hexa" -// || frameType == "HexaCoax" || frameType == "HexaX" || frameType == "Octo" || frameType == "OctoV" -// || frameType == "OctoCoaxP" || frameType == "OctoCoaxX") { -// category = "Multirotor"; -// } else if (frameType == "HeliCP") { -// category = "Helicopter"; -// } else if (frameType.startsWith("GroundVehicle")) { -// category = "Ground"; -// } else { -// category = "Custom"; -// } -// return category; -//} - - -QString ConfigVehicleTypeWidget::frameCategory(QString frameType) -{ - QString category; - if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" - || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { - category = "FixedWing"; - } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" - || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" - || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax" - || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV" - || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" - || frameType == "OctoCoaxX" || frameType == "Octo Coax X") { - category = "Multirotor"; - } else if (frameType == "HeliCP") { - category = "Helicopter"; - } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" - || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" - || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { - category = "Ground"; - } else { - category = "Custom"; - } - return category; -} - /** Sends the config to the board (airframe type) @@ -309,21 +223,9 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() // Sets airframe type default to "Custom" QString airframeType = "Custom"; - if (m_aircraft->aircraftType->currentText() == "Fixed Wing") { - airframeType = m_fixedwing->updateConfigObjectsFromWidgets(); - } - else if (m_aircraft->aircraftType->currentText() == "Multirotor") { - airframeType = m_multirotor->updateConfigObjectsFromWidgets(); - } - else if (m_aircraft->aircraftType->currentText() == "Helicopter") { - airframeType = m_heli->updateConfigObjectsFromWidgets(); - } - else if (m_aircraft->aircraftType->currentText() == "Ground") { - airframeType = m_groundvehicle->updateConfigObjectsFromWidgets(); - } - else { - airframeType = m_custom->updateConfigObjectsFromWidgets(); - } + + VehicleConfig *vehicleConfig = (VehicleConfig *) m_aircraft->airframesWidget->currentWidget(); + airframeType = vehicleConfig->updateConfigObjectsFromWidgets(); // set the airframe type UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -347,6 +249,62 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() // } //} +QString ConfigVehicleTypeWidget::frameCategory(QString frameType) +{ + QString category; + if (frameType == "FixedWing" || frameType == "Elevator aileron rudder" || frameType == "FixedWingElevon" + || frameType == "Elevon" || frameType == "FixedWingVtail" || frameType == "Vtail") { + category = "Fixed Wing"; + } else if (frameType == "Tri" || frameType == "Tricopter Y" || frameType == "QuadX" || frameType == "Quad X" + || frameType == "QuadP" || frameType == "Quad +" || frameType == "Hexa" || frameType == "Hexacopter" + || frameType == "HexaX" || frameType == "Hexacopter X" || frameType == "HexaCoax" + || frameType == "Hexacopter Y6" || frameType == "Octo" || frameType == "Octocopter" || frameType == "OctoV" + || frameType == "Octocopter V" || frameType == "OctoCoaxP" || frameType == "Octo Coax +" + || frameType == "OctoCoaxX" || frameType == "Octo Coax X") { + category = "Multirotor"; + } else if (frameType == "HeliCP") { + category = "Helicopter"; + } else if (frameType == "GroundVehicleCar" || frameType == "Turnable (car)" + || frameType == "GroundVehicleDifferential" || frameType == "Differential (tank)" + || frameType == "GroundVehicleMotorcyle" || frameType == "Motorcycle") { + category = "Ground"; + } else { + category = "Custom"; + } + return category; +} + +VehicleConfig *ConfigVehicleTypeWidget::getVehicleConfigWidget(QString frameCategory) +{ + VehicleConfig *vehiculeConfig; + if (vehicleIndexMap.contains(frameCategory)) { + int index = vehicleIndexMap.value(frameCategory); + vehiculeConfig = (VehicleConfig *) m_aircraft->airframesWidget->widget(index); + } else { + vehiculeConfig = createVehicleConfigWidget(frameCategory); + int index = m_aircraft->airframesWidget->insertWidget(m_aircraft->airframesWidget->count(), vehiculeConfig); + vehicleIndexMap[frameCategory] = index; + } + return vehiculeConfig; +} + +VehicleConfig *ConfigVehicleTypeWidget::createVehicleConfigWidget(QString frameCategory) +{ + qDebug() << "creating" << frameCategory; + if (frameCategory == "Fixed Wing") { + return new ConfigFixedWingWidget(); + } else if (frameCategory == "Multirotor") { + return new ConfigMultiRotorWidget(); + } else if (frameCategory == "Helicopter") { + return new ConfigCcpmWidget(); + } else if (frameCategory == "Ground") { + return new ConfigGroundVehicleWidget(); + } else if (frameCategory == "Custom") { + return new ConfigCustomWidget(); + } + return NULL; +} + /** Enables and runs feed forward testing */ diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index 7ce980449..c19abac4e 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -33,6 +33,7 @@ #include "../uavobjectwidgetutils/configtaskwidget.h" #include +#include #include #include #include @@ -55,24 +56,25 @@ public slots: private: Ui_AircraftWidget *m_aircraft; - VehicleConfig *m_heli; - VehicleConfig *m_fixedwing; - VehicleConfig *m_multirotor; - VehicleConfig *m_groundvehicle; - VehicleConfig *m_custom; - - void updateFeedForwardUI(); + // Maps a frame category to its index in the m_aircraft->airframesWidget QStackedWidget + QMap vehicleIndexMap; QString frameCategory(QString frameType); + VehicleConfig *getVehicleConfigWidget(QString frameCategory); + VehicleConfig *createVehicleConfigWidget(QString frameCategory); + + // Feed Forward + void updateFeedForwardUI(); + bool ffTuningInProgress; bool ffTuningPhase; UAVObject::Metadata accInitialData; private slots: void switchAirframeType(int index); - void enableFFTest(); void openHelp(); + void enableFFTest(); }; From 5f39206ebd570c9c69f9df7411a4e6d42d56bd9a Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Mon, 22 Apr 2013 21:23:47 +0200 Subject: [PATCH 22/32] OP-907 vehicle config - removed uncessary setupUI calls. + fixed regression in multirotor config widget : svg display was not updated when switching frame type + formatting --- .../cfg_vehicletypes/configccpmwidget.cpp | 4 +- .../configfixedwingwidget.cpp | 2 +- .../configgroundvehiclewidget.cpp | 4 +- .../configmultirotorwidget.cpp | 44 +++++++++---------- .../cfg_vehicletypes/configmultirotorwidget.h | 8 ++-- .../config/cfg_vehicletypes/vehicleconfig.cpp | 6 ++- 6 files changed, 34 insertions(+), 34 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index e11281754..9335df774 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -232,7 +232,7 @@ ConfigCcpmWidget::ConfigCcpmWidget(QWidget *parent) : m_aircraft->ccpmType->addItems(Types); m_aircraft->ccpmType->setCurrentIndex(m_aircraft->ccpmType->count() - 1); - refreshWidgetsValues(QString("HeliCP")); + //refreshWidgetsValues(QString("HeliCP")); UpdateType(); @@ -296,7 +296,7 @@ void ConfigCcpmWidget::refreshWidgetsValues(QString frameType) GUIConfigDataUnion config = getConfigData(); // swashplate config - setComboCurrentIndex( m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType +1)); + setComboCurrentIndex(m_aircraft->ccpmType, m_aircraft->ccpmType->count() - (config.heli.SwashplateType + 1)); setComboCurrentIndex(m_aircraft->ccpmSingleServo, config.heli.FirstServoIndex); // ccpm mixing options diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 6d385c0a4..8f0365133 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -89,7 +89,7 @@ ConfigFixedWingWidget::ConfigFixedWingWidget(QWidget *parent) : // Set default model to "Elevator aileron rudder" m_aircraft->fixedWingType->setCurrentIndex(m_aircraft->fixedWingType->findText("Elevator aileron rudder")); - setupUI(m_aircraft->fixedWingType->currentText()); + //setupUI(m_aircraft->fixedWingType->currentText()); connect(m_aircraft->fixedWingType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 4b1e265b8..20c062a6e 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -81,7 +81,7 @@ ConfigGroundVehicleWidget::ConfigGroundVehicleWidget(QWidget *parent) : // Set default model to "Turnable (car)" m_aircraft->groundVehicleType->setCurrentIndex(m_aircraft->groundVehicleType->findText("Turnable (car)")); - setupUI(m_aircraft->groundVehicleType->currentText()); + //setupUI(m_aircraft->groundVehicleType->currentText()); connect(m_aircraft->groundVehicleType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); } @@ -199,8 +199,6 @@ void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) */ void ConfigGroundVehicleWidget::refreshWidgetsValues(QString frameType) { - qDebug() << "ConfigGroundVehicleWidget::refreshWidgetsValues - frame type:" << frameType; - setupUI(frameType); UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 2b412c977..52fd8aef6 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -86,7 +86,7 @@ QStringList ConfigMultiRotorWidget::getChannelDescriptions() } ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : - VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(1) + VehicleConfig(parent), m_aircraft(new Ui_MultiRotorConfigWidget()), invertMotors(false) { m_aircraft->setupUi(this); @@ -116,7 +116,7 @@ ConfigMultiRotorWidget::ConfigMultiRotorWidget(QWidget *parent) : // Set default model to "Quad X" m_aircraft->multirotorFrameType->setCurrentIndex(m_aircraft->multirotorFrameType->findText("Quad X")); - setupUI(m_aircraft->multirotorFrameType->currentText()); + //setupUI(m_aircraft->multirotorFrameType->currentText()); connect(m_aircraft->multirotorFrameType, SIGNAL(currentIndexChanged(QString)), this, SLOT(setupUI(QString))); @@ -134,8 +134,6 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) Q_ASSERT(m_aircraft); Q_ASSERT(quad); - qDebug() << "ConfigMultiRotorWidget::setupUI - frame type" << frameType; - // disable triyaw channel m_aircraft->triYawChannelBox->setEnabled(false); @@ -246,8 +244,9 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) m_aircraft->mrPitchMixLevel->setValue(50); setYawMixLevel(50); } + // Draw the appropriate airframe - //drawAirframe(frameType); + updateAirframe(frameType); } void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) @@ -503,7 +502,7 @@ void ConfigMultiRotorWidget::refreshWidgetsValues(QString frameType) } } - drawAirframe(frameType); + updateAirframe(frameType); } /** @@ -720,12 +719,12 @@ void ConfigMultiRotorWidget::setYawMixLevel(int value) void ConfigMultiRotorWidget::reverseMultirotorMotor(){ QString frameType = m_aircraft->multirotorFrameType->currentText(); - drawAirframe(frameType); + updateAirframe(frameType); } -void ConfigMultiRotorWidget::drawAirframe(QString frameType) +void ConfigMultiRotorWidget::updateAirframe(QString frameType) { - qDebug() << "ConfigMultiRotorWidget::drawAirframe - frame type" << frameType; + qDebug() << "ConfigMultiRotorWidget::updateAirframe - frame type" << frameType; QString elementId; if (frameType == "Tri" || frameType == "Tricopter Y") { @@ -750,8 +749,8 @@ void ConfigMultiRotorWidget::drawAirframe(QString frameType) elementId = "octo-coax-X"; } - invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; - if (invertMotors <= 0) { + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked(); + if (invertMotors) { elementId += "_reverse"; } @@ -953,27 +952,28 @@ bool ConfigMultiRotorWidget::setupHexa(bool pLayout) */ bool ConfigMultiRotorWidget::setupMultiRotorMixer(double mixerFactors[8][3]) { - QList mmList; - mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 - << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 - << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 - << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; - UAVDataObject* mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); Q_ASSERT(mixer); resetMotorAndServoMixers(mixer); // and enable only the relevant channels: - double pFactor = (double) m_aircraft->mrPitchMixLevel->value() / 100; - double rFactor = (double) m_aircraft->mrRollMixLevel->value() / 100; - invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked() ? -1 : 1; - double yFactor = invertMotors * (double) m_aircraft->mrYawMixLevel->value() / 100; + double pFactor = (double) m_aircraft->mrPitchMixLevel->value() / 100.0; + double rFactor = (double) m_aircraft->mrRollMixLevel->value() / 100.0; + invertMotors = m_aircraft->MultirotorRevMixerCheckBox->isChecked(); + double yFactor = (invertMotors ? -1.0 : 1.0) * (double) m_aircraft->mrYawMixLevel->value() / 100.0; + + QList mmList; + mmList << m_aircraft->multiMotorChannelBox1 << m_aircraft->multiMotorChannelBox2 + << m_aircraft->multiMotorChannelBox3 << m_aircraft->multiMotorChannelBox4 + << m_aircraft->multiMotorChannelBox5 << m_aircraft->multiMotorChannelBox6 + << m_aircraft->multiMotorChannelBox7 << m_aircraft->multiMotorChannelBox8; for (int i = 0; i < 8; i++) { if (mmList.at(i)->isEnabled()) { int channel = mmList.at(i)->currentIndex() - 1; - if (channel > -1) + if (channel > -1) { setupQuadMotor(channel, mixerFactors[i][0] * pFactor, rFactor * mixerFactors[i][1], yFactor * mixerFactors[i][2]); + } } } return true; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 2b2844fad..4726cee79 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -35,9 +35,9 @@ #include "uavobject.h" #include "uavtalk/telemetrymanager.h" +#include #include -#include -#include +#include class Ui_Widget; @@ -62,7 +62,7 @@ protected: private: Ui_MultiRotorConfigWidget *m_aircraft; QGraphicsSvgItem *quad; - float invertMotors; + bool invertMotors; virtual void resetActuators(GUIConfigDataUnion *configData); @@ -75,7 +75,7 @@ private: void setYawMixLevel(int); - void drawAirframe(QString multiRotorType); + void updateAirframe(QString multiRotorType); private slots: virtual void setupUI(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index d488744ed..725314591 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -102,6 +102,7 @@ void VehicleConfig::setConfigData(GUIConfigDataUnion configData) void VehicleConfig::setupUI(QString frameType) { + Q_UNUSED(frameType); } QString VehicleConfig::updateConfigObjectsFromWidgets() @@ -111,10 +112,12 @@ QString VehicleConfig::updateConfigObjectsFromWidgets() void VehicleConfig::refreshWidgetsValues(QString frameType) { + Q_UNUSED(frameType); } void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) { + Q_UNUSED(configData); } // NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name @@ -122,7 +125,7 @@ void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) // FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate void VehicleConfig::populateChannelComboBoxes() { - QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); + QList l = findChildren(QRegExp("\\S+ChannelBo\\S+")); foreach(QComboBox *combobox, l) { combobox->addItems(channelNames); } @@ -136,7 +139,6 @@ void VehicleConfig::populateChannelComboBoxes() void VehicleConfig::setComboCurrentIndex(QComboBox *box, int index) { Q_ASSERT(box); - if (index >= 0 && index < box->count()) { box->setCurrentIndex(index); } From d7596a64ff8999c36a0fd8aa35465e999515c8d9 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 24 Apr 2013 22:05:31 +0200 Subject: [PATCH 23/32] OP-907 reverted airframe.ui border from 9 to 12 to make it more consistent with other config tabs --- ground/openpilotgcs/src/plugins/config/airframe.ui | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/airframe.ui b/ground/openpilotgcs/src/plugins/config/airframe.ui index ad91b79ff..da2f1898c 100755 --- a/ground/openpilotgcs/src/plugins/config/airframe.ui +++ b/ground/openpilotgcs/src/plugins/config/airframe.ui @@ -15,7 +15,7 @@ - 9 + 12 @@ -197,8 +197,8 @@ 0 0 - 838 - 467 + 832 + 461 From 99c052651c60da7dabcb6297c92e9884defd1265 Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Wed, 24 Apr 2013 23:24:23 +0200 Subject: [PATCH 24/32] OP-907 fixed regression in vehicle config : "dirty" state management was broken. + added comments --- .../cfg_vehicletypes/configccpmwidget.cpp | 35 +++++++++ .../cfg_vehicletypes/configccpmwidget.h | 1 + .../cfg_vehicletypes/configcustomwidget.cpp | 7 ++ .../cfg_vehicletypes/configcustomwidget.h | 1 + .../configfixedwingwidget.cpp | 15 ++++ .../cfg_vehicletypes/configfixedwingwidget.h | 1 + .../configgroundvehiclewidget.cpp | 6 ++ .../configgroundvehiclewidget.h | 1 + .../configmultirotorwidget.cpp | 17 ++++ .../cfg_vehicletypes/configmultirotorwidget.h | 1 + .../config/cfg_vehicletypes/vehicleconfig.cpp | 16 +++- .../config/cfg_vehicletypes/vehicleconfig.h | 14 ++++ .../config/configvehicletypewidget.cpp | 78 +++++++++++-------- .../plugins/config/configvehicletypewidget.h | 17 +++- 14 files changed, 171 insertions(+), 39 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp index 9335df774..6e764dc41 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.cpp @@ -277,6 +277,41 @@ void ConfigCcpmWidget::setupUI(QString frameType) Q_UNUSED(frameType); } +void ConfigCcpmWidget::registerWidgets(ConfigTaskWidget &parent) { + parent.addWidget(m_aircraft->ccpmType); + parent.addWidget(m_aircraft->ccpmTailChannel); + parent.addWidget(m_aircraft->ccpmEngineChannel); + parent.addWidget(m_aircraft->ccpmServoWChannel); + parent.addWidget(m_aircraft->ccpmServoXChannel); + parent.addWidget(m_aircraft->ccpmServoYChannel); + parent.addWidget(m_aircraft->ccpmSingleServo); + parent.addWidget(m_aircraft->ccpmServoZChannel); + parent.addWidget(m_aircraft->ccpmAngleW); + parent.addWidget(m_aircraft->ccpmAngleX); + parent.addWidget(m_aircraft->ccpmCorrectionAngle); + parent.addWidget(m_aircraft->ccpmAngleZ); + parent.addWidget(m_aircraft->ccpmAngleY); + parent.addWidget(m_aircraft->ccpmCollectivePassthrough); + parent.addWidget(m_aircraft->ccpmLinkRoll); + parent.addWidget(m_aircraft->ccpmLinkCyclic); + parent.addWidget(m_aircraft->ccpmRevoSlider); + parent.addWidget(m_aircraft->ccpmREVOspinBox); + parent.addWidget(m_aircraft->ccpmCollectiveSlider); + parent.addWidget(m_aircraft->ccpmCollectivespinBox); + parent.addWidget(m_aircraft->ccpmCollectiveScale); + parent.addWidget(m_aircraft->ccpmCollectiveScaleBox); + parent.addWidget(m_aircraft->ccpmCyclicScale); + parent.addWidget(m_aircraft->ccpmPitchScale); + parent.addWidget(m_aircraft->ccpmPitchScaleBox); + parent.addWidget(m_aircraft->ccpmRollScale); + parent.addWidget(m_aircraft->ccpmRollScaleBox); + parent.addWidget(m_aircraft->SwashLvlPositionSlider); + parent.addWidget(m_aircraft->SwashLvlPositionSpinBox); + parent.addWidget(m_aircraft->ThrottleCurve->getCurveWidget()); + parent.addWidget(m_aircraft->PitchCurve->getCurveWidget()); + parent.addWidget(m_aircraft->ccpmAdvancedSettingsTable); +} + void ConfigCcpmWidget::resetActuators(GUIConfigDataUnion *configData) { configData->heli.Throttle = 0; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h index e2f0e8c08..a0e4fa094 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configccpmwidget.h @@ -97,6 +97,7 @@ private: int MixerChannelData[6]; + virtual void registerWidgets(ConfigTaskWidget &parent); virtual void resetActuators(GUIConfigDataUnion *configData); int ShowDisclaimer(int messageID); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp index 6d0aa91b5..684435b0a 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.cpp @@ -68,6 +68,7 @@ ConfigCustomWidget::ConfigCustomWidget(QWidget *parent) : for (int i = 1; i < (int) VehicleConfig::CHANNEL_NUMELEM; i++) { m_aircraft->customMixerTable->setItemDelegateForRow(i, sbd); } + } ConfigCustomWidget::~ConfigCustomWidget() @@ -80,6 +81,12 @@ void ConfigCustomWidget::setupUI(QString frameType) Q_ASSERT(m_aircraft); } +void ConfigCustomWidget::registerWidgets(ConfigTaskWidget &parent) { + parent.addWidget(m_aircraft->customMixerTable); + parent.addWidget(m_aircraft->customThrottle1Curve->getCurveWidget()); + parent.addWidget(m_aircraft->customThrottle2Curve->getCurveWidget()); +} + void ConfigCustomWidget::resetActuators(GUIConfigDataUnion *configData) { } diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h index 1debb9a41..1bf7bbf75 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configcustomwidget.h @@ -61,6 +61,7 @@ protected: private: Ui_CustomConfigWidget *m_aircraft; + virtual void registerWidgets(ConfigTaskWidget &parent); virtual void resetActuators(GUIConfigDataUnion *configData); private slots: diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp index 8f0365133..a2b7bf79f 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.cpp @@ -165,6 +165,21 @@ void ConfigFixedWingWidget::setupUI(QString frameType) } } +void ConfigFixedWingWidget::registerWidgets(ConfigTaskWidget &parent) { + parent.addWidget(m_aircraft->fixedWingThrottle->getCurveWidget()); + parent.addWidget(m_aircraft->fixedWingType); + + parent.addWidget(m_aircraft->fwEngineChannelBox); + parent.addWidget(m_aircraft->fwAileron1ChannelBox); + parent.addWidget(m_aircraft->fwAileron2ChannelBox); + parent.addWidget(m_aircraft->fwElevator1ChannelBox); + parent.addWidget(m_aircraft->fwElevator2ChannelBox); + parent.addWidget(m_aircraft->fwRudder1ChannelBox); + parent.addWidget(m_aircraft->fwRudder2ChannelBox); + parent.addWidget(m_aircraft->elevonSlider1); + parent.addWidget(m_aircraft->elevonSlider2); +} + void ConfigFixedWingWidget::resetActuators(GUIConfigDataUnion *configData) { configData->fixedwing.FixedWingPitch1 = 0; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h index 26f5c282e..c738920d9 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configfixedwingwidget.h @@ -57,6 +57,7 @@ public: private: Ui_FixedWingConfigWidget *m_aircraft; + virtual void registerWidgets(ConfigTaskWidget &parent); virtual void resetActuators(GUIConfigDataUnion *configData); bool setupFrameFixedWing(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp index 20c062a6e..771a2afb5 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.cpp @@ -186,6 +186,12 @@ void ConfigGroundVehicleWidget::setupUI(QString frameType) } } +void ConfigGroundVehicleWidget::registerWidgets(ConfigTaskWidget &parent) { + parent.addWidget(m_aircraft->groundVehicleThrottle1->getCurveWidget()); + parent.addWidget(m_aircraft->groundVehicleThrottle2->getCurveWidget()); + parent.addWidget(m_aircraft->groundVehicleType); +} + void ConfigGroundVehicleWidget::resetActuators(GUIConfigDataUnion *configData) { configData->ground.GroundVehicleSteering1 = 0; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h index 3f8abea37..475f54a19 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configgroundvehiclewidget.h @@ -57,6 +57,7 @@ public: private: Ui_GroundConfigWidget *m_aircraft; + virtual void registerWidgets(ConfigTaskWidget &parent); virtual void resetActuators(GUIConfigDataUnion *configData); bool setupGroundVehicleCar(QString airframeType); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp index 52fd8aef6..7fc9d46a5 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.cpp @@ -249,6 +249,23 @@ void ConfigMultiRotorWidget::setupUI(QString frameType) updateAirframe(frameType); } +void ConfigMultiRotorWidget::registerWidgets(ConfigTaskWidget &parent) { + parent.addWidget(m_aircraft->multiThrottleCurve->getCurveWidget()); + parent.addWidget(m_aircraft->multirotorFrameType); + parent.addWidget(m_aircraft->multiMotorChannelBox1); + parent.addWidget(m_aircraft->multiMotorChannelBox2); + parent.addWidget(m_aircraft->multiMotorChannelBox3); + parent.addWidget(m_aircraft->multiMotorChannelBox4); + parent.addWidget(m_aircraft->multiMotorChannelBox5); + parent.addWidget(m_aircraft->multiMotorChannelBox6); + parent.addWidget(m_aircraft->multiMotorChannelBox7); + parent.addWidget(m_aircraft->multiMotorChannelBox8); + parent.addWidget(m_aircraft->mrPitchMixLevel); + parent.addWidget(m_aircraft->mrRollMixLevel); + parent.addWidget(m_aircraft->mrYawMixLevel); + parent.addWidget(m_aircraft->triYawChannelBox); +} + void ConfigMultiRotorWidget::resetActuators(GUIConfigDataUnion *configData) { configData->multi.VTOLMotorN = 0; diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h index 4726cee79..9361c0755 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/configmultirotorwidget.h @@ -64,6 +64,7 @@ private: QGraphicsSvgItem *quad; bool invertMotors; + virtual void registerWidgets(ConfigTaskWidget &parent); virtual void resetActuators(GUIConfigDataUnion *configData); bool setupQuad(bool pLayout); diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 725314591..6a4bb87b8 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -105,21 +105,29 @@ void VehicleConfig::setupUI(QString frameType) Q_UNUSED(frameType); } -QString VehicleConfig::updateConfigObjectsFromWidgets() -{ - return QString(); -} +//void VehicleConfig::refreshWidgetsValues(UAVObject *o = NULL) +//void VehicleConfig::updateObjectsFromWidgets() void VehicleConfig::refreshWidgetsValues(QString frameType) { Q_UNUSED(frameType); } +QString VehicleConfig::updateConfigObjectsFromWidgets() +{ + return QString(); +} + void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) { Q_UNUSED(configData); } + +void VehicleConfig::registerWidgets(ConfigTaskWidget &parent) { + Q_UNUSED(parent); +} + // NEW STYLE: Loop through the widgets looking for all widgets that have "ChannelBox" in their name // The upshot of this is that ALL new ComboBox widgets for selecting the output channel must have "ChannelBox" in their name // FOR WHATEVER REASON, THIS DOES NOT WORK WITH ChannelBox. ChannelBo is sufficiently accurate diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index e9aa55175..ee72b1249 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -102,6 +102,14 @@ typedef union groundGUISettingsStruct ground; } GUIConfigDataUnion; +class ConfigTaskWidget; + +/* + * This class handles vehicle specific configuration UI and associated logic. + * + * This class derives from ConfigTaskWidget and overrides its the default "binding" mechanism. + * It does not use the "dirty" state management directlyand registers its relevant widgets with ConfigTaskWidget to do so. + */ class VehicleConfig: public ConfigTaskWidget { Q_OBJECT @@ -152,6 +160,8 @@ public: VehicleConfig(QWidget *parent = 0); ~VehicleConfig(); + virtual void registerWidgets(ConfigTaskWidget &parent); + virtual void refreshWidgetsValues(QString frameType); virtual QString updateConfigObjectsFromWidgets(); @@ -178,6 +188,10 @@ protected: double getCurveMin(QList *curve); double getCurveMax(QList *curve); +//protected slots: +// virtual void refreshWidgetsValues(UAVObject *o = NULL); +// virtual void updateObjectsFromWidgets(); + private: static UAVObjectManager *getUAVObjectManager(); diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp index 52ef16629..f22d84214 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.cpp @@ -142,6 +142,15 @@ ConfigVehicleTypeWidget::ConfigVehicleTypeWidget(QWidget *parent) : ConfigTaskWi refreshWidgetsValues(); + // register widgets for dirty state management + addWidget(m_aircraft->aircraftType); + + // register FF widgets for dirty state management + addWidget(m_aircraft->feedForwardSlider); + addWidget(m_aircraft->accelTime); + addWidget(m_aircraft->decelTime); + addWidget(m_aircraft->maxAccelSlider); + disableMouseWheelEvents(); } @@ -162,19 +171,18 @@ void ConfigVehicleTypeWidget::switchAirframeType(int index) /** Refreshes the current value of the SystemSettings which holds the aircraft type + Note: The default behavior of ConfigTaskWidget is bypassed. + Therefore no automatic synchronization of UAV Objects to UI is done. */ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) { Q_UNUSED(o); - qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - begin"; - if (!allObjectsUpdated()) { return; } bool dirty = isDirty(); - qDebug() << "ConfigVehicleTypeWidget::refreshWidgetsValues - isDirty:" << dirty; // Get the Airframe type from the system settings: UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -192,7 +200,9 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) setComboCurrentIndex(m_aircraft->aircraftType, m_aircraft->aircraftType->findText(category)); VehicleConfig *vehicleConfig = getVehicleConfigWidget(category); - vehicleConfig->refreshWidgetsValues(frameType); + if (vehicleConfig) { + vehicleConfig->refreshWidgetsValues(frameType); + } updateFeedForwardUI(); @@ -207,25 +217,19 @@ void ConfigVehicleTypeWidget::refreshWidgetsValues(UAVObject *o) We do all the tasks common to all airframes, or family of airframes, and we call additional methods for specific frames, so that we do not have a code that is too heavy. + + Note: The default behavior of ConfigTaskWidget is bypassed. + Therefore no automatic synchronization of UI to UAV Objects is done. */ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() { - UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); - Q_ASSERT(mixer); - - QPointer vconfig = new VehicleConfig(); - - // Update feed forward settings - vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0); - vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value()); - vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); - vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); - - // Sets airframe type default to "Custom" + // Airframe type defaults to Custom QString airframeType = "Custom"; VehicleConfig *vehicleConfig = (VehicleConfig *) m_aircraft->airframesWidget->currentWidget(); - airframeType = vehicleConfig->updateConfigObjectsFromWidgets(); + if (vehicleConfig) { + airframeType = vehicleConfig->updateConfigObjectsFromWidgets(); + } // set the airframe type UAVDataObject *system = dynamic_cast(getObjectManager()->getObject(QString("SystemSettings"))); @@ -236,19 +240,21 @@ void ConfigVehicleTypeWidget::updateObjectsFromWidgets() field->setValue(airframeType); } + // Update feed forward settings + UAVDataObject *mixer = dynamic_cast(getObjectManager()->getObject(QString("MixerSettings"))); + Q_ASSERT(mixer); + + QPointer vconfig = new VehicleConfig(); + + vconfig->setMixerValue(mixer, "FeedForward", m_aircraft->feedForwardSlider->value() / 100.0); + vconfig->setMixerValue(mixer, "AccelTime", m_aircraft->accelTime->value()); + vconfig->setMixerValue(mixer, "DecelTime", m_aircraft->decelTime->value()); + vconfig->setMixerValue(mixer, "MaxAccel", m_aircraft->maxAccelSlider->value()); + + // TODO call refreshWidgetsValues() to reflect actual saved values ? updateFeedForwardUI(); } -/** - Reset the contents of a field - */ -//void ConfigVehicleTypeWidget::resetField(UAVObjectField *field) -//{ -// for (unsigned int i = 0; i < field->getNumElements(); i++) { -// field->setValue(0, i); -// } -//} - QString ConfigVehicleTypeWidget::frameCategory(QString frameType) { QString category; @@ -277,20 +283,24 @@ QString ConfigVehicleTypeWidget::frameCategory(QString frameType) VehicleConfig *ConfigVehicleTypeWidget::getVehicleConfigWidget(QString frameCategory) { VehicleConfig *vehiculeConfig; - if (vehicleIndexMap.contains(frameCategory)) { - int index = vehicleIndexMap.value(frameCategory); - vehiculeConfig = (VehicleConfig *) m_aircraft->airframesWidget->widget(index); - } else { + if (!vehicleIndexMap.contains(frameCategory)) { + // create config widget vehiculeConfig = createVehicleConfigWidget(frameCategory); + // bind config widget "field" to this ConfigTaskWodget + // this is necessary to get "dirty" state management + vehiculeConfig->registerWidgets(*this); + // add config widget to UI int index = m_aircraft->airframesWidget->insertWidget(m_aircraft->airframesWidget->count(), vehiculeConfig); vehicleIndexMap[frameCategory] = index; } + int index = vehicleIndexMap.value(frameCategory); + vehiculeConfig = (VehicleConfig *) m_aircraft->airframesWidget->widget(index); return vehiculeConfig; } VehicleConfig *ConfigVehicleTypeWidget::createVehicleConfigWidget(QString frameCategory) { - qDebug() << "creating" << frameCategory; + qDebug() << "ConfigVehicleTypeWidget::createVehicleConfigWidget - creating" << frameCategory; if (frameCategory == "Fixed Wing") { return new ConfigFixedWingWidget(); } else if (frameCategory == "Multirotor") { @@ -318,7 +328,7 @@ void ConfigVehicleTypeWidget::enableFFTest() && m_aircraft->ffTestBox3->isChecked()) { if (!ffTuningInProgress) { // Initiate tuning: - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject( + UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject( QString("ManualControlCommand"))); UAVObject::Metadata mdata = obj->getMetadata(); accInitialData = mdata; @@ -356,7 +366,7 @@ void ConfigVehicleTypeWidget::enableFFTest() // Disarm! if (ffTuningInProgress) { ffTuningInProgress = false; - UAVDataObject* obj = dynamic_cast(getObjectManager()->getObject( + UAVDataObject *obj = dynamic_cast(getObjectManager()->getObject( QString("ManualControlCommand"))); UAVObject::Metadata mdata = obj->getMetadata(); mdata = accInitialData; // Restore metadata diff --git a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h index c19abac4e..6184fd6fb 100644 --- a/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h +++ b/ground/openpilotgcs/src/plugins/config/configvehicletypewidget.h @@ -38,6 +38,21 @@ #include #include +/* + * This class derives from ConfigTaskWidget and overrides its default "binding" mechanism. + * This widget bypasses automatic synchronization of UAVObjects and UI by providing its own implementations of + * virtual void refreshWidgetsValues(UAVObject *obj = NULL); + * virtual void updateObjectsFromWidgets(); + * + * It does use the "dirty" state management and registers its relevant widgets with ConfigTaskWidget to do so. + * + * This class also manages child ConfigTaskWidget : see VehicleConfig class and its derived classes. + * Note: for "dirty" state management it is important to register the fields of child widgets with the parent + * ConfigVehicleTypeWidget class. + * + * TODO consider to call "super" to benefit from default logic... + * TODO improve handling of relationship with VehicleConfig derived classes (i.e. ConfigTaskWidget within ConfigTaskWidget) + */ class ConfigVehicleTypeWidget: public ConfigTaskWidget { Q_OBJECT @@ -49,7 +64,7 @@ public: ConfigVehicleTypeWidget(QWidget *parent = 0); ~ConfigVehicleTypeWidget(); -public slots: +protected slots: virtual void refreshWidgetsValues(UAVObject *o = NULL); virtual void updateObjectsFromWidgets(); From 6ff2b1873de32de8ab56f7fff71201c8f2a7767d Mon Sep 17 00:00:00 2001 From: Philippe Renon Date: Thu, 25 Apr 2013 00:07:06 +0200 Subject: [PATCH 25/32] OP-907 fixed regression in vehicle config : "dirty" state management was broken (continued). --- .../config/cfg_vehicletypes/vehicleconfig.cpp | 15 +++++++++++---- .../config/cfg_vehicletypes/vehicleconfig.h | 6 +++--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp index 6a4bb87b8..e70ee0835 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.cpp @@ -105,9 +105,6 @@ void VehicleConfig::setupUI(QString frameType) Q_UNUSED(frameType); } -//void VehicleConfig::refreshWidgetsValues(UAVObject *o = NULL) -//void VehicleConfig::updateObjectsFromWidgets() - void VehicleConfig::refreshWidgetsValues(QString frameType) { Q_UNUSED(frameType); @@ -115,7 +112,17 @@ void VehicleConfig::refreshWidgetsValues(QString frameType) QString VehicleConfig::updateConfigObjectsFromWidgets() { - return QString(); + return NULL; +} + +void VehicleConfig::refreshWidgetsValues(UAVObject *o) +{ + Q_UNUSED(o); +} + +void VehicleConfig::updateObjectsFromWidgets() +{ + } void VehicleConfig::resetActuators(GUIConfigDataUnion *configData) diff --git a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h index ee72b1249..f116d05b9 100644 --- a/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h +++ b/ground/openpilotgcs/src/plugins/config/cfg_vehicletypes/vehicleconfig.h @@ -188,9 +188,9 @@ protected: double getCurveMin(QList *curve); double getCurveMax(QList *curve); -//protected slots: -// virtual void refreshWidgetsValues(UAVObject *o = NULL); -// virtual void updateObjectsFromWidgets(); +protected slots: + virtual void refreshWidgetsValues(UAVObject *o = NULL); + virtual void updateObjectsFromWidgets(); private: static UAVObjectManager *getUAVObjectManager(); From 45f456580f9322fc4d83aa28a8c24f2407fcb791 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Fri, 26 Apr 2013 17:59:52 +0300 Subject: [PATCH 26/32] Fix pios debug pin functions and defines (thanks to Mathieu for the patch) --- flight/modules/Osd/OsdEtStd/OsdEtStd.c | 4 ++-- flight/pios/pios.h | 1 + flight/pios/stm32f10x/pios_debug.c | 18 +++++++++--------- flight/pios/stm32f4xx/pios_debug.c | 18 +++++++++--------- .../coptercontrol/firmware/inc/pios_config.h | 1 + .../boards/coptercontrol/firmware/pios_board.c | 6 +++--- .../oplinkmini/firmware/inc/pios_config.h | 1 + .../boards/osd/firmware/inc/pios_config.h | 1 + .../revolution/firmware/inc/pios_config.h | 1 + .../boards/revolution/firmware/pios_board.c | 4 ++-- .../revoproto/firmware/inc/pios_config.h | 1 + .../boards/revoproto/firmware/pios_board.c | 4 ++-- 12 files changed, 33 insertions(+), 27 deletions(-) diff --git a/flight/modules/Osd/OsdEtStd/OsdEtStd.c b/flight/modules/Osd/OsdEtStd/OsdEtStd.c index edd148942..a1e4a5d69 100644 --- a/flight/modules/Osd/OsdEtStd/OsdEtStd.c +++ b/flight/modules/Osd/OsdEtStd/OsdEtStd.c @@ -41,7 +41,7 @@ // #define DEBUG_PORT PIOS_COM_GPS //#define ENABLE_DEBUG_MSG -//#define USE_DEBUG_PINS +//#define PIOS_ENABLE_DEBUG_PINS //#define DUMP_CONFIG // Enable this do read and dump the OSD config // @@ -78,7 +78,7 @@ #define OSDMSG_GPS_STAT_FIX 0x2B #define OSDMSG_GPS_STAT_HB_FLAG 0x10 -#ifdef USE_DEBUG_PINS +#ifdef PIOS_ENABLE_DEBUG_PINS #define DEBUG_PIN_RUNNING 0 #define DEBUG_PIN_I2C 1 #define DebugPinHigh(x) PIOS_DEBUG_PinHigh(x) diff --git a/flight/pios/pios.h b/flight/pios/pios.h index 5e581b345..f1e7e7f4a 100644 --- a/flight/pios/pios.h +++ b/flight/pios/pios.h @@ -65,6 +65,7 @@ /* PIOS debug interface */ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define DEBUG_LEVEL 0 */ +/* #define PIOS_ENABLE_DEBUG_PINS */ #include /* PIOS common functions */ diff --git a/flight/pios/stm32f10x/pios_debug.c b/flight/pios/stm32f10x/pios_debug.c index f7c9d6cf3..e7e7e148e 100644 --- a/flight/pios/stm32f10x/pios_debug.c +++ b/flight/pios/stm32f10x/pios_debug.c @@ -7,7 +7,7 @@ * @{ * * @file pios_debug.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. * @brief Debugging Functions * @see The GNU Public License (GPL) Version 3 * @@ -60,13 +60,13 @@ void PIOS_DEBUG_Init(const struct pios_tim_channel * channels, uint8_t num_chann GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Pin = chan->init->GPIO_Pin; + GPIO_InitStructure.GPIO_Pin = chan->pin.init.GPIO_Pin; /* Initialize the GPIO */ - GPIO_Init(chan->init->port, &GPIO_InitStructure); + GPIO_Init(chan->pin.gpio, &GPIO_InitStructure); /* Set the pin low */ - GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); + GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET); } #endif // PIOS_ENABLE_DEBUG_PINS } @@ -84,7 +84,7 @@ void PIOS_DEBUG_PinHigh(uint8_t pin) const struct pios_tim_channel * chan = &debug_channels[pin]; - GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_Set); + GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_SET); #endif // PIOS_ENABLE_DEBUG_PINS } @@ -102,7 +102,7 @@ void PIOS_DEBUG_PinLow(uint8_t pin) const struct pios_tim_channel * chan = &debug_channels[pin]; - GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); + GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET); #endif // PIOS_ENABLE_DEBUG_PINS } @@ -124,8 +124,8 @@ void PIOS_DEBUG_PinValue8Bit(uint8_t value) * This is sketchy since it assumes a particular ordering * and bitwise layout of the channels provided to the debug code. */ - debug_channels[0].init.port->BSRR = bsrr_l; - debug_channels[4].init.port->BSRR = bsrr_h; + debug_channels[0].pin.gpio->BSRR = bsrr_l; + debug_channels[4].pin.gpio->BSRR = bsrr_h; PIOS_IRQ_Enable(); #endif // PIOS_ENABLE_DEBUG_PINS @@ -143,7 +143,7 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value) * and bitwise layout of the channels provided to the debug code. */ uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6); - debug_channels[0].init.port->BSRR = bsrr_l; + debug_channels[0].pin.gpio->BSRR = bsrr_l; #endif // PIOS_ENABLE_DEBUG_PINS } diff --git a/flight/pios/stm32f4xx/pios_debug.c b/flight/pios/stm32f4xx/pios_debug.c index 51efbc188..e7e7e148e 100644 --- a/flight/pios/stm32f4xx/pios_debug.c +++ b/flight/pios/stm32f4xx/pios_debug.c @@ -7,7 +7,7 @@ * @{ * * @file pios_debug.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2013. * @brief Debugging Functions * @see The GNU Public License (GPL) Version 3 * @@ -60,13 +60,13 @@ void PIOS_DEBUG_Init(const struct pios_tim_channel * channels, uint8_t num_chann GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; - GPIO_InitStructure.GPIO_Pin = chan->init->GPIO_Pin; + GPIO_InitStructure.GPIO_Pin = chan->pin.init.GPIO_Pin; /* Initialize the GPIO */ - GPIO_Init(chan->init->port, &GPIO_InitStructure); + GPIO_Init(chan->pin.gpio, &GPIO_InitStructure); /* Set the pin low */ - GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); + GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET); } #endif // PIOS_ENABLE_DEBUG_PINS } @@ -84,7 +84,7 @@ void PIOS_DEBUG_PinHigh(uint8_t pin) const struct pios_tim_channel * chan = &debug_channels[pin]; - GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_Set); + GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_SET); #endif // PIOS_ENABLE_DEBUG_PINS } @@ -102,7 +102,7 @@ void PIOS_DEBUG_PinLow(uint8_t pin) const struct pios_tim_channel * chan = &debug_channels[pin]; - GPIO_WriteBit(chan->init->port, chan->init->GPIO_Pin, Bit_RESET); + GPIO_WriteBit(chan->pin.gpio, chan->pin.init.GPIO_Pin, Bit_RESET); #endif // PIOS_ENABLE_DEBUG_PINS } @@ -124,8 +124,8 @@ void PIOS_DEBUG_PinValue8Bit(uint8_t value) * This is sketchy since it assumes a particular ordering * and bitwise layout of the channels provided to the debug code. */ - debug_channels[0].init.port->BSRR = bsrr_l; - debug_channels[4].init.port->BSRR = bsrr_h; + debug_channels[0].pin.gpio->BSRR = bsrr_l; + debug_channels[4].pin.gpio->BSRR = bsrr_h; PIOS_IRQ_Enable(); #endif // PIOS_ENABLE_DEBUG_PINS @@ -143,7 +143,7 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value) * and bitwise layout of the channels provided to the debug code. */ uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6); - debug_channels[0].init.port->BSRR = bsrr_l; + debug_channels[0].pin.gpio->BSRR = bsrr_l; #endif // PIOS_ENABLE_DEBUG_PINS } diff --git a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h index ea4f2ae1d..207920f98 100644 --- a/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h +++ b/flight/targets/boards/coptercontrol/firmware/inc/pios_config.h @@ -38,6 +38,7 @@ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define DEBUG_LEVEL 0 */ +/* #define PIOS_ENABLE_DEBUG_PINS */ /* PIOS FreeRTOS support */ #define PIOS_INCLUDE_FREERTOS diff --git a/flight/targets/boards/coptercontrol/firmware/pios_board.c b/flight/targets/boards/coptercontrol/firmware/pios_board.c index d620acfee..12b38640d 100644 --- a/flight/targets/boards/coptercontrol/firmware/pios_board.c +++ b/flight/targets/boards/coptercontrol/firmware/pios_board.c @@ -773,7 +773,7 @@ void PIOS_Board_Init(void) { /* Remap AFIO pin for PB4 (Servo 5 Out)*/ GPIO_PinRemapConfig( GPIO_Remap_SWJ_NoJTRST, ENABLE); -#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS +#ifndef PIOS_ENABLE_DEBUG_PINS switch (hwsettings_rcvrport) { case HWSETTINGS_CC_RCVRPORT_DISABLED: case HWSETTINGS_CC_RCVRPORT_PWM: @@ -787,8 +787,8 @@ void PIOS_Board_Init(void) { break; } #else - PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels)); -#endif /* PIOS_DEBUG_ENABLE_DEBUG_PINS */ + PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins)); +#endif /* PIOS_ENABLE_DEBUG_PINS */ switch(bdinfo->board_rev) { case BOARD_REVISION_CC: diff --git a/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h b/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h index 1da5edbe0..6d149e4f1 100644 --- a/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h +++ b/flight/targets/boards/oplinkmini/firmware/inc/pios_config.h @@ -38,6 +38,7 @@ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define DEBUG_LEVEL 0 */ +/* #define PIOS_ENABLE_DEBUG_PINS */ /* PIOS FreeRTOS support */ #define PIOS_INCLUDE_FREERTOS diff --git a/flight/targets/boards/osd/firmware/inc/pios_config.h b/flight/targets/boards/osd/firmware/inc/pios_config.h index c08dda8b5..3772c5939 100644 --- a/flight/targets/boards/osd/firmware/inc/pios_config.h +++ b/flight/targets/boards/osd/firmware/inc/pios_config.h @@ -38,6 +38,7 @@ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define DEBUG_LEVEL 0 */ +/* #define PIOS_ENABLE_DEBUG_PINS */ /* PIOS FreeRTOS support */ #define PIOS_INCLUDE_FREERTOS diff --git a/flight/targets/boards/revolution/firmware/inc/pios_config.h b/flight/targets/boards/revolution/firmware/inc/pios_config.h index 1df7180b3..1025db7e3 100644 --- a/flight/targets/boards/revolution/firmware/inc/pios_config.h +++ b/flight/targets/boards/revolution/firmware/inc/pios_config.h @@ -38,6 +38,7 @@ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define DEBUG_LEVEL 0 */ +/* #define PIOS_ENABLE_DEBUG_PINS */ /* PIOS FreeRTOS support */ #define PIOS_INCLUDE_FREERTOS diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 5263da346..559ab4a81 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -777,11 +777,11 @@ void PIOS_Board_Init(void) { pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id; #endif /* PIOS_INCLUDE_GCSRCVR */ -#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS +#ifndef PIOS_ENABLE_DEBUG_PINS // pios_servo_cfg points to the correct configuration based on input port settings PIOS_Servo_Init(pios_servo_cfg); #else - PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels)); + PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins)); #endif if (PIOS_I2C_Init(&pios_i2c_mag_pressure_adapter_id, &pios_i2c_mag_pressure_adapter_cfg)) { diff --git a/flight/targets/boards/revoproto/firmware/inc/pios_config.h b/flight/targets/boards/revoproto/firmware/inc/pios_config.h index c148d9142..2e428bd01 100644 --- a/flight/targets/boards/revoproto/firmware/inc/pios_config.h +++ b/flight/targets/boards/revoproto/firmware/inc/pios_config.h @@ -38,6 +38,7 @@ /* #define PIOS_INCLUDE_DEBUG_CONSOLE */ /* #define DEBUG_LEVEL 0 */ +/* #define PIOS_ENABLE_DEBUG_PINS */ /* PIOS FreeRTOS support */ #define PIOS_INCLUDE_FREERTOS diff --git a/flight/targets/boards/revoproto/firmware/pios_board.c b/flight/targets/boards/revoproto/firmware/pios_board.c index d4b390b72..8a0679a5b 100644 --- a/flight/targets/boards/revoproto/firmware/pios_board.c +++ b/flight/targets/boards/revoproto/firmware/pios_board.c @@ -826,7 +826,7 @@ void PIOS_Board_Init(void) { pios_rcvr_group_map[MANUALCONTROLSETTINGS_CHANNELGROUPS_GCS] = pios_gcsrcvr_rcvr_id; #endif /* PIOS_INCLUDE_GCSRCVR */ -#ifndef PIOS_DEBUG_ENABLE_DEBUG_PINS +#ifndef PIOS_ENABLE_DEBUG_PINS switch (hwsettings_rcvrport) { case HWSETTINGS_RV_RCVRPORT_DISABLED: case HWSETTINGS_RV_RCVRPORT_PWM: @@ -842,7 +842,7 @@ void PIOS_Board_Init(void) { break; } #else - PIOS_DEBUG_Init(&pios_tim_servo_all_channels, NELEMENTS(pios_tim_servo_all_channels)); + PIOS_DEBUG_Init(pios_tim_servoport_all_pins, NELEMENTS(pios_tim_servoport_all_pins)); #endif if (PIOS_I2C_Init(&pios_i2c_mag_adapter_id, &pios_i2c_mag_adapter_cfg)) { From 47619c9937bf0f0c00dbd45e670d5ccc1c8f3e0c Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Fri, 26 Apr 2013 21:04:10 +0300 Subject: [PATCH 27/32] Make F4 pios debug pins compilable, still should be revised for real use --- flight/pios/stm32f4xx/pios_debug.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/flight/pios/stm32f4xx/pios_debug.c b/flight/pios/stm32f4xx/pios_debug.c index e7e7e148e..8fe050b07 100644 --- a/flight/pios/stm32f4xx/pios_debug.c +++ b/flight/pios/stm32f4xx/pios_debug.c @@ -58,7 +58,9 @@ void PIOS_DEBUG_Init(const struct pios_tim_channel * channels, uint8_t num_chann // Initialise pins as standard output pins GPIO_InitTypeDef GPIO_InitStructure; GPIO_StructInit(&GPIO_InitStructure); - GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; + GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; + GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; + GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Pin = chan->pin.init.GPIO_Pin; @@ -115,6 +117,9 @@ void PIOS_DEBUG_PinValue8Bit(uint8_t value) return; } +#pragma message("This code is not portable and should be revised") + PIOS_Assert(0); + uint32_t bsrr_l = ( ((~value)&0x0F)<<(16+6) ) | ((value & 0x0F)<<6); uint32_t bsrr_h = ( ((~value)&0xF0)<<(16+6-4) ) | ((value & 0xF0)<<(6-4)); @@ -124,8 +129,8 @@ void PIOS_DEBUG_PinValue8Bit(uint8_t value) * This is sketchy since it assumes a particular ordering * and bitwise layout of the channels provided to the debug code. */ - debug_channels[0].pin.gpio->BSRR = bsrr_l; - debug_channels[4].pin.gpio->BSRR = bsrr_h; + //debug_channels[0].pin.gpio->BSRR = bsrr_l; + //debug_channels[4].pin.gpio->BSRR = bsrr_h; PIOS_IRQ_Enable(); #endif // PIOS_ENABLE_DEBUG_PINS @@ -138,12 +143,15 @@ void PIOS_DEBUG_PinValue4BitL(uint8_t value) return; } +#pragma message("This code is not portable and should be revised") + PIOS_Assert(0); + /* * This is sketchy since it assumes a particular ordering * and bitwise layout of the channels provided to the debug code. */ uint32_t bsrr_l = ((~(value & 0x0F)<<(16+6))) | ((value & 0x0F)<<6); - debug_channels[0].pin.gpio->BSRR = bsrr_l; + //debug_channels[0].pin.gpio->BSRR = bsrr_l; #endif // PIOS_ENABLE_DEBUG_PINS } From 0394a3511c616731c203a4d4ed1f2fd47bfab324 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Tue, 30 Apr 2013 02:02:36 +0200 Subject: [PATCH 28/32] Rename template files to *.template to screen from uncrustify processing --- .../OpenPilotOSX.xcodeproj/project.pbxproj | 8 +- ...ecttemplate.pyt => uavobject.pyt.template} | 28 ++---- .../targets/boards/simposix/firmware/Makefile | 2 +- flight/targets/common/entire_flash/Makefile | 2 +- ...filetemplate.inc => Makefile.inc.template} | 0 ...vobjecttemplate.h => uavobject.h.template} | 57 ++++------- ...ittemplate.h => uavobjectsinit.h.template} | 0 ...vobjecttemplate.c => uavobject.c.template} | 77 +++++++-------- ...ittemplate.c => uavobjectsinit.c.template} | 2 +- ground/.gitattributes | 4 + .../openpilotgcs/src/app/gcsversioninfo.pri | 2 +- ...ttemplate.java => uavobject.java.template} | 2 +- ...late.java => uavobjectsinit.java.template} | 2 +- ...ecttemplate.cpp => uavobject.cpp.template} | 35 ++++--- ...vobjecttemplate.h => uavobject.h.template} | 0 ...vobjecttemplate.m => uavobject.m.template} | 0 ...bjecttemplate.py => uavobject.py.template} | 0 ...mplate.cpp => uavobjectsinit.cpp.template} | 4 +- ...mmon-template => Makefile.common.template} | 0 ...late.c => packet-op-uavobjects.c.template} | 0 .../flight/uavobjectgeneratorflight.cpp | 98 +++++++++---------- .../flight/uavobjectgeneratorflight.h | 2 + .../generators/gcs/uavobjectgeneratorgcs.cpp | 6 +- .../java/uavobjectgeneratorjava.cpp | 4 +- .../matlab/uavobjectgeneratormatlab.cpp | 4 +- .../matlab/uavobjectgeneratormatlab.h | 2 + .../python/uavobjectgeneratorpython.cpp | 21 ++-- .../wireshark/uavobjectgeneratorwireshark.cpp | 4 +- make/.gitattributes | 4 +- make/firmware-defs.mk | 10 +- ...nfotemplate.c => firmware_info.c.template} | 0 ...template.h => gcs_version_info.h.template} | 0 32 files changed, 177 insertions(+), 203 deletions(-) rename flight/modules/FlightPlan/lib/{uavobjecttemplate.pyt => uavobject.pyt.template} (86%) rename flight/uavobjects/{Makefiletemplate.inc => Makefile.inc.template} (100%) rename flight/uavobjects/inc/{uavobjecttemplate.h => uavobject.h.template} (85%) rename flight/uavobjects/inc/{uavobjectsinittemplate.h => uavobjectsinit.h.template} (100%) rename flight/uavobjects/{uavobjecttemplate.c => uavobject.c.template} (58%) rename flight/uavobjects/{uavobjectsinittemplate.c => uavobjectsinit.c.template} (98%) rename ground/openpilotgcs/src/libs/juavobjects/templates/{uavobjecttemplate.java => uavobject.java.template} (99%) rename ground/openpilotgcs/src/libs/juavobjects/templates/{uavobjectsinittemplate.java => uavobjectsinit.java.template} (96%) rename ground/openpilotgcs/src/plugins/uavobjects/{uavobjecttemplate.cpp => uavobject.cpp.template} (79%) rename ground/openpilotgcs/src/plugins/uavobjects/{uavobjecttemplate.h => uavobject.h.template} (100%) rename ground/openpilotgcs/src/plugins/uavobjects/{uavobjecttemplate.m => uavobject.m.template} (100%) rename ground/openpilotgcs/src/plugins/uavobjects/{uavobjecttemplate.py => uavobject.py.template} (100%) rename ground/openpilotgcs/src/plugins/uavobjects/{uavobjectsinittemplate.cpp => uavobjectsinit.cpp.template} (96%) rename ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/{Makefile.common-template => Makefile.common.template} (100%) rename ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/{packet-op-uavobjects-template.c => packet-op-uavobjects.c.template} (100%) rename make/templates/{firmwareinfotemplate.c => firmware_info.c.template} (100%) rename make/templates/{gcs_version_info_template.h => gcs_version_info.h.template} (100%) diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index 273032d6a..14b7c9ae2 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -17,8 +17,8 @@ 65904F2614632C1700FD9482 /* board-info.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "board-info.mk"; sourceTree = ""; }; 65904F2714632C1700FD9482 /* board-info.mk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = "board-info.mk"; sourceTree = ""; }; 65904F2814632C1700FD9482 /* version-info.py */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.python; path = "version-info.py"; sourceTree = ""; }; - 65904F2914632C1700FD9482 /* firmwareinfotemplate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = firmwareinfotemplate.c; sourceTree = ""; }; - 65904F2A14632C1700FD9482 /* gcsversioninfotemplate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gcsversioninfotemplate.h; sourceTree = ""; }; + 65904F2914632C1700FD9482 /* firmware_info.c.template */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = firmware_info.c.template; sourceTree = ""; }; + 65904F2A14632C1700FD9482 /* gcs_version_info.h.template */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = gcs_version_info.h.template; sourceTree = ""; }; 65904F2D14632C1700FD9482 /* README.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.txt; sourceTree = ""; }; 65904F2E14632C1700FD9482 /* shell_script.reg */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = shell_script.reg; sourceTree = ""; }; 65904F2F14632C1700FD9482 /* install */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = install; sourceTree = ""; }; @@ -79,8 +79,8 @@ 65904F1A14632C1700FD9482 /* templates */ = { isa = PBXGroup; children = ( - 65904F2914632C1700FD9482 /* firmwareinfotemplate.c */, - 65904F2A14632C1700FD9482 /* gcsversioninfotemplate.h */, + 65904F2914632C1700FD9482 /* firmware_info.c.template */, + 65904F2A14632C1700FD9482 /* gcs_version_info.h.template */, ); path = templates; sourceTree = ""; diff --git a/flight/modules/FlightPlan/lib/uavobjecttemplate.pyt b/flight/modules/FlightPlan/lib/uavobject.pyt.template similarity index 86% rename from flight/modules/FlightPlan/lib/uavobjecttemplate.pyt rename to flight/modules/FlightPlan/lib/uavobject.pyt.template index d86dddc09..ff6bab315 100644 --- a/flight/modules/FlightPlan/lib/uavobjecttemplate.pyt +++ b/flight/modules/FlightPlan/lib/uavobject.pyt.template @@ -30,31 +30,21 @@ # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # - from uavobject import * $(DATAFIELDS) # Object $(NAME) definition class $(NAME)(UAVObject): - # Object constants - OBJID = $(UOBJID) + # Object constants + OBJID = $(UOBJID) - # Constructor - def __init__(self): - UAVObject.__init__(self, $(NAME).OBJID) + # Constructor + def __init__(self): + UAVObject.__init__(self, $(NAME).OBJID) - # Create object fields + # Create object fields $(DATAFIELDINIT) - # Read field data - self.read() - self.metadata.read() - - - - - - - - - + # Read field data + self.read() + self.metadata.read() diff --git a/flight/targets/boards/simposix/firmware/Makefile b/flight/targets/boards/simposix/firmware/Makefile index 9086033ef..ed5e958b7 100644 --- a/flight/targets/boards/simposix/firmware/Makefile +++ b/flight/targets/boards/simposix/firmware/Makefile @@ -257,7 +257,7 @@ ALLSRC = $(ASRCARM) $(ASRC) $(SRCARM) $(SRC) $(CPPSRCARM) $(CPPSRC) ALLSRCBASE = $(notdir $(basename $(ALLSRC))) # Define all object files. -ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE) uavobjectsinit.o.firmwareinfo )) +ALLOBJ = $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE) uavobjectsinit.o.firmware_info )) # Define all listing files (used for make clean). LSTFILES = $(addprefix $(OUTDIR)/, $(addsuffix .lst, $(ALLSRCBASE))) diff --git a/flight/targets/common/entire_flash/Makefile b/flight/targets/common/entire_flash/Makefile index 3326b6685..8a1826b2c 100644 --- a/flight/targets/common/entire_flash/Makefile +++ b/flight/targets/common/entire_flash/Makefile @@ -38,7 +38,7 @@ bin: $(OUTDIR)/$(TARGET).bin BL_BIN = $(BUILD_DIR)/bl_$(BOARD_NAME)/bl_$(BOARD_NAME).bin FW_BIN = $(BUILD_DIR)/fw_$(BOARD_NAME)/fw_$(BOARD_NAME).bin -FWINFO_BIN = $(FW_BIN).firmwareinfo.bin +FWINFO_BIN = $(FW_BIN).firmware_info.bin $(OUTDIR)/$(TARGET).bin: $(BL_BIN) $(FW_BIN) $(V0) @$(ECHO) $(MSG_FLASH_IMG) $@ diff --git a/flight/uavobjects/Makefiletemplate.inc b/flight/uavobjects/Makefile.inc.template similarity index 100% rename from flight/uavobjects/Makefiletemplate.inc rename to flight/uavobjects/Makefile.inc.template diff --git a/flight/uavobjects/inc/uavobjecttemplate.h b/flight/uavobjects/inc/uavobject.h.template similarity index 85% rename from flight/uavobjects/inc/uavobjecttemplate.h rename to flight/uavobjects/inc/uavobject.h.template index 5734f5960..971c2d567 100644 --- a/flight/uavobjects/inc/uavobjecttemplate.h +++ b/flight/uavobjects/inc/uavobject.h.template @@ -6,11 +6,11 @@ * @brief $(DESCRIPTION) * * Autogenerated files and functions for $(NAME) Object - + * * @{ * * @file $(NAMELC).h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. * @brief Implementation of the $(NAME) object. This file has been * automatically generated by the UAVObjectGenerator. * @@ -40,68 +40,51 @@ #ifndef $(NAMEUC)_H #define $(NAMEUC)_H -// Object constants +/* Object constants */ #define $(NAMEUC)_OBJID $(OBJIDHEX) #define $(NAMEUC)_ISSINGLEINST $(ISSINGLEINST) #define $(NAMEUC)_ISSETTINGS $(ISSETTINGS) #define $(NAMEUC)_NUMBYTES sizeof($(NAME)Data) -// Generic interface functions +/* Generic interface functions */ int32_t $(NAME)Initialize(); UAVObjHandle $(NAME)Handle(); void $(NAME)SetDefaults(UAVObjHandle obj, uint16_t instId); -// Packed Object data (unaligned). -// Should only be used where 4 byte alignment can be guaranteed -// (eg a single instance on the heap) -typedef struct { -$(DATAFIELDS) -} __attribute__((packed)) $(NAME)DataPacked; - -// Packed Object data. -// Alignment is forced to 4 bytes so as to avoid the potential for CPU usage faults -// on Cortex M4F during load/store of float UAVO fields -typedef $(NAME)DataPacked __attribute__((aligned(4))) $(NAME)Data; - - -// Typesafe Object access functions -/** - * @function $(NAME)Get(dataOut) - * @brief Populate a $(NAME)Data object - * @param[out] dataOut +/* + * Packed Object data (unaligned). + * Should only be used where 4 byte alignment can be guaranteed + * (eg a single instance on the heap) */ +typedef struct { +$(DATAFIELDS)} __attribute__((packed)) $(NAME)DataPacked; + +/* + * Packed Object data. + * Alignment is forced to 4 bytes so as to avoid the potential for CPU usage faults + * on Cortex M4F during load/store of float UAVO fields + */ +typedef $(NAME)DataPacked __attribute__((aligned(4))) $(NAME)Data; + +/* Typesafe Object access functions */ static inline int32_t $(NAME)Get($(NAME)Data *dataOut) { return UAVObjGetData($(NAME)Handle(), dataOut); } - static inline int32_t $(NAME)Set(const $(NAME)Data *dataIn) { return UAVObjSetData($(NAME)Handle(), dataIn); } - static inline int32_t $(NAME)InstGet(uint16_t instId, $(NAME)Data *dataOut) { return UAVObjGetInstanceData($(NAME)Handle(), instId, dataOut); } - static inline int32_t $(NAME)InstSet(uint16_t instId, const $(NAME)Data *dataIn) { return UAVObjSetInstanceData($(NAME)Handle(), instId, dataIn); } - static inline int32_t $(NAME)ConnectQueue(xQueueHandle queue) { return UAVObjConnectQueue($(NAME)Handle(), queue, EV_MASK_ALL_UPDATES); } - static inline int32_t $(NAME)ConnectCallback(UAVObjEventCallback cb) { return UAVObjConnectCallback($(NAME)Handle(), cb, EV_MASK_ALL_UPDATES); } - static inline uint16_t $(NAME)CreateInstance() { return UAVObjCreateInstance($(NAME)Handle(), &$(NAME)SetDefaults); } - static inline void $(NAME)RequestUpdate() { UAVObjRequestUpdate($(NAME)Handle()); } - static inline void $(NAME)RequestInstUpdate(uint16_t instId) { UAVObjRequestInstanceUpdate($(NAME)Handle(), instId); } - static inline void $(NAME)Updated() { UAVObjUpdated($(NAME)Handle()); } - static inline void $(NAME)InstUpdated(uint16_t instId) { UAVObjInstanceUpdated($(NAME)Handle(), instId); } - static inline int32_t $(NAME)GetMetadata(UAVObjMetadata *dataOut) { return UAVObjGetMetadata($(NAME)Handle(), dataOut); } - static inline int32_t $(NAME)SetMetadata(const UAVObjMetadata *dataIn) { return UAVObjSetMetadata($(NAME)Handle(), dataIn); } - static inline int8_t $(NAME)ReadOnly() { return UAVObjReadOnly($(NAME)Handle()); } -// Field information $(DATAFIELDINFO) -// set/Get functions +/* Set/Get functions */ $(SETGETFIELDSEXTERN) #endif // $(NAMEUC)_H diff --git a/flight/uavobjects/inc/uavobjectsinittemplate.h b/flight/uavobjects/inc/uavobjectsinit.h.template similarity index 100% rename from flight/uavobjects/inc/uavobjectsinittemplate.h rename to flight/uavobjects/inc/uavobjectsinit.h.template diff --git a/flight/uavobjects/uavobjecttemplate.c b/flight/uavobjects/uavobject.c.template similarity index 58% rename from flight/uavobjects/uavobjecttemplate.c rename to flight/uavobjects/uavobject.c.template index 304bfa85a..f7e37723f 100644 --- a/flight/uavobjects/uavobjecttemplate.c +++ b/flight/uavobjects/uavobject.c.template @@ -9,7 +9,7 @@ * @{ * * @file $(NAMELC).c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010-2013. * @brief Implementation of the $(NAME) object. This file has been * automatically generated by the UAVObjectGenerator. * @@ -36,7 +36,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "openpilot.h" +#include #include "$(NAMELC).h" // Private variables @@ -53,28 +53,22 @@ static UAVObjHandle handle __attribute__((section("_uavo_handles"))); */ int32_t $(NAME)Initialize(void) { - // Compile time assertion that the $(NAME)DataPacked and $(NAME)Data structs - // have the same size (though instances of $(NAME)Data - // should be placed in memory by the linker/compiler on a 4 byte alignment). - PIOS_STATIC_ASSERT(sizeof($(NAME)DataPacked) == sizeof($(NAME)Data)); + // Compile time assertion that the $(NAME)DataPacked and $(NAME)Data structs + // have the same size (though instances of $(NAME)Data + // should be placed in memory by the linker/compiler on a 4 byte alignment). + PIOS_STATIC_ASSERT(sizeof($(NAME)DataPacked) == sizeof($(NAME)Data)); - // Don't set the handle to null if already registered - if(UAVObjGetByID($(NAMEUC)_OBJID) != NULL) - return -2; - - // Register object with the object manager - handle = UAVObjRegister($(NAMEUC)_OBJID, - $(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_NUMBYTES, &$(NAME)SetDefaults); + // Don't set the handle to null if already registered + if (UAVObjGetByID($(NAMEUC)_OBJID)) { + return -2; + } - // Done - if (handle != 0) - { - return 0; - } - else - { - return -1; - } + // Register object with the object manager + handle = UAVObjRegister($(NAMEUC)_OBJID, + $(NAMEUC)_ISSINGLEINST, $(NAMEUC)_ISSETTINGS, $(NAMEUC)_NUMBYTES, &$(NAME)SetDefaults); + + // Done + return handle ? 0 : -1; } /** @@ -84,27 +78,27 @@ int32_t $(NAME)Initialize(void) */ void $(NAME)SetDefaults(UAVObjHandle obj, uint16_t instId) { - $(NAME)Data data; - UAVObjMetadata metadata; + $(NAME)Data data; + UAVObjMetadata metadata; - // Initialize object fields to their default values - UAVObjGetInstanceData(obj, instId, &data); - memset(&data, 0, sizeof($(NAME)Data)); + // Initialize object fields to their default values + UAVObjGetInstanceData(obj, instId, &data); + memset(&data, 0, sizeof($(NAME)Data)); $(INITFIELDS) - UAVObjSetInstanceData(obj, instId, &data); + UAVObjSetInstanceData(obj, instId, &data); - // Initialize object metadata to their default values - metadata.flags = - $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT | - $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT | - $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | - $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | - $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; - metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); - metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); - metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); - UAVObjSetMetadata(obj, &metadata); + // Initialize object metadata to their default values + metadata.flags = + $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT | + $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT | + $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | + $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | + $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | + $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; + metadata.telemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); + metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); + metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); + UAVObjSetMetadata(obj, &metadata); } /** @@ -112,7 +106,7 @@ $(INITFIELDS) */ UAVObjHandle $(NAME)Handle() { - return handle; + return handle; } /** @@ -123,4 +117,3 @@ $(SETGETFIELDS) /** * @} */ - diff --git a/flight/uavobjects/uavobjectsinittemplate.c b/flight/uavobjects/uavobjectsinit.c.template similarity index 98% rename from flight/uavobjects/uavobjectsinittemplate.c rename to flight/uavobjects/uavobjectsinit.c.template index 724156047..ea340b0c3 100644 --- a/flight/uavobjects/uavobjectsinittemplate.c +++ b/flight/uavobjects/uavobjectsinit.c.template @@ -27,7 +27,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include "openpilot.h" +#include $(OBJINC) /** diff --git a/ground/.gitattributes b/ground/.gitattributes index a9834a726..0417f63e1 100644 --- a/ground/.gitattributes +++ b/ground/.gitattributes @@ -15,3 +15,7 @@ *.pri text eol=crlf *.pro text eol=crlf + +*.h.template text eol=crlf +*.c.template text eol=crlf +*.cpp.template text eol=crlf diff --git a/ground/openpilotgcs/src/app/gcsversioninfo.pri b/ground/openpilotgcs/src/app/gcsversioninfo.pri index cc1d9c629..bec785f58 100644 --- a/ground/openpilotgcs/src/app/gcsversioninfo.pri +++ b/ground/openpilotgcs/src/app/gcsversioninfo.pri @@ -34,7 +34,7 @@ PYTHON_DIR = python-2.7.4 VERSION_INFO_DIR = $$GCS_BUILD_TREE/../openpilotgcs-synthetics VERSION_INFO_HEADER = $$VERSION_INFO_DIR/gcs_version_info.h VERSION_INFO_SCRIPT = $$ROOT_DIR/make/scripts/version-info.py - VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcs_version_info_template.h + VERSION_INFO_TEMPLATE = $$ROOT_DIR/make/templates/gcs_version_info.h.template VERSION_INFO_COMMAND = $$PYTHON \"$$VERSION_INFO_SCRIPT\" UAVO_DEF_PATH = $$ROOT_DIR/shared/uavobjectdefinition diff --git a/ground/openpilotgcs/src/libs/juavobjects/templates/uavobjecttemplate.java b/ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template similarity index 99% rename from ground/openpilotgcs/src/libs/juavobjects/templates/uavobjecttemplate.java rename to ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template index cb6d15fe5..2944f1270 100644 --- a/ground/openpilotgcs/src/libs/juavobjects/templates/uavobjecttemplate.java +++ b/ground/openpilotgcs/src/libs/juavobjects/templates/uavobject.java.template @@ -1,7 +1,7 @@ /** ****************************************************************************** * - * @file uavobjecttemplate.cpp + * @file $(NAME).java * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief Template for an uavobject in java * $(GENERATEDWARNING) diff --git a/ground/openpilotgcs/src/libs/juavobjects/templates/uavobjectsinittemplate.java b/ground/openpilotgcs/src/libs/juavobjects/templates/uavobjectsinit.java.template similarity index 96% rename from ground/openpilotgcs/src/libs/juavobjects/templates/uavobjectsinittemplate.java rename to ground/openpilotgcs/src/libs/juavobjects/templates/uavobjectsinit.java.template index 1e4a4d513..f87664c6b 100644 --- a/ground/openpilotgcs/src/libs/juavobjects/templates/uavobjectsinittemplate.java +++ b/ground/openpilotgcs/src/libs/juavobjects/templates/uavobjectsinit.java.template @@ -2,7 +2,7 @@ ****************************************************************************** * * - * @file uavobjectsinittemplate.java + * @file UAVObjectsInitialize.java * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. * @brief the template for the uavobjects init part * $(GENERATEDWARNING) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template similarity index 79% rename from ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp rename to ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template index 694a314a2..df78735bb 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.cpp.template @@ -30,6 +30,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "$(NAMELC).h" #include "uavobjectfield.h" @@ -43,10 +44,10 @@ const QString $(NAME)::CATEGORY = QString("$(CATEGORY)"); $(NAME)::$(NAME)(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAME) { // Create fields - QList fields; + QList fields; $(FIELDSINIT) // Initialize object - initializeFields(fields, (quint8*)&data, NUMBYTES); + initializeFields(fields, (quint8 *)&data, NUMBYTES); // Set the default field values setDefaultFieldValues(); // Set the object description @@ -55,8 +56,7 @@ $(FIELDSINIT) // Set the Category of this object type setCategory(CATEGORY); - connect(this, SIGNAL(objectUpdated(UAVObject*)), - SLOT(emitNotifications())); + connect(this, SIGNAL(objectUpdated(UAVObject *)), SLOT(emitNotifications())); } /** @@ -66,12 +66,12 @@ UAVObject::Metadata $(NAME)::getDefaultMetadata() { UAVObject::Metadata metadata; metadata.flags = - $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT | - $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT | - $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | - $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | - $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | - $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; + $(FLIGHTACCESS) << UAVOBJ_ACCESS_SHIFT | + $(GCSACCESS) << UAVOBJ_GCS_ACCESS_SHIFT | + $(FLIGHTTELEM_ACKED) << UAVOBJ_TELEMETRY_ACKED_SHIFT | + $(GCSTELEM_ACKED) << UAVOBJ_GCS_TELEMETRY_ACKED_SHIFT | + $(FLIGHTTELEM_UPDATEMODE) << UAVOBJ_TELEMETRY_UPDATE_MODE_SHIFT | + $(GCSTELEM_UPDATEMODE) << UAVOBJ_GCS_TELEMETRY_UPDATE_MODE_SHIFT; metadata.flightTelemetryUpdatePeriod = $(FLIGHTTELEM_UPDATEPERIOD); metadata.gcsTelemetryUpdatePeriod = $(GCSTELEM_UPDATEPERIOD); metadata.loggingUpdatePeriod = $(LOGGING_UPDATEPERIOD); @@ -106,8 +106,7 @@ void $(NAME)::setData(const DataFields& data) // Get metadata Metadata mdata = getMetadata(); // Update object if the access mode permits - if ( UAVObject::GetGcsAccess(mdata) == ACCESS_READWRITE ) - { + if (UAVObject::GetGcsAccess(mdata) == ACCESS_READWRITE) { this->data = data; emit objectUpdatedAuto(this); // trigger object updated event emit objectUpdated(this); @@ -124,9 +123,9 @@ void $(NAME)::emitNotifications() * Do not use this function directly to create new instances, the * UAVObjectManager should be used instead. */ -UAVDataObject* $(NAME)::clone(quint32 instID) +UAVDataObject *$(NAME)::clone(quint32 instID) { - $(NAME)* obj = new $(NAME)(); + $(NAME) *obj = new $(NAME)(); obj->initialize(instID, this->getMetaObject()); return obj; } @@ -134,18 +133,18 @@ UAVDataObject* $(NAME)::clone(quint32 instID) /** * Create a clone of this object only to be used to retrieve defaults */ -UAVDataObject* $(NAME)::dirtyClone() +UAVDataObject *$(NAME)::dirtyClone() { - $(NAME)* obj = new $(NAME)(); + $(NAME) *obj = new $(NAME)(); return obj; } /** * Static function to retrieve an instance of the object. */ -$(NAME)* $(NAME)::GetInstance(UAVObjectManager* objMngr, quint32 instID) +$(NAME) *$(NAME)::GetInstance(UAVObjectManager *objMngr, quint32 instID) { - return dynamic_cast<$(NAME)*>(objMngr->getObject($(NAME)::OBJID, instID)); + return dynamic_cast<$(NAME) *>(objMngr->getObject($(NAME)::OBJID, instID)); } $(PROPERTIES_IMPL) diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.h.template similarity index 100% rename from ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.h rename to ground/openpilotgcs/src/plugins/uavobjects/uavobject.h.template diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.m b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.m.template similarity index 100% rename from ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.m rename to ground/openpilotgcs/src/plugins/uavobjects/uavobject.m.template diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.py b/ground/openpilotgcs/src/plugins/uavobjects/uavobject.py.template similarity index 100% rename from ground/openpilotgcs/src/plugins/uavobjects/uavobjecttemplate.py rename to ground/openpilotgcs/src/plugins/uavobjects/uavobject.py.template diff --git a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectsinittemplate.cpp b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectsinit.cpp.template similarity index 96% rename from ground/openpilotgcs/src/plugins/uavobjects/uavobjectsinittemplate.cpp rename to ground/openpilotgcs/src/plugins/uavobjects/uavobjectsinit.cpp.template index 3ed79898a..5a102fb23 100644 --- a/ground/openpilotgcs/src/plugins/uavobjects/uavobjectsinittemplate.cpp +++ b/ground/openpilotgcs/src/plugins/uavobjects/uavobjectsinit.cpp.template @@ -29,14 +29,16 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "uavobjectsinit.h" + $(OBJINC) /** * Function used to initialize the first instance of each object. * This file is automatically updated by the UAVObjectGenerator. */ -void UAVObjectsInitialize(UAVObjectManager* objMngr) +void UAVObjectsInitialize(UAVObjectManager *objMngr) { $(OBJINIT) } diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common-template b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common.template similarity index 100% rename from ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common-template rename to ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/Makefile.common.template diff --git a/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects-template.c b/ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects.c.template similarity index 100% rename from ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects-template.c rename to ground/openpilotgcs/src/plugins/uavobjects/wireshark/op-uavobjects/packet-op-uavobjects.c.template diff --git a/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp b/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp index fcf32171f..696d9dfd3 100644 --- a/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp +++ b/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.cpp @@ -35,15 +35,15 @@ bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString template QString flightObjInit,objInc,objFileNames,objNames; qint32 sizeCalc; - flightCodePath = QDir( templatepath + QString("flight/uavobjects")); + flightCodePath = QDir( templatepath + QString(FLIGHT_CODE_DIR)); flightOutputPath = QDir( outputpath + QString("flight") ); flightOutputPath.mkpath(flightOutputPath.absolutePath()); - flightCodeTemplate = readFile( flightCodePath.absoluteFilePath("uavobjecttemplate.c") ); - flightIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobjecttemplate.h") ); - flightInitTemplate = readFile( flightCodePath.absoluteFilePath("uavobjectsinittemplate.c") ); - flightInitIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobjectsinittemplate.h") ); - flightMakeTemplate = readFile( flightCodePath.absoluteFilePath("Makefiletemplate.inc") ); + flightCodeTemplate = readFile( flightCodePath.absoluteFilePath("uavobject.c.template") ); + flightIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobject.h.template") ); + flightInitTemplate = readFile( flightCodePath.absoluteFilePath("uavobjectsinit.c.template") ); + flightInitIncludeTemplate = readFile( flightCodePath.absoluteFilePath("inc/uavobjectsinit.h.template") ); + flightMakeTemplate = readFile( flightCodePath.absoluteFilePath("Makefile.inc.template") ); if ( flightCodeTemplate.isNull() || flightIncludeTemplate.isNull() || flightInitTemplate.isNull()) { cerr << "Error: Could not open flight template files." << endl; @@ -54,10 +54,10 @@ bool UAVObjectGeneratorFlight::generate(UAVObjectParser* parser,QString template for (int objidx = 0; objidx < parser->getNumObjects(); ++objidx) { ObjectInfo* info=parser->getObjectByIndex(objidx); process_object(info); - flightObjInit.append("#ifdef UAVOBJ_INIT_" + info->namelc +"\r\n"); - flightObjInit.append(" " + info->name + "Initialize();\r\n"); - flightObjInit.append("#endif\r\n"); - objInc.append("#include \"" + info->namelc + ".h\"\r\n"); + flightObjInit.append("#ifdef UAVOBJ_INIT_" + info->namelc +"\n"); + flightObjInit.append(" " + info->name + "Initialize();\n"); + flightObjInit.append("#endif\n"); + objInc.append("#include \"" + info->namelc + ".h\"\n"); objFileNames.append(" " + info->namelc); objNames.append(" " + info->name); if (parser->getNumBytes(objidx)>sizeCalc) { @@ -124,12 +124,12 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) // Append field if ( info->fields[n]->numElements > 1 ) { - fields.append( QString(" %1 %2[%3];\r\n").arg(type) + fields.append( QString(" %1 %2[%3];\n").arg(type) .arg(info->fields[n]->name).arg(info->fields[n]->numElements) ); } else { - fields.append( QString(" %1 %2;\r\n").arg(type).arg(info->fields[n]->name) ); + fields.append( QString(" %1 %2;\n").arg(type).arg(info->fields[n]->name) ); } } outInclude.replace(QString("$(DATAFIELDS)"), fields); @@ -138,16 +138,16 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) QString enums; for (int n = 0; n < info->fields.length(); ++n) { - enums.append(QString("// Field %1 information\r\n").arg(info->fields[n]->name)); + enums.append(QString("/* Field %1 information */\n").arg(info->fields[n]->name)); // Only for enum types if (info->fields[n]->type == FIELDTYPE_ENUM) { - enums.append(QString("/* Enumeration options for field %1 */\r\n").arg(info->fields[n]->name)); - enums.append("typedef enum { "); + enums.append(QString("\n// Enumeration options for field %1\n").arg(info->fields[n]->name)); + enums.append("typedef enum {\n"); // Go through each option QStringList options = info->fields[n]->options; for (int m = 0; m < options.length(); ++m) { - QString s = (m == (options.length()-1)) ? "%1_%2_%3=%4" : "%1_%2_%3=%4, "; + QString s = (m == (options.length()-1)) ? " %1_%2_%3=%4\n" : " %1_%2_%3=%4,\n"; enums.append( s .arg( info->name.toUpper() ) .arg( info->fields[n]->name.toUpper() ) @@ -155,20 +155,20 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) .arg(m) ); } - enums.append( QString(" } %1%2Options;\r\n") + enums.append( QString("} %1%2Options;\n") .arg( info->name ) .arg( info->fields[n]->name ) ); } // Generate element names (only if field has more than one element) if (info->fields[n]->numElements > 1 && !info->fields[n]->defaultElementNames) { - enums.append(QString("/* Array element names for field %1 */\r\n").arg(info->fields[n]->name)); - enums.append("typedef enum { "); + enums.append(QString("\n// Array element names for field %1\n").arg(info->fields[n]->name)); + enums.append("typedef enum {\n"); // Go through the element names QStringList elemNames = info->fields[n]->elementNames; for (int m = 0; m < elemNames.length(); ++m) { - QString s = (m != (elemNames.length()-1)) ? "%1_%2_%3=%4, " : "%1_%2_%3=%4"; + QString s = (m != (elemNames.length()-1)) ? " %1_%2_%3=%4,\n" : " %1_%2_%3=%4\n"; enums.append( s .arg( info->name.toUpper() ) .arg( info->fields[n]->name.toUpper() ) @@ -176,19 +176,21 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) .arg(m) ); } - enums.append( QString(" } %1%2Elem;\r\n") + enums.append( QString("} %1%2Elem;\n") .arg( info->name ) .arg( info->fields[n]->name ) ); } // Generate array information if (info->fields[n]->numElements > 1) { - enums.append(QString("/* Number of elements for field %1 */\r\n").arg(info->fields[n]->name)); - enums.append( QString("#define %1_%2_NUMELEM %3\r\n") + enums.append(QString("\n// Number of elements for field %1\n").arg(info->fields[n]->name)); + enums.append( QString("#define %1_%2_NUMELEM %3\n") .arg( info->name.toUpper() ) .arg( info->fields[n]->name.toUpper() ) .arg( info->fields[n]->numElements ) ); } + + enums.append(QString("\n")); } outInclude.replace(QString("$(DATAFIELDINFO)"), enums); @@ -203,19 +205,19 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) { if ( info->fields[n]->type == FIELDTYPE_ENUM ) { - initfields.append( QString("\tdata.%1 = %2;\r\n") + initfields.append( QString(" data.%1 = %2;\n") .arg( info->fields[n]->name ) .arg( info->fields[n]->options.indexOf( info->fields[n]->defaultValues[0] ) ) ); } else if ( info->fields[n]->type == FIELDTYPE_FLOAT32 ) { - initfields.append( QString("\tdata.%1 = %2;\r\n") + initfields.append( QString(" data.%1 = %2;\n") .arg( info->fields[n]->name ) .arg( info->fields[n]->defaultValues[0].toFloat() ) ); } else { - initfields.append( QString("\tdata.%1 = %2;\r\n") + initfields.append( QString(" data.%1 = %2;\n") .arg( info->fields[n]->name ) .arg( info->fields[n]->defaultValues[0].toInt() ) ); } @@ -227,21 +229,21 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) { if ( info->fields[n]->type == FIELDTYPE_ENUM ) { - initfields.append( QString("\tdata.%1[%2] = %3;\r\n") + initfields.append( QString(" data.%1[%2] = %3;\n") .arg( info->fields[n]->name ) .arg( idx ) .arg( info->fields[n]->options.indexOf( info->fields[n]->defaultValues[idx] ) ) ); } else if ( info->fields[n]->type == FIELDTYPE_FLOAT32 ) { - initfields.append( QString("\tdata.%1[%2] = %3;\r\n") + initfields.append( QString(" data.%1[%2] = %3;\n") .arg( info->fields[n]->name ) .arg( idx ) .arg( info->fields[n]->defaultValues[idx].toFloat() ) ); } else { - initfields.append( QString("\tdata.%1[%2] = %3;\r\n") + initfields.append( QString(" data.%1[%2] = %3;\n") .arg( info->fields[n]->name ) .arg( idx ) .arg( info->fields[n]->defaultValues[idx].toInt() ) ); @@ -263,58 +265,58 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) { /* Set */ - setgetfields.append( QString("void %2%3Set( %1 *New%3 )\r\n") + setgetfields.append( QString("void %2%3Set(%1 *New%3)\n") .arg( fieldTypeStrC[info->fields[n]->type] ) .arg( info->name ) .arg( info->fields[n]->name ) ); - setgetfields.append( QString("{\r\n") ); - setgetfields.append( QString("\tUAVObjSetDataField(%1Handle(), (void*)New%2, offsetof( %1Data, %2), sizeof(%3));\r\n") + setgetfields.append( QString("{\n") ); + setgetfields.append( QString(" UAVObjSetDataField(%1Handle(), (void *)New%2, offsetof(%1Data, %2), sizeof(%3));\n") .arg( info->name ) .arg( info->fields[n]->name ) .arg( fieldTypeStrC[info->fields[n]->type] ) ); - setgetfields.append( QString("}\r\n") ); + setgetfields.append( QString("}\n") ); /* GET */ - setgetfields.append( QString("void %2%3Get( %1 *New%3 )\r\n") + setgetfields.append( QString("void %2%3Get(%1 *New%3)\n") .arg( fieldTypeStrC[info->fields[n]->type] ) .arg( info->name ) .arg( info->fields[n]->name )); - setgetfields.append( QString("{\r\n") ); - setgetfields.append( QString("\tUAVObjGetDataField(%1Handle(), (void*)New%2, offsetof( %1Data, %2), sizeof(%3));\r\n") + setgetfields.append( QString("{\n") ); + setgetfields.append( QString(" UAVObjGetDataField(%1Handle(), (void *)New%2, offsetof(%1Data, %2), sizeof(%3));\n") .arg( info->name ) .arg( info->fields[n]->name ) .arg( fieldTypeStrC[info->fields[n]->type] ) ); - setgetfields.append( QString("}\r\n") ); + setgetfields.append( QString("}\n") ); } else { /* SET */ - setgetfields.append( QString("void %2%3Set( %1 *New%3 )\r\n") + setgetfields.append( QString("void %2%3Set( %1 *New%3 )\n") .arg( fieldTypeStrC[info->fields[n]->type] ) .arg( info->name ) .arg( info->fields[n]->name ) ); - setgetfields.append( QString("{\r\n") ); - setgetfields.append( QString("\tUAVObjSetDataField(%1Handle(), (void*)New%2, offsetof( %1Data, %2), %3*sizeof(%4));\r\n") + setgetfields.append( QString("{\n") ); + setgetfields.append( QString(" UAVObjSetDataField(%1Handle(), (void *)New%2, offsetof(%1Data, %2), %3*sizeof(%4));\n") .arg( info->name ) .arg( info->fields[n]->name ) .arg( info->fields[n]->numElements ) .arg( fieldTypeStrC[info->fields[n]->type] ) ); - setgetfields.append( QString("}\r\n") ); + setgetfields.append( QString("}\n") ); /* GET */ - setgetfields.append( QString("void %2%3Get( %1 *New%3 )\r\n") + setgetfields.append( QString("void %2%3Get( %1 *New%3 )\n") .arg( fieldTypeStrC[info->fields[n]->type] ) .arg( info->name ) .arg( info->fields[n]->name ) ); - setgetfields.append( QString("{\r\n") ); - setgetfields.append( QString("\tUAVObjGetDataField(%1Handle(), (void*)New%2, offsetof( %1Data, %2), %3*sizeof(%4));\r\n") + setgetfields.append( QString("{\n") ); + setgetfields.append( QString(" UAVObjGetDataField(%1Handle(), (void *)New%2, offsetof(%1Data, %2), %3*sizeof(%4));\n") .arg( info->name ) .arg( info->fields[n]->name ) .arg( info->fields[n]->numElements ) .arg( fieldTypeStrC[info->fields[n]->type] ) ); - setgetfields.append( QString("}\r\n") ); + setgetfields.append( QString("}\n") ); } } } @@ -328,13 +330,13 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) { /* SET */ - setgetfieldsextern.append( QString("extern void %2%3Set( %1 *New%3 );\r\n") + setgetfieldsextern.append( QString("extern void %2%3Set(%1 *New%3);\n") .arg( fieldTypeStrC[info->fields[n]->type] ) .arg( info->name ) .arg( info->fields[n]->name ) ); /* GET */ - setgetfieldsextern.append( QString("extern void %2%3Get( %1 *New%3 );\r\n") + setgetfieldsextern.append( QString("extern void %2%3Get(%1 *New%3);\n") .arg( fieldTypeStrC[info->fields[n]->type] ) .arg( info->name ) .arg( info->fields[n]->name ) ); @@ -357,5 +359,3 @@ bool UAVObjectGeneratorFlight::process_object(ObjectInfo* info) return true; } - - diff --git a/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.h b/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.h index db728374b..e475c21ba 100644 --- a/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.h +++ b/ground/uavobjgenerator/generators/flight/uavobjectgeneratorflight.h @@ -27,6 +27,8 @@ #ifndef UAVOBJECTGENERATORFLIGHT_H #define UAVOBJECTGENERATORFLIGHT_H +#define FLIGHT_CODE_DIR "flight/uavobjects" + #include "../generator_common.h" class UAVObjectGeneratorFlight diff --git a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp index b2a58444e..93fb980e2 100644 --- a/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp +++ b/ground/uavobjgenerator/generators/gcs/uavobjectgeneratorgcs.cpp @@ -39,9 +39,9 @@ bool UAVObjectGeneratorGCS::generate(UAVObjectParser* parser,QString templatepat gcsOutputPath = QDir( outputpath + QString("gcs") ); gcsOutputPath.mkpath(gcsOutputPath.absolutePath()); - gcsCodeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjecttemplate.cpp") ); - gcsIncludeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjecttemplate.h") ); - QString gcsInitTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjectsinittemplate.cpp") ); + gcsCodeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobject.cpp.template") ); + gcsIncludeTemplate = readFile( gcsCodePath.absoluteFilePath("uavobject.h.template") ); + QString gcsInitTemplate = readFile( gcsCodePath.absoluteFilePath("uavobjectsinit.cpp.template") ); if (gcsCodeTemplate.isEmpty() || gcsIncludeTemplate.isEmpty() || gcsInitTemplate.isEmpty()) { std::cerr << "Problem reading gcs code templates" << endl; diff --git a/ground/uavobjgenerator/generators/java/uavobjectgeneratorjava.cpp b/ground/uavobjgenerator/generators/java/uavobjectgeneratorjava.cpp index dc593fd5f..3698ebba1 100644 --- a/ground/uavobjgenerator/generators/java/uavobjectgeneratorjava.cpp +++ b/ground/uavobjgenerator/generators/java/uavobjectgeneratorjava.cpp @@ -39,8 +39,8 @@ bool UAVObjectGeneratorJava::generate(UAVObjectParser* parser,QString templatepa javaOutputPath = QDir( outputpath + QString("java") ); javaOutputPath.mkpath(javaOutputPath.absolutePath()); - javaCodeTemplate = readFile( javaCodePath.absoluteFilePath("uavobjecttemplate.java") ); - QString javaInitTemplate = readFile( javaCodePath.absoluteFilePath("uavobjectsinittemplate.java") ); + javaCodeTemplate = readFile( javaCodePath.absoluteFilePath("uavobject.java.template") ); + QString javaInitTemplate = readFile( javaCodePath.absoluteFilePath("uavobjectsinit.java.template") ); if (javaCodeTemplate.isEmpty() || javaInitTemplate.isEmpty()) { std::cerr << "Problem reading java code templates" << endl; diff --git a/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp b/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp index 515366112..d0894b892 100644 --- a/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp +++ b/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.cpp @@ -35,11 +35,11 @@ bool UAVObjectGeneratorMatlab::generate(UAVObjectParser* parser,QString template fieldSizeStrMatlab << "1" << "2" << "4" << "1" << "2" << "4" << "4" << "1"; - QDir matlabTemplatePath = QDir( templatepath + QString("ground/openpilotgcs/src/plugins/uavobjects")); + QDir matlabTemplatePath = QDir( templatepath + QString(MATLAB_CODE_DIR)); QDir matlabOutputPath = QDir( outputpath + QString("matlab") ); matlabOutputPath.mkpath(matlabOutputPath.absolutePath()); - QString matlabCodeTemplate = readFile( matlabTemplatePath.absoluteFilePath( "uavobjecttemplate.m") ); + QString matlabCodeTemplate = readFile( matlabTemplatePath.absoluteFilePath( "uavobject.m.template") ); if (matlabCodeTemplate.isEmpty() ) { std::cerr << "Problem reading matlab templates" << endl; diff --git a/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.h b/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.h index 67817867b..1d3761724 100644 --- a/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.h +++ b/ground/uavobjgenerator/generators/matlab/uavobjectgeneratormatlab.h @@ -27,6 +27,8 @@ #ifndef UAVOBJECTGENERATORMATLAB_H #define UAVOBJECTGENERATORMATLAB_H +#define MATLAB_CODE_DIR "ground/openpilotgcs/src/plugins/uavobjects" + #include "../generator_common.h" class UAVObjectGeneratorMatlab diff --git a/ground/uavobjgenerator/generators/python/uavobjectgeneratorpython.cpp b/ground/uavobjgenerator/generators/python/uavobjectgeneratorpython.cpp index 095fb37bb..35e8e017c 100644 --- a/ground/uavobjgenerator/generators/python/uavobjectgeneratorpython.cpp +++ b/ground/uavobjgenerator/generators/python/uavobjectgeneratorpython.cpp @@ -29,10 +29,10 @@ using namespace std; bool UAVObjectGeneratorPython::generate(UAVObjectParser* parser,QString templatepath,QString outputpath) { // Load template and setup output directory - pythonCodePath = QDir( templatepath + QString("flight/Modules/FlightPlan/lib")); + pythonCodePath = QDir( templatepath + QString("flight/modules/FlightPlan/lib")); pythonOutputPath = QDir( outputpath + QString("python") ); pythonOutputPath.mkpath(pythonOutputPath.absolutePath()); - pythonCodeTemplate = readFile( pythonCodePath.absoluteFilePath("uavobjecttemplate.pyt") ); + pythonCodeTemplate = readFile( pythonCodePath.absoluteFilePath("uavobject.pyt.template") ); if (pythonCodeTemplate.isEmpty()) { std::cerr << "Problem reading python templates" << endl; return false; @@ -71,20 +71,20 @@ bool UAVObjectGeneratorPython::process_object(ObjectInfo* info) // Only for enum types if (info->fields[n]->type == FIELDTYPE_ENUM) { - datafields.append(QString("\t# Enumeration options\n")); + datafields.append(QString(" # Enumeration options\n")); // Go through each option QStringList options = info->fields[n]->options; for (int m = 0; m < options.length(); ++m) { QString name = options[m].toUpper().replace(QRegExp(ENUM_SPECIAL_CHARS), ""); if (name[0].isDigit()) name = QString("N%1").arg(name); - datafields.append(QString("\t%1 = %2\n").arg(name).arg(m)); + datafields.append(QString(" %1 = %2\n").arg(name).arg(m)); } } // Generate element names (only if field has more than one element) if (info->fields[n]->numElements > 1 && !info->fields[n]->defaultElementNames) { - datafields.append(QString("\t# Array element names\n")); + datafields.append(QString(" # Array element names\n")); // Go through the element names QStringList elemNames = info->fields[n]->elementNames; for (int m = 0; m < elemNames.length(); ++m) @@ -92,12 +92,12 @@ bool UAVObjectGeneratorPython::process_object(ObjectInfo* info) QString name = elemNames[m].toUpper().replace(QRegExp(ENUM_SPECIAL_CHARS), ""); if (name[0].isDigit()) name = QString("N%1").arg(name); - datafields.append(QString("\t%1 = %2\n").arg(name).arg(m)); + datafields.append(QString(" %1 = %2\n").arg(name).arg(m)); } } // Constructor - datafields.append(QString("\tdef __init__(self):\n")); - datafields.append(QString("\t\tUAVObjectField.__init__(self, %1, %2)\n\n").arg(info->fields[n]->type).arg(info->fields[n]->numElements)); + datafields.append(QString(" def __init__(self):\n")); + datafields.append(QString(" UAVObjectField.__init__(self, %1, %2)\n\n").arg(info->fields[n]->type).arg(info->fields[n]->numElements)); } outCode.replace(QString("$(DATAFIELDS)"), datafields); @@ -105,8 +105,8 @@ bool UAVObjectGeneratorPython::process_object(ObjectInfo* info) QString fields; for (int n = 0; n < info->fields.length(); ++n) { - fields.append(QString("\t\tself.%1 = %1Field()\n").arg(info->fields[n]->name)); - fields.append(QString("\t\tself.addField(self.%1)\n").arg(info->fields[n]->name)); + fields.append(QString(" self.%1 = %1Field()\n").arg(info->fields[n]->name)); + fields.append(QString(" self.addField(self.%1)\n").arg(info->fields[n]->name)); } outCode.replace(QString("$(DATAFIELDINIT)"), fields); @@ -119,4 +119,3 @@ bool UAVObjectGeneratorPython::process_object(ObjectInfo* info) return true; } - diff --git a/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp b/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp index c0669d9e6..653e466e3 100644 --- a/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp +++ b/ground/uavobjgenerator/generators/wireshark/uavobjectgeneratorwireshark.cpp @@ -40,8 +40,8 @@ bool UAVObjectGeneratorWireshark::generate(UAVObjectParser* parser,QString templ wiresharkOutputPath = QDir( outputpath + QString("wireshark") ); wiresharkOutputPath.mkpath(wiresharkOutputPath.absolutePath()); - wiresharkCodeTemplate = readFile( wiresharkCodePath.absoluteFilePath("op-uavobjects/packet-op-uavobjects-template.c") ); - wiresharkMakeTemplate = readFile( wiresharkCodePath.absoluteFilePath("op-uavobjects/Makefile.common-template") ); + wiresharkCodeTemplate = readFile( wiresharkCodePath.absoluteFilePath("op-uavobjects/packet-op-uavobjects.c.template") ); + wiresharkMakeTemplate = readFile( wiresharkCodePath.absoluteFilePath("op-uavobjects/Makefile.common.template") ); if ( wiresharkCodeTemplate.isNull() || wiresharkMakeTemplate.isNull()) { cerr << "Error: Could not open wireshark template files." << endl; diff --git a/make/.gitattributes b/make/.gitattributes index 59b05a332..fe48df9c1 100644 --- a/make/.gitattributes +++ b/make/.gitattributes @@ -7,7 +7,7 @@ *.sh text eol=lf /doxygen/*.cfg text eol=lf -/templates/firmwareinfotemplate.c text eol=lf -/templates/gcs_version_info_template.h text eol=crlf +/templates/firmware_info.c.template text eol=lf +/templates/gcs_version_info.h.template text eol=crlf /templates/*.txt text eol=crlf /uncrustify/*.cfg text eol=lf diff --git a/make/firmware-defs.mk b/make/firmware-defs.mk index ca7c42c67..dbda89b26 100644 --- a/make/firmware-defs.mk +++ b/make/firmware-defs.mk @@ -133,21 +133,21 @@ endef define OPFW_TEMPLATE FORCE: -$(1).firmwareinfo.c: $(1) $(ROOT_DIR)/make/templates/firmwareinfotemplate.c FORCE +$(1).firmware_info.c: $(1) $(ROOT_DIR)/make/templates/firmware_info.c.template FORCE @$(ECHO) $(MSG_FWINFO) $$(call toprel, $$@) $(V1) $(VERSION_INFO) \ - --template=$(ROOT_DIR)/make/templates/firmwareinfotemplate.c \ + --template=$(ROOT_DIR)/make/templates/firmware_info.c.template \ --outfile=$$@ \ --image=$(1) \ --type=$(2) \ --revision=$(3) \ --uavodir=$(ROOT_DIR)/shared/uavobjectdefinition -$(eval $(call COMPILE_C_TEMPLATE, $(1).firmwareinfo.c)) +$(eval $(call COMPILE_C_TEMPLATE, $(1).firmware_info.c)) -$(OUTDIR)/$(notdir $(basename $(1))).opfw : $(1) $(1).firmwareinfo.bin +$(OUTDIR)/$(notdir $(basename $(1))).opfw : $(1) $(1).firmware_info.bin @$(ECHO) $(MSG_OPFIRMWARE) $$(call toprel, $$@) - $(V1) $(CAT) $(1) $(1).firmwareinfo.bin > $$@ + $(V1) $(CAT) $(1) $(1).firmware_info.bin > $$@ endef # Assemble: create object files from assembler source files. diff --git a/make/templates/firmwareinfotemplate.c b/make/templates/firmware_info.c.template similarity index 100% rename from make/templates/firmwareinfotemplate.c rename to make/templates/firmware_info.c.template diff --git a/make/templates/gcs_version_info_template.h b/make/templates/gcs_version_info.h.template similarity index 100% rename from make/templates/gcs_version_info_template.h rename to make/templates/gcs_version_info.h.template From 363e1705cf247e77ead54d727475d702cf7352bc Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Mon, 29 Apr 2013 17:06:08 +0200 Subject: [PATCH 29/32] uncrustify: update configuration (EOL comment and class indents, extra ';' removals) --- make/uncrustify/uncrustify.cfg | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/make/uncrustify/uncrustify.cfg b/make/uncrustify/uncrustify.cfg index e4e60eb43..e4de43332 100644 --- a/make/uncrustify/uncrustify.cfg +++ b/make/uncrustify/uncrustify.cfg @@ -102,7 +102,7 @@ indent_namespace_limit = 0 # number indent_extern = false # false/true # Whether the 'class' body is indented -indent_class = false # false/true +indent_class = true # false/true # Whether to indent the stuff after a leading class colon indent_class_colon = false # false/true @@ -164,7 +164,7 @@ indent_sing_line_comments = 0 # number # If set, will indent trailing single line ('//') comments relative # to the code instead of trying to keep the same absolute column -indent_relative_single_line_comments = false # false/true +indent_relative_single_line_comments = true # false/true # Spaces to indent 'case' from 'switch' # Usually 0 or indent_columns. @@ -1398,7 +1398,7 @@ mod_pawn_semicolon = false # false/true mod_full_paren_if_bool = false # false/true # Whether to remove superfluous semicolons -mod_remove_extra_semicolon = true # false/true +mod_remove_extra_semicolon = false # false/true # If a function body exceeds the specified number of newlines and doesn't have a comment after # the close brace, a comment will be added. From 7c6da1df65815eddd55eb9ac71c887f2de077bff Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Tue, 30 Apr 2013 11:51:46 +0200 Subject: [PATCH 30/32] OPLinkMini: remove duplicated pvPortMalloc defines, fix #ifdef macro name When the #define is reformatted by uncrustify, it differs from the same in FreeRTOS default config and gives error. So the removal of it serves to 2 purposes: removes the duplication and fixes uncrustified builds. --- .../targets/boards/oplinkmini/firmware/inc/FreeRTOSConfig.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/flight/targets/boards/oplinkmini/firmware/inc/FreeRTOSConfig.h b/flight/targets/boards/oplinkmini/firmware/inc/FreeRTOSConfig.h index c1e5d957c..38ff0bc7c 100644 --- a/flight/targets/boards/oplinkmini/firmware/inc/FreeRTOSConfig.h +++ b/flight/targets/boards/oplinkmini/firmware/inc/FreeRTOSConfig.h @@ -76,7 +76,7 @@ NVIC value of 255. */ #endif /* Enable run time stats collection */ -#if defined(DIAG_STACK) +#ifdef DIAG_TASKS #define configCHECK_FOR_STACK_OVERFLOW 2 #define configGENERATE_RUN_TIME_STATS 1 @@ -91,9 +91,6 @@ do {\ #define configCHECK_FOR_STACK_OVERFLOW 1 #endif -void *pvPortMallocGeneric( size_t xWantedSize, size_t alignment); -#define pvPortMallocAligned( x, puxStackBuffer ) ( ( ( puxStackBuffer ) == NULL ) ? ( pvPortMallocGeneric( ( x ) , portBYTE_ALIGNMENT) ) : ( puxStackBuffer ) ) - /** * @} */ From dbc35d2b71a9fb0c31626d4ee33b7e29e9f805a3 Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Tue, 30 Apr 2013 22:15:58 +0200 Subject: [PATCH 31/32] Update flight/.gitattributes to include *.template files --- flight/.gitattributes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/flight/.gitattributes b/flight/.gitattributes index e85fe7958..d4d1fb4f6 100644 --- a/flight/.gitattributes +++ b/flight/.gitattributes @@ -15,3 +15,6 @@ Makefile text eol=lf Makefile.* text eol=lf *.mk text eol=lf + +*.h.template text eol=lf +*.c.template text eol=lf From b30385d4fa9013f331679ed490c1bf0bff0c129f Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Wed, 1 May 2013 12:01:51 +0300 Subject: [PATCH 32/32] uncrustify: use no spaces in empty for statements: for ( ; ;) -> for (;;) It can be rolled back and a space after last semicolon could be added if desired: for ( ; ; ). But it looks not nice in ~20 files where this statement is used. --- make/uncrustify/uncrustify.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/uncrustify/uncrustify.cfg b/make/uncrustify/uncrustify.cfg index e4de43332..912b82b3b 100644 --- a/make/uncrustify/uncrustify.cfg +++ b/make/uncrustify/uncrustify.cfg @@ -397,7 +397,7 @@ sp_before_semi = remove # ignore/add/remove/force sp_before_semi_for = remove # ignore/add/remove/force # Add or remove space before a semicolon of an empty part of a for statement. -sp_before_semi_for_empty = force # ignore/add/remove/force +sp_before_semi_for_empty = remove # ignore/add/remove/force # Add or remove space after ';', except when followed by a comment. Default=Add sp_after_semi = force # ignore/add/remove/force