Commit 089860de authored by Gus Grubba's avatar Gus Grubba

Update UI

Add gimbal to external control signal
parent 3f474fcc
...@@ -56,7 +56,6 @@ ...@@ -56,7 +56,6 @@
<file alias="px4.png">resources/firmware/px4.png</file> <file alias="px4.png">resources/firmware/px4.png</file>
</qresource> </qresource>
<qresource prefix="/res/calibration"> <qresource prefix="/res/calibration">
<file alias="joystick.svg">resources/calibration/joystick/joystick.svg</file>
<file alias="accel_back.png">resources/calibration/accel_back.png</file> <file alias="accel_back.png">resources/calibration/accel_back.png</file>
<file alias="accel_down.png">resources/calibration/accel_down.png</file> <file alias="accel_down.png">resources/calibration/accel_down.png</file>
<file alias="accel_front.png">resources/calibration/accel_front.png</file> <file alias="accel_front.png">resources/calibration/accel_front.png</file>
...@@ -99,48 +98,4 @@ ...@@ -99,48 +98,4 @@
<qresource prefix="/opengl"> <qresource prefix="/opengl">
<file>resources/opengl/buglist.json</file> <file>resources/opengl/buglist.json</file>
</qresource> </qresource>
<qresource prefix="/qml/calibration/joystick/mode1">
<file alias="joystickCenter.png">resources/calibration/joystick/mode1/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode1/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode1/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode1/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode1/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode1/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode1/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode1/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode1/joystickYawRight.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode2">
<file alias="joystickCenter.png">resources/calibration/joystick/mode2/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode2/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode2/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode2/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode2/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode2/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode2/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode2/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode2/joystickYawRight.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode3">
<file alias="joystickCenter.png">resources/calibration/joystick/mode3/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode3/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode3/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode3/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode3/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode3/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode3/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode3/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode3/joystickYawRight.png</file>
</qresource>
<qresource prefix="/qml/calibration/joystick/mode4">
<file alias="joystickCenter.png">resources/calibration/joystick/mode4/joystickCenter.png</file>
<file alias="joystickPitchDown.png">resources/calibration/joystick/mode4/joystickPitchDown.png</file>
<file alias="joystickPitchUp.png">resources/calibration/joystick/mode4/joystickPitchUp.png</file>
<file alias="joystickRollLeft.png">resources/calibration/joystick/mode4/joystickRollLeft.png</file>
<file alias="joystickRollRight.png">resources/calibration/joystick/mode4/joystickRollRight.png</file>
<file alias="joystickThrottleDown.png">resources/calibration/joystick/mode4/joystickThrottleDown.png</file>
<file alias="joystickThrottleUp.png">resources/calibration/joystick/mode4/joystickThrottleUp.png</file>
<file alias="joystickYawLeft.png">resources/calibration/joystick/mode4/joystickYawLeft.png</file>
<file alias="joystickYawRight.png">resources/calibration/joystick/mode4/joystickYawRight.png</file>
</qresource>
</RCC> </RCC>
...@@ -38,6 +38,10 @@ ...@@ -38,6 +38,10 @@
<file alias="HealthPageWidget.qml">src/FlightMap/Widgets/HealthPageWidget.qml</file> <file alias="HealthPageWidget.qml">src/FlightMap/Widgets/HealthPageWidget.qml</file>
<file alias="HelpSettings.qml">src/ui/preferences/HelpSettings.qml</file> <file alias="HelpSettings.qml">src/ui/preferences/HelpSettings.qml</file>
<file alias="JoystickConfig.qml">src/VehicleSetup/JoystickConfig.qml</file> <file alias="JoystickConfig.qml">src/VehicleSetup/JoystickConfig.qml</file>
<file alias="JoystickConfigButtons.qml">src/VehicleSetup/JoystickConfigButtons.qml</file>
<file alias="JoystickConfigAdvanced.qml">src/VehicleSetup/JoystickConfigAdvanced.qml</file>
<file alias="JoystickConfigGeneral.qml">src/VehicleSetup/JoystickConfigGeneral.qml</file>
<file alias="JoystickConfigCalibration.qml">src/VehicleSetup/JoystickConfigCalibration.qml</file>
<file alias="LinkSettings.qml">src/ui/preferences/LinkSettings.qml</file> <file alias="LinkSettings.qml">src/ui/preferences/LinkSettings.qml</file>
<file alias="LogDownloadPage.qml">src/AnalyzeView/LogDownloadPage.qml</file> <file alias="LogDownloadPage.qml">src/AnalyzeView/LogDownloadPage.qml</file>
<file alias="LogReplaySettings.qml">src/ui/preferences/LogReplaySettings.qml</file> <file alias="LogReplaySettings.qml">src/ui/preferences/LogReplaySettings.qml</file>
...@@ -60,6 +64,7 @@ ...@@ -60,6 +64,7 @@
<file alias="QGCViewDialogContainer.qml">src/QmlControls/QGCViewDialogContainer.qml</file> <file alias="QGCViewDialogContainer.qml">src/QmlControls/QGCViewDialogContainer.qml</file>
<file alias="QGroundControl/Controls/AnalyzePage.qml">src/AnalyzeView/AnalyzePage.qml</file> <file alias="QGroundControl/Controls/AnalyzePage.qml">src/AnalyzeView/AnalyzePage.qml</file>
<file alias="QGroundControl/Controls/AppMessages.qml">src/QmlControls/AppMessages.qml</file> <file alias="QGroundControl/Controls/AppMessages.qml">src/QmlControls/AppMessages.qml</file>
<file alias="QGroundControl/Controls/AxisMonitor.qml">src/QmlControls/AxisMonitor.qml</file>
<file alias="QGroundControl/Controls/CameraCalc.qml">src/PlanView/CameraCalc.qml</file> <file alias="QGroundControl/Controls/CameraCalc.qml">src/PlanView/CameraCalc.qml</file>
<file alias="QGroundControl/Controls/CameraSection.qml">src/PlanView/CameraSection.qml</file> <file alias="QGroundControl/Controls/CameraSection.qml">src/PlanView/CameraSection.qml</file>
<file alias="QGroundControl/Controls/ClickableColor.qml">src/QmlControls/ClickableColor.qml</file> <file alias="QGroundControl/Controls/ClickableColor.qml">src/QmlControls/ClickableColor.qml</file>
......
...@@ -684,11 +684,9 @@ QString Joystick::getButtonAction(int button) ...@@ -684,11 +684,9 @@ QString Joystick::getButtonAction(int button)
QVariantList Joystick::buttonActions(void) QVariantList Joystick::buttonActions(void)
{ {
QVariantList list; QVariantList list;
for (int button=0; button<_totalButtonCount; button++) { for (int button=0; button<_totalButtonCount; button++) {
list += QVariant::fromValue(_rgButtonActions[button]); list += QVariant::fromValue(_rgButtonActions[button]);
} }
return list; return list;
} }
...@@ -703,13 +701,10 @@ void Joystick::setThrottleMode(int mode) ...@@ -703,13 +701,10 @@ void Joystick::setThrottleMode(int mode)
qCWarning(JoystickLog) << "Invalid throttle mode" << mode; qCWarning(JoystickLog) << "Invalid throttle mode" << mode;
return; return;
} }
_throttleMode = static_cast<ThrottleMode_t>(mode);
_throttleMode = (ThrottleMode_t)mode;
if (_throttleMode == ThrottleModeDownZero) { if (_throttleMode == ThrottleModeDownZero) {
setAccumulator(false); setAccumulator(false);
} }
_saveSettings(); _saveSettings();
emit throttleModeChanged(_throttleMode); emit throttleModeChanged(_throttleMode);
} }
...@@ -725,7 +720,6 @@ void Joystick::setNegativeThrust(bool allowNegative) ...@@ -725,7 +720,6 @@ void Joystick::setNegativeThrust(bool allowNegative)
return; return;
} }
_negativeThrust = allowNegative; _negativeThrust = allowNegative;
_saveSettings(); _saveSettings();
emit negativeThrustChanged(_negativeThrust); emit negativeThrustChanged(_negativeThrust);
} }
...@@ -738,7 +732,6 @@ float Joystick::exponential(void) ...@@ -738,7 +732,6 @@ float Joystick::exponential(void)
void Joystick::setExponential(float expo) void Joystick::setExponential(float expo)
{ {
_exponential = expo; _exponential = expo;
_saveSettings(); _saveSettings();
emit exponentialChanged(_exponential); emit exponentialChanged(_exponential);
} }
...@@ -751,7 +744,6 @@ bool Joystick::accumulator(void) ...@@ -751,7 +744,6 @@ bool Joystick::accumulator(void)
void Joystick::setAccumulator(bool accu) void Joystick::setAccumulator(bool accu)
{ {
_accumulator = accu; _accumulator = accu;
_saveSettings(); _saveSettings();
emit accumulatorChanged(_accumulator); emit accumulatorChanged(_accumulator);
} }
...@@ -764,7 +756,6 @@ bool Joystick::deadband(void) ...@@ -764,7 +756,6 @@ bool Joystick::deadband(void)
void Joystick::setDeadband(bool deadband) void Joystick::setDeadband(bool deadband)
{ {
_deadband = deadband; _deadband = deadband;
_saveSettings(); _saveSettings();
} }
...@@ -776,7 +767,6 @@ bool Joystick::circleCorrection(void) ...@@ -776,7 +767,6 @@ bool Joystick::circleCorrection(void)
void Joystick::setCircleCorrection(bool circleCorrection) void Joystick::setCircleCorrection(bool circleCorrection)
{ {
_circleCorrection = circleCorrection; _circleCorrection = circleCorrection;
_saveSettings(); _saveSettings();
emit circleCorrectionChanged(_circleCorrection); emit circleCorrectionChanged(_circleCorrection);
} }
...@@ -799,7 +789,6 @@ void Joystick::setFrequency(float val) ...@@ -799,7 +789,6 @@ void Joystick::setFrequency(float val)
void Joystick::setCalibrationMode(bool calibrating) void Joystick::setCalibrationMode(bool calibrating)
{ {
_calibrationMode = calibrating; _calibrationMode = calibrating;
if (calibrating && !isRunning()) { if (calibrating && !isRunning()) {
_pollingStartedForCalibration = true; _pollingStartedForCalibration = true;
startPolling(_multiVehicleManager->activeVehicle()); startPolling(_multiVehicleManager->activeVehicle());
...@@ -815,7 +804,6 @@ void Joystick::_buttonAction(const QString& action) ...@@ -815,7 +804,6 @@ void Joystick::_buttonAction(const QString& action)
if (!_activeVehicle || !_activeVehicle->joystickEnabled()) { if (!_activeVehicle || !_activeVehicle->joystickEnabled()) {
return; return;
} }
if (action == _buttonActionArm) { if (action == _buttonActionArm) {
_activeVehicle->setArmed(true); _activeVehicle->setArmed(true);
} else if (action == _buttonActionDisarm) { } else if (action == _buttonActionDisarm) {
......
import QtQuick 2.11
import QtQuick.Controls 2.4
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
Item {
property int axisValue: 0
property int deadbandValue: 0
property bool narrowIndicator: false
property color deadbandColor: "#8c161a"
property bool mapped: false
property bool reversed: false
property color __barColor: qgcPal.windowShade
// Bar
Rectangle {
id: bar
anchors.verticalCenter: parent.verticalCenter
width: parent.width
height: parent.height / 2
color: __barColor
}
// Deadband
Rectangle {
id: deadbandBar
anchors.verticalCenter: parent.verticalCenter
x: _deadbandPosition
width: _deadbandWidth
height: parent.height / 2
color: deadbandColor
visible: controller.deadbandToggle
property real _percentDeadband: ((2 * deadbandValue) / (32768.0 * 2))
property real _deadbandWidth: parent.width * _percentDeadband
property real _deadbandPosition: (parent.width - _deadbandWidth) / 2
}
// Center point
Rectangle {
anchors.horizontalCenter: parent.horizontalCenter
width: ScreenTools.defaultFontPixelWidth / 2
height: parent.height
color: qgcPal.window
}
// Indicator
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: parent.narrowIndicator ? height/6 : height
height: parent.height * 0.75
x: (reversed ? (parent.width - _indicatorPosition) : _indicatorPosition) - (width / 2)
radius: width / 2
color: qgcPal.text
visible: mapped
property real _percentAxisValue: ((axisValue + 32768.0) / (32768.0 * 2))
property real _indicatorPosition: parent.width * _percentAxisValue
}
QGCLabel {
anchors.fill: parent
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: qsTr("Not Mapped")
visible: !mapped
}
ColorAnimation {
id: barAnimation
target: bar
property: "color"
from: "yellow"
to: __barColor
duration: 1500
}
// Axis value debugger
/*
QGCLabel {
anchors.fill: parent
text: axisValue
}
*/
}
...@@ -2,6 +2,7 @@ Module QGroundControl.Controls ...@@ -2,6 +2,7 @@ Module QGroundControl.Controls
AnalyzePage 1.0 AnalyzePage.qml AnalyzePage 1.0 AnalyzePage.qml
AppMessages 1.0 AppMessages.qml AppMessages 1.0 AppMessages.qml
AxisMonitor 1.0 AxisMonitor.qml
CameraCalc 1.0 CameraCalc.qml CameraCalc 1.0 CameraCalc.qml
APMSubMotorDisplay 1.0 APMSubMotorDisplay.qml APMSubMotorDisplay 1.0 APMSubMotorDisplay.qml
CameraSection 1.0 CameraSection.qml CameraSection 1.0 CameraSection.qml
......
...@@ -2741,11 +2741,18 @@ void Vehicle::_remoteControlRSSIChanged(uint8_t rssi) ...@@ -2741,11 +2741,18 @@ void Vehicle::_remoteControlRSSIChanged(uint8_t rssi)
} }
} }
void Vehicle::virtualTabletJoystickValue(double roll, double pitch, double yaw, double thrust) void Vehicle::virtualTabletJoystickValue(double roll, double pitch, double yaw, double thrust, double gimbalPitch, double gimbalYaw)
{ {
// The following if statement prevents the virtualTabletJoystick from sending values if the standard joystick is enabled // The following if statement prevents the virtualTabletJoystick from sending values if the standard joystick is enabled
if ( !_joystickEnabled && !_highLatencyLink) { if ( !_joystickEnabled && !_highLatencyLink) {
_uas->setExternalControlSetpoint(roll, pitch, yaw, thrust, 0, JoystickModeRC); _uas->setExternalControlSetpoint(
static_cast<float>(roll),
static_cast<float>(pitch),
static_cast<float>(yaw),
static_cast<float>(thrust),
static_cast<float>(gimbalPitch),
static_cast<float>(gimbalYaw),
0, JoystickModeRC);
} }
} }
......
...@@ -697,7 +697,7 @@ public: ...@@ -697,7 +697,7 @@ public:
// Called when the message drop-down is invoked to clear current count // Called when the message drop-down is invoked to clear current count
Q_INVOKABLE void resetMessages(); Q_INVOKABLE void resetMessages();
Q_INVOKABLE void virtualTabletJoystickValue(double roll, double pitch, double yaw, double thrust); Q_INVOKABLE void virtualTabletJoystickValue(double roll, double pitch, double yaw, double thrust, double gimbalPitch = 0, double gimbalYaw = 0);
Q_INVOKABLE void disconnectInactiveVehicle(void); Q_INVOKABLE void disconnectInactiveVehicle(void);
/// Command vehicle to return to launch /// Command vehicle to return to launch
......
This diff is collapsed.
/****************************************************************************
*
* (c) 2009-2016 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.11
import QtQuick.Controls 2.4
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.11
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Item {
width: grid.width + (ScreenTools.defaultFontPixelWidth * 2)
height: grid.height + (ScreenTools.defaultFontPixelHeight * 2)
//---------------------------------------------------------------------
GridLayout {
id: grid
columns: 2
columnSpacing: ScreenTools.defaultFontPixelWidth
rowSpacing: ScreenTools.defaultFontPixelHeight
anchors.centerIn: parent
//-------------------------------------------------------------
//-------------------------------------------------------------
QGCRadioButton {
text: qsTr("Full down stick is zero throttle")
checked: _activeJoystick ? _activeJoystick.throttleMode === 1 : false
onClicked: _activeJoystick.throttleMode = 1
Layout.columnSpan: 2
}
QGCRadioButton {
text: qsTr("Center stick is zero throttle")
checked: _activeJoystick ? _activeJoystick.throttleMode === 0 : false
onClicked: _activeJoystick.throttleMode = 0
Layout.columnSpan: 2
}
//-------------------------------------------------------------
QGCLabel {
text: qsTr("Spring loaded throttle smoothing")
visible: _activeJoystick ? _activeJoystick.throttleMode === 0 : false
Layout.alignment: Qt.AlignVCenter
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 36
}
QGCCheckBox {
checked: _activeJoystick ? _activeJoystick.accumulator : false
visible: _activeJoystick ? _activeJoystick.throttleMode === 0 : false
onClicked: _activeJoystick.accumulator = checked
}
//-------------------------------------------------------------
QGCLabel {
text: qsTr("Allow negative Thrust")
visible: activeVehicle.supportsNegativeThrust
Layout.alignment: Qt.AlignVCenter
}
QGCCheckBox {
visible: activeVehicle.supportsNegativeThrust
enabled: _activeJoystick.negativeThrust = activeVehicle.supportsNegativeThrust
checked: _activeJoystick ? _activeJoystick.negativeThrust : false
onClicked: _activeJoystick.negativeThrust = checked
}
//---------------------------------------------------------------------
QGCLabel {
text: qsTr("Exponential:")
}
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCSlider {
id: expoSlider
width: ScreenTools.defaultFontPixelWidth * 20
minimumValue: 0
maximumValue: 0.75
Component.onCompleted: value = -_activeJoystick.exponential
onValueChanged: _activeJoystick.exponential = -value
}
QGCLabel {
id: expoSliderIndicator
text: expoSlider.value.toFixed(2)
}
}
//-----------------------------------------------------------------
//-- Enable Advanced Mode
QGCLabel {
text: qsTr("Enable further advanced settings (careful!)")
Layout.alignment: Qt.AlignVCenter
Layout.minimumWidth: ScreenTools.defaultFontPixelWidth * 36
}
QGCCheckBox {
id: advancedSettings
checked: activeVehicle.joystickMode !== 0
onClicked: {
if (!checked) {
activeVehicle.joystickMode = 0
}
}
}
//-----------------------------------------------------------------
//-- Mode
QGCLabel {
Layout.alignment: Qt.AlignVCenter
text: qsTr("Joystick mode:")
visible: advancedSettings.checked
}
QGCComboBox {
enabled: advancedSettings.checked
currentIndex: activeVehicle.joystickMode
width: ScreenTools.defaultFontPixelWidth * 20
model: activeVehicle.joystickModes
onActivated: activeVehicle.joystickMode = index
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Message Frequency
QGCLabel {
text: qsTr("Message frequency (Hz):")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCTextField {
text: _activeJoystick.frequency
enabled: advancedSettings.checked
validator: DoubleValidator { bottom: 0.25; top: 100.0; }
inputMethodHints: Qt.ImhFormattedNumbersOnly
Layout.alignment: Qt.AlignVCenter
onEditingFinished: {
_activeJoystick.frequency = parseFloat(text)
}
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Enable circle correction
QGCLabel {
text: qsTr("Enable circle correction")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCCheckBox {
checked: activeVehicle.joystickMode !== 0
enabled: advancedSettings.checked
Component.onCompleted: {
checked = _activeJoystick.circleCorrection
}
onClicked: {
_activeJoystick.circleCorrection = checked
}
visible: advancedSettings.checked
}
//-----------------------------------------------------------------
//-- Deadband
QGCLabel {
text: qsTr("Deadbands")
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCCheckBox {
enabled: advancedSettings.checked
checked: controller.deadbandToggle
onClicked: controller.deadbandToggle = checked
Layout.alignment: Qt.AlignVCenter
visible: advancedSettings.checked
}
QGCLabel{
Layout.fillWidth: true
Layout.columnSpan: 2
font.pointSize: ScreenTools.smallFontPointSize
wrapMode: Text.WordWrap
visible: advancedSettings.checked
text: qsTr("Deadband can be set during the first ") +
qsTr("step of calibration by gently wiggling each axis. ") +
qsTr("Deadband can also be adjusted by clicking and ") +
qsTr("dragging vertically on the corresponding axis monitor.")
}
}
}
/****************************************************************************
*
* (c) 2009-2016 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.11
import QtQuick.Controls 2.4
import QtQuick.Dialogs 1.3
import QtQuick.Layouts 1.11
import QGroundControl 1.0
import QGroundControl.Palette 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
Item {
width: availableWidth
height: (activeVehicle.supportsJSButton ? buttonCol.height : buttonFlow.height) + (ScreenTools.defaultFontPixelHeight * 2)
Connections {
target: _activeJoystick
onRawButtonPressedChanged: {
if (buttonActionRepeater.itemAt(index)) {
buttonActionRepeater.itemAt(index).pressed = pressed
}
if (jsButtonActionRepeater.itemAt(index)) {
jsButtonActionRepeater.itemAt(index).pressed = pressed
}
}
}
Flow {
id: buttonFlow
width: parent.width
spacing: ScreenTools.defaultFontPixelWidth
visible: !activeVehicle.supportsJSButton
anchors.centerIn: parent
Repeater {
id: buttonActionRepeater
model: _activeJoystick ? Math.min(_activeJoystick.totalButtonCount, _maxButtons) : []
Row {
spacing: ScreenTools.defaultFontPixelWidth
property bool pressed
QGCCheckBox {
anchors.verticalCenter: parent.verticalCenter
checked: _activeJoystick ? _activeJoystick.buttonActions[modelData] !== "" : false
onClicked: _activeJoystick.setButtonAction(modelData, checked ? buttonActionCombo.textAt(buttonActionCombo.currentIndex) : "")
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5
height: width
border.width: 1
border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button
QGCLabel {
anchors.fill: parent
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData
}
}
QGCComboBox {
id: buttonActionCombo
width: ScreenTools.defaultFontPixelWidth * 20
model: _activeJoystick ? _activeJoystick.actions : 0
onActivated: _activeJoystick.setButtonAction(modelData, textAt(index))
Component.onCompleted: currentIndex = find(_activeJoystick.buttonActions[modelData])
}
}
}
}
Column {
id: buttonCol
width: parent.width
visible: activeVehicle.supportsJSButton
spacing: ScreenTools.defaultFontPixelHeight / 3
Row {
spacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
horizontalAlignment: Text.AlignHCenter
width: ScreenTools.defaultFontPixelHeight * 1.5
text: qsTr("#")
}
QGCLabel {
width: ScreenTools.defaultFontPixelWidth * 15
text: qsTr("Function: ")
}
QGCLabel {
width: ScreenTools.defaultFontPixelWidth * 15
text: qsTr("Shift Function: ")
}
}
Repeater {
id: jsButtonActionRepeater
model: _activeJoystick ? Math.min(_activeJoystick.totalButtonCount, _maxButtons) : 0
Row {
spacing: ScreenTools.defaultFontPixelWidth
visible: activeVehicle.supportsJSButton
property bool pressed
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: ScreenTools.defaultFontPixelHeight * 1.5
height: width
border.width: 1
border.color: qgcPal.text
color: pressed ? qgcPal.buttonHighlight : qgcPal.button
QGCLabel {
anchors.fill: parent
color: pressed ? qgcPal.buttonHighlightText : qgcPal.buttonText
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData
}
}
FactComboBox {
id: mainJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_FUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_FUNCTION") : null;
indexModel: false
}
FactComboBox {
id: shiftJSButtonActionCombo
width: ScreenTools.defaultFontPixelWidth * 15
fact: controller.parameterExists(-1, "BTN"+index+"_SFUNCTION") ? controller.getParameterFact(-1, "BTN" + index + "_SFUNCTION") : null;
indexModel: false
}
}
}
}
}
This diff is collapsed.
...@@ -28,21 +28,6 @@ const int JoystickConfigController::_calMinDelta = 1000; ///< Amo ...@@ -28,21 +28,6 @@ const int JoystickConfigController::_calMinDelta = 1000; ///< Amo
const int JoystickConfigController::_stickDetectSettleMSecs = 500; const int JoystickConfigController::_stickDetectSettleMSecs = 500;
const char* JoystickConfigController::_imageFilePrefix = "calibration/joystick/";
const char* JoystickConfigController::_imageFileMode1Dir = "mode1/";
const char* JoystickConfigController::_imageFileMode2Dir = "mode2/";
const char* JoystickConfigController::_imageFileMode3Dir = "mode3/";
const char* JoystickConfigController::_imageFileMode4Dir = "mode4/";
const char* JoystickConfigController::_imageCenter = "joystickCenter.png";
const char* JoystickConfigController::_imageThrottleUp = "joystickThrottleUp.png";
const char* JoystickConfigController::_imageThrottleDown = "joystickThrottleDown.png";
const char* JoystickConfigController::_imageYawLeft = "joystickYawLeft.png";
const char* JoystickConfigController::_imageYawRight = "joystickYawRight.png";
const char* JoystickConfigController::_imageRollLeft = "joystickRollLeft.png";
const char* JoystickConfigController::_imageRollRight = "joystickRollRight.png";
const char* JoystickConfigController::_imagePitchUp = "joystickPitchUp.png";
const char* JoystickConfigController::_imagePitchDown = "joystickPitchDown.png";
static const JoystickConfigController::stateStickPositions stSticksCentered { static const JoystickConfigController::stateStickPositions stSticksCentered {
0.25, 0.5, 0.75, 0.5 0.25, 0.5, 0.75, 0.5
}; };
...@@ -137,7 +122,7 @@ JoystickConfigController::~JoystickConfigController() ...@@ -137,7 +122,7 @@ JoystickConfigController::~JoystickConfigController()
/// @brief Returns the state machine entry for the specified state. /// @brief Returns the state machine entry for the specified state.
const JoystickConfigController::stateMachineEntry* JoystickConfigController::_getStateMachineEntry(int step) const JoystickConfigController::stateMachineEntry* JoystickConfigController::_getStateMachineEntry(int step)
{ {
static const char* msgBegin = "Allow all sticks to center as shown in diagram.\n\nClick Next to continue"; static const char* msgBegin = "Allow all sticks to center as shown in diagram.\nClick Next to continue";
static const char* msgThrottleUp = "Move the Throttle stick all the way up and hold it there..."; static const char* msgThrottleUp = "Move the Throttle stick all the way up and hold it there...";
static const char* msgThrottleDown = "Move the Throttle stick all the way down and hold it there..."; static const char* msgThrottleDown = "Move the Throttle stick all the way down and hold it there...";
static const char* msgYawLeft = "Move the Yaw stick all the way to the left and hold it there..."; static const char* msgYawLeft = "Move the Yaw stick all the way to the left and hold it there...";
...@@ -151,7 +136,7 @@ const JoystickConfigController::stateMachineEntry* JoystickConfigController::_ge ...@@ -151,7 +136,7 @@ const JoystickConfigController::stateMachineEntry* JoystickConfigController::_ge
static const char* msgGimbalPitchUp = "Move the Gimbal Pitch control all the way up and hold it there..."; static const char* msgGimbalPitchUp = "Move the Gimbal Pitch control all the way up and hold it there...";
static const char* msgGimbalYawLeft = "Move the Gimbal Yaw control all the way to the left and hold it there..."; static const char* msgGimbalYawLeft = "Move the Gimbal Yaw control all the way to the left and hold it there...";
static const char* msgGimbalYawRight = "Move the Gimbal Yaw control all the way to the right and hold it there..."; static const char* msgGimbalYawRight = "Move the Gimbal Yaw control all the way to the right and hold it there...";
static const char* msgComplete = "All settings have been captured. Click Next to enable the joystick."; static const char* msgComplete = "All settings have been captured.\nClick Next to enable the joystick.";
static const stateMachineEntry rgStateMachine[] = { static const stateMachineEntry rgStateMachine[] = {
//Function //Function
...@@ -189,6 +174,24 @@ void JoystickConfigController::_advanceState() ...@@ -189,6 +174,24 @@ void JoystickConfigController::_advanceState()
_setupCurrentState(); _setupCurrentState();
} }
bool JoystickConfigController::nextEnabled()
{
if(_currentStep >= 0) {
const stateMachineEntry* state = _getStateMachineEntry(_currentStep);
return state->nextFn != nullptr;
}
return false;
}
bool JoystickConfigController::skipEnabled()
{
if(_currentStep >= 0) {
const stateMachineEntry* state = _getStateMachineEntry(_currentStep);
return state->skipFn != nullptr;
}
return false;
}
/// @brief Sets up the state machine according to the current step from _currentStep. /// @brief Sets up the state machine according to the current step from _currentStep.
void JoystickConfigController::_setupCurrentState() void JoystickConfigController::_setupCurrentState()
{ {
...@@ -197,14 +200,14 @@ void JoystickConfigController::_setupCurrentState() ...@@ -197,14 +200,14 @@ void JoystickConfigController::_setupCurrentState()
_stickDetectAxis = _axisNoAxis; _stickDetectAxis = _axisNoAxis;
_stickDetectSettleStarted = false; _stickDetectSettleStarted = false;
_calSaveCurrentValues(); _calSaveCurrentValues();
_nextButton->setEnabled(state->nextFn != nullptr);
_skipButton->setEnabled(state->skipFn != nullptr);
_currentStickPositions.clear(); _currentStickPositions.clear();
_currentStickPositions << state->stickPositions.leftX << state->stickPositions.leftY << state->stickPositions.rightX << state->stickPositions.rightY; _currentStickPositions << state->stickPositions.leftX << state->stickPositions.leftY << state->stickPositions.rightX << state->stickPositions.rightY;
_currentGimbalPositions.clear(); _currentGimbalPositions.clear();
_currentGimbalPositions << state->gimbalPositions.leftX << state->gimbalPositions.leftY << state->gimbalPositions.rightX << state->gimbalPositions.rightY; _currentGimbalPositions << state->gimbalPositions.leftX << state->gimbalPositions.leftY << state->gimbalPositions.rightX << state->gimbalPositions.rightY;
emit stickPositionsChanged(); emit stickPositionsChanged();
emit gimbalPositionsChanged(); emit gimbalPositionsChanged();
emit nextEnabledChanged();
emit skipEnabledChanged();
} }
void JoystickConfigController::_axisValueChanged(int axis, int value) void JoystickConfigController::_axisValueChanged(int axis, int value)
...@@ -300,7 +303,6 @@ void JoystickConfigController::_inputCenterWaitBegin(Joystick::AxisFunction_t fu ...@@ -300,7 +303,6 @@ void JoystickConfigController::_inputCenterWaitBegin(Joystick::AxisFunction_t fu
if ((abs(value) * 1.1f > _rgAxisInfo[axis].deadband) && (_activeJoystick->deadband())) { //add 10% on top of existing deadband if ((abs(value) * 1.1f > _rgAxisInfo[axis].deadband) && (_activeJoystick->deadband())) { //add 10% on top of existing deadband
_axisDeadbandChanged(axis, static_cast<int>(abs(value) * 1.1f)); _axisDeadbandChanged(axis, static_cast<int>(abs(value) * 1.1f));
} }
_nextButton->setEnabled(true);
// FIXME: Doesn't wait for center // FIXME: Doesn't wait for center
} }
...@@ -588,8 +590,6 @@ void JoystickConfigController::_startCalibration() ...@@ -588,8 +590,6 @@ void JoystickConfigController::_startCalibration()
{ {
_activeJoystick->setCalibrationMode(true); _activeJoystick->setCalibrationMode(true);
_resetInternalCalibrationValues(); _resetInternalCalibrationValues();
_nextButton->setProperty("text", "Next");
_cancelButton->setEnabled(true);
_currentStep = 0; _currentStep = 0;
_setupCurrentState(); _setupCurrentState();
emit calibratingChanged(); emit calibratingChanged();
...@@ -602,11 +602,13 @@ void JoystickConfigController::_stopCalibration() ...@@ -602,11 +602,13 @@ void JoystickConfigController::_stopCalibration()
_activeJoystick->setCalibrationMode(false); _activeJoystick->setCalibrationMode(false);
_setInternalCalibrationValuesFromSettings(); _setInternalCalibrationValuesFromSettings();
_setStatusText(""); _setStatusText("");
_nextButton->setProperty("text", tr("Calibrate"));
_nextButton->setEnabled(true);
_cancelButton->setEnabled(false);
_skipButton->setEnabled(false);
emit calibratingChanged(); emit calibratingChanged();
_currentStickPositions.clear();
_currentGimbalPositions.clear();
_currentStickPositions << _sticksCentered.leftX << _sticksCentered.leftY << _sticksCentered.rightX << _sticksCentered.rightY;
_currentGimbalPositions << stGimbalCentered.leftX << stGimbalCentered.leftY << stGimbalCentered.rightX << stGimbalCentered.rightY;
emit stickPositionsChanged();
emit gimbalPositionsChanged();
} }
/// @brief Saves the current axis values, so that we can detect when the use moves an input. /// @brief Saves the current axis values, so that we can detect when the use moves an input.
...@@ -618,22 +620,6 @@ void JoystickConfigController::_calSaveCurrentValues() ...@@ -618,22 +620,6 @@ void JoystickConfigController::_calSaveCurrentValues()
} }
} }
/// @brief Set up the Save state of calibration.
void JoystickConfigController::_calSave()
{
_calState = calStateSave;
_setStatusText(tr(
"The current calibration settings are now displayed for each axis on screen.\n\n"
"Click the Next button to upload calibration to board. Click Cancel if you don't want to save these values."));
_nextButton->setEnabled(true);
_skipButton->setEnabled(false);
_cancelButton->setEnabled(true);
// This updates the internal values according to the validation rules. Then _updateView will tick and update ui
// such that the settings that will be written out are displayed.
_validateCalibration();
}
void JoystickConfigController::_setStickPositions() void JoystickConfigController::_setStickPositions()
{ {
_sticksCentered = stSticksCentered; _sticksCentered = stSticksCentered;
......
...@@ -41,10 +41,6 @@ public: ...@@ -41,10 +41,6 @@ public:
Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged) Q_PROPERTY(QString statusText READ statusText NOTIFY statusTextChanged)
Q_PROPERTY(QQuickItem* cancelButton MEMBER _cancelButton)
Q_PROPERTY(QQuickItem* nextButton MEMBER _nextButton)
Q_PROPERTY(QQuickItem* skipButton MEMBER _skipButton)
Q_PROPERTY(bool rollAxisMapped READ rollAxisMapped NOTIFY rollAxisMappedChanged) Q_PROPERTY(bool rollAxisMapped READ rollAxisMapped NOTIFY rollAxisMappedChanged)
Q_PROPERTY(bool pitchAxisMapped READ pitchAxisMapped NOTIFY pitchAxisMappedChanged) Q_PROPERTY(bool pitchAxisMapped READ pitchAxisMapped NOTIFY pitchAxisMappedChanged)
Q_PROPERTY(bool yawAxisMapped READ yawAxisMapped NOTIFY yawAxisMappedChanged) Q_PROPERTY(bool yawAxisMapped READ yawAxisMapped NOTIFY yawAxisMappedChanged)
...@@ -66,6 +62,8 @@ public: ...@@ -66,6 +62,8 @@ public:
Q_PROPERTY(int transmitterMode READ transmitterMode WRITE setTransmitterMode NOTIFY transmitterModeChanged) Q_PROPERTY(int transmitterMode READ transmitterMode WRITE setTransmitterMode NOTIFY transmitterModeChanged)
Q_PROPERTY(bool calibrating READ calibrating NOTIFY calibratingChanged) Q_PROPERTY(bool calibrating READ calibrating NOTIFY calibratingChanged)
Q_PROPERTY(bool nextEnabled READ nextEnabled NOTIFY nextEnabledChanged)
Q_PROPERTY(bool skipEnabled READ skipEnabled NOTIFY skipEnabledChanged)
Q_PROPERTY(QList<qreal> stickPositions READ stickPositions NOTIFY stickPositionsChanged) Q_PROPERTY(QList<qreal> stickPositions READ stickPositions NOTIFY stickPositionsChanged)
Q_PROPERTY(QList<qreal> gimbalPositions READ gimbalPositions NOTIFY gimbalPositionsChanged) Q_PROPERTY(QList<qreal> gimbalPositions READ gimbalPositions NOTIFY gimbalPositionsChanged)
...@@ -103,6 +101,8 @@ public: ...@@ -103,6 +101,8 @@ public:
void setTransmitterMode (int mode); void setTransmitterMode (int mode);
bool calibrating () { return _currentStep != -1; } bool calibrating () { return _currentStep != -1; }
bool nextEnabled ();
bool skipEnabled ();
QList<qreal> stickPositions () { return _currentStickPositions; } QList<qreal> stickPositions () { return _currentStickPositions; }
QList<qreal> gimbalPositions () { return _currentGimbalPositions; } QList<qreal> gimbalPositions () { return _currentGimbalPositions; }
...@@ -132,6 +132,8 @@ signals: ...@@ -132,6 +132,8 @@ signals:
void deadbandToggled (bool value); void deadbandToggled (bool value);
void transmitterModeChanged (int mode); void transmitterModeChanged (int mode);
void calibratingChanged (); void calibratingChanged ();
void nextEnabledChanged ();
void skipEnabledChanged ();
void stickPositionsChanged (); void stickPositionsChanged ();
void gimbalPositionsChanged (); void gimbalPositionsChanged ();
void hasGimbalChanged (); void hasGimbalChanged ();
...@@ -213,7 +215,6 @@ private: ...@@ -213,7 +215,6 @@ private:
void _startCalibration (); void _startCalibration ();
void _stopCalibration (); void _stopCalibration ();
void _calSave ();
void _calSaveCurrentValues (); void _calSaveCurrentValues ();
...@@ -223,23 +224,6 @@ private: ...@@ -223,23 +224,6 @@ private:
void _setStatusText (const QString& text); void _setStatusText (const QString& text);
// Member variables
static const char* _imageFileMode1Dir;
static const char* _imageFileMode2Dir;
static const char* _imageFileMode3Dir;
static const char* _imageFileMode4Dir;
static const char* _imageFilePrefix;
static const char* _imageCenter;
static const char* _imageThrottleUp;
static const char* _imageThrottleDown;
static const char* _imageYawLeft;
static const char* _imageYawRight;
static const char* _imageRollLeft;
static const char* _imageRollRight;
static const char* _imagePitchUp;
static const char* _imagePitchDown;
stateStickPositions _sticksCentered; stateStickPositions _sticksCentered;
stateStickPositions _sticksThrottleUp; stateStickPositions _sticksThrottleUp;
stateStickPositions _sticksThrottleDown; stateStickPositions _sticksThrottleDown;
...@@ -286,14 +270,10 @@ private: ...@@ -286,14 +270,10 @@ private:
int _stickDetectValue; int _stickDetectValue;
bool _stickDetectSettleStarted; bool _stickDetectSettleStarted;
QTime _stickDetectSettleElapsed; QTime _stickDetectSettleElapsed;
static const int _stickDetectSettleMSecs;
QString _statusText; static const int _stickDetectSettleMSecs;
QQuickItem* _cancelButton = nullptr; QString _statusText;
QQuickItem* _nextButton = nullptr;
QQuickItem* _skipButton = nullptr;
JoystickManager* _joystickManager; JoystickManager* _joystickManager;
}; };
......
This diff is collapsed.
...@@ -839,8 +839,12 @@ void UAS::processParamValueMsg(mavlink_message_t& msg, const QString& paramName, ...@@ -839,8 +839,12 @@ void UAS::processParamValueMsg(mavlink_message_t& msg, const QString& paramName,
* Set the manual control commands. * Set the manual control commands.
* This can only be done if the system has manual inputs enabled and is armed. * This can only be done if the system has manual inputs enabled and is armed.
*/ */
void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float thrust, quint16 buttons, int joystickMode) void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float thrust, float gimbalPitch, float gimbalYaw, quint16 buttons, int joystickMode)
{ {
//-- TODO
Q_UNUSED(gimbalPitch);
Q_UNUSED(gimbalYaw);
if (!_vehicle) { if (!_vehicle) {
return; return;
} }
...@@ -997,11 +1001,11 @@ void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float t ...@@ -997,11 +1001,11 @@ void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float t
} else if (joystickMode == Vehicle::JoystickModeRC) { } else if (joystickMode == Vehicle::JoystickModeRC) {
// Save the new manual control inputs // Save the new manual control inputs
manualRollAngle = roll; manualRollAngle = roll;
manualPitchAngle = pitch; manualPitchAngle = pitch;
manualYawAngle = yaw; manualYawAngle = yaw;
manualThrust = thrust; manualThrust = thrust;
manualButtons = buttons; manualButtons = buttons;
// Store scaling values for all 3 axes // Store scaling values for all 3 axes
const float axesScaling = 1.0 * 1000.0; const float axesScaling = 1.0 * 1000.0;
...@@ -1009,19 +1013,22 @@ void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float t ...@@ -1009,19 +1013,22 @@ void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float t
// Calculate the new commands for roll, pitch, yaw, and thrust // Calculate the new commands for roll, pitch, yaw, and thrust
const float newRollCommand = roll * axesScaling; const float newRollCommand = roll * axesScaling;
// negate pitch value because pitch is negative for pitching forward but mavlink message argument is positive for forward // negate pitch value because pitch is negative for pitching forward but mavlink message argument is positive for forward
const float newPitchCommand = -pitch * axesScaling; const float newPitchCommand = -pitch * axesScaling;
const float newYawCommand = yaw * axesScaling; const float newYawCommand = yaw * axesScaling;
const float newThrustCommand = thrust * axesScaling; const float newThrustCommand = thrust * axesScaling;
//qDebug() << newRollCommand << newPitchCommand << newYawCommand << newThrustCommand;
// Send the MANUAL_COMMAND message // Send the MANUAL_COMMAND message
mavlink_msg_manual_control_pack_chan(mavlink->getSystemId(), mavlink_msg_manual_control_pack_chan(
mavlink->getComponentId(), static_cast<uint8_t>(mavlink->getSystemId()),
_vehicle->priorityLink()->mavlinkChannel(), static_cast<uint8_t>(mavlink->getComponentId()),
&message, _vehicle->priorityLink()->mavlinkChannel(),
this->uasId, &message,
newPitchCommand, newRollCommand, newThrustCommand, newYawCommand, buttons); static_cast<uint8_t>(this->uasId),
static_cast<int16_t>(newPitchCommand),
static_cast<int16_t>(newRollCommand),
static_cast<int16_t>(newThrustCommand),
static_cast<int16_t>(newYawCommand),
buttons);
} }
_vehicle->sendMessageOnLink(_vehicle->priorityLink(), message); _vehicle->sendMessageOnLink(_vehicle->priorityLink(), message);
......
...@@ -263,7 +263,7 @@ public slots: ...@@ -263,7 +263,7 @@ public slots:
#endif #endif
/** @brief Set the values for the manual control of the vehicle */ /** @brief Set the values for the manual control of the vehicle */
void setExternalControlSetpoint(float roll, float pitch, float yaw, float thrust, quint16 buttons, int joystickMode); void setExternalControlSetpoint(float roll, float pitch, float yaw, float thrust, float gimbalPitch, float gimbalYaw, quint16 buttons, int joystickMode);
/** @brief Set the values for the 6dof manual control of the vehicle */ /** @brief Set the values for the 6dof manual control of the vehicle */
#ifndef __mobile__ #ifndef __mobile__
......
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