Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
54583d5
first sisotool chechpoint
icam0 May 23, 2018
2e1bf7d
second sisotool checkpoint
icam0 May 24, 2018
f4545dd
changed matplotlib event handler
icam0 May 25, 2018
e3c1f31
improved sisotool readability
icam0 May 25, 2018
72ffb63
Merge branch 'bode_margins_plot' into sisotool_merge
icam0 May 25, 2018
bde60f5
Added display of GM and PM in bode plot. Fixed Hz bug support. Fixed …
icam0 May 28, 2018
bc74a0a
Added support for both matplotlib 1.x.x. and 2.x.x and fixed redrawin…
icam0 May 29, 2018
1e3a925
Added docstring and unittest
icam0 May 29, 2018
94a0ea1
removed bug where a pole or zero would be deleted if only 1 of them w…
icam0 May 30, 2018
c0e533e
root locus smooth with zoom bug
icam0 Jun 2, 2018
fe13ae1
Fixed zooming on plot. Now displays smoother root locus plot.
icam0 Jun 2, 2018
2ba8277
Fixed paning on plot and clicking on the root locus plot while zoomed
icam0 Jun 3, 2018
c26187f
Added unit test for rootlocus zoom functionality
icam0 Jun 3, 2018
9962cea
Fixed sisotool unittest
icam0 Jun 3, 2018
938ae88
Fixed frequency response unittest
icam0 Jun 3, 2018
9f13a77
small change to sisotool test
icam0 Jun 3, 2018
6e06a9c
small change to unittests
icam0 Jun 3, 2018
cdb9f42
fixed python 2 integer division error in false gain of rootlocus
icam0 Jun 3, 2018
90959bd
changed root locus test to a numerically more significant one.
icam0 Jun 3, 2018
70ec8be
changed root locus test indices.
icam0 Jun 3, 2018
9f50e13
Merge branch 'master' into sisotool_final
repagh Jul 9, 2018
3e7cad6
Merge branch 'master' into sisotool_final
murrayrm Dec 29, 2018
43d8b95
Merge branch 'master' into sisotool_final
murrayrm Apr 11, 2019
03f87a3
Fix small typo from manual merge
murrayrm Apr 12, 2019
17c4a95
fixed issues identified in review
murrayrm Apr 12, 2019
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
Next Next commit
first sisotool chechpoint
  • Loading branch information
icam0 committed May 23, 2018
commit 54583d52a223430c79998f8d09ebf0cfb5952b7f
1 change: 1 addition & 0 deletions control/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
from .canonical import *
from .robust import *
from .config import *
from .sisotool import *

# Exceptions
from .exception import *
Expand Down
48 changes: 30 additions & 18 deletions control/rlocus.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

# Main function: compute a root locus diagram
def root_locus(sys, kvect=None, xlim=None, ylim=None, plotstr='-', Plot=True,
PrintGain=True, grid=False):
PrintGain=True, grid=False, sisotool = False, f=None, ax =None):
"""Root locus plot

Calculate the root locus by finding the roots of 1+k*TF(s)
Expand Down Expand Up @@ -103,21 +103,21 @@ def root_locus(sys, kvect=None, xlim=None, ylim=None, plotstr='-', Plot=True,

# Create the Plot
if Plot:
figure_number = pylab.get_fignums()
figure_title = [pylab.figure(numb).canvas.get_window_title() for numb in figure_number]
new_figure_name = "Root Locus"
rloc_num = 1
while new_figure_name in figure_title:
new_figure_name = "Root Locus " + str(rloc_num)
rloc_num += 1
f = pylab.figure(new_figure_name)
if sisotool == False:
figure_number = pylab.get_fignums()
figure_title = [pylab.figure(numb).canvas.get_window_title() for numb in figure_number]
new_figure_name = "Root Locus"
rloc_num = 1
while new_figure_name in figure_title:
new_figure_name = "Root Locus " + str(rloc_num)
rloc_num += 1
f = pylab.figure(new_figure_name)
ax = pylab.axes()

ax = pylab.axes()

if PrintGain:
click_point, = ax.plot([0], [0],color='k',markersize = 0,marker='s',zorder=20)
f.canvas.mpl_connect(
'button_release_event', partial(_RLFeedbackClicks, sys=sys,fig=f,point=click_point))
'button_release_event', partial(_RLFeedbackClicks,sys=sys,fig=f,sisotool=sisotool))

# plot open loop poles
poles = array(denp.r)
Expand Down Expand Up @@ -344,21 +344,33 @@ def _RLSortRoots(mymat):
return sorted


def _RLFeedbackClicks(event, sys,fig,point):
def _RLFeedbackClicks(event,sys,fig,sisotool):
"""Print root-locus gain feedback for clicks on the root-locus plot
"""
(nump, denp) = _systopoly1d(sys)
s = complex(event.xdata, event.ydata)
K = -1./sys.horner(s)
if abs(K.real) > 1e-8 and abs(K.imag/K.real) < 0.04:
print("Clicked at %10.4g%+10.4gj gain %10.4g damp %10.4g" %
(s.real, s.imag, K.real, -1 * s.real / abs(s)))
point.set_ydata(s.imag)
point.set_xdata(s.real)
point.set_markersize(8)
fig.suptitle("Clicked at: %10.4g%+10.4gj gain: %10.4g damp: %10.4g" %
(s.real, s.imag, K.real, -1 * s.real / abs(s)))
fig.canvas.draw()
(s.real, s.imag, K.real, -1 * s.real / abs(s)))

ax = fig.axes[0]
for line in reversed(ax.lines):
if len(line.get_xdata()) == 1:
line.remove()
del line
else:
break

if sisotool:
mymat = _RLFindRoots(nump, denp, K.real)
ax.plot([root.real for root in mymat],[root.imag for root in mymat],'m.',marker='s',markersize=8, zorder=20)
else:
ax.plot(s.real, s.imag, 'k.', marker='s', markersize=8, zorder=20)

fig.canvas.draw()

def _sgrid_func(fig=None, zeta=None, wn=None):
if fig is None:
Expand Down
10 changes: 10 additions & 0 deletions control/sisotool.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
__all__ = ['sisotool']

from .freqplot import bode_plot
from .rlocus import root_locus
import matplotlib.pyplot as plt

def sisotool(sys, kvect=None,PrintGain=True,grid=False,dB=None,Hz=None,deg=None):
f, (ax1, ax2) = plt.subplots(1, 2)
root_locus(sys,ax=ax1,f=f,sisotool=True)
#bode_plot(sys,ax=ax2)