test(tecs): add closed-loop unit tests for TECSControl

Purpose: define, pinpoint and fix basic internal consistency issues.
TECS should be able to handle this case (zero noise or model mismatch)
almost perfectly.

Some of them fail currently, will come up with fixes afterwards.

The model has 2 states (airspeed, height) and 2 inputs (throttle and
pitch). The dynamics correspond exactly to the model assumed in TECS and
the pitch input applies immediately without any inner dynamics.

This model is simulated at 50Hz, and the test harness allows changing
tecs parameters, and airspeed / altitude setpoints. It also records the
maximum airspeed error over each simulation run.
This commit is contained in:
Balduin
2026-04-23 11:24:56 +02:00
parent 3ac9b267ca
commit 2556b33e07
4 changed files with 549 additions and 3 deletions
+5 -3
View File
@@ -32,8 +32,10 @@
############################################################################
px4_add_library(tecs
TECS.cpp
TECS.hpp
)
TECS.cpp
TECS.hpp
)
target_link_libraries(tecs PRIVATE geo)
px4_add_unit_gtest(SRC TECSClosedLoopTest.cpp EXTRA_SRCS TECSTestStubs.cpp LINKLIBS tecs motion_planning)
+2
View File
@@ -380,6 +380,8 @@ private:
float ske_weighting; ///< Specific kinetic energy weight.
};
friend class TECSClosedLoopTest;
private:
/**
* @brief Get control error from etpoint and estimate
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
// Minimal stubs satisfying TECS.cpp link requirements in unit test builds.
// PX4_WARN calls in TECS.cpp are only reached on invalid dt; they are never
// triggered by the closed-loop tests which always pass dt = 0.02 s.
#include <cstdarg>
#include <cstdio>
extern "C" __attribute__((visibility("default")))
void px4_log_modulename(int /*level*/, const char * /*module*/, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
fprintf(stderr, "\n");
}