Skip to content

Commit

Permalink
Merge pull request #71 from JuliaControl/resdist
Browse files Browse the repository at this point in the history
add method for resonant augmentation that takes input matrix
  • Loading branch information
baggepinnen committed Nov 15, 2022
2 parents 24eb932 + 9a3bb88 commit 041969f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/model_augmentation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ function add_resonant_disturbance(sys::AbstractStateSpace{Continuous}, ω, ζ, A
measurement ? add_measurement_disturbance(sys, Ad, Cd) : add_disturbance(sys, Ad, Cd)
end

"""
add_resonant_disturbance(sys::AbstractStateSpace, ω, ζ, Bd::AbstractArray)
- `Bd`: The disturbance input matrix.
"""
function add_resonant_disturbance(sys::AbstractStateSpace, ω, ζ, Bd::AbstractArray)
Ad = [-ζ -float(ω); ω -ζ]
if isdiscrete(sys)
Ad .*= sys.Ts
Ad = exp(Ad)
end
add_disturbance(sys, Ad, [Bd zeros(sys.nx)])
end

"""
add_differentiator(sys::StateSpace{<:Discrete})
Expand Down
7 changes: 7 additions & 0 deletions test/test_augmentation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ Gd = add_resonant_disturbance(G, 1, 0, 1, measurement=true)
@test rank(ctrb(Gd)) == 3
@test any(isapprox(1, atol=eps()), imag.(poles(Gd)))

# Discrete time and input matrix
G = c2d(ss(tf(1.0, [1, 1])), 0.1)
Gd = add_resonant_disturbance(G, 1, 0, [1.0])
@test sminreal(Gd) == G
@test Gd.nx == 3
allapproxin(a, b) = all(any(a .≈ b', dims=2))
@test allapproxin(poles(Gd), [eigvals(exp([0 -1; 1 0]*0.1)); exp(-1*0.1)])


##
Expand Down

0 comments on commit 041969f

Please sign in to comment.