diff options
author | Lorenz Meier <lm@inf.ethz.ch> | 2014-07-18 07:28:49 +0200 |
---|---|---|
committer | Lorenz Meier <lm@inf.ethz.ch> | 2014-07-18 07:28:49 +0200 |
commit | 6c50e510a5fcadab19a6d5ff709c0da473e4ace0 (patch) | |
tree | 93e9b8924bc396039fe9fb292e2f8d1c743c3afc /src/modules/controllib/blocks.cpp | |
parent | dc612d75c788bc8b2a90c200a13a5a5a0e3a68d9 (diff) | |
download | px4-firmware-6c50e510a5fcadab19a6d5ff709c0da473e4ace0.tar.gz px4-firmware-6c50e510a5fcadab19a6d5ff709c0da473e4ace0.tar.bz2 px4-firmware-6c50e510a5fcadab19a6d5ff709c0da473e4ace0.zip |
Derivative fix: Comments and code style
Diffstat (limited to 'src/modules/controllib/blocks.cpp')
-rw-r--r-- | src/modules/controllib/blocks.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/modules/controllib/blocks.cpp b/src/modules/controllib/blocks.cpp index 04cb023a8..0175acda9 100644 --- a/src/modules/controllib/blocks.cpp +++ b/src/modules/controllib/blocks.cpp @@ -293,10 +293,16 @@ int blockIntegralTrapTest() float BlockDerivative::update(float input) { - float output = 0.0f; + float output; if (_initialized) { output = _lowPass.update((input - getU()) / getDt()); } else { + // if this is the first call to update + // we have no valid derivative + // and so we use the assumption the + // input value is not changing much, + // which is the best we can do here. + output = 0.0f; _initialized = true; } setU(input); |