Skip to content

Commit 6c00501

Browse files
authored
Merge pull request #201 from baggepinnen/fix-llpf-parameters
Qualify parameters in the LowLevelParticleFilters methods, add timeevol to FRD
2 parents bfc0f7c + 6d49a13 commit 6c00501

6 files changed

Lines changed: 17 additions & 7 deletions

File tree

‎Project.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ControlSystemIdentification"
22
uuid = "3abffc1c-5106-53b7-b354-a47bfc086282"
3-
version = "2.12.0"
3+
version = "2.12.1"
44
authors = ["baggepinnen <baggepinnen@gmail.com>"]
55

66
[deps]

‎src/frd.jl‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,12 @@ end
9191
Base.lastindex(f::FRD) = length(f)
9292
function Base.getproperty(f::FRD, s::Symbol)
9393
s === :Ts && return π / maximum(f.w)
94+
s === :timeevol && return Continuous()
9495
s === :nu && return ninputs(f)
9596
s === :ny && return noutputs(f)
9697
getfield(f, s)
9798
end
98-
Base.propertynames(f::FRD, private::Bool = false) = (fieldnames(typeof(f))..., :Ts)
99+
Base.propertynames(f::FRD, private::Bool = false) = (fieldnames(typeof(f))..., :Ts, :timeevol, :nu, :ny)
99100

100101
function Base.show(io::IO, frd::FRD)
101102
write(io, "Frequency (rad/s)\n")
@@ -120,7 +121,7 @@ function ControlSystemsBase.bode(f::FRD, w::AbstractVector = f.w; unwrap=true)
120121
reshape(abs.(f.r), f.ny, f.nu, :), angles, f.w
121122
end
122123

123-
function ControlSystemsBase.freqresp(f::FRD, w::AbstractVector{W} = f.w) where W <: Real
124+
function ControlSystemsBase.freqresp(f::FRD, w::AbstractVector{W} = f.w; kwargs...) where W <: Real # kwargs such as balance do not apply to frequency-response data
124125
w == f.w || error("Frequency vector must match the one stored in the FRD")
125126
reshape(f.r, f.ny, f.nu, :)
126127
end

‎src/subspace.jl‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,23 +247,23 @@ end
247247

248248
m2vv(x) = collect.(eachcol(x))
249249

250-
function LowLevelParticleFilters.forward_trajectory(kf::LowLevelParticleFilters.AbstractFilter, d::AbstractIdData, p=parameters(kf))
250+
function LowLevelParticleFilters.forward_trajectory(kf::LowLevelParticleFilters.AbstractFilter, d::AbstractIdData, p=LowLevelParticleFilters.parameters(kf))
251251
y = time2(output(d))
252252
u = input(d)
253253
U = m2vv(u)
254254
Y = m2vv(y)
255255
forward_trajectory(kf, U, Y, p)
256256
end
257257

258-
function LowLevelParticleFilters.smooth(kf::LowLevelParticleFilters.AbstractFilter, d::AbstractIdData, p=parameters(kf))
258+
function LowLevelParticleFilters.smooth(kf::LowLevelParticleFilters.AbstractFilter, d::AbstractIdData, p=LowLevelParticleFilters.parameters(kf))
259259
y = time2(output(d))
260260
u = input(d)
261261
U = m2vv(u)
262262
Y = m2vv(y)
263263
LowLevelParticleFilters.smooth(kf, U, Y, p)
264264
end
265265

266-
function LowLevelParticleFilters.smooth(kf::LowLevelParticleFilters.AbstractFilter, M::Int, d::AbstractIdData, p=parameters(kf))
266+
function LowLevelParticleFilters.smooth(kf::LowLevelParticleFilters.AbstractFilter, M::Int, d::AbstractIdData, p=LowLevelParticleFilters.parameters(kf))
267267
y = time2(output(d))
268268
u = input(d)
269269
U = m2vv(u)

‎test/test_basis_functions.jl‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ for basis in [kautz(av), laguerre(1,n), laguerre_oo(1,n), adhocbasis(av)]
99
F = sum_basis(basis, p)
1010
fr1 = freqresp(F, w) |> vec
1111
fr2 = freqresp(tf(1), basis, w, p) |> vec
12-
@test norm(fr1-fr2) < 1e-10
12+
@test norm(fr1-fr2) < 2e-9
1313
@test basislength(basis) == n
1414
end
1515
basis = laguerre_oo(1,n)

‎test/test_frd.jl‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@ frd = FRD(w, G); # Build a frequency-response data object
176176

177177
@test bode(frd) == bode(G, w)
178178
@test nyquist(frd) == nyquist(G, w)
179+
@test ControlSystemsBase.iscontinuous(frd)
180+
@test freqresp(frd, w; balance = false) == freqresp(frd)
179181

180182
@test size([frd frd]) == (ny, 2nu)
181183
@test size([frd; frd]) == (2ny, nu)

‎test/test_subspace.jl‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,13 @@ end
166166
@test kf.B == res.B
167167
@test kf.C == res.C
168168

169+
sol = ControlSystemIdentification.LowLevelParticleFilters.forward_trajectory(kf, d)
170+
@test length(sol.x) == length(d)
171+
if pkgversion(ControlSystemIdentification.LowLevelParticleFilters) >= v"3.33.1" # Earlier versions dispatch smooth(::KalmanFilter, ::AbstractIdData) to their own method
172+
ssol = ControlSystemIdentification.LowLevelParticleFilters.smooth(kf, d)
173+
@test length(ssol.xT) == length(d)
174+
end
175+
169176
end
170177

171178
# Test u scaling

0 commit comments

Comments
 (0)