Skip to content

Commit

Permalink
remove LQG
Browse files Browse the repository at this point in the history
The functionality was very buggy and poorly tested. A much improved version with proper tests are available in https://github.com/JuliaControl/RobustAndOptimalControl.jl/blob/master/src/lqg.jl
  • Loading branch information
baggepinnen committed Oct 20, 2021
1 parent a0c960a commit 91314d3
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 338 deletions.
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))
3 changes: 0 additions & 3 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 Down Expand Up @@ -142,8 +141,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 Down
4 changes: 0 additions & 4 deletions src/synthesis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ For the continuous time model `dx = Ax + Bu`.
Solve the LQR problem for state-space system `sys`. Works for both discrete
and continuous time systems.
See also `LQG`
Usage example:
```julia
using LinearAlgebra # For identity matrix I
Expand Down Expand Up @@ -44,8 +42,6 @@ end
kalman(sys, R1, R2)
Calculate the optimal Kalman gain
See also `LQG`
"""
kalman(A, C, R1,R2) = Matrix(lqr(A',C',R1,R2)')

Expand Down
277 changes: 0 additions & 277 deletions src/types/lqg.jl

This file was deleted.

1 change: 0 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ my_tests = [
"test_timeresp",
"test_analysis",
"test_matrix_comps",
"test_lqg",
"test_synthesis",
"test_pid_design",
"test_partitioned_statespace",
Expand Down
Loading

0 comments on commit 91314d3

Please sign in to comment.