Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
cf07eb30
Commit
cf07eb30
authored
Oct 12, 2015
by
Lorenz Meier
Browse files
Fix the joystick range by properly limiting the calculation
parent
0f6fee56
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Joystick/Joystick.cc
View file @
cf07eb30
...
...
@@ -283,11 +283,16 @@ void Joystick::run(void)
axis
=
_rgFunctionAxis
[
throttleFunction
];
float
throttle
=
_adjustRange
(
_rgAxisValues
[
axis
],
_rgCalibration
[
axis
]);
float
roll_limited
=
std
::
max
(
static_cast
<
float
>
(
-
M_PI_4
),
std
::
min
(
roll
,
static_cast
<
float
>
(
M_PI_4
)));
float
pitch_limited
=
std
::
max
(
static_cast
<
float
>
(
-
M_PI_4
),
std
::
min
(
pitch
,
static_cast
<
float
>
(
M_PI_4
)));
float
yaw_limited
=
std
::
max
(
static_cast
<
float
>
(
-
M_PI_4
),
std
::
min
(
yaw
,
static_cast
<
float
>
(
M_PI_4
)));
float
throttle_limited
=
std
::
max
(
static_cast
<
float
>
(
-
M_PI_4
),
std
::
min
(
throttle
,
static_cast
<
float
>
(
M_PI_4
)));
// Map from unit circle to linear range and limit
roll
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
roll
)),
1.0
f
));
pitch
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
pitch
)),
1.0
f
));
yaw
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
yaw
)),
1.0
f
));
throttle
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
throttle
)),
1.0
f
));
roll
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
roll
_limited
)),
1.0
f
));
pitch
=
std
::
max
(
-
1.0
f
,
std
::
min
(
tanf
(
asinf
(
pitch
_limited
)),
1.0
f
));
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
));
// Adjust throttle to 0:1 range
if
(
_throttleMode
==
ThrottleModeCenterZero
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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