Skip to content

Commit e7c1a55

Browse files
committed
updated according to updates in SystemsBase
1 parent 76082d7 commit e7c1a55

14 files changed

+71
-204
lines changed

src/ControlToolbox.jl

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
module ControlToolbox
22

3-
using ControlCore
3+
using SystemsBase
44
using Polynomials
5+
using Optim
56

67
import Base: step
78
import Base.LinAlg: BlasFloat
8-
import ControlCore: LtiSystem, StateSpace, RationalTF, ZeroPoleGain
9-
import ControlCore: Siso, Continuous
9+
import SystemsBase: LtiSystem, StateSpace, RationalTF
1010

1111
export
1212
c2d,
@@ -26,15 +26,15 @@ export
2626
dlyap,
2727
covar,
2828
norm,
29-
gram
30-
31-
# using DSP
29+
gram,
30+
realjordanform,
31+
place
3232

3333
include("c2d.jl")
3434
include("d2c.jl")
3535
include("analysis/isstable.jl")
3636
include("analysis/margins.jl")
37-
#include("analysis/rlocus.jl")
37+
include("analysis/rlocus.jl")
3838
include("analysis/damp.jl")
3939
include("analysis/dcgain.jl")
4040
include("analysis/markovparam.jl")
@@ -43,9 +43,11 @@ include("matrix_comps/lyapunov.jl")
4343
include("matrix_comps/covar.jl")
4444
include("matrix_comps/norm.jl")
4545
include("matrix_comps/gram.jl")
46-
#include("simulation/utils.jl")
46+
include("matrix_comps/realjordanform.jl")
47+
include("simulation/utils.jl")
4748
#include("simulation/lsim.jl")
4849
#include("simulation/step.jl")
4950
#include("simulation/impulse.jl")
51+
include("design/place.jl")
5052

5153
end # module

src/analysis/dcgain.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
dcgain(s::StateSpace{Siso{true}}) = _dcgain(s)[1]
2-
dcgain(s::StateSpace{Siso{false}}) = _dcgain(s)
3-
dcgain(s::LtiSystem) = dcgain(ss(s))
1+
dcgain(s::StateSpace{Val{:siso}}) = _dcgain(s)[1]
2+
dcgain(s::StateSpace{Val{:mimo}}) = _dcgain(s)
3+
dcgain(s::LtiSystem) = dcgain(ss(s))
44

5-
_dcgain{S}(s::StateSpace{S,Continuous{true}}) = s.D - s.C/s.A*s.B
6-
_dcgain{S}(s::StateSpace{S,Continuous{false}}) = s.C/(speye(size(s.A)) - s.A)*s.B + s.D
5+
_dcgain{S}(s::StateSpace{S,Val{:cont}}) = s.D - s.C/s.A*s.B
6+
_dcgain{S}(s::StateSpace{S,Val{:disc}}) = s.C/(I - s.A)*s.B + s.D

src/analysis/isstable.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11

2-
isstable{S}(s::LtiSystem{S,Continuous{false}}) = maximum(abs(poles(s))) < 1
2+
isstable{S}(s::LtiSystem{S,Val{:disc}}) = maximum(abs(poles(s))) < 1
33

4-
isstable{S}(s::LtiSystem{S,Continuous{true}}) = maximum(real(poles(s))) < 0
4+
isstable{S}(s::LtiSystem{S,Val{:cont}}) = maximum(real(poles(s))) < 0
55

6-
isstable(s::LtiSystem{Siso{false}}) = map(isstable, getmatrix(s))
6+
isstable(s::LtiSystem{Val{:mimo}}) = map(isstable, getmatrix(s))
77

88
# TODO: How to handle pole-zero cancellation
99

src/analysis/margins.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ frequency for LTI system `sys` or data from bode-plot `mag`, `phase`, `w`.
66
By definition, unity gain feedback with phase `pm` would make the closed
77
loop system unstable. By default `pm` is given in radians.
88
"""
9-
function phasemargin(sys::RationalTF{Siso{true},Continuous{true}}; deg::Bool=false)
9+
function phasemargin(sys::RationalTF{Val{:siso},Val{:cont}}; deg::Bool=false)
1010
# For sys = 1/(s+1)^2*(s+10)^2*(s+100)^4/100^4/10 the output from phasemargin is off by a noticable ammount. Haven't been able to replicate or find the problem, might be because of instabilities in roots() though...
1111

1212
Z, P = sys.num[1], sys.den[1]
@@ -27,7 +27,7 @@ function phasemargin(sys::RationalTF{Siso{true},Continuous{true}}; deg::Bool=fal
2727
end
2828

2929
# For other representations, convert to transfer function
30-
phasemargin(sys::LtiSystem{Siso{true}}; deg::Bool=false) = phasemargin(tf(sys), deg=deg)
30+
phasemargin(sys::LtiSystem{Val{:siso}}; deg::Bool=false) = phasemargin(tf(sys), deg=deg)
3131

3232

3333
"""
@@ -39,7 +39,7 @@ ammount of (pure gain) negative feedback that would make the
3939
closed loop system unstable. By default the result is given
4040
in linear units (not dB).
4141
"""
42-
function gainmargin(sys::RationalTF{Siso{true}}; dB::Bool=false)
42+
function gainmargin(sys::RationalTF{Val{:siso}}; dB::Bool=false)
4343
Z, P = sys.num[1], sys.den[1]
4444

4545
# To find w180, first solve imag(sys(jw)) == 0

src/analysis/rlocus.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Returns the closed-loop system
88
- pole trajectories at evenly spaced intervals of the gain, if `K` is
99
omitted
1010
"""
11-
function rlocus(sys::ControlCore.LtiSystem)
11+
function rlocus(sys::LtiSystem)
1212
N::Integer = 100 # Number of points in root locus
1313

1414
K = Vector{Real}(N) # Vector of gains
@@ -31,15 +31,15 @@ function rlocus(sys::ControlCore.LtiSystem)
3131
return rlocus(sys, K)
3232
end
3333

34-
function rlocus{T<:Real}(sys::ControlCore.LtiSystem, K::AbstractVector{T})
34+
function rlocus{T<:Real}(sys::LtiSystem, K::AbstractVector{T})
3535
plist = Matrix{eltype(poles(sys))}(length(K), length(denvec(sys))-1)
3636
for idx in eachindex(K)
3737
plist[idx,:] = rlocus(sys, K[idx])[1]
3838
end
3939
(plist, K)
4040
end
4141

42-
rlocus(sys::ControlCore.LtiSystem, k::Real) = poles(feedback(sys,k)), k
42+
rlocus(sys::LtiSystem, k::Real) = poles(feedback(sys,k)), k
4343

4444
"""
4545
`max_cplx_distance(C)`

0 commit comments

Comments
 (0)