Skip to content

Commit 8f45221

Browse files
committed
test: debug
1 parent d607150 commit 8f45221

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

src/estimator/construct.jl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ function KalmanCovariances(
105105
) where {NT<:Real}
106106
validate_kfcov(model, i_ym, nint_u, nint_ym, Q̂, R̂, P̂_0)
107107
Q̂, R̂ = NT.(Q̂), NT.(R̂)
108-
!isnothing(P̂_0) && (P̂_0 .= NT.(P̂_0))
108+
if !isnothing(P̂_0)
109+
P̂_0 .= NT.(P̂_0)
110+
end
111+
println(Q̂)
112+
println(R̂)
113+
println(P̂_0)
109114
return KalmanCovariances{NT}(Q̂, R̂, P̂_0, He)
110115
end
111116

src/estimator/mhe/execute.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -797,14 +797,14 @@ function setmodel_estimator!(
797797
invQ̂ = Hermitian(estim.buffer.Q̂, :L)
798798
invQ̂ .= estim.cov.
799799
inv!(invQ̂)
800-
estim.invQ̂_He .= Hermitian(repeatdiag(invQ̂, He), :L)
800+
estim.cov.invQ̂_He .= Hermitian(repeatdiag(invQ̂, He), :L)
801801
end
802802
if !isnothing(R̂)
803803
estim.cov.R̂ .= to_hermitian(R̂)
804804
invR̂ = Hermitian(estim.buffer.R̂, :L)
805805
invR̂ .= estim.cov.
806806
inv!(invR̂)
807-
estim.invR̂_He .= Hermitian(repeatdiag(invR̂, He), :L)
807+
estim.cov.invR̂_He .= Hermitian(repeatdiag(invR̂, He), :L)
808808
end
809809
return nothing
810810
end

test/2_test_state_estim.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -864,8 +864,8 @@ end
864864
@test mhe3.nx̂ == 5
865865

866866
mhe4 = MovingHorizonEstimator(nonlinmodel, He=5, σQ=[1,2,3,4], σQint_ym=[5, 6], σR=[7, 8])
867-
@test mhe4. Hermitian(diagm(Float64[1, 4, 9 ,16, 25, 36]))
868-
@test mhe4. Hermitian(diagm(Float64[49, 64]))
867+
@test mhe4.cov. Hermitian(diagm(Float64[1, 4, 9 ,16, 25, 36]))
868+
@test mhe4.cov. Hermitian(diagm(Float64[49, 64]))
869869

870870
mhe5 = MovingHorizonEstimator(nonlinmodel, He=5, nint_ym=[2,2])
871871
@test mhe5.nxs == 4
@@ -1116,7 +1116,7 @@ end
11161116
)
11171117
mhe.P̂arr_old[1, 1] = Inf # Inf to trigger fallback
11181118
P̂arr_old_copy = deepcopy(mhe.P̂arr_old)
1119-
invP̄_copy = deepcopy(mhe.invP̄)
1119+
invP̄_copy = deepcopy(mhe.cov.invP̄)
11201120
@test_logs(
11211121
(:error, "Arrival covariance P̄ is not finite: keeping the old one"),
11221122
preparestate!(mhe, [50, 30], [5])
@@ -1425,7 +1425,7 @@ end
14251425
# recuperate P̂(-1|-1) exact value using the Unscented Kalman filter:
14261426
preparestate!(ukf, [50, 30], [20])
14271427
preparestate!(ekf, [50, 30], [20])
1428-
σP̂ = sqrt.(diag(ukf.P̂))
1428+
σP̂ = sqrt.(diag(ukf.cov.P̂))
14291429
mhe = MovingHorizonEstimator(nonlinmodel, He=5, nint_ym=0, direct=true, σP_0=σP̂)
14301430
updatestate!(ukf, [10, 50], [50, 30], [20])
14311431
updatestate!(ekf, [10, 50], [50, 30], [20])

0 commit comments

Comments
 (0)