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
dca59af3
Commit
dca59af3
authored
Oct 10, 2015
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1942 from DonLakeFlyer/Joystick
Fix multi-joystick bugs and validation bug
parents
5dba401d
8849a2d7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
48 deletions
+38
-48
Joystick.cc
src/Joystick/Joystick.cc
+1
-1
JoystickConfig.qml
src/VehicleSetup/JoystickConfig.qml
+10
-1
JoystickConfigController.cc
src/VehicleSetup/JoystickConfigController.cc
+27
-41
JoystickConfigController.h
src/VehicleSetup/JoystickConfigController.h
+0
-5
No files found.
src/Joystick/Joystick.cc
View file @
dca59af3
...
...
@@ -334,7 +334,7 @@ void Joystick::run(void)
_lastButtonBits
=
newButtonBits
;
qCDebug
(
JoystickValuesLog
)
<<
"
roll:pitch:yaw:throttle"
<<
roll
<<
-
pitch
<<
yaw
<<
throttle
;
qCDebug
(
JoystickValuesLog
)
<<
"
name:roll:pitch:yaw:throttle"
<<
name
()
<<
roll
<<
-
pitch
<<
yaw
<<
throttle
;
emit
manualControl
(
roll
,
-
pitch
,
yaw
,
throttle
,
buttonPressedBits
,
_activeVehicle
->
joystickMode
());
}
...
...
src/VehicleSetup/JoystickConfig.qml
View file @
dca59af3
...
...
@@ -381,7 +381,16 @@ QGCView {
width
:
parent
.
width
-
activeJoystickLabel
.
width
-
parent
.
spacing
model
:
joystickManager
.
joystickNames
onActivated
:
_activeJoystick
.
setActiveJoystickName
(
textAt
(
index
))
onActivated
:
joystickManager
.
activeJoystickName
=
textAt
(
index
)
Component.onCompleted
:
{
var
index
=
joystickCombo
.
find
(
joystickManager
.
activeJoystickName
)
if
(
index
==
-
1
)
{
console
.
warn
(
"
Active joystick name not in combo
"
,
joystickManager
.
activeJoystickName
)
}
else
{
joystickCombo
.
currentIndex
=
index
}
}
}
}
...
...
src/VehicleSetup/JoystickConfigController.cc
View file @
dca59af3
...
...
@@ -54,8 +54,6 @@ const char* JoystickConfigController::_imageRollRight = "joystickRollRight.p
const
char
*
JoystickConfigController
::
_imagePitchUp
=
"joystickPitchUp.png"
;
const
char
*
JoystickConfigController
::
_imagePitchDown
=
"joystickPitchDown.png"
;
const
char
*
JoystickConfigController
::
_settingsGroup
=
"Joysticks"
;
JoystickConfigController
::
JoystickConfigController
(
void
)
:
_activeJoystick
(
NULL
)
,
_currentStep
(
-
1
)
...
...
@@ -71,21 +69,17 @@ JoystickConfigController::JoystickConfigController(void)
connect
(
joystickManager
,
&
JoystickManager
::
activeJoystickChanged
,
this
,
&
JoystickConfigController
::
_activeJoystickChanged
);
_activeJoystickChanged
(
joystickManager
->
activeJoystick
());
_loadSettings
();
_resetInternalCalibrationValues
();
_activeJoystick
->
startCalibrationMode
(
Joystick
::
CalibrationModeMonitor
);
}
void
JoystickConfigController
::
start
(
void
)
{
_stopCalibration
();
_setInternalCalibrationValuesFromSettings
();
}
JoystickConfigController
::~
JoystickConfigController
()
{
_activeJoystick
->
stopCalibrationMode
(
Joystick
::
CalibrationModeMonitor
);
_storeSettings
();
}
/// @brief Returns the state machine entry for the specified state.
...
...
@@ -460,7 +454,7 @@ void JoystickConfigController::_setInternalCalibrationValuesFromSettings(void)
info
->
axisMax
=
calibration
.
max
;
info
->
reversed
=
calibration
.
reversed
;
qCDebug
(
JoystickConfigControllerLog
)
<<
"Read settings
axis:min:max:trim:reversed"
<<
axis
<<
info
->
axisMin
<<
info
->
axisMax
<<
info
->
axisTrim
<<
info
->
reversed
;
qCDebug
(
JoystickConfigControllerLog
)
<<
"Read settings
name:axis:min:max:trim:reversed"
<<
joystick
->
name
()
<<
axis
<<
info
->
axisMin
<<
info
->
axisMax
<<
info
->
axisTrim
<<
info
->
reversed
;
}
for
(
int
function
=
0
;
function
<
Joystick
::
maxFunction
;
function
++
)
{
...
...
@@ -484,30 +478,29 @@ void JoystickConfigController::_validateCalibration(void)
if
(
chan
<
_axisCount
)
{
// Validate Min/Max values. Although the axis appears as available we still may
// not have good min/max/trim values for it. Set to defaults if needed.
if
(
info
->
axisMin
>
_calValidMinValue
||
info
->
axisMax
<
_calValidMaxValue
)
{
if
(
info
->
axisMin
<
_calValidMinValue
||
info
->
axisMax
>
_calValidMaxValue
)
{
qCDebug
(
JoystickConfigControllerLog
)
<<
"_validateCalibration resetting axis"
<<
chan
;
info
->
axisMin
=
_calDefaultMinValue
;
info
->
axisMax
=
_calDefaultMaxValue
;
info
->
axisTrim
=
info
->
axisMin
+
((
info
->
axisMax
-
info
->
axisMin
)
/
2
);
}
else
{
switch
(
_rgAxisInfo
[
chan
].
function
)
{
case
Joystick
:
:
throttleFunction
:
case
Joystick
:
:
yawFunction
:
case
Joystick
:
:
rollFunction
:
case
Joystick
:
:
pitchFunction
:
// Make sure trim is within min/max
if
(
info
->
axisTrim
<
info
->
axisMin
)
{
info
->
axisTrim
=
info
->
axisMin
;
}
else
if
(
info
->
axisTrim
>
info
->
axisMax
)
{
info
->
axisTrim
=
info
->
axisMax
;
}
break
;
default:
// Non-attitude control axiss have calculated trim
info
->
axisTrim
=
info
->
axisMin
+
((
info
->
axisMax
-
info
->
axisMin
)
/
2
);
break
;
}
}
switch
(
_rgAxisInfo
[
chan
].
function
)
{
case
Joystick
:
:
throttleFunction
:
case
Joystick
:
:
yawFunction
:
case
Joystick
:
:
rollFunction
:
case
Joystick
:
:
pitchFunction
:
// Make sure trim is within min/max
if
(
info
->
axisTrim
<
info
->
axisMin
)
{
info
->
axisTrim
=
info
->
axisMin
;
}
else
if
(
info
->
axisTrim
>
info
->
axisMax
)
{
info
->
axisTrim
=
info
->
axisMax
;
}
break
;
default:
// Non-attitude control axis have calculated trim
info
->
axisTrim
=
info
->
axisMin
+
((
info
->
axisMax
-
info
->
axisMin
)
/
2
);
break
;
}
}
else
{
// Unavailable axiss are set to defaults
...
...
@@ -610,20 +603,6 @@ void JoystickConfigController::_calSave(void)
_validateCalibration
();
}
void
JoystickConfigController
::
_loadSettings
(
void
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
}
void
JoystickConfigController
::
_storeSettings
(
void
)
{
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
}
void
JoystickConfigController
::
_setHelpImage
(
const
char
*
imageFile
)
{
QString
file
=
_imageFilePrefix
;
...
...
@@ -749,13 +728,20 @@ void JoystickConfigController::_signalAllAttiudeValueChanges(void)
void
JoystickConfigController
::
_activeJoystickChanged
(
Joystick
*
joystick
)
{
bool
joystickTransition
=
false
;
if
(
_activeJoystick
)
{
joystickTransition
=
true
;
disconnect
(
_activeJoystick
,
&
Joystick
::
rawAxisValueChanged
,
this
,
&
JoystickConfigController
::
_axisValueChanged
);
_activeJoystick
=
NULL
;
}
if
(
joystick
)
{
_activeJoystick
=
joystick
;
if
(
joystickTransition
)
{
_stopCalibration
();
}
_activeJoystick
->
startCalibrationMode
(
Joystick
::
CalibrationModeMonitor
);
connect
(
_activeJoystick
,
&
Joystick
::
rawAxisValueChanged
,
this
,
&
JoystickConfigController
::
_axisValueChanged
);
}
}
src/VehicleSetup/JoystickConfigController.h
View file @
dca59af3
...
...
@@ -197,9 +197,6 @@ private:
void
_setHelpImage
(
const
char
*
imageFile
);
void
_loadSettings
(
void
);
void
_storeSettings
(
void
);
void
_signalAllAttiudeValueChanges
(
void
);
// Member variables
...
...
@@ -216,8 +213,6 @@ private:
static
const
char
*
_imagePitchUp
;
static
const
char
*
_imagePitchDown
;
static
const
char
*
_settingsGroup
;
static
const
int
_updateInterval
;
///< Interval for ui update timer
int
_rgFunctionAxisMapping
[
Joystick
::
maxFunction
];
///< Maps from joystick function to axis index. _axisMax indicates axis not set for this function.
...
...
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