-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathstate_estim.jl
More file actions
62 lines (51 loc) · 2.11 KB
/
Copy pathstate_estim.jl
File metadata and controls
62 lines (51 loc) · 2.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
@doc raw"""
Abstract supertype of all state estimators.
---
(estim::StateEstimator)(d=[]) -> ŷ
Functor allowing callable `StateEstimator` object as an alias for [`evaloutput`](@ref).
# Examples
```jldoctest
julia> kf = KalmanFilter(setop!(LinModel(tf(3, [10, 1]), 2), yop=[20]), direct=false);
julia> ŷ = kf()
1-element Vector{Float64}:
20.0
```
"""
abstract type StateEstimator{NT<:Real} end
const IntVectorOrInt = Union{Int, Vector{Int}}
include("estimator/construct.jl")
include("estimator/execute.jl")
include("estimator/kalman.jl")
include("estimator/luenberger.jl")
include("estimator/mhe.jl")
include("estimator/internal_model.jl")
include("estimator/manual.jl")
function Base.show(io::IO, estim::StateEstimator)
model = estim.model
nu, nd = model.nu, model.nd
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
other_dims = get_other_dims(estim)
n = maximum(ndigits.((nu, nx̂, nym, nyu, nd, other_dims...))) + 1
println(io, "$(nameof(typeof(estim))) estimator with a sample time Ts = $(model.Ts) s:")
println(io, "├ model: $(nameof(typeof(estim.model)))")
print_details(io, estim)
println(io, "└ dimensions:")
print_estim_dim(io, estim, n)
end
"Return additional dimensions on `estim` if any, for adequate padding with spaces."
get_other_dims(::StateEstimator) = tuple()
"Print only the `estim.direct` field by default."
function print_details(io::IO, estim::StateEstimator)
println(io, "├ direct: $(estim.direct)")
end
"Print the overall dimensions of the state estimator `estim` with left padding `n`."
function print_estim_dim(io::IO, estim::StateEstimator, n)
nu, nd = estim.model.nu, estim.model.nd
nx̂, nym, nyu = estim.nx̂, estim.nym, estim.nyu
niu, niym = sum(estim.nint_u), sum(estim.nint_ym)
println(io, " ├$(lpad(nu, n)) manipulated inputs u ($niu integrating states)")
println(io, " ├$(lpad(nx̂, n)) estimated states x̂")
println(io, " ├$(lpad(nym, n)) measured outputs ym ($niym integrating states)")
println(io, " ├$(lpad(nyu, n)) unmeasured outputs yu")
print(io, " └$(lpad(nd, n)) measured disturbances d")
end