Skip to content

Commit

Permalink
better warnings in dab
Browse files Browse the repository at this point in the history
  • Loading branch information
baggepinnen committed Feb 14, 2023
1 parent 34543bc commit eb58411
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/ControlSystemsBase/src/discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ function rst(bplus,bminus,a,bm1,am,ao,ar=[1],as=[1] ;cont=true)
ae = conv(a,ar)
be = conv(bminus,as)
aoam = conv(am,ao)
r1,s1 = dab(ae,be,aoam)
ret = dab(ae,be,aoam)
ret === nothing && error("Controller not casual, deg(S) > deg(R), consider increasing degree of observer polynomial")
r1,s1 = ret

r = conv(conv(r1,ar),bplus)
s = conv(s1,as)
Expand All @@ -131,6 +133,8 @@ function rst(bplus,bminus,a,bm1,am,ao,ar=[1],as=[1] ;cont=true)
t = t/r[1]
r = r/r[1]

length(s) > length(r) && @warn("Controller not casual, deg(S) > deg(R), consider increasing degree of observer polynomial")

r,s,t
end

Expand Down Expand Up @@ -219,7 +223,6 @@ function dab(a,b,c)
rs = (c'/(m'))'
r = rs[1:nr]
s = rs[nr+1:nc]
length(s) > length(r) && @warn("Controller not casual, deg(S) > deg(R), consider increasing degree of observer polynomial")
r,s
end

Expand Down
3 changes: 3 additions & 0 deletions lib/ControlSystemsBase/test/test_discrete.jl
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,7 @@ p = poles(Gcl)
@test norm(minimum(abs.((poles(tf(1,Ao)) .- sort(p, by=imag)')), dims=2)) < 1e-6


pd = c2d_poly2poly(A, 0.1)
@test pd denvec(c2d(P, 0.1))[]

end

0 comments on commit eb58411

Please sign in to comment.