Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add method for resonant augmentation that takes input matrix #71

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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