Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions control/passivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
except ImportError as e:
cvx = None

lmi_epsilon = 1e-12
Comment thread
Mark-Yeatman marked this conversation as resolved.
Resolved

def is_passive(sys):
Comment thread
Mark-Yeatman marked this conversation as resolved.
Resolved
'''
Expand All @@ -30,6 +31,10 @@ def is_passive(sys):
C = sys.C
D = sys.D

#account for strictly proper systems
[n,m] = D.shape
D = D + np.nextafter(0,1)*np.eye(n,m)

def make_LMI_matrix(P):
V = np.vstack((
np.hstack((A.T @ P + P@A, P@B)),
Expand Down Expand Up @@ -59,6 +64,7 @@ def make_LMI_matrix(P):
c = cvx.matrix(0.0, (number_of_opt_vars, 1))

# crunch feasibility solution
cvx.solvers.options['show_progress'] = False
sol = cvx.solvers.sdp(c,
Gs=[cvx.matrix(coefficents)],
hs=[cvx.matrix(constants)])
Expand Down
12 changes: 12 additions & 0 deletions control/tests/passivity_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,22 @@ def test_is_passive():
D = numpy.array([[1.5]])
sys = ss(A, B, C, D)

# happy path is passive
assert(passivity.is_passive(sys))

# happy path not passive
D = -D
sys = ss(A, B, C, D)

assert(not passivity.is_passive(sys))

#edge cases of D=0 boundary condition
Comment thread
Mark-Yeatman marked this conversation as resolved.
Resolved
B *= 0
C *= 0
D *= 0
sys = ss(A, B, C, D)
assert(passivity.is_passive(sys))

A = A*1e12
sys = ss(A, B, C, D)
assert(passivity.is_passive(sys))