mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-23 22:58:10 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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
@@ -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");
|
||||
}
|
||||
Reference in New Issue
Block a user