AlphaBetaFilter Icon
AlphaBetaFilter
Alpha-beta tracker: position and rate estimates for a scalar measurement.
This is the smallest filter that predicts: on every sample the state advances by its own rate estimate, and the prediction is then corrected toward the measurement. The rate output is the filtered rate of change of the input, available without a separate differentiator.
Standard stability constraint: $0 < \alpha < 1$, $0 < \beta \le 2 - \alpha$. The default beta is Kalata's steady-state relation $\beta = 2(2 - \alpha) - 4\sqrt{1 - \alpha}$, which makes the tracker the steady-state Kalman filter for a double-integrator (constant-velocity) target and the critically damped choice for the given alpha; with the default alpha = 0.5 it is $\beta \approx 0.172$.
The rate state initializes to zero under every initialization variant; the enum selects only the position state.
Usage
DiscreteComponents.AlphaBetaFilter(alpha=0.5, beta=2 * (2 - alpha) - 4 * sqrt(1 - alpha))
Parameters:
| Name | Description | Units | Default value |
|---|---|---|---|
Ts | Sample interval [s] | – | SampleTime() |
initialization | – | DiscreteCom...t(; y0=0.0) | |
alpha | Position correction gain, in (0, 1) | – | 0.5 |
beta | Rate correction gain, in (0, 2 - alpha); the default is the steady-state Kalman (critically damped) value for alpha | – | 2 * (2 - al...(1 - alpha) |
Connectors
u- This connector represents a real signal as an input to a component (RealInput)y- This connector represents a real signal as an output from a component (RealOutput)rate- This connector represents a real signal as an output from a component (RealOutput)
Variables
| Name | Description | Units |
|---|---|---|
pred | This sample's prediction from the previous state | – |
resid | Innovation: measurement minus prediction | – |
Behavior
using DiscreteComponents #hide
using ModelingToolkit #hide
@variables alpha #hide
@variables beta #hide
@named sys = DiscreteComponents.AlphaBetaFilter(alpha=alpha, beta=beta) #hide
full_equations(sys) #hideSource
"""
Alpha-beta tracker: position and rate estimates for a scalar measurement.
This is the smallest filter that predicts: on every sample the state advances by its own rate estimate, and the prediction is then corrected toward the measurement. The `rate` output is the filtered rate of change of the input, available without a separate differentiator.
Standard stability constraint: ``0 < \alpha < 1``, ``0 < \beta \le 2 - \alpha``. The default `beta` is Kalata's steady-state relation ``\beta = 2(2 - \alpha) - 4\sqrt{1 - \alpha}``, which makes the tracker the steady-state Kalman filter for a double-integrator (constant-velocity) target and the critically damped choice for the given `alpha`; with the default `alpha = 0.5` it is ``\beta \approx 0.172``.
The rate state initializes to zero under every `initialization` variant; the enum selects only the position state.
"""
component AlphaBetaFilter@[input clk extends Discrete]
"Measured value"
u = RealInput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Position estimate"
y = RealOutput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 170, "x2": 1100, "y2": 270, "rot": 0}
},
"tags": []
}
}
"Rate estimate [units of u per second]"
rate = RealOutput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 640, "x2": 1100, "y2": 740, "rot": 0}
},
"tags": []
}
}
"Position correction gain, in (0, 1)"
parameter alpha::Real = 0.5
"Rate correction gain, in (0, 2 - alpha); the default is the steady-state Kalman (critically damped) value for alpha"
parameter beta::Real = 2 * (2 - alpha) - 4 * sqrt(1 - alpha)
"Sample interval [s]"
structural parameter Ts::Real = SampleTime()
structural parameter initialization::InitialCondition = DiscreteComponents.InitialCondition.InitialOutput(y0 = 0.0)
"This sample's prediction from the previous state"
variable pred::Real
"Innovation: measurement minus prediction"
variable resid::Real
relations
pred@clk = y@(clk-1) + Ts * rate@(clk-1)
resid@clk = u@clk - pred@clk
y@clk = pred@clk + alpha * resid@clk
rate@clk = rate@(clk-1) + (beta / Ts) * resid@clk
initial rate@(clk-1) = 0
switch initialization
case InitialOutput
initial y@(clk-1) = (initialization.y0 - alpha * u@clk) / (1 - alpha)
case SteadyState
initial y@(clk-1) = u@clk
case InitialState
initial y@(clk-1) = initialization.x0
end
metadata {
"Dyad": {"icons": {"default": "dyad://DiscreteComponents/AlphaBetaFilter.svg"}}
}
end
Flattened Source
"""
Alpha-beta tracker: position and rate estimates for a scalar measurement.
This is the smallest filter that predicts: on every sample the state advances by its own rate estimate, and the prediction is then corrected toward the measurement. The `rate` output is the filtered rate of change of the input, available without a separate differentiator.
Standard stability constraint: ``0 < \alpha < 1``, ``0 < \beta \le 2 - \alpha``. The default `beta` is Kalata's steady-state relation ``\beta = 2(2 - \alpha) - 4\sqrt{1 - \alpha}``, which makes the tracker the steady-state Kalman filter for a double-integrator (constant-velocity) target and the critically damped choice for the given `alpha`; with the default `alpha = 0.5` it is ``\beta \approx 0.172``.
The rate state initializes to zero under every `initialization` variant; the enum selects only the position state.
"""
component AlphaBetaFilter
"Measured value"
u = RealInput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": -100, "y1": 450, "x2": 0, "y2": 550, "rot": 0}
},
"tags": []
}
}
"Position estimate"
y = RealOutput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 170, "x2": 1100, "y2": 270, "rot": 0}
},
"tags": []
}
}
"Rate estimate [units of u per second]"
rate = RealOutput@[clk]() {
"Dyad": {
"placement": {
"diagram": {"iconName": "default", "x1": 1000, "y1": 640, "x2": 1100, "y2": 740, "rot": 0}
},
"tags": []
}
}
"Position correction gain, in (0, 1)"
parameter alpha::Real = 0.5
"Rate correction gain, in (0, 2 - alpha); the default is the steady-state Kalman (critically damped) value for alpha"
parameter beta::Real = 2 * (2 - alpha) - 4 * sqrt(1 - alpha)
"Sample interval [s]"
structural parameter Ts::Real = SampleTime()
structural parameter initialization::InitialCondition = DiscreteComponents.InitialCondition.InitialOutput(y0 = 0.0)
"This sample's prediction from the previous state"
variable pred::Real
"Innovation: measurement minus prediction"
variable resid::Real
relations
pred@clk = y@(clk-1) + Ts * rate@(clk-1)
resid@clk = u@clk - pred@clk
y@clk = pred@clk + alpha * resid@clk
rate@clk = rate@(clk-1) + (beta / Ts) * resid@clk
initial rate@(clk-1) = 0
switch initialization
case InitialOutput
initial y@(clk-1) = (initialization.y0 - alpha * u@clk) / (1 - alpha)
case SteadyState
initial y@(clk-1) = u@clk
case InitialState
initial y@(clk-1) = initialization.x0
end
metadata {
"Dyad": {"icons": {"default": "dyad://DiscreteComponents/AlphaBetaFilter.svg"}}
}
endTest Cases
No test cases defined.
Related
- Examples
- Experiments
- Analyses