Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Alberto Ruiz Garcia
Firmware
Commits
455ba0e1
Commit
455ba0e1
authored
7 years ago
by
Matthias Grob
Browse files
Options
Downloads
Patches
Plain Diff
mathlib Functions: added SuperExpo function for stick feel enhancement
parent
3ce5525b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lib/mathlib/math/Functions.hpp
+24
-1
24 additions, 1 deletion
src/lib/mathlib/math/Functions.hpp
with
24 additions
and
1 deletion
src/lib/mathlib/math/Functions.hpp
+
24
−
1
View file @
455ba0e1
...
...
@@ -54,7 +54,11 @@ int sign(T val)
/*
* So called exponential curve function implementation.
* It is essentially a linear combination between a linear and a cubic function.
* It's used in the range [-1,1]
* @param value [-1,1] input value to function
* @param e [0,1] function parameter to set ratio between linear and cubic shape
* 0 - pure linear function
* 1 - pure cubic function
* @return result of function output
*/
template
<
typename
_Tp
>
inline
const
_Tp
expo
(
const
_Tp
&
value
,
const
_Tp
&
e
)
...
...
@@ -63,6 +67,25 @@ inline const _Tp expo(const _Tp &value, const _Tp &e)
return
(
1
-
e
)
*
x
+
e
*
x
*
x
*
x
;
}
/*
* So called SuperExpo function implementation.
* It is a 1/(1-x) function to further shape the rc input curve intuitively.
* I enhanced it compared to other implementations to keep the scale between [-1,1].
* @param value [-1,1] input value to function
* @param e [0,1] function parameter to set ratio between linear and cubic shape (see expo)
* @param g [0,1) function parameter to set SuperExpo shape
* 0 - pure expo function
* 0.99 - very strong bent curve, stays zero until maximum stick input
* 1 - DO NOT USE, division by zero on maxima
* @return result of function output
*/
template
<
typename
_Tp
>
inline
const
_Tp
superexpo
(
const
_Tp
&
value
,
const
_Tp
&
e
,
const
_Tp
&
g
)
{
_Tp
x
=
constrain
(
value
,
(
_Tp
)
-
1
,
(
_Tp
)
1
);
return
expo
(
x
,
e
)
*
(
1
-
g
)
/
(
1
-
fabsf
(
x
)
*
g
);
}
template
<
typename
_Tp
>
inline
const
_Tp
deadzone
(
const
_Tp
&
value
,
const
_Tp
&
dz
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment