Skip to content

Commit

Permalink
Merge pull request #565 from JuliaControl/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
baggepinnen authored Nov 7, 2021
2 parents bde0c05 + 7e43220 commit 7533957
Show file tree
Hide file tree
Showing 50 changed files with 999 additions and 1,021 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- master
- dev
push:
branches:
- master
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ Some of the available commands are:
##### Constructing systems
ss, tf, zpk
##### Analysis
pole, tzero, norm, hinfnorm, linfnorm, ctrb, obsv, gangoffour, margin, markovparam, damp, dampreport, zpkdata, dcgain, covar, gram, sigma, sisomargin
poles, tzeros, norm, hinfnorm, linfnorm, ctrb, obsv, gangoffour, margin, markovparam, damp, dampreport, zpkdata, dcgain, covar, gram, sigma, sisomargin
##### Synthesis
care, dare, dlyap, lqr, dlqr, place, leadlink, laglink, leadlinkat, rstd, rstc, dab, balreal, baltrunc
###### PID design
Expand Down
8 changes: 4 additions & 4 deletions docs/src/examples/example.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```@meta
DocTestSetup = quote
using ControlSystems
using ControlSystems, Plots
plotsDir = joinpath(dirname(pathof(ControlSystems)), "..", "docs", "build", "plots")
mkpath(plotsDir)
save_docs_plot(name) = Plots.savefig(joinpath(plotsDir,name))
Expand All @@ -25,7 +25,7 @@ u(x,t) = -L*x .+ 1.5(t>=2.5)# Form control law (u is a function of t and x), a
t =0:Ts:5
x0 = [1,0]
y, t, x, uout = lsim(sys,u,t,x0=x0)
Plots.plot(t,x, lab=["Position" "Velocity"], xlabel="Time [s]")
Plots.plot(t,x', lab=["Position" "Velocity"], xlabel="Time [s]")
save_docs_plot("lqrplot.svg"); # hide
Expand Down Expand Up @@ -132,8 +132,8 @@ R,S,T = rstc(B⁺,B⁻,A,Bm,Am,Ao,AR) # Calculate the 2-DOF controller polynomia
Gcl = tf(conv(B,T),zpconv(A,R,B,S)) # Form the closed loop polynomial from reference to output, the closed-loop characteristic polynomial is AR + BS, the function zpconv takes care of the polynomial multiplication and makes sure the coefficient vectores are of equal length
stepplot(P)
stepplot!(Gcl) # Visualize the open and closed loop responses.
plot(step(P))
plot!(step(Gcl)) # Visualize the open and closed loop responses.
save_docs_plot("ppstepplot.svg") # hide
gangoffourplot(P, tf(-S,R)) # Plot the gang of four to check that all tranfer functions are OK
save_docs_plot("ppgofplot.svg"); # hide
Expand Down
7 changes: 7 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

```@meta
CurrentModule = ControlSystems
DocTestFilters = [
r"StateSpace.+?\n"
r"HeteroStateSpace.+?\n"
r"TransferFunction.+?\n"
r"DelayLtiSystem.+?\n"
r"┌ Warning: Keyword argument hover.+?\n.+?\n" # remove next line as well
]
```

## Guide
Expand Down
2 changes: 1 addition & 1 deletion docs/src/man/creating_systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ D =
Continuous-time state-space model
julia> HeteroStateSpace(sys, to_sized)
HeteroStateSpace{Continuous, SizedMatrix{2, 2, Int64, 2}, SizedMatrix{2, 1, Int64, 2}, SizedMatrix{1, 2, Int64, 2}, SizedMatrix{1, 1, Int64, 2}}
HeteroStateSpace{Continuous, SizedMatrix{2, 2, Int64, 2, Matrix{Int64}}, SizedMatrix{2, 1, Int64, 2, Matrix{Int64}}, SizedMatrix{1, 2, Int64, 2, Matrix{Int64}}, SizedMatrix{1, 1, Int64, 2, Matrix{Int64}}}
A =
-5 0
0 -5
Expand Down
22 changes: 15 additions & 7 deletions example/dc_motor_lqg_design.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function motor(Ke, Kt, L, R, J, b=1e-3)
end

p60 = motor(Ke, Kt, L, Rel, J)
f1 = stepplot(p60)
f1 = stepplot(p60, 1)
f2 = bodeplot(p60)

# LQR control
Expand All @@ -45,12 +45,20 @@ Nbar = 1. ./ (p60.D - (p60.C - p60.D*K) * inv(p60.A - p60.B*K) * p60.B)
Vd = [10. 0 # covariance of the speed estimation
0 10]; # covariance of the current estimation
Vn = 0.04; # covariance for the speed measurement (radians/s)^2
G = LQG(p60, Q, mat(R), Vd, mat(Vn))
Gcl = G[:cl]
T = G[:T]
S = G[:S];
Ka = kalman(p60, Vd, mat(Vn))
C = ControlSystems.observer_controller(p60, K, Ka)

Gcl = let (A,B,C,D) = ssdata(p60)
Acl = [A-B*K B*K; zero(A) A-Ka*C]
Bcl = [B * Nbar; zero(B)]
Ccl = [C zero(C)]
ss(Acl, Bcl, Ccl, 0)
end

T = Gcl
S = 1-T

# 1000 logarithmically spaced values from -3 to 3
f3 = sigmaplot([S,T], exp10.(range(-3, stop=3, length=1000)))
f4 = stepplot(Gcl, label=["Closed loop system using LQG"])
f3 = bodeplot([Gcl, S, T], exp10.(range(-3, stop=3, length=1000)))
f4 = stepplot(Gcl, 1, label="Closed loop system using LQG")
Plots.plot(f1, f2, f3, f4, layout=(2,2), size=(800, 600))
16 changes: 10 additions & 6 deletions src/ControlSystems.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export LTISystem,
ss,
tf,
zpk,
LQG,
isproper,
# Linear Algebra
balance,
Expand All @@ -32,7 +31,6 @@ export LTISystem,
ctrb,
obsv,
place,
luenberger,
# Model Simplification
reduce_sys,
sminreal,
Expand All @@ -42,10 +40,12 @@ export LTISystem,
similarity_transform,
prescale,
innovation_form,
observer_predictor,
observer_controller,
# Stability Analysis
isstable,
pole,
tzero,
poles,
tzeros,
dcgain,
zpkdata,
damp,
Expand Down Expand Up @@ -115,6 +115,8 @@ using MacroTools

abstract type AbstractSystem end


include("types/result_types.jl")
include("types/TimeEvolution.jl")
## Added interface:
# timeevol(Lti) -> TimeEvolution (not exported)
Expand All @@ -141,8 +143,6 @@ include("types/DelayLtiSystem.jl")
include("types/tf.jl")
include("types/zpk.jl")

include("types/lqg.jl") # QUESTION: is it really motivated to have an LQG type?

include("utilities.jl")

include("types/promotion.jl")
Expand All @@ -169,10 +169,14 @@ include("delay_systems.jl")

include("plotting.jl")

@deprecate pole poles
@deprecate tzero tzeros
@deprecate num numvec
@deprecate den denvec
@deprecate norminf hinfnorm
@deprecate diagonalize(s::AbstractStateSpace, digits) diagonalize(s::AbstractStateSpace)
@deprecate luenberger(sys, p) place(sys, p, :o)
@deprecate luenberger(A, C, p) place(A, C, p, :o)
# There are some deprecations in pid_control.jl for laglink/leadlink/leadlinkat

function covar(D::Union{AbstractMatrix,UniformScaling}, R)
Expand Down
Loading

0 comments on commit 7533957

Please sign in to comment.