Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SOAAP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Martin Streitenberger
SOAAP
Commits
e9326c37
Commit
e9326c37
authored
1 year ago
by
Maximilian Leske
Browse files
Options
Downloads
Patches
Plain Diff
Anpassen der EulerAngles.cpp an den Softwarestand SOAPP 2.0
parent
c88cfb20
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
libraries/EulerAngles/EulerAngles.cpp
+167
-1
167 additions, 1 deletion
libraries/EulerAngles/EulerAngles.cpp
with
167 additions
and
1 deletion
libraries/EulerAngles/EulerAngles.cpp
+
167
−
1
View file @
e9326c37
...
...
@@ -7,6 +7,16 @@
// Lizenz: CC-BY-SA (siehe Wikipedia: Creative Commons)
//
//###########################################################################
// Anpassungschronik
// Stand: 12.02.2024
//Nachrüstung vom 04.10.2023 -> Einfügen der "angepassten" Berechnungnen der Eulerwinkel
//###########################################################################
#include
"EulerAngles.h"
...
...
@@ -23,8 +33,10 @@ EulerAngles::EulerAngles()
// Anwenderfunktionen
// ---------------------------------------------------------------------------
//
float
EulerAngles
::
getRollFromGravity
(
float
accY
,
float
accZ
)
{
if
(
accZ
<
0
)
{
if
(
accZ
>
-
minTanDenom
)
...
...
@@ -35,6 +47,7 @@ float EulerAngles::getRollFromGravity(float accY, float accZ)
if
(
accZ
<
minTanDenom
)
accZ
=
minTanDenom
;
}
return
(
atan2
(
accY
,
accZ
));
}
...
...
@@ -50,4 +63,157 @@ float EulerAngles::getPitchFromGravity(float accX, float accY, float accZ)
denom
=
-
denom
;
return
(
atan2
(
-
accX
,
denom
));
}
//#########################################################################
// Nachrüstung/ Erweiterung der Eulerfunktionen Stand: 04.10.2023 #
float
EulerAngles
::
getNewRollFromGravity
(
float
accX
,
float
accY
,
float
accZ
)
{
float
Phi
;
//"Ausfiltern" zu großer Beschleunigungswerte
if
(
accX
<
0
)
{
if
(
accX
>
-
minTanDenom
)
{
accX
=
-
minTanDenom
;
}
}
else
{
if
(
accX
<
minTanDenom
)
{
accX
=
minTanDenom
;
}
}
if
(
accY
<
0
)
{
if
(
accY
>
-
minTanDenom
)
{
accY
=
-
minTanDenom
;
}
}
else
{
if
(
accY
<
minTanDenom
)
{
accY
=
minTanDenom
;
}
}
if
(
accZ
<
0
)
{
if
(
accZ
>
-
minTanDenom
)
{
accZ
=
-
minTanDenom
;
}
}
else
{
if
(
accZ
<
minTanDenom
)
{
accZ
=
minTanDenom
;
}
}
Phi
=
atan2
(
accY
,(
accZ
));
return
(
Phi
);
}
float
EulerAngles
::
getNewPitchFromGravity
(
float
accX
,
float
accY
,
float
accZ
)
{
float
Phi
;
float
Theta
;
float
accZ2
;
//"Ausfiltern" zu großer Beschleunigungswerte
if
(
accX
<
0
)
{
if
(
accX
>
-
minTanDenom
)
{
accX
=
-
minTanDenom
;
}
}
else
{
if
(
accX
<
minTanDenom
)
{
accX
=
minTanDenom
;
}
}
if
(
accY
<
0
)
{
if
(
accY
>
-
minTanDenom
)
{
accY
=
-
minTanDenom
;
}
}
else
{
if
(
accY
<
minTanDenom
)
{
accY
=
minTanDenom
;
}
}
if
(
accZ
<
0
)
{
if
(
accZ
>
-
minTanDenom
)
{
accZ
=
-
minTanDenom
;
}
}
else
{
if
(
accZ
<
minTanDenom
)
{
accZ
=
minTanDenom
;
}
}
Phi
=
getNewRollFromGravity
(
accX
,
accY
,
accZ
);
accZ2
=
accY
*
sin
(
Phi
)
+
accZ
*
cos
(
Phi
);
Theta
=
atan
(
-
accX
/
accZ2
);
return
(
Theta
);
}
float
EulerAngles
::
getNewYawFromMagnetAndGravity
(
float
magX
,
float
magY
,
float
magZ
,
float
accX
,
float
accY
,
float
accZ
)
{
//"Ausfiltern" zu großer Beschleunigungswerte
if
(
accX
<
0
)
{
if
(
accX
>
-
minTanDenom
)
{
accX
=
-
minTanDenom
;
}
}
else
{
if
(
accX
<
minTanDenom
)
{
accX
=
minTanDenom
;
}
}
if
(
accY
<
0
)
{
if
(
accY
>
-
minTanDenom
)
{
accY
=
-
minTanDenom
;
}
}
else
{
if
(
accY
<
minTanDenom
)
{
accY
=
minTanDenom
;
}
}
if
(
accZ
<
0
)
{
if
(
accZ
>
-
minTanDenom
)
{
accZ
=
-
minTanDenom
;
}
}
else
{
if
(
accZ
<
minTanDenom
)
{
accZ
=
minTanDenom
;
}
}
float
Phi
;
float
Theta
;
float
Psi
;
float
magX2
,
magY2
,
magZ2
;
Phi
=
getNewRollFromGravity
(
accX
,
accY
,
accZ
);
Theta
=
getNewPitchFromGravity
(
accX
,
accY
,
accZ
);
magY2
=
magZ
*
sin
(
Phi
)
-
magY
*
cos
(
Phi
);
magZ2
=
magY
*
sin
(
Phi
)
+
magZ
*
cos
(
Phi
);
magX2
=
magX
*
cos
(
Theta
)
+
magZ2
*
sin
(
Theta
);
Psi
=
atan2
(
magY2
,
magX2
);
return
(
Psi
);
}
// Ende Nachrüstung/ Erweiterung der Eulerfunktionen #
//#########################################################################
\ No newline at end of file
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