Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
524b8548
Commit
524b8548
authored
Nov 28, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Virtual joystick support
parent
7661b921
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
228 additions
and
42 deletions
+228
-42
qgroundcontrol.pro
qgroundcontrol.pro
+2
-0
qgroundcontrol.qrc
qgroundcontrol.qrc
+1
-0
FlightDisplayView.qml
src/FlightDisplay/FlightDisplayView.qml
+114
-1
QGCQuickWidget.cc
src/QGCQuickWidget.cc
+1
-0
JoystickThumbPad.qml
src/QmlControls/JoystickThumbPad.qml
+74
-0
QGroundControl.Controls.qmldir
src/QmlControls/QGroundControl.Controls.qmldir
+28
-34
Vehicle.cc
src/Vehicle/Vehicle.cc
+5
-0
Vehicle.h
src/Vehicle/Vehicle.h
+2
-1
UAS.cc
src/uas/UAS.cc
+0
-2
UAS.h
src/uas/UAS.h
+0
-2
GeneralSettings.qml
src/ui/preferences/GeneralSettings.qml
+1
-2
No files found.
qgroundcontrol.pro
View file @
524b8548
...
...
@@ -258,6 +258,7 @@ HEADERS += \
src
/
QGCFileDialog
.
h
\
src
/
QGCGeo
.
h
\
src
/
QGCLoggingCategory
.
h
\
src
/
QGCMapPalette
.
h
\
src
/
QGCMessageBox
.
h
\
src
/
QGCPalette
.
h
\
src
/
QGCQmlWidgetHolder
.
h
\
...
...
@@ -371,6 +372,7 @@ SOURCES += \
src
/
QGCDockWidget
.
cc
\
src
/
QGCFileDialog
.
cc
\
src
/
QGCLoggingCategory
.
cc
\
src
/
QGCMapPalette
.
cc
\
src
/
QGCPalette
.
cc
\
src
/
QGCQmlWidgetHolder
.
cpp
\
src
/
QGCQuickWidget
.
cc
\
...
...
qgroundcontrol.qrc
View file @
524b8548
...
...
@@ -32,6 +32,7 @@
<file alias="QGroundControl/Controls/DropButton.qml">src/QmlControls/DropButton.qml</file>
<file alias="QGroundControl/Controls/ExclusiveGroupItem.qml">src/QmlControls/ExclusiveGroupItem.qml</file>
<file alias="QGroundControl/Controls/IndicatorButton.qml">src/QmlControls/IndicatorButton.qml</file>
<file alias="QGroundControl/Controls/JoystickThumbPad.qml">src/QmlControls/JoystickThumbPad.qml</file>
<file alias="QGroundControl/Controls/MainToolBar.qml">src/ui/toolbar/MainToolBar.qml</file>
<file alias="QGroundControl/Controls/MainToolBarIndicators.qml">src/ui/toolbar/MainToolBarIndicators.qml</file>
<file alias="QGroundControl/Controls/MissionItemEditor.qml">src/QmlControls/MissionItemEditor.qml</file>
...
...
src/FlightDisplay/FlightDisplayView.qml
View file @
524b8548
...
...
@@ -21,7 +21,7 @@ This file is part of the QGROUNDCONTROL project
======================================================================*/
import
QtQuick
2.
4
import
QtQuick
2.
5
import
QtQuick
.
Controls
1.3
import
QtQuick
.
Controls
.
Styles
1.2
import
QtQuick
.
Dialogs
1.2
...
...
@@ -216,4 +216,117 @@ Item {
height
:
availableHeight
}
Item
{
id
:
multiTouchItem
anchors.left
:
parent
.
left
anchors.right
:
parent
.
right
anchors.bottom
:
parent
.
bottom
height
:
thumbAreaHeight
visible
:
QGroundControl
.
virtualTabletJoystick
readonly
property
real
thumbAreaHeight
:
parent
.
height
/
4
QGCMapPalette
{
id
:
mapPal
;
lightColors
:
!
isBackgroundDark
}
Component.onCompleted
:
console
.
log
(
"
test
"
,
mapPal
)
MultiPointTouchArea
{
anchors.fill
:
parent
maximumTouchPoints
:
2
property
var
leftRect
:
Qt
.
rect
(
0
,
0
,
parent
.
thumbAreaHeight
,
parent
.
thumbAreaHeight
)
property
var
rightRect
:
Qt
.
rect
(
parent
.
width
-
parent
.
thumbAreaHeight
,
0
,
parent
.
thumbAreaHeight
,
parent
.
thumbAreaHeight
)
function
pointInRect
(
rect
,
point
)
{
return
point
.
x
>=
rect
.
x
&&
point
.
y
>=
rect
.
y
&&
point
.
x
<=
rect
.
x
+
rect
.
width
&&
point
.
y
<=
rect
.
y
+
rect
.
height
}
function
newTouchPoints
(
touchPoints
)
{
var
point1Location
=
0
var
point2Location
=
0
var
point1
if
(
touchPoints
.
length
>
0
)
{
point1
=
touchPoints
[
0
]
if
(
pointInRect
(
leftRect
,
point1
))
{
point1Location
=
-
1
}
else
if
(
pointInRect
(
rightRect
,
point1
))
{
point1Location
=
1
}
}
var
point2
if
(
touchPoints
.
length
==
2
)
{
point2
=
touchPoints
[
1
]
if
(
pointInRect
(
leftRect
,
point2
))
{
point2Location
=
-
1
}
else
if
(
pointInRect
(
rightRect
,
point2
))
{
point2Location
=
1
}
}
// Make sure points are not both in the same rect
if
(
point1Location
!=
point2Location
)
{
if
(
point1Location
!=
0
)
{
if
(
point1Location
==
-
1
)
{
leftStick
.
stickPosition
=
point1
}
else
{
rightStick
.
stickPosition
=
Qt
.
point
(
point1
.
x
-
(
multiTouchItem
.
width
-
multiTouchItem
.
thumbAreaHeight
),
point1
.
y
)
}
}
if
(
point2Location
!=
0
)
{
if
(
point2Location
==
-
1
)
{
rightStick
.
stickPosition
=
Qt
.
point
(
point2
.
x
-
(
multiTouchItem
.
width
-
multiTouchItem
.
thumbAreaHeight
),
point2
.
y
)
}
else
{
leftStick
.
stickPosition
=
point2
}
}
}
}
onPressed
:
newTouchPoints
(
touchPoints
)
onTouchUpdated
:
newTouchPoints
(
touchPoints
)
onReleased
:
{
leftStick
.
reCenter
()
rightStick
.
reCenter
()
}
}
Timer
{
interval
:
10
running
:
QGroundControl
.
virtualTabletJoystick
repeat
:
true
onTriggered
:
{
if
(
_activeVehicle
)
{
_activeVehicle
.
virtualTabletJoystickValue
(
rightStick
.
xAxis
,
rightStick
.
yAxis
,
leftStick
.
xAxis
,
leftStick
.
yAxis
)
}
}
}
JoystickThumbPad
{
id
:
leftStick
anchors.left
:
parent
.
left
anchors.bottom
:
parent
.
bottom
width
:
parent
.
thumbAreaHeight
height
:
parent
.
thumbAreaHeight
yAxisThrottle
:
true
lightColors
:
!
isBackgroundDark
}
JoystickThumbPad
{
id
:
rightStick
anchors.right
:
parent
.
right
anchors.bottom
:
parent
.
bottom
width
:
parent
.
thumbAreaHeight
height
:
parent
.
thumbAreaHeight
lightColors
:
!
isBackgroundDark
}
}
}
src/QGCQuickWidget.cc
View file @
524b8548
...
...
@@ -39,6 +39,7 @@
QGCQuickWidget
::
QGCQuickWidget
(
QWidget
*
parent
)
:
QQuickWidget
(
parent
)
{
setAttribute
(
Qt
::
WA_AcceptTouchEvents
);
rootContext
()
->
engine
()
->
addImportPath
(
"qrc:/qml"
);
rootContext
()
->
setContextProperty
(
"multiVehicleManager"
,
qgcApp
()
->
toolbox
()
->
multiVehicleManager
());
rootContext
()
->
setContextProperty
(
"joystickManager"
,
qgcApp
()
->
toolbox
()
->
joystickManager
());
...
...
src/QmlControls/JoystickThumbPad.qml
0 → 100644
View file @
524b8548
import
QtQuick
2.5
import
QtQuick
.
Controls
1.2
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
ScreenTools
1.0
Rectangle
{
radius
:
width
/
2
border.color
:
mapPal
.
thumbJoystick
border.width
:
2
color
:
"
transparent
"
property
alias
lightColors
:
mapPal
.
lightColors
/// true: use light colors from QGCMapPalette for drawing
property
var
stickPosition
:
Qt
.
point
(
0
,
0
)
property
real
xAxis
:
0
/// Value range [-1,1], negative values left stick, positive values right stick
property
real
yAxis
:
0
/// Value range [-1,1], negative values up stick, positive values down stick
property
bool
yAxisThrottle
:
false
/// true: yAxis used for throttle, range [1,0], positive value are stick up
property
bool
_stickCenteredOnce
:
false
QGCMapPalette
{
id
:
mapPal
}
onWidthChanged
:
{
if
(
!
_stickCenteredOnce
&&
width
!=
0
)
{
reCenter
()
}
}
onStickPositionChanged
:
{
var
xAxisTemp
=
stickPosition
.
x
/
width
xAxisTemp
*=
2.0
xAxisTemp
-=
1.0
xAxis
=
xAxisTemp
var
yAxisTemp
=
stickPosition
.
y
/
width
yAxisTemp
*=
2.0
yAxisTemp
-=
1.0
if
(
yAxisThrottle
)
{
yAxisTemp
=
((
yAxisTemp
*
-
1.0
)
/
2.0
)
+
0.5
}
yAxis
=
yAxisTemp
}
function
reCenter
()
{
stickPosition
=
Qt
.
point
(
width
/
2
,
width
/
2
)
}
Column
{
QGCLabel
{
text
:
xAxis
}
QGCLabel
{
text
:
yAxis
}
}
Rectangle
{
anchors.margins
:
parent
.
width
/
4
anchors.fill
:
parent
radius
:
width
/
2
border.color
:
mapPal
.
thumbJoystick
border.width
:
2
color
:
"
transparent
"
}
Rectangle
{
width
:
hatWidth
height
:
hatWidth
radius
:
hatWidthHalf
color
:
mapPal
.
thumbJoystick
x
:
stickPosition
.
x
-
hatWidthHalf
y
:
stickPosition
.
y
-
hatWidthHalf
readonly
property
real
hatWidth
:
ScreenTools
.
defaultFontPixelHeight
readonly
property
real
hatWidthHalf
:
ScreenTools
.
defaultFontPixelHeight
/
2
}
}
src/QmlControls/QGroundControl.Controls.qmldir
View file @
524b8548
Module QGroundControl.Controls
QGCLabel 1.0 QGCLabel.qml
QGCButton 1.0 QGCButton.qml
QGCRadioButton 1.0 QGCRadioButton.qml
QGCCheckBox 1.0 QGCCheckBox.qml
QGCTextField 1.0 QGCTextField.qml
QGCComboBox 1.0 QGCComboBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml
QGCToolBarButton 1.0 QGCToolBarButton.qml
QGCMovableItem 1.0 QGCMovableItem.qml
SubMenuButton 1.0 SubMenuButton.qml
IndicatorButton 1.0 IndicatorButton.qml
ClickableColor 1.0 ClickableColor.qml
DropButton 1.0 DropButton.qml
RoundButton 1.0 RoundButton.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml
ExclusiveGroupItem 1.0 ExclusiveGroupItem.qml
IndicatorButton 1.0 IndicatorButton.qml
JoystickThumbPad 1.0 JoystickThumbPad.qml
MainToolBar 1.0 MainToolBar.qml
MissionItemEditor 1.0 MissionItemEditor.qml
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml
ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml
ParameterEditor 1.0 ParameterEditor.qml
ParameterEditorDialog 1.0 ParameterEditorDialog.qml
ModeSwitchDisplay 1.0 ModeSwitchDisplay.qml
QGCButton 1.0 QGCButton.qml
QGCCheckBox 1.0 QGCCheckBox.qml
QGCColoredImage 1.0 QGCColoredImage.qml
QGCComboBox 1.0 QGCComboBox.qml
QGCLabel 1.0 QGCLabel.qml
QGCMovableItem 1.0 QGCMovableItem.qml
QGCRadioButton 1.0 QGCRadioButton.qml
QGCTextField 1.0 QGCTextField.qml
QGCToolBarButton 1.0 QGCToolBarButton.qml
QGCView 1.0 QGCView.qml
QGCViewPanel 1.0 QGCViewPanel.qml
QGCViewDialog 1.0 QGCViewDialog.qml
QGCViewMessage 1.0 QGCViewMessage.qml
MissionItemIndexLabel 1.0 MissionItemIndexLabel.qml
MissionItemEditor 1.0 MissionItemEditor.qml
MainToolBar 1.0 MainToolBar.qml
QGCViewPanel 1.0 QGCViewPanel.qml
RoundButton 1.0 RoundButton.qml
SignalStrength 1.0 SignalStrength.qml
ClickableColor 1.0 ClickableColor.qml
SubMenuButton 1.0 SubMenuButton.qml
VehicleRotationCal 1.0 VehicleRotationCal.qml
VehicleSummaryRow 1.0 VehicleSummaryRow.qml
ViewWidget 1.0 ViewWidget.qml
src/Vehicle/Vehicle.cc
View file @
524b8548
...
...
@@ -1074,3 +1074,8 @@ void Vehicle::_remoteControlRSSIChanged(uint8_t rssi)
emit
rcRSSIChanged
(
_rcRSSI
);
}
}
void
Vehicle
::
virtualTabletJoystickValue
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
)
{
_uas
->
setExternalControlSetpoint
(
roll
,
pitch
,
yaw
,
thrust
,
0
,
JoystickModeRC
);
}
src/Vehicle/Vehicle.h
View file @
524b8548
...
...
@@ -124,13 +124,14 @@ public:
// Called when the message drop-down is invoked to clear current count
Q_INVOKABLE
void
resetMessages
();
Q_INVOKABLE
void
virtualTabletJoystickValue
(
double
roll
,
double
pitch
,
double
yaw
,
double
thrust
);
// Property accessors
QGeoCoordinate
coordinate
(
void
)
{
return
_coordinate
;
}
bool
coordinateValid
(
void
)
{
return
_coordinateValid
;
}
QmlObjectListModel
*
missionItemsModel
(
void
);
typedef
enum
{
JoystickModeRC
,
///< Joystick emulates an RC Transmitter
JoystickModeAttitude
,
...
...
src/uas/UAS.cc
View file @
524b8548
...
...
@@ -1508,7 +1508,6 @@ void UAS::executeCommand(MAV_CMD command, int confirmation, float param1, float
* Set the manual control commands.
* This can only be done if the system has manual inputs enabled and is armed.
*/
#ifndef __mobile__
void
UAS
::
setExternalControlSetpoint
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
quint16
buttons
,
int
joystickMode
)
{
if
(
!
_vehicle
)
{
...
...
@@ -1690,7 +1689,6 @@ void UAS::setExternalControlSetpoint(float roll, float pitch, float yaw, float t
emit
attitudeThrustSetPointChanged
(
this
,
roll
,
pitch
,
yaw
,
thrust
,
QGC
::
groundTimeMilliseconds
());
}
}
#endif
#ifndef __mobile__
void
UAS
::
setManual6DOFControlCommands
(
double
x
,
double
y
,
double
z
,
double
roll
,
double
pitch
,
double
yaw
)
...
...
src/uas/UAS.h
View file @
524b8548
...
...
@@ -555,9 +555,7 @@ public slots:
void
stopLowBattAlarm
();
/** @brief Set the values for the manual control of the vehicle */
#ifndef __mobile__
void
setExternalControlSetpoint
(
float
roll
,
float
pitch
,
float
yaw
,
float
thrust
,
quint16
buttons
,
int
joystickMode
);
#endif
/** @brief Set the values for the 6dof manual control of the vehicle */
#ifndef __mobile__
...
...
src/ui/preferences/GeneralSettings.qml
View file @
524b8548
...
...
@@ -234,10 +234,9 @@ Rectangle {
//-----------------------------------------------------------------
//-- Virtual joystick settings
QGCCheckBox
{
text
:
"
Thumb Joystick (WIP - be careful!)
"
text
:
"
Virtual Joystick
"
checked
:
QGroundControl
.
virtualTabletJoystick
onClicked
:
QGroundControl
.
virtualTabletJoystick
=
checked
visible
:
ScreenTools
.
isMobile
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment