mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-28 12:24:08 +08:00
teest_controlmath: incomplete set of thrust to attitude tests
This commit is contained in:
parent
0afd0807bb
commit
ddecb4d3a4
@ -12,6 +12,7 @@ public:
|
||||
private:
|
||||
bool testConstrainTilt();
|
||||
bool testConstrainPIDu();
|
||||
bool testThrAttMapping();
|
||||
|
||||
|
||||
};
|
||||
@ -20,6 +21,7 @@ bool ControlMathTest::run_tests()
|
||||
{
|
||||
ut_run_test(testConstrainTilt);
|
||||
ut_run_test(testConstrainPIDu);
|
||||
ut_run_test(testThrAttMapping);
|
||||
|
||||
return (_tests_failed == 0);
|
||||
}
|
||||
@ -212,4 +214,45 @@ bool ControlMathTest::testConstrainPIDu()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ControlMathTest::testThrAttMapping()
|
||||
{
|
||||
|
||||
/* expected: zero roll, zero pitch, zero yaw, full thr mag
|
||||
* reasone: thrust pointing full upward
|
||||
*/
|
||||
matrix::Vector3f thr{0.0f, 0.0f, -1.0f};
|
||||
float yaw = 0.0f;
|
||||
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.0f < EPS);
|
||||
|
||||
/* 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.0f < EPS);
|
||||
|
||||
/* expected: same as before but roll 180
|
||||
* reason: thrust points straight down and order Euler
|
||||
* order is: 1. roll, 2. pitch, 3. yaw
|
||||
*/
|
||||
thr = matrix::Vector3f(0.0f, 0.0f, 1.0f);
|
||||
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.0f < EPS);
|
||||
|
||||
/* TODO: find a good way to test it */
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ut_declare_test_c(test_controlmath, ControlMathTest)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user