We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 21bd589 commit 2ed9d57Copy full SHA for 2ed9d57
src/estimator/kalman.jl
@@ -567,7 +567,7 @@ function update_estimate!(estim::UnscentedKalmanFilter{NT}, u, ym, d) where NT<:
567
nym, nx̂, nσ = estim.nym, estim.nx̂, estim.nσ
568
γ, m̂, Ŝ = estim.γ, estim.m̂, estim.Ŝ
569
# --- initialize matrices ---
570
- X̂ = Matrix{NT}(undef, nx̂, nσ)
+ X̂, X̂_next = Matrix{NT}(undef, nx̂, nσ), Matrix{NT}(undef, nx̂, nσ)
571
ŷm = Vector{NT}(undef, nym)
572
ŷ = Vector{NT}(undef, estim.model.ny)
573
Ŷm = Matrix{NT}(undef, nym, nσ)
@@ -600,7 +600,7 @@ function update_estimate!(estim::UnscentedKalmanFilter{NT}, u, ym, d) where NT<:
600
X̂_cor .= x̂_cor
601
X̂_cor[:, 2:nx̂+1] .+= γ_sqrt_P̂_cor
602
X̂_cor[:, nx̂+2:end] .-= γ_sqrt_P̂_cor
603
- X̂_next = X̂_cor
+ X̂_next = similar(X̂_cor)
604
for j in axes(X̂_next, 2)
605
@views f̂!(X̂_next[:, j], estim, estim.model, X̂_cor[:, j], u, d)
606
end
src/model/nonlinmodel.jl
@@ -130,3 +130,19 @@ h!(y, model::NonLinModel, x, d) = model.h!(y, x, d)
130
131
typestr(model::NonLinModel) = "nonlinear"
132
133
+function rk4!(x, u, d)
134
+ xterm .= x
135
+ fc!(ẋ, xterm, u, d)
136
+ k1 .= ẋ
137
+ xterm .= @. x + k1 * Ts/2
138
139
+ k2 .= ẋ
140
+ xterm .= @. x + k2 * Ts/2
141
142
+ k3 .= ẋ
143
+ xterm .= @. x + k3 * Ts
144
145
+ k4 .= ẋ
146
+ x .+= @. (k1 + 2k2 + 2k3 + k4)*Ts/6
147
+ return x
148
+end
0 commit comments