function
MathUtilities.deadzone
Remove a centered dead band and rescale the remaining travel to full range
The PX4 stick dead band, math::deadzone in
src/lib/mathlib/math/Functions.hpp. The output is continuous
at the band edge and reaches unit magnitude at unit input, so the dead
band costs travel rather than authority.
Public declarations
Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.
| Role | Name | Type | Dimensions / attributes / default | Description |
|---|---|---|---|---|
| input | value | Real | | Normalized input, nominally in [-1, 1] |
| input | width | Real | | Half-width of the dead band, in [0, 0.99] |
| output | result | Real | | Zero inside the dead band, +/-1 at full input |
Modelica declarations and implementation
Show parameters, interfaces and source
Parameters, inputs, outputs, defaults and equations from the source file.
function deadzone
"Remove a centered dead band and rescale the remaining travel to full range"
input Real value "Normalized input, nominally in [-1, 1]";
input Real width "Half-width of the dead band, in [0, 0.99]";
output Real result "Zero inside the dead band, +/-1 at full input";
protected
Real clipped;
Real band;
algorithm
clipped := MathUtilities.clip(value, -1.0, 1.0);
band := MathUtilities.clip(width, 0.0, 0.99);
result := if abs(clipped) <= band then
0.0
else
(clipped - sign(clipped) * band) / (1.0 - band);
annotation(
Inline = true,
Documentation(info = "<html>
<p>The PX4 stick dead band, <code>math::deadzone</code> in
<code>src/lib/mathlib/math/Functions.hpp</code>. The output is continuous
at the band edge and reaches unit magnitude at unit input, so the dead
band costs travel rather than authority.</p>
</html>"));
end deadzone;