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
735c5544
Commit
735c5544
authored
6 years ago
by
Daniel Agar
Browse files
Options
Downloads
Patches
Plain Diff
tests add ctlmath and use float FLT_EPSILON
parent
367a18f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
platforms/posix/cmake/sitl_tests.cmake
+1
-0
1 addition, 0 deletions
platforms/posix/cmake/sitl_tests.cmake
src/modules/mc_pos_control/mc_pos_control_tests/test_controlmath.cpp
+13
-14
13 additions, 14 deletions
.../mc_pos_control/mc_pos_control_tests/test_controlmath.cpp
with
14 additions
and
14 deletions
platforms/posix/cmake/sitl_tests.cmake
+
1
−
0
View file @
735c5544
...
...
@@ -9,6 +9,7 @@ set(tests
commander
controllib
conv
ctlmath
dataman
file2
float
...
...
This diff is collapsed.
Click to expand it.
src/modules/mc_pos_control/mc_pos_control_tests/test_controlmath.cpp
+
13
−
14
View file @
735c5544
#include
<unit_test.h>
#include
"../Utility/ControlMath.hpp"
#include
<mathlib/mathlib.h>
static
const
float
EPS
=
0.00000001
f
;
#include
<cfloat>
class
ControlMathTest
:
public
UnitTest
{
...
...
@@ -29,20 +28,20 @@ bool ControlMathTest::testThrAttMapping()
matrix
::
Vector3f
thr
{
0.0
f
,
0.0
f
,
-
1.0
f
};
float
yaw
=
0.0
f
;
vehicle_attitude_setpoint_s
att
=
ControlMath
::
thrustToAttitude
(
thr
,
yaw
);
ut_
compare
(
""
,
att
.
roll_body
,
EPS
);
ut_assert_true
(
att
.
pitch_body
<
EPS
);
ut_assert_true
(
att
.
yaw_body
<
EPS
);
ut_assert_true
(
att
.
thrust
-
1.0
f
<
EPS
);
ut_
assert_true
(
att
.
roll_body
<
FLT_EPSILON
);
ut_assert_true
(
att
.
pitch_body
<
FLT_EPSILON
);
ut_assert_true
(
att
.
yaw_body
<
FLT_EPSILON
);
ut_assert_true
(
att
.
thrust
-
1.0
f
<
FLT_EPSILON
);
/* expected: same as before but with 90 yaw
* reason: only yaw changed
*/
yaw
=
M_PI_2_F
;
att
=
ControlMath
::
thrustToAttitude
(
thr
,
yaw
);
ut_assert_true
(
att
.
roll_body
<
EPS
);
ut_assert_true
(
att
.
pitch_body
<
EPS
);
ut_assert_true
(
att
.
yaw_body
-
M_PI_2_F
<
EPS
);
ut_assert_true
(
att
.
thrust
-
1.0
f
<
EPS
);
ut_assert_true
(
att
.
roll_body
<
FLT_EPSILON
);
ut_assert_true
(
att
.
pitch_body
<
FLT_EPSILON
);
ut_assert_true
(
att
.
yaw_body
-
M_PI_2_F
<
FLT_EPSILON
);
ut_assert_true
(
att
.
thrust
-
1.0
f
<
FLT_EPSILON
);
/* expected: same as before but roll 180
* reason: thrust points straight down and order Euler
...
...
@@ -50,10 +49,10 @@ bool ControlMathTest::testThrAttMapping()
*/
thr
=
matrix
::
Vector3f
(
0.0
f
,
0.0
f
,
1.0
f
);
att
=
ControlMath
::
thrustToAttitude
(
thr
,
yaw
);
ut_assert_true
(
fabsf
(
att
.
roll_body
)
-
M_PI_F
<
EPS
);
ut_assert_true
(
fabsf
(
att
.
pitch_body
)
<
EPS
);
ut_assert_true
(
att
.
yaw_body
-
M_PI_2_F
<
EPS
);
ut_assert_true
(
att
.
thrust
-
1.0
f
<
EPS
);
ut_assert_true
(
fabsf
(
att
.
roll_body
)
-
M_PI_F
<
FLT_EPSILON
);
ut_assert_true
(
fabsf
(
att
.
pitch_body
)
<
FLT_EPSILON
);
ut_assert_true
(
att
.
yaw_body
-
M_PI_2_F
<
FLT_EPSILON
);
ut_assert_true
(
att
.
thrust
-
1.0
f
<
FLT_EPSILON
);
/* TODO: find a good way to test it */
...
...
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