|
115 | 115 | @test x̂ ≈ [0, 0]
|
116 | 116 | @test isa(x̂, Vector{Float32})
|
117 | 117 | @test_throws ArgumentError updatestate!(skalmanfilter1, [10, 50])
|
| 118 | + @test_throws ErrorException setstate!(skalmanfilter1, [1,2,3,4], diagm(.1:.1:.4)) |
118 | 119 | end
|
119 | 120 |
|
120 | 121 | @testitem "SteadyKalmanFilter set model" setup=[SetupMPCtests] begin
|
|
211 | 212 | @test evaloutput(kalmanfilter1, d) ≈ kalmanfilter1(d) ≈ [50, 30]
|
212 | 213 | @test_skip @allocations(evaloutput(kalmanfilter1, d)) == 0
|
213 | 214 | @test initstate!(kalmanfilter1, [10, 50], [50, 30+1]) ≈ [zeros(3); [1]]
|
214 |
| - setstate!(kalmanfilter1, [1,2,3,4]) |
| 215 | + setstate!(kalmanfilter1, [1,2,3,4], diagm(.1:.1:.4)) |
215 | 216 | @test kalmanfilter1.x̂0 ≈ [1,2,3,4]
|
| 217 | + @test kalmanfilter1.P̂ ≈ diagm(.1:.1:.4) |
216 | 218 | for i in 1:40
|
217 | 219 | preparestate!(kalmanfilter1, [50, 30])
|
218 | 220 | updatestate!(kalmanfilter1, [11, 52], [50, 30])
|
|
363 | 365 | x̂ = updatestate!(lo3, [0], [0])
|
364 | 366 | @test x̂ ≈ [0, 0]
|
365 | 367 | @test isa(x̂, Vector{Float32})
|
| 368 | + @test_throws ErrorException setstate!(lo1, [1,2,3,4], diagm(.1:.1:.4)) |
366 | 369 | end
|
367 | 370 |
|
368 | 371 | @testitem "Luenberger set model" setup=[SetupMPCtests] begin
|
|
484 | 487 | x̂ = updatestate!(internalmodel3, [0], [0])
|
485 | 488 | @test x̂ ≈ [0]
|
486 | 489 | @test isa(x̂, Vector{Float32})
|
| 490 | + @test_throws ErrorException setstate!(internalmodel1, [1,2,3,4], diagm(.1:.1:.4)) |
487 | 491 | end
|
488 | 492 |
|
489 | 493 | @testitem "InternalModel set model" setup=[SetupMPCtests] begin
|
|
598 | 602 | @test evaloutput(ukf1, d) ≈ ukf1(d) ≈ [50, 30]
|
599 | 603 | @test_skip @allocations(evaloutput(ukf1, d)) == 0
|
600 | 604 | @test initstate!(ukf1, [10, 50], [50, 30+1]) ≈ zeros(4) atol=1e-9
|
601 |
| - setstate!(ukf1, [1,2,3,4]) |
| 605 | + setstate!(ukf1, [1,2,3,4], diagm(.1:.1:.4)) |
602 | 606 | @test ukf1.x̂0 ≈ [1,2,3,4]
|
| 607 | + @test ukf1.P̂ ≈ diagm(.1:.1:.4) |
603 | 608 | for i in 1:40
|
604 | 609 | preparestate!(ukf1, [50, 30])
|
605 | 610 | updatestate!(ukf1, [11, 52], [50, 30])
|
|
757 | 762 | @test evaloutput(ekf1, d) ≈ ekf1(d) ≈ [50, 30]
|
758 | 763 | @test_skip @allocations(evaloutput(ekf1, d)) == 0
|
759 | 764 | @test initstate!(ekf1, [10, 50], [50, 30+1]) ≈ zeros(4);
|
760 |
| - setstate!(ekf1, [1,2,3,4]) |
| 765 | + setstate!(ekf1, [1,2,3,4], diagm(.1:.1:.4)) |
761 | 766 | @test ekf1.x̂0 ≈ [1,2,3,4]
|
| 767 | + @test ekf1.P̂ ≈ diagm(.1:.1:.4) |
762 | 768 | for i in 1:40
|
763 | 769 | preparestate!(ekf1, [50, 30])
|
764 | 770 | updatestate!(ekf1, [11, 52], [50, 30])
|
@@ -1055,6 +1061,7 @@ end
|
1055 | 1061 | x̂ = preparestate!(mhe6, [50, 30], [5])
|
1056 | 1062 | @test x̂ ≈ zeros(6) atol=1e-9
|
1057 | 1063 | @test_nowarn ModelPredictiveControl.info2debugstr(info)
|
| 1064 | + @test_throws ErrorException setstate!(mhe1, [1,2,3,4,5,6], diagm(.1:.1:.6)) |
1058 | 1065 | end
|
1059 | 1066 |
|
1060 | 1067 | @testitem "MovingHorizonEstimator fallbacks for arrival covariance estimation" setup=[SetupMPCtests] begin
|
|
0 commit comments