9 changed files with 293 additions and 2 deletions
@ -0,0 +1,86 @@
@@ -0,0 +1,86 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
|
||||
#include "PX4FlightBehavior.h" |
||||
#include "PX4AutoPilotPlugin.h" |
||||
#include "AirframeComponent.h" |
||||
|
||||
PX4FlightBehavior::PX4FlightBehavior(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) |
||||
: VehicleComponent(vehicle, autopilot, parent) |
||||
, _name(tr("Flight Behavior")) |
||||
{ |
||||
} |
||||
|
||||
QString PX4FlightBehavior::name() const |
||||
{ |
||||
return _name; |
||||
} |
||||
|
||||
QString PX4FlightBehavior::description() const |
||||
{ |
||||
return tr("Flight Behavior is used to configure flight characteristics."); |
||||
} |
||||
|
||||
QString PX4FlightBehavior::iconResource() const |
||||
{ |
||||
return "/qmlimages/TuningComponentIcon.png"; |
||||
} |
||||
|
||||
bool PX4FlightBehavior::requiresSetup() const |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
bool PX4FlightBehavior::setupComplete() const |
||||
{ |
||||
return true; |
||||
} |
||||
|
||||
QStringList PX4FlightBehavior::setupCompleteChangedTriggerList() const |
||||
{ |
||||
return QStringList(); |
||||
} |
||||
|
||||
QUrl PX4FlightBehavior::setupSource() const |
||||
{ |
||||
QString qmlFile; |
||||
|
||||
switch (_vehicle->vehicleType()) { |
||||
case MAV_TYPE_FIXED_WING: |
||||
qmlFile = ""; |
||||
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/PX4FlightBehaviorCopter.qml"; |
||||
break; |
||||
case MAV_TYPE_VTOL_DUOROTOR: |
||||
case MAV_TYPE_VTOL_QUADROTOR: |
||||
case MAV_TYPE_VTOL_TILTROTOR: |
||||
case MAV_TYPE_VTOL_RESERVED2: |
||||
case MAV_TYPE_VTOL_RESERVED3: |
||||
case MAV_TYPE_VTOL_RESERVED4: |
||||
case MAV_TYPE_VTOL_RESERVED5: |
||||
qmlFile = ""; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
|
||||
return QUrl::fromUserInput(qmlFile); |
||||
} |
||||
|
||||
QUrl PX4FlightBehavior::summaryQmlSource() const |
||||
{ |
||||
return QUrl(); |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
/****************************************************************************
|
||||
* |
||||
* (c) 2021 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
|
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
|
||||
#pragma once |
||||
|
||||
#include "VehicleComponent.h" |
||||
|
||||
class PX4FlightBehavior : public VehicleComponent |
||||
{ |
||||
Q_OBJECT |
||||
|
||||
public: |
||||
PX4FlightBehavior(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = nullptr); |
||||
|
||||
// Virtuals from VehicleComponent
|
||||
QStringList setupCompleteChangedTriggerList() const final; |
||||
|
||||
// Virtuals from VehicleComponent
|
||||
QString name() const final; |
||||
QString description() const final; |
||||
QString iconResource() const final; |
||||
bool requiresSetup() const final; |
||||
bool setupComplete() const final; |
||||
QUrl setupSource() const final; |
||||
QUrl summaryQmlSource() const final; |
||||
bool allowSetupWhileArmed() const final { return true; } |
||||
bool allowSetupWhileFlying() const final { return true; } |
||||
|
||||
private: |
||||
const QString _name; |
||||
}; |
@ -0,0 +1,155 @@
@@ -0,0 +1,155 @@
|
||||
/**************************************************************************** |
||||
* |
||||
* (c) 2021 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org> |
||||
* |
||||
* QGroundControl is licensed according to the terms in the file |
||||
* COPYING.md in the root of the source code directory. |
||||
* |
||||
****************************************************************************/ |
||||
|
||||
import QtQuick 2.3 |
||||
import QtQuick.Controls 1.2 |
||||
import QtQuick.Layouts 1.2 |
||||
|
||||
import QGroundControl 1.0 |
||||
import QGroundControl.FactSystem 1.0 |
||||
import QGroundControl.Controls 1.0 |
||||
import QGroundControl.Palette 1.0 |
||||
import QGroundControl.ScreenTools 1.0 |
||||
|
||||
SetupPage { |
||||
id: flightBehavior |
||||
pageComponent: pageComponent |
||||
property real _margins: ScreenTools.defaultFontPixelHeight |
||||
|
||||
FactPanelController { |
||||
id: controller |
||||
} |
||||
|
||||
QGCPalette { |
||||
id: qgcPal |
||||
} |
||||
|
||||
property Fact _sys_vehicle_resp: controller.getParameterFact(-1, "SYS_VEHICLE_RESP", false) |
||||
property Fact _mpc_xy_vel_all: controller.getParameterFact(-1, "MPC_XY_VEL_ALL", false) |
||||
property Fact _mpc_z_vel_all: controller.getParameterFact(-1, "MPC_Z_VEL_ALL", false) |
||||
|
||||
Component { |
||||
id: pageComponent |
||||
|
||||
Column { |
||||
|
||||
spacing: _margins |
||||
|
||||
Column { |
||||
visible: _sys_vehicle_resp |
||||
|
||||
QGCCheckBox { |
||||
id: responsivenessCheckbox |
||||
text: qsTr("Enable responsiveness slider (if enabled, acceleration limit parameters and others are automatically set)") |
||||
checked: _sys_vehicle_resp && _sys_vehicle_resp.value >= 0 |
||||
onClicked: { |
||||
if (checked) { |
||||
_sys_vehicle_resp.value = Math.abs(_sys_vehicle_resp.value) |
||||
} else { |
||||
_sys_vehicle_resp.value = -Math.abs(_sys_vehicle_resp.value) |
||||
} |
||||
} |
||||
} |
||||
|
||||
FactSliderPanel { |
||||
width: availableWidth |
||||
enabled: responsivenessCheckbox.checked |
||||
|
||||
sliderModel: ListModel { |
||||
id: responsivenessSlider |
||||
|
||||
ListElement { |
||||
title: qsTr("Responsiveness") |
||||
description: qsTr("A higher value makes the vehicle react faster. Be aware that this affects braking as well, and a combination of slow responsiveness with high maximum velocity will lead to long braking distances.") |
||||
param: "SYS_VEHICLE_RESP" |
||||
min: 0.01 |
||||
max: 1 |
||||
step: 0.01 |
||||
} |
||||
} |
||||
} |
||||
QGCLabel { |
||||
visible: _sys_vehicle_resp && _sys_vehicle_resp.value > 0.8 |
||||
color: qgcPal.warningText |
||||
text: "Warning: a high responsiveness requires a vehicle with large thrust-to-weight ratio. The vehicle might lose altitude otherwise." |
||||
} |
||||
} |
||||
|
||||
Column { |
||||
visible: _mpc_xy_vel_all |
||||
|
||||
QGCCheckBox { |
||||
id: xyVelCheckbox |
||||
text: qsTr("Enable horizontal velocity slider (if enabled, individual velocity limit parameters are automatically set)") |
||||
checked: _mpc_xy_vel_all ? (_mpc_xy_vel_all.value >= 0) : false |
||||
onClicked: { |
||||
if (checked) { |
||||
_mpc_xy_vel_all.value = Math.abs(_mpc_xy_vel_all.value) |
||||
} else { |
||||
_mpc_xy_vel_all.value = -Math.abs(_mpc_xy_vel_all.value) |
||||
} |
||||
} |
||||
} |
||||
|
||||
FactSliderPanel { |
||||
width: availableWidth |
||||
enabled: xyVelCheckbox.checked |
||||
|
||||
sliderModel: ListModel { |
||||
id: xyVelSlider |
||||
|
||||
ListElement { |
||||
title: qsTr("Horizontal velocity (m/s)") |
||||
description: qsTr("Limit the horizonal velocity (applies to all modes).") |
||||
param: "MPC_XY_VEL_ALL" |
||||
min: 0.5 |
||||
max: 20 |
||||
step: 0.5 |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
Column { |
||||
visible: _mpc_z_vel_all |
||||
|
||||
QGCCheckBox { |
||||
id: zVelCheckbox |
||||
text: qsTr("Enable vertical velocity slider (if enabled, individual velocity limit parameters are automatically set)") |
||||
checked: _mpc_z_vel_all && _mpc_z_vel_all.value >= 0 |
||||
onClicked: { |
||||
if (checked) { |
||||
_mpc_z_vel_all.value = Math.abs(_mpc_z_vel_all.value) |
||||
} else { |
||||
_mpc_z_vel_all.value = -Math.abs(_mpc_z_vel_all.value) |
||||
} |
||||
} |
||||
} |
||||
|
||||
FactSliderPanel { |
||||
width: availableWidth |
||||
enabled: zVelCheckbox.checked |
||||
|
||||
sliderModel: ListModel { |
||||
id: zVelSlider |
||||
|
||||
ListElement { |
||||
title: qsTr("Vertial velocity (m/s)") |
||||
description: qsTr("Limit the vertical velocity (applies to all modes).") |
||||
param: "MPC_Z_VEL_ALL" |
||||
min: 0.2 |
||||
max: 8 |
||||
step: 0.2 |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} // Column |
||||
} // Component - pageComponent |
||||
} // SetupPage |
Loading…
Reference in new issue