Skip to content

Commit 2cb763f

Browse files
committed
remove code related to julia 1.6 compatibility
1 parent b22a18b commit 2cb763f

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/estimator/kalman.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@ struct SteadyKalmanFilter{NT<:Real, SM<:LinModel} <: StateEstimator{NT}
3838
Â, B̂u, Ĉ, B̂d, D̂d, x̂op, f̂op = augment_model(model, As, Cs_u, Cs_y)
3939
Ĉm, D̂dm = Ĉ[i_ym, :], D̂d[i_ym, :]
4040
validate_kfcov(nym, nx̂, Q̂, R̂)
41+
if ny == nym
42+
R̂_y =
43+
else
44+
R̂_y = zeros(NT, ny, ny)
45+
R̂_y[i_ym, i_ym] =
46+
R̂_y = Hermitian(R̂_y, :L)
47+
end
4148
= try
42-
Q̂_kalman = Matrix(Q̂) # Matrix() required for Julia 1.6
43-
R̂_kalman = zeros(NT, ny, ny)
44-
R̂_kalman[i_ym, i_ym] =
45-
ControlSystemsBase.kalman(Discrete, Â, Ĉ, Q̂_kalman, R̂_kalman; direct)[:, i_ym]
49+
ControlSystemsBase.kalman(Discrete, Â, Ĉ, Q̂, R̂_y; direct)[:, i_ym]
4650
catch my_error
4751
if isa(my_error, ErrorException)
4852
error("Cannot compute the optimal Kalman gain K̂ for the "*

src/model/solver.jl

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,11 @@ function get_solver_functions(NT::DataType, solver::RungeKutta, fc!, hc!, Ts, _
4747
k4_cache::DiffCache{Vector{NT}, Vector{NT}} = DiffCache(zeros(NT, nx), Nc)
4848
f! = function inner_solver_f!(xnext, x, u, d, p)
4949
CT = promote_type(eltype(x), eltype(u), eltype(d))
50-
# dummy variable for get_tmp, necessary for PreallocationTools + Julia 1.6 :
51-
var::CT = 0
52-
xcur = get_tmp(xcur_cache, var)
53-
k1 = get_tmp(k1_cache, var)
54-
k2 = get_tmp(k2_cache, var)
55-
k3 = get_tmp(k3_cache, var)
56-
k4 = get_tmp(k4_cache, var)
50+
xcur = get_tmp(xcur_cache, CT)
51+
k1 = get_tmp(k1_cache, CT)
52+
k2 = get_tmp(k2_cache, CT)
53+
k3 = get_tmp(k3_cache, CT)
54+
k4 = get_tmp(k4_cache, CT)
5755
xterm = xnext
5856
@. xcur = x
5957
for i=1:solver.supersample

0 commit comments

Comments
 (0)