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
79c6eefe
Commit
79c6eefe
authored
Mar 25, 2017
by
Don Gagne
Committed by
GitHub
Mar 25, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #4766 from nanthony21/expoSlider
Exponential Slider
parents
f21eb645
1cdfd636
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
22 deletions
+34
-22
Joystick.cc
src/Joystick/Joystick.cc
+10
-12
Joystick.h
src/Joystick/Joystick.h
+5
-5
QGCSlider.qml
src/QmlControls/QGCSlider.qml
+1
-0
JoystickConfig.qml
src/VehicleSetup/JoystickConfig.qml
+18
-5
No files found.
src/Joystick/Joystick.cc
View file @
79c6eefe
...
...
@@ -55,7 +55,7 @@ Joystick::Joystick(const QString& name, int axisCount, int buttonCount, int hatC
,
_rgButtonValues
(
NULL
)
,
_lastButtonBits
(
0
)
,
_throttleMode
(
ThrottleModeCenterZero
)
,
_exponential
(
false
)
,
_exponential
(
0
)
,
_accumulator
(
false
)
,
_deadband
(
false
)
,
_activeVehicle
(
NULL
)
...
...
@@ -109,7 +109,7 @@ void Joystick::_setDefaultCalibration(void) {
_rgFunctionAxis
[
yawFunction
]
=
0
;
_rgFunctionAxis
[
throttleFunction
]
=
1
;
_exponential
=
false
;
_exponential
=
0
;
_accumulator
=
false
;
_deadband
=
false
;
_throttleMode
=
ThrottleModeCenterZero
;
...
...
@@ -162,7 +162,7 @@ void Joystick::_loadSettings(void)
qCDebug
(
JoystickLog
)
<<
"_loadSettings "
<<
_name
;
_calibrated
=
settings
.
value
(
_calibratedSettingsKey
,
false
).
toBool
();
_exponential
=
settings
.
value
(
_exponentialSettingsKey
,
false
).
toBool
();
_exponential
=
settings
.
value
(
_exponentialSettingsKey
,
0
).
toFloat
();
_accumulator
=
settings
.
value
(
_accumulatorSettingsKey
,
false
).
toBool
();
_deadband
=
settings
.
value
(
_deadbandSettingsKey
,
false
).
toBool
();
...
...
@@ -443,16 +443,14 @@ void Joystick::run(void)
yaw
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
yaw_limited
)),
1.0
f
));
throttle
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
throttle_limited
)),
1.0
f
));
if
(
_exponential
)
{
if
(
_exponential
!=
0
)
{
// Exponential (0% to -50% range like most RC radios)
// 0 for no exponential
// -0.5 for strong exponential
float
expo
=
-
0.35
f
;
//_exponential is set by a slider in joystickConfig.qml
// Calculate new RPY with exponential applied
roll
=
-
expo
*
powf
(
roll
,
3
)
+
(
1
+
expo
)
*
roll
;
pitch
=
-
expo
*
powf
(
pitch
,
3
)
+
(
1
+
expo
)
*
pitch
;
yaw
=
-
expo
*
powf
(
yaw
,
3
)
+
(
1
+
expo
)
*
yaw
;
roll
=
-
_exponential
*
powf
(
roll
,
3
)
+
(
1
+
_exponential
)
*
roll
;
pitch
=
-
_exponential
*
powf
(
pitch
,
3
)
+
(
1
+
_exponential
)
*
pitch
;
yaw
=
-
_exponential
*
powf
(
yaw
,
3
)
+
(
1
+
_exponential
)
*
yaw
;
}
// Adjust throttle to 0:1 range
...
...
@@ -682,12 +680,12 @@ void Joystick::setThrottleMode(int mode)
emit
throttleModeChanged
(
_throttleMode
);
}
bool
Joystick
::
exponential
(
void
)
float
Joystick
::
exponential
(
void
)
{
return
_exponential
;
}
void
Joystick
::
setExponential
(
bool
expo
)
void
Joystick
::
setExponential
(
float
expo
)
{
_exponential
=
expo
;
...
...
src/Joystick/Joystick.h
View file @
79c6eefe
...
...
@@ -72,7 +72,7 @@ public:
Q_INVOKABLE
QString
getButtonAction
(
int
button
);
Q_PROPERTY
(
int
throttleMode
READ
throttleMode
WRITE
setThrottleMode
NOTIFY
throttleModeChanged
)
Q_PROPERTY
(
bool
exponential
READ
exponential
WRITE
setExponential
NOTIFY
exponentialChanged
)
Q_PROPERTY
(
float
exponential
READ
exponential
WRITE
setExponential
NOTIFY
exponentialChanged
)
Q_PROPERTY
(
bool
accumulator
READ
accumulator
WRITE
setAccumulator
NOTIFY
accumulatorChanged
)
Q_PROPERTY
(
bool
requiresCalibration
READ
requiresCalibration
CONSTANT
)
...
...
@@ -106,8 +106,8 @@ public:
int
throttleMode
(
void
);
void
setThrottleMode
(
int
mode
);
bool
exponential
(
void
);
void
setExponential
(
bool
expo
);
float
exponential
(
void
);
void
setExponential
(
float
expo
);
bool
accumulator
(
void
);
void
setAccumulator
(
bool
accu
);
...
...
@@ -141,7 +141,7 @@ signals:
void
throttleModeChanged
(
int
mode
);
void
exponentialChanged
(
bool
exponential
);
void
exponentialChanged
(
float
exponential
);
void
accumulatorChanged
(
bool
accumulator
);
...
...
@@ -206,7 +206,7 @@ protected:
ThrottleMode_t
_throttleMode
;
bool
_exponential
;
float
_exponential
;
bool
_accumulator
;
bool
_deadband
;
...
...
src/QmlControls/QGCSlider.qml
View file @
79c6eefe
...
...
@@ -13,6 +13,7 @@ import QtQuick.Controls.Styles 1.4
import
QGroundControl
.
Palette
1.0
import
QGroundControl
.
ScreenTools
1.0
import
QtQuick
.
Controls
.
Private
1.0
Slider
{
property
var
_qgcPal
:
QGCPalette
{
colorGroupEnabled
:
enabled
}
...
...
src/VehicleSetup/JoystickConfig.qml
View file @
79c6eefe
...
...
@@ -456,12 +456,25 @@ SetupPage {
Column
{
spacing
:
ScreenTools
.
defaultFontPixelHeight
/
3
QGC
CheckBox
{
id
:
exponentia
l
checked
:
_activeJoystick
?
_activeJoystick
.
exponential
:
false
text
:
qsTr
(
"
Use exponential curve on roll, pitch, yaw
"
)
QGC
Label
{
id
:
expoSliderLabe
l
text
:
qsTr
(
"
Exponential:
"
)
}
onClicked
:
_activeJoystick
.
exponential
=
checked
Row
{
QGCSlider
{
id
:
expoSlider
minimumValue
:
0
maximumValue
:
0.75
Component.onCompleted
:
value
=-
_activeJoystick
.
exponential
onValueChanged
:
_activeJoystick
.
exponential
=-
value
}
QGCLabel
{
id
:
expoSliderIndicator
text
:
expoSlider
.
value
.
toFixed
(
2
)
}
}
}
...
...
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