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
85468e6b
Commit
85468e6b
authored
Jul 16, 2019
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Calibration of gimbal axis done.
parent
c5b75b70
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1078 additions
and
875 deletions
+1078
-875
Joystick.cc
src/Joystick/Joystick.cc
+30
-37
JoystickConfig.qml
src/VehicleSetup/JoystickConfig.qml
+833
-732
JoystickConfigController.cc
src/VehicleSetup/JoystickConfigController.cc
+163
-83
JoystickConfigController.h
src/VehicleSetup/JoystickConfigController.h
+52
-23
No files found.
src/Joystick/Joystick.cc
View file @
85468e6b
...
...
@@ -175,10 +175,8 @@ void Joystick::_activeVehicleChanged(Vehicle* activeVehicle)
void
Joystick
::
_loadSettings
()
{
QSettings
settings
;
QSettings
settings
;
settings
.
beginGroup
(
_settingsGroup
);
Vehicle
*
activeVehicle
=
_multiVehicleManager
->
activeVehicle
();
if
(
_txModeSettingsKey
&&
activeVehicle
)
...
...
@@ -191,25 +189,25 @@ void Joystick::_loadSettings()
qCDebug
(
JoystickLog
)
<<
"_loadSettings "
<<
_name
;
_calibrated
=
settings
.
value
(
_calibratedSettingsKey
,
false
).
toBool
();
_exponential
=
settings
.
value
(
_exponentialSettingsKey
,
0
).
toFloat
();
_accumulator
=
settings
.
value
(
_accumulatorSettingsKey
,
false
).
toBool
();
_deadband
=
settings
.
value
(
_deadbandSettingsKey
,
false
).
toBool
();
_calibrated
=
settings
.
value
(
_calibratedSettingsKey
,
false
).
toBool
();
_exponential
=
settings
.
value
(
_exponentialSettingsKey
,
0
).
toFloat
();
_accumulator
=
settings
.
value
(
_accumulatorSettingsKey
,
false
).
toBool
();
_deadband
=
settings
.
value
(
_deadbandSettingsKey
,
false
).
toBool
();
_frequency
=
settings
.
value
(
_frequencySettingsKey
,
25.0
f
).
toFloat
();
_circleCorrection
=
settings
.
value
(
_circleCorrectionSettingsKey
,
false
).
toBool
();
_frequency
=
settings
.
value
(
_frequencySettingsKey
,
25.0
f
).
toFloat
();
_throttleMode
=
(
ThrottleMode_t
)
settings
.
value
(
_throttleModeSettingsKey
,
ThrottleModeDownZero
).
toInt
(
&
convertOk
);
_throttleMode
=
static_cast
<
ThrottleMode_t
>
(
settings
.
value
(
_throttleModeSettingsKey
,
ThrottleModeDownZero
).
toInt
(
&
convertOk
)
);
badSettings
|=
!
convertOk
;
qCDebug
(
JoystickLog
)
<<
"_loadSettings calibrated:txmode:throttlemode:exponential:deadband:badsettings"
<<
_calibrated
<<
_transmitterMode
<<
_throttleMode
<<
_exponential
<<
_deadband
<<
badSettings
;
QString
minTpl
(
"Axis%1Min"
);
QString
maxTpl
(
"Axis%1Max"
);
QString
trimTpl
(
"Axis%1Trim"
);
QString
revTpl
(
"Axis%1Rev"
);
QString
minTpl
(
"Axis%1Min"
);
QString
maxTpl
(
"Axis%1Max"
);
QString
trimTpl
(
"Axis%1Trim"
);
QString
revTpl
(
"Axis%1Rev"
);
QString
deadbndTpl
(
"Axis%1Deadbnd"
);
for
(
int
axis
=
0
;
axis
<
_axisCount
;
axis
++
)
{
for
(
int
axis
=
0
;
axis
<
_axisCount
;
axis
++
)
{
Calibration_t
*
calibration
=
&
_rgCalibration
[
axis
];
calibration
->
center
=
settings
.
value
(
trimTpl
.
arg
(
axis
),
0
).
toInt
(
&
convertOk
);
...
...
@@ -226,7 +224,6 @@ void Joystick::_loadSettings()
calibration
->
reversed
=
settings
.
value
(
revTpl
.
arg
(
axis
),
false
).
toBool
();
qCDebug
(
JoystickLog
)
<<
"_loadSettings axis:min:max:trim:reversed:deadband:badsettings"
<<
axis
<<
calibration
->
min
<<
calibration
->
max
<<
calibration
->
center
<<
calibration
->
reversed
<<
calibration
->
deadband
<<
badSettings
;
}
...
...
@@ -268,31 +265,29 @@ void Joystick::_saveSettings()
settings
.
beginGroup
(
_name
);
settings
.
setValue
(
_calibratedSettingsKey
,
_calibrated
);
settings
.
setValue
(
_exponentialSettingsKey
,
_exponential
);
settings
.
setValue
(
_accumulatorSettingsKey
,
_accumulator
);
settings
.
setValue
(
_deadbandSettingsKey
,
_deadband
);
settings
.
setValue
(
_circleCorrectionSettingsKey
,
_circleCorrection
);
settings
.
setValue
(
_frequencySettingsKey
,
_frequency
);
settings
.
setValue
(
_calibratedSettingsKey
,
_calibrated
);
settings
.
setValue
(
_exponentialSettingsKey
,
_exponential
);
settings
.
setValue
(
_accumulatorSettingsKey
,
_accumulator
);
settings
.
setValue
(
_deadbandSettingsKey
,
_deadband
);
settings
.
setValue
(
_frequencySettingsKey
,
_frequency
);
settings
.
setValue
(
_throttleModeSettingsKey
,
_throttleMode
);
settings
.
setValue
(
_circleCorrectionSettingsKey
,
_circleCorrection
);
qCDebug
(
JoystickLog
)
<<
"_saveSettings calibrated:throttlemode:deadband:txmode"
<<
_calibrated
<<
_throttleMode
<<
_deadband
<<
_circleCorrection
<<
_transmitterMode
;
QString
minTpl
(
"Axis%1Min"
);
QString
maxTpl
(
"Axis%1Max"
);
QString
trimTpl
(
"Axis%1Trim"
);
QString
revTpl
(
"Axis%1Rev"
);
QString
minTpl
(
"Axis%1Min"
);
QString
maxTpl
(
"Axis%1Max"
);
QString
trimTpl
(
"Axis%1Trim"
);
QString
revTpl
(
"Axis%1Rev"
);
QString
deadbndTpl
(
"Axis%1Deadbnd"
);
for
(
int
axis
=
0
;
axis
<
_axisCount
;
axis
++
)
{
for
(
int
axis
=
0
;
axis
<
_axisCount
;
axis
++
)
{
Calibration_t
*
calibration
=
&
_rgCalibration
[
axis
];
settings
.
setValue
(
trimTpl
.
arg
(
axis
),
calibration
->
center
);
settings
.
setValue
(
minTpl
.
arg
(
axis
),
calibration
->
min
);
settings
.
setValue
(
maxTpl
.
arg
(
axis
),
calibration
->
max
);
settings
.
setValue
(
revTpl
.
arg
(
axis
),
calibration
->
reversed
);
settings
.
setValue
(
deadbndTpl
.
arg
(
axis
),
calibration
->
deadband
);
qCDebug
(
JoystickLog
)
<<
"_saveSettings name:axis:min:max:trim:reversed:deadband"
<<
_name
<<
axis
...
...
@@ -308,12 +303,12 @@ void Joystick::_saveSettings()
int
temp
[
maxFunction
];
_remapAxes
(
_transmitterMode
,
2
,
temp
);
for
(
int
function
=
0
;
function
<
maxFunction
;
function
++
)
{
for
(
int
function
=
0
;
function
<
maxFunction
;
function
++
)
{
settings
.
setValue
(
_rgFunctionSettingsKey
[
function
],
temp
[
function
]);
qCDebug
(
JoystickLog
)
<<
"_saveSettings name:function:axis"
<<
_name
<<
function
<<
_rgFunctionSettingsKey
[
function
];
}
for
(
int
button
=
0
;
button
<
_totalButtonCount
;
button
++
)
{
for
(
int
button
=
0
;
button
<
_totalButtonCount
;
button
++
)
{
settings
.
setValue
(
QString
(
_buttonActionSettingsKey
).
arg
(
button
),
_rgButtonActions
[
button
]);
qCDebug
(
JoystickLog
)
<<
"_saveSettings button:action"
<<
button
<<
_rgButtonActions
[
button
];
}
...
...
@@ -321,13 +316,11 @@ void Joystick::_saveSettings()
// Relative mappings of axis functions between different TX modes
int
Joystick
::
_mapFunctionMode
(
int
mode
,
int
function
)
{
static
const
int
mapping
[][
4
]
=
{
{
2
,
1
,
0
,
3
},
{
2
,
3
,
0
,
1
},
{
0
,
1
,
2
,
3
},
{
0
,
3
,
2
,
1
}};
static
const
int
mapping
[][
6
]
=
{
{
yawFunction
,
pitchFunction
,
rollFunction
,
throttleFunction
,
gimbalPitchFunction
,
gimbalYawFunction
},
{
yawFunction
,
throttleFunction
,
rollFunction
,
pitchFunction
,
gimbalPitchFunction
,
gimbalYawFunction
},
{
rollFunction
,
pitchFunction
,
yawFunction
,
throttleFunction
,
gimbalPitchFunction
,
gimbalYawFunction
},
{
rollFunction
,
throttleFunction
,
yawFunction
,
pitchFunction
,
gimbalPitchFunction
,
gimbalYawFunction
}};
return
mapping
[
mode
-
1
][
function
];
}
...
...
src/VehicleSetup/JoystickConfig.qml
View file @
85468e6b
This diff is collapsed.
Click to expand it.
src/VehicleSetup/JoystickConfigController.cc
View file @
85468e6b
This diff is collapsed.
Click to expand it.
src/VehicleSetup/JoystickConfigController.h
View file @
85468e6b
...
...
@@ -7,10 +7,8 @@
*
****************************************************************************/
/// @file
/// @brief
Radio
Config Qml Controller
/// @brief
Joystick
Config Qml Controller
/// @author Don Gagne <don@thegagnes.com
#ifndef JoystickConfigController_H
...
...
@@ -31,7 +29,6 @@ namespace Ui {
class
JoystickConfigController
;
}
class
JoystickConfigController
:
public
FactPanelController
{
Q_OBJECT
...
...
@@ -42,7 +39,8 @@ public:
JoystickConfigController
(
void
);
~
JoystickConfigController
();
Q_PROPERTY
(
QQuickItem
*
statusText
MEMBER
_statusText
)
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
)
...
...
@@ -52,6 +50,7 @@ public:
Q_PROPERTY
(
bool
yawAxisMapped
READ
yawAxisMapped
NOTIFY
yawAxisMappedChanged
)
Q_PROPERTY
(
bool
throttleAxisMapped
READ
throttleAxisMapped
NOTIFY
throttleAxisMappedChanged
)
Q_PROPERTY
(
bool
hasGimbal
READ
hasGimbal
NOTIFY
hasGimbalChanged
)
Q_PROPERTY
(
bool
gimbalPitchAxisMapped
READ
gimbalPitchAxisMapped
NOTIFY
gimbalPitchAxisMappedChanged
)
Q_PROPERTY
(
bool
gimbalYawAxisMapped
READ
gimbalYawAxisMapped
NOTIFY
gimbalYawAxisMappedChanged
)
...
...
@@ -65,16 +64,20 @@ public:
Q_PROPERTY
(
bool
deadbandToggle
READ
getDeadbandToggle
WRITE
setDeadbandToggle
NOTIFY
deadbandToggled
)
Q_PROPERTY
(
int
transmitterMode
READ
transmitterMode
WRITE
setTransmitterMode
NOTIFY
transmitterModeChanged
)
Q_PROPERTY
(
QString
imageHelp
MEMBER
_imageHelp
NOTIFY
imageHelpChanged
)
Q_PROPERTY
(
bool
calibrating
READ
calibrating
NOTIFY
calibratingChanged
)
Q_PROPERTY
(
int
transmitterMode
READ
transmitterMode
WRITE
setTransmitterMode
NOTIFY
transmitterModeChanged
)
Q_PROPERTY
(
bool
calibrating
READ
calibrating
NOTIFY
calibratingChanged
)
Q_PROPERTY
(
QList
<
qreal
>
stickPositions
READ
stickPositions
NOTIFY
stickPositionsChanged
)
Q_PROPERTY
(
QList
<
qreal
>
gimbalPositions
READ
gimbalPositions
NOTIFY
gimbalPositionsChanged
)
Q_INVOKABLE
void
cancelButtonClicked
();
Q_INVOKABLE
void
skipButtonClicked
();
Q_INVOKABLE
void
nextButtonClicked
();
Q_INVOKABLE
void
start
();
Q_INVOKABLE
void
setDeadbandValue
(
int
axis
,
int
value
);
QString
statusText
()
{
return
_statusText
;
}
bool
rollAxisMapped
()
{
return
_rgFunctionAxisMapping
[
Joystick
::
rollFunction
]
!=
_axisNoAxis
;
}
bool
pitchAxisMapped
()
{
return
_rgFunctionAxisMapping
[
Joystick
::
pitchFunction
]
!=
_axisNoAxis
;
}
bool
yawAxisMapped
()
{
return
_rgFunctionAxisMapping
[
Joystick
::
yawFunction
]
!=
_axisNoAxis
;
}
...
...
@@ -89,6 +92,8 @@ public:
bool
gimbalPitchAxisReversed
();
bool
gimbalYawAxisReversed
();
bool
hasGimbal
()
{
return
_axisCount
>
5
;
}
bool
getDeadbandToggle
();
void
setDeadbandToggle
(
bool
);
...
...
@@ -98,31 +103,40 @@ public:
void
setTransmitterMode
(
int
mode
);
bool
calibrating
()
{
return
_currentStep
!=
-
1
;
}
QList
<
qreal
>
stickPositions
()
{
return
_currentStickPositions
;
}
QList
<
qreal
>
gimbalPositions
()
{
return
_currentGimbalPositions
;
}
struct
stateStickPositions
{
qreal
leftX
;
qreal
leftY
;
qreal
rightX
;
qreal
rightY
;
};
signals:
void
axisValueChanged
(
int
axis
,
int
value
);
void
axisDeadbandChanged
(
int
axis
,
int
value
);
void
rollAxisMappedChanged
(
bool
mapped
);
void
pitchAxisMappedChanged
(
bool
mapped
);
void
yawAxisMappedChanged
(
bool
mapped
);
void
throttleAxisMappedChanged
(
bool
mapped
);
void
gimbalPitchAxisMappedChanged
(
bool
mapped
);
void
gimbalYawAxisMappedChanged
(
bool
mapped
);
void
rollAxisReversedChanged
(
bool
reversed
);
void
pitchAxisReversedChanged
(
bool
reversed
);
void
yawAxisReversedChanged
(
bool
reversed
);
void
throttleAxisReversedChanged
(
bool
reversed
);
void
gimbalPitchAxisReversedChanged
(
bool
reversed
);
void
gimbalYawAxisReversedChanged
(
bool
reversed
);
void
deadbandToggled
(
bool
value
);
void
imageHelpChanged
(
QString
source
);
void
transmitterModeChanged
(
int
mode
);
void
calibratingChanged
();
void
stickPositionsChanged
();
void
gimbalPositionsChanged
();
void
hasGimbalChanged
();
void
statusTextChanged
();
// @brief Signalled when in unit test mode and a message box should be displayed by the next button
void
nextButtonMessageBoxDisplayed
();
...
...
@@ -143,13 +157,14 @@ private:
calStateTrims
,
calStateSave
};
typedef
void
(
JoystickConfigController
::*
inputFn
)(
Joystick
::
AxisFunction_t
function
,
int
axis
,
int
value
);
typedef
void
(
JoystickConfigController
::*
buttonFn
)(
void
);
struct
stateMachineEntry
{
Joystick
::
AxisFunction_t
function
;
const
char
*
instructions
;
const
char
*
image
;
stateStickPositions
stickPositions
;
stateStickPositions
gimbalPositions
;
inputFn
rcInputFn
;
buttonFn
nextFn
;
buttonFn
skipFn
;
...
...
@@ -202,9 +217,11 @@ private:
void
_calSaveCurrentValues
();
void
_set
HelpImage
(
const
char
*
imageFile
);
void
_set
StickPositions
(
);
void
_signalAllAttitudeValueChanges
();
void
_setStatusText
(
const
QString
&
text
);
// Member variables
...
...
@@ -222,7 +239,20 @@ private:
static
const
char
*
_imageRollRight
;
static
const
char
*
_imagePitchUp
;
static
const
char
*
_imagePitchDown
;
stateStickPositions
_sticksCentered
;
stateStickPositions
_sticksThrottleUp
;
stateStickPositions
_sticksThrottleDown
;
stateStickPositions
_sticksYawLeft
;
stateStickPositions
_sticksYawRight
;
stateStickPositions
_sticksRollLeft
;
stateStickPositions
_sticksRollRight
;
stateStickPositions
_sticksPitchUp
;
stateStickPositions
_sticksPitchDown
;
QList
<
qreal
>
_currentStickPositions
;
QList
<
qreal
>
_currentGimbalPositions
;
int
_rgFunctionAxisMapping
[
Joystick
::
maxFunction
];
///< Maps from joystick function to axis index. _axisMax indicates axis not set for this function.
static
const
int
_attitudeControls
=
5
;
...
...
@@ -258,13 +288,12 @@ private:
QTime
_stickDetectSettleElapsed
;
static
const
int
_stickDetectSettleMSecs
;
QQuickItem
*
_statusText
=
nullptr
;
QString
_statusText
;
QQuickItem
*
_cancelButton
=
nullptr
;
QQuickItem
*
_nextButton
=
nullptr
;
QQuickItem
*
_skipButton
=
nullptr
;
QString
_imageHelp
;
JoystickManager
*
_joystickManager
;
};
...
...
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