Generated reference › Alpha Beta Filter — Robotics/Perception Filters
kind: generated#block#robotics-perception-filters

Alpha Beta Filter — Robotics/Perception Filters

Robotics/Perception_Filters/Alpha_Beta_Filter · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Description#

The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.

Alpha-Beta Filter

Robotics / Perception Filters

The g-h tracker: takes a noisy position measurement and produces a smoothed position and the velocity implied by it.

  • predictxp = x + v·Ts
  • residualr = z − xp
  • correctx = xp + α·r, v = v + (β/Ts)·r

It is the steady-state Kalman filter for the constant-velocity model – the same structure with the gains frozen rather than propagated. There is no covariance to carry and two scalars to tune, which is the right trade whenever the noise statistics are not known well enough to earn the full recursion.

Ports

  • z – the measured position, a scalar, in whatever unit the estimate should carry (metres, radians, counts).
  • estimate – a [2,1] column (position, velocity). The velocity is in units per second. Its size is fixed, not inherited.

Parameters

  • Alpha (position gain) – how hard the residual pulls the POSITION, in [0, 1] for a sensible filter. 1 snaps to every measurement (no smoothing); 0 ignores measurements entirely and coasts on the model.
  • Beta (velocity gain) – how hard the residual pulls the VELOCITY. Larger tracks acceleration faster and amplifies noise more. Stability wants 0 < β < 4 − 2α; a common starting point is β ≈ α²/(2−α), which is the critically damped choice.
  • Initial Position / Initial Velocity – the estimate at t = 0. A good initial velocity matters more than a good initial position: the filter corrects position quickly and velocity slowly.
  • Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period. It must resolve to a positive value, since β/Ts divides by it.

Code export

All ten targets: Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog and PLC Structured Text. α, Ts and the folded β/Ts are baked into the generated body at export time rather than exposed as tunable parameters.

The three HDL targets are genuinely synthesizable Q16.16: the per-sample work is four multiplies and four adds, and the one division is folded away at export.

Simulink bridge

None, measured rather than assumed: the tracking filters ship in the Sensor Fusion and Tracking Toolbox, which is not installed on this machine.

Notes

  • Stateful and inherently discrete. The state is the (position, velocity) pair.
  • The output is the estimate at the START of the step, published before the predict-correct pass, so the first sample is exactly the configured seed and a measurement first appears in the output at k+1.
  • It assumes CONSTANT VELOCITY between samples. Under a sustained acceleration a both estimates settle to a constant lag, and the two are not the same size: position lags by a·Ts²·(1−α)/β and velocity by a·Ts·(2α−β)/(2β). Both follow from the steady-state residual r = a·Ts²/β – the value the velocity correction must see each step for the estimate to gain a·Ts. The position lag carries Ts² and is usually the small one; the velocity lag carries Ts and is what a tracker notices first. That is the model's error, not the filter's, and the cure is an alpha-beta-gamma tracker rather than a larger gain.
  • β is scaled by Ts inside the block, so the same pair of gains means the same filter at any rate. The exported core carries β/Ts already folded.
  • For a full Kalman filter – propagated covariance, time-varying gains – use State Estimation / Kalman Filter.

Code facts#

FactValue
registered typeRobotics/Perception_Filters/Alpha_Beta_Filter
familyRobotics/Perception_Filters
solver environment classICoreBlock_0_Robotics_1_Perception_Filters_2_Alpha_Beta_Filter
sourcesrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Perception_Filters/Alpha_Beta_Filter/ICoreBlock_0_Robotics_1_Perception_Filters_2_Alpha_Beta_Filter.cpp
headersrc/ICoreSDK/ICoreBlockLibrary/Blocks/Robotics/Perception_Filters/Alpha_Beta_Filter/ICoreBlock_0_Robotics_1_Perception_Filters_2_Alpha_Beta_Filter.h
default size on canvas140 × 84 px
ports at insert1 in, 1 out
code generators implementedPython, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text

Ports#

#DirectionSignal typeDescription label
1inICoreDoublez
2outICoreDoubleestimate

Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.

Configuration variables#

Config variableDefaultSimulink parameter
Alpha (position gain)0.5
Beta (velocity gain)0.1
Initial Position0
Initial Velocity0

Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.

supportSupport::None
Simulink path
port-count rulePortsParam::None
SampleTime parameteryes

Caveat (shown to the user): no Simulink equivalent available: the tracking filters ship in the Sensor Fusion and Tracking Toolbox, which is not installed. Rebuild the predict-correct pair from Unit Delay, Gain and Sum blocks there, remembering that beta is scaled by the sample time as it is here

Catalog contract: src/ICoreSDK/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h

Description vs code#

The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.

The verdict above is tools/docs/check_block_descriptions.py (P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.

File banner (developer view)#

The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).

Alpha-Beta Filter — the g-h tracker xp = x + v*Ts (predict) r = z - xp (residual) x = xp + alpha*r (correct position) v = v + (beta/Ts)*r (correct velocity)

Two states, affine, and the only division - beta/Ts - is folded once at config load. So the three HDL targets are genuinely synthesizable Q16.16, and the reference multiplies by the SAME folded constant the exports bake in. See the header.

Sample results#

Alpha Beta Filter — Step: 0 -> 1 at t = 1 sAlpha Beta Filter — Step: 0 -> 1 at t = 1 s00.51012345t (s)in ICoreDouble-Out-0out ICoreDouble-Out-0 [2x1] entry 0

The same rig also ran:

StimulusWhat it isOutput range
impulseImpulse: one sample of 1 at k = 5, 0 elsewhere (Repeating Sequence Stair)-0.01514 … 0.5
rampRamp: slope 1 from t = 00 … 5.7
sineSine Wave: amplitude 1, 2 rad/s, no phase, no bias-1.102 … 1.102
tableRepeating Sequence Stair: [-2 -1 -0.5 0 0.5 1 2 3], one entry per sample-1.1 … 2.341

Plotted: step — Step: 0 -> 1 at t = 1 s

Category dynamic · sample time 0.1 · 60 steps · commit ccf005c8 · produced by docsSample --out <folder> --steps 60 · data docs/generated/samples/Robotics__Perception_Filters__Alpha_Beta_Filter.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).