Commit b434b4a4 authored by Don Gagne's avatar Don Gagne

PX4 Tuning Component

parent 5399a291
......@@ -586,6 +586,7 @@ HEADERS+= \
src/AutoPilotPlugins/PX4/SafetyComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponent.h \
src/AutoPilotPlugins/PX4/SensorsComponentController.h \
src/AutoPilotPlugins/PX4/PX4TuningComponent.h \
src/FirmwarePlugin/FirmwarePluginManager.h \
src/FirmwarePlugin/FirmwarePlugin.h \
src/FirmwarePlugin/APM/APMFirmwarePlugin.h \
......@@ -642,6 +643,7 @@ SOURCES += \
src/AutoPilotPlugins/PX4/SafetyComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponent.cc \
src/AutoPilotPlugins/PX4/SensorsComponentController.cc \
src/AutoPilotPlugins/PX4/PX4TuningComponent.cc \
src/FirmwarePlugin/APM/APMFirmwarePlugin.cc \
src/FirmwarePlugin/APM/APMParameterMetaData.cc \
src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.cc \
......
......@@ -75,6 +75,7 @@
<file alias="QGroundControl/Controls/VehicleRotationCal.qml">src/QmlControls/VehicleRotationCal.qml</file>
<file alias="QGroundControl/Controls/VehicleSummaryRow.qml">src/QmlControls/VehicleSummaryRow.qml</file>
<file alias="QGroundControl/Controls/ViewWidget.qml">src/ViewWidgets/ViewWidget.qml</file>
<file alias="QGroundControl/Controls/FactSliderPanel.qml">src/QmlControls/FactSliderPanel.qml</file>
<file alias="QGroundControl/FactControls/FactCheckBox.qml">src/FactSystem/FactControls/FactCheckBox.qml</file>
<file alias="QGroundControl/FactControls/FactComboBox.qml">src/FactSystem/FactControls/FactComboBox.qml</file>
<file alias="QGroundControl/FactControls/FactLabel.qml">src/FactSystem/FactControls/FactLabel.qml</file>
......@@ -105,6 +106,8 @@
<file alias="QmlTest.qml">src/QmlControls/QmlTest.qml</file>
<file alias="RadioComponent.qml">src/AutoPilotPlugins/Common/RadioComponent.qml</file>
<file alias="PX4RadioComponentSummary.qml">src/AutoPilotPlugins/PX4/PX4RadioComponentSummary.qml</file>
<file alias="PX4TuningComponentCopter.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentCopter.qml</file>
<file alias="PX4TuningComponentPlane.qml">src/AutoPilotPlugins/PX4/PX4TuningComponentPlane.qml</file>
<file alias="APMNotSupported.qml">src/AutoPilotPlugins/APM/APMNotSupported.qml</file>
<file alias="APMCameraComponent.qml">src/AutoPilotPlugins/APM/APMCameraComponent.qml</file>
<file alias="APMCameraComponentSummary.qml">src/AutoPilotPlugins/APM/APMCameraComponentSummary.qml</file>
......@@ -118,8 +121,6 @@
<file alias="APMSafetyComponentSummaryPlane.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSummaryPlane.qml</file>
<file alias="APMSafetyComponentSummaryRover.qml">src/AutoPilotPlugins/APM/APMSafetyComponentSummaryRover.qml</file>
<file alias="APMTuningComponentCopter.qml">src/AutoPilotPlugins/APM/APMTuningComponentCopter.qml</file>
<file alias="APMTuningComponentPlane.qml">src/AutoPilotPlugins/APM/APMTuningComponentPlane.qml</file>
<file alias="APMTuningComponentRover.qml">src/AutoPilotPlugins/APM/APMTuningComponentRover.qml</file>
<file alias="SafetyComponent.qml">src/AutoPilotPlugins/PX4/SafetyComponent.qml</file>
<file alias="SafetyComponentSummary.qml">src/AutoPilotPlugins/PX4/SafetyComponentSummary.qml</file>
<file alias="SensorsComponent.qml">src/AutoPilotPlugins/PX4/SensorsComponent.qml</file>
......
......@@ -66,9 +66,6 @@ QUrl APMTuningComponent::setupSource(void) const
QString qmlFile;
switch (_vehicle->vehicleType()) {
case MAV_TYPE_FIXED_WING:
qmlFile = "qrc:/qml/APMTuningComponentPlane.qml";
break;
case MAV_TYPE_QUADROTOR:
case MAV_TYPE_COAXIAL:
case MAV_TYPE_HELICOPTER:
......@@ -77,11 +74,8 @@ QUrl APMTuningComponent::setupSource(void) const
case MAV_TYPE_TRICOPTER:
qmlFile = "qrc:/qml/APMTuningComponentCopter.qml";
break;
case MAV_TYPE_GROUND_ROVER:
qmlFile = "qrc:/qml/APMTuningComponentRover.qml";
break;
default:
qmlFile = "qrc:/qml/APMNotSupported.qml";
// No tuning panel
break;
}
......
......@@ -95,34 +95,32 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
if (parametersReady()) {
_airframeComponent = new AirframeComponent(_vehicle, this);
Q_CHECK_PTR(_airframeComponent);
_airframeComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_airframeComponent));
_radioComponent = new PX4RadioComponent(_vehicle, this);
Q_CHECK_PTR(_radioComponent);
_radioComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_radioComponent));
_flightModesComponent = new FlightModesComponent(_vehicle, this);
Q_CHECK_PTR(_flightModesComponent);
_flightModesComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_flightModesComponent));
_sensorsComponent = new SensorsComponent(_vehicle, this);
Q_CHECK_PTR(_sensorsComponent);
_sensorsComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_sensorsComponent));
_powerComponent = new PowerComponent(_vehicle, this);
Q_CHECK_PTR(_powerComponent);
_powerComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_powerComponent));
_safetyComponent = new SafetyComponent(_vehicle, this);
Q_CHECK_PTR(_safetyComponent);
_safetyComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_safetyComponent));
_tuningComponent = new PX4TuningComponent(_vehicle, this);
_tuningComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_tuningComponent));
} else {
qWarning() << "Call to vehicleCompenents prior to parametersReady";
}
......
......@@ -32,6 +32,7 @@
#include "SensorsComponent.h"
#include "SafetyComponent.h"
#include "PowerComponent.h"
#include "PX4TuningComponent.h"
#include "Vehicle.h"
#include <QImage>
......@@ -58,6 +59,7 @@ public:
SensorsComponent* sensorsComponent(void) { return _sensorsComponent; }
SafetyComponent* safetyComponent(void) { return _safetyComponent; }
PowerComponent* powerComponent(void) { return _powerComponent; }
PX4TuningComponent* tuningComponent(void) { return _tuningComponent; }
public slots:
// FIXME: This is public until we restructure AutoPilotPlugin/FirmwarePlugin/Vehicle
......@@ -72,6 +74,7 @@ private:
SensorsComponent* _sensorsComponent;
SafetyComponent* _safetyComponent;
PowerComponent* _powerComponent;
PX4TuningComponent* _tuningComponent;
bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed
};
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#include "PX4TuningComponent.h"
#include "PX4AutoPilotPlugin.h"
#include "AirframeComponent.h"
PX4TuningComponent::PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: PX4Component(vehicle, autopilot, parent)
, _name("Tuning")
{
}
QString PX4TuningComponent::name(void) const
{
return _name;
}
QString PX4TuningComponent::description(void) const
{
return tr("The Tuning Component is used to tune the flight characteristics of the Vehicle.");
}
QString PX4TuningComponent::iconResource(void) const
{
return "/qmlimages/TuningComponentIcon.png";
}
bool PX4TuningComponent::requiresSetup(void) const
{
return false;
}
bool PX4TuningComponent::setupComplete(void) const
{
return true;
}
QStringList PX4TuningComponent::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}
QUrl PX4TuningComponent::setupSource(void) const
{
QString qmlFile;
switch (_vehicle->vehicleType()) {
case MAV_TYPE_FIXED_WING:
qmlFile = "qrc:/qml/PX4TuningComponentPlane.qml";
break;
case MAV_TYPE_QUADROTOR:
case MAV_TYPE_COAXIAL:
case MAV_TYPE_HELICOPTER:
case MAV_TYPE_HEXAROTOR:
case MAV_TYPE_OCTOROTOR:
case MAV_TYPE_TRICOPTER:
qmlFile = "qrc:/qml/PX4TuningComponentCopter.qml";
break;
default:
break;
}
return QUrl::fromUserInput(qmlFile);
}
QUrl PX4TuningComponent::summaryQmlSource(void) const
{
return QUrl();
}
QString PX4TuningComponent::prerequisiteSetup(void) const
{
PX4AutoPilotPlugin* plugin = dynamic_cast<PX4AutoPilotPlugin*>(_autopilot);
if (plugin) {
if (!plugin->airframeComponent()->setupComplete()) {
return plugin->airframeComponent()->name();
}
}
qWarning() << "Internal error: plugin cast failed";
return QString();
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
(c) 2009 - 2014 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.5
import QGroundControl.Controls 1.0
QGCLabel {
anchors.fill: parent
text: "Not supported"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
}
#ifndef PX4TuningComponent_H
#define PX4TuningComponent_H
#include "PX4Component.h"
class PX4TuningComponent : public PX4Component
{
Q_OBJECT
public:
PX4TuningComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from PX4Component
virtual QStringList setupCompleteChangedTriggerList(void) const;
// Virtuals from VehicleComponent
virtual QString name(void) const;
virtual QString description(void) const;
virtual QString iconResource(void) const;
virtual bool requiresSetup(void) const;
virtual bool setupComplete(void) const;
virtual QUrl setupSource(void) const;
virtual QUrl summaryQmlSource(void) const;
virtual QString prerequisiteSetup(void) const;
private:
const QString _name;
};
#endif
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.5
import QtQuick.Controls 1.4
import QGroundControl.Controls 1.0
FactSliderPanel {
anchors.fill: parent
sliderModel: ListModel {
ListElement {
title: "Roll sensitivity"
description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy."
param: "MC_ROLL_TC"
min: 0
max: 100
step: 1
}
ListElement {
title: "Pitch sensitivity"
description: "Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy."
param: "MC_PITCH_TC"
min: 0
max: 100
step: 1
}
ListElement {
title: "Altitude control sensitivity"
description: "Slide to the left to make altitude control smoother and less twitchy. Slide to the right to make altitude control more accurate and more aggressive."
param: "MPC_Z_FF"
min: 0
max: 100
step: 1
}
ListElement {
title: "Position control sensitivity"
description: "Slide to the left to make flight in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive."
param: "MPC_XY_FF"
min: 0
max: 100
step: 1
}
}
}
......@@ -21,13 +21,49 @@
======================================================================*/
import QtQuick 2.5
import QtQuick 2.5
import QtQuick.Controls 1.4
import QGroundControl.Controls 1.0
import QGroundControl.Controls 1.0
QGCLabel {
anchors.fill: parent
text: "Not supported"
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
FactSliderPanel {
anchors.fill: parent
sliderModel: ListModel {
ListElement {
title: "Roll sensitivity"
description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy."
param: "FW_R_TC"
min: 0
max: 100
step: 1
}
ListElement {
title: "Pitch sensitivity"
description: "Slide to the left to make pitch control faster and more accurate. Slide to the right if pitch oscillates or is too twitchy."
param: "FW_P_TC"
min: 0
max: 100
step: 1
}
ListElement {
title: "Cruise throttle"
description: "This is the throttle setting required to achieve the desired cruise speed."
param: "FW_THR_CRUISE"
min: 0
max: 100
step: 1
}
ListElement {
title: "Position control sensitivity"
description: "Slide to the left to make flight in position control mode smoother and less twitchy. Slide to the right to make position control more accurate and more aggressive."
param: "FW_L1_PERIOD"
min: 0
max: 100
step: 1
}
}
}
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL 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.
QGROUNDCONTROL 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 QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
import QtQuick 2.5
import QtQuick.Controls 1.4
import QGroundControl.FactSystem 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
QGCView {
viewPanel: panel
property string panelTitle: "Title" ///< Title for panel
/// ListModel must contains elements which look like this:
/// ListElement {
/// title: "Roll sensitivity"
/// description: "Slide to the left to make roll control faster and more accurate. Slide to the right if roll oscillates or is too twitchy."
/// param: "MC_ROLL_TC"
/// min: 0
/// max: 100
/// step: 1
/// }
property ListModel sliderModel
FactPanelController { id: controller; factPanel: panel }
QGCPalette { id: palette; colorGroupEnabled: enabled }
property real _margins: ScreenTools.defaultFontPixelHeight
property bool _loadComplete: false
Component.onCompleted: {
// Qml Sliders have a strange behavior in which they first set Slider::value to some internal
// setting and then set Slider::value to the bound properties value. If you have an onValueChanged
// handler which updates your property with the new value, this first value change will trash
// your bound values. In order to work around this we don't set the values into the Sliders until
// after Qml load is done. We also don't track value changes until Qml load completes.
for (var i=0; i<sliderModel.count; i++) {
sliderRepeater.itemAt(i).sliderValue = controller.getParameterFact(-1, sliderModel.get(i).param).value
}
_loadComplete = true
}
QGCViewPanel {
id: panel
anchors.fill: parent
Flickable {
clip: true
anchors.fill: parent
boundsBehavior: Flickable.StopAtBounds
contentHeight: sliderRect.y + sliderRect.height
flickableDirection: Flickable.VerticalFlick
QGCLabel {
id: panelLabel
text: panelTitle
font.weight: Font.DemiBold
}
Rectangle {
id: sliderRect
anchors.topMargin: _margins / 2
anchors.left: parent.left
anchors.right: parent.right
anchors.top: panelLabel.bottom
height: sliderColumns.y + sliderColumns.height + _margins
color: palette.windowShade
Column {
id: sliderColumns
anchors.margins: _margins
anchors.left: parent.left
anchors.right: parent.right
anchors.top: parent.top
spacing: _margins
Repeater {
id: sliderRepeater
model: sliderModel
Column {
anchors.left: parent.left
anchors.right: parent.right
property alias sliderValue: slider.value
QGCLabel {
text: title
font.weight: Font.DemiBold
}
QGCLabel {
text: description
}
Slider {
id: slider
anchors.left: parent.left
anchors.right: parent.right
minimumValue: min
maximumValue: max
stepSize: step
tickmarksEnabled: true
property Fact fact: controller.getParameterFact(-1, param)
onValueChanged: {
if (_loadComplete) {
fact.value = value
}
}
}
} // Column
} // Repeater
} // Column
} // Rectangle
} // Flickable
} // QGCViewPanel
} // QGCView
......@@ -3,6 +3,7 @@ Module QGroundControl.Controls
ClickableColor 1.0 ClickableColor.qml
DropButton 1.0 DropButton.qml
ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml
FactSliderPanel 1.0 FactSliderPanel.qml
IndicatorButton 1.0 IndicatorButton.qml
JoystickThumbPad 1.0 JoystickThumbPad.qml
MainToolBar 1.0 MainToolBar.qml
......
......@@ -250,10 +250,12 @@
1 50 MC_PITCHRATE_I 0 9
1 50 MC_PITCHRATE_P 0.13 9
1 50 MC_PITCH_P 7 9
1 50 MC_PITCH_TC 0.200 9
1 50 MC_ROLLRATE_D 0.004 9
1 50 MC_ROLLRATE_I 0 9
1 50 MC_ROLLRATE_P 0.13 9
1 50 MC_ROLL_P 7 9
1 50 MC_ROLL_TC 0.200 9
1 50 MC_YAWRATE_D 0 9
1 50 MC_YAWRATE_I 0.25 9
1 50 MC_YAWRATE_MAX 120 9
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment