Skip to content

Commit 236a73c

Browse files
committed
debug test LinModel construction
1 parent e63b7a9 commit 236a73c

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/model/linmodel.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ Discrete-time linear model with a sample time Ts = 0.5 s and:
153153
```
154154
"""
155155
function LinModel(sys::TransferFunction, Ts::Union{Real,Nothing} = nothing; kwargs...)
156-
return LinModel(ss(sys), Ts; kwargs...) # minreal is called later in the constructor
156+
sys_min = minreal(ss(sys)) # remove useless states with pole-zero cancellation
157+
return LinModel(sys_min, Ts; kwargs...)
157158
end
158159

159160

@@ -175,8 +176,8 @@ Discrete-time linear model with a sample time Ts = 0.5 s and:
175176
```
176177
"""
177178
function LinModel(sys::DelayLtiSystem, Ts::Real; kwargs...)
178-
# c2d only supports :zoh for DelayLtiSystem
179-
return LinModel(c2d(sys, Ts, :zoh), Ts; kwargs...)
179+
sys_dis = minreal(c2d(sys, Ts, :zoh)) # c2d only supports :zoh for DelayLtiSystem
180+
return LinModel(sys_dis, Ts; kwargs...)
180181
end
181182

182183

test/test_sim_model.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ Gss2 = c2d(sys_ss[:,1:2], 0.5Ts, :zoh)
5757

5858
linmodel6 = LinModel([delay(4) delay(4)]*sys,Ts,i_d=[3])
5959
@test linmodel6.nx == 3
60+
println(eigvals(linmodel6.A))
6061
@test sum(eigvals(linmodel6.A) .≈ 0) == 1
6162

6263
linmodel7 = LinModel(

test/test_state_estim.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ end
363363
@test ukf1. zeros(4) atol=1e-9
364364
@test evaloutput(ukf1) ukf1() [50, 30]
365365
@test evaloutput(ukf1, Float64[]) ukf1(Float64[]) [50, 30]
366-
@test initstate!(ukf1, [10, 50], [50, 30+1]) zeros(4)
366+
@test initstate!(ukf1, [10, 50], [50, 30+1]) zeros(4) atol=1e-9
367367
setstate!(ukf1, [1,2,3,4])
368368
@test ukf1. [1,2,3,4]
369369
for i in 1:1000

0 commit comments

Comments
 (0)