49 #define ASSERT_CL(T) if (!(T)) { printf("FAIL\n"); return -1; } 90 return failed ? -1 : 0;
95 printf(
"Test BlockLimit\t\t\t: ");
111 printf(
"Test BlockLimitSym\t\t: ");
126 printf(
"Test BlockLowPass\t\t: ");
142 for (
int i = 0; i < 100; i++) {
154 printf(
"Test BlockHighPass\t\t: ");
173 for (
int i = 0; i < 100; i++) {
185 printf(
"Test BlockLowPass2\t\t: ");
201 for (
int i = 0; i < 100; i++) {
213 printf(
"Test BlockIntegral\t\t: ");
226 for (
int i = 0; i < 100; i++) {
232 integral.
setY(-0.9
f);
235 for (
int i = 0; i < 100; i++) {
250 printf(
"Test BlockIntegralTrap\t\t: ");
266 for (
int i = 0; i < 100; i++) {
272 integral.
setU(-1.0
f);
273 integral.
setY(-0.9
f);
276 for (
int i = 0; i < 100; i++) {
293 printf(
"Test BlockDerivative\t\t: ");
302 derivative.
setU(1.0
f);
316 printf(
"Test BlockP\t\t\t: ");
317 BlockP blockP(
nullptr,
"TEST_P");
332 printf(
"Test BlockPI\t\t\t: ");
333 BlockPI blockPI(
nullptr,
"TEST");
354 printf(
"Test BlockPD\t\t\t: ");
355 BlockPD blockPD(
nullptr,
"TEST");
379 printf(
"Test BlockPID\t\t\t: ");
409 printf(
"Test BlockOutput\t\t: ");
432 printf(
"Test BlockRandUniform\t\t: ");
440 float mean = blockRandUniform.
update();
442 for (
int i = 2; i < n + 1; i++) {
443 float val = blockRandUniform.
update();
444 mean += (val - mean) / i;
450 blockRandUniform.
getMax()) / 2, 1e-1));
458 printf(
"Test BlockRandGauss\t\t: ");
466 float mean = blockRandGauss.
update();
470 for (
int i = 2; i < n + 1; i++) {
471 float val = blockRandGauss.
update();
472 float newMean = mean + (val - mean) / i;
473 sum += (val - mean) * (val - newMean);
477 float stdDev = sqrtf(sum / (n - 1));
487 printf(
"Test BlockStats\t\t\t: ");
504 printf(
"Test BlockDelay\t\t\t: ");
float update(float input)
float update(float input)
float update(float input)
matrix::Vector< Type, M > getMean()
BlockDerivative & getDerivative()
int blockIntegralTrapTest()
A symmetric limiter/ saturation.
A high pass filter as described here: http://en.wikipedia.org/wiki/High-pass_filter.
float update(float input)
void setState(float state)
virtual void setDt(float dt)
void setState(float state)
float update(float input)
A low pass filter as described here: http://en.wikipedia.org/wiki/Low-pass_filter.
bool __EXPORT less_than_or_equal(float a, float b)
An output trim/ saturation block.
bool __EXPORT equal(float a, float b, float epsilon)
A proportional-derivative controller.
matrix::Matrix< Type, M, N > update(const matrix::Matrix< Type, M, N > &u)
int blockDerivativeTest()
float update(float input)
A proportional-integral controller.
void setDt(float dt) override
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
BlockIntegral & getIntegral()
bool __EXPORT greater_than_or_equal(float a, float b)
A rectangular integrator.
float update(float input)
__EXPORT int controllib_test_main(int argc, char *argv[])
float update(float input)
int blockRandUniformTest()
A proportional-integral-derivative controller.
A trapezoidal integrator.
float update(float input)
Update the state and get current derivative.
matrix::Vector< Type, M > getStdDev()
A proportional controller.
A simple derivative approximation.
float update(float input)
float update(float input)
A 2nd order low pass filter block which uses the default px4 2nd order low pass filter.
BlockDerivative & getDerivative()
BlockIntegral & getIntegral()
float update(float input)
void update(const matrix::Vector< Type, M > &u)