|
| 1 | +# __init__.py - initialization for control systems toolbox |
| 2 | +# |
| 3 | +# Author: Richard M. Murray |
| 4 | +# Date: 24 May 09 |
| 5 | +# |
| 6 | +# This file contains the initialization information from the control package. |
| 7 | +# |
| 8 | +# Copyright (c) 2009 by California Institute of Technology |
| 9 | +# All rights reserved. |
| 10 | +# |
| 11 | +# Redistribution and use in source and binary forms, with or without |
| 12 | +# modification, are permitted provided that the following conditions |
| 13 | +# are met: |
| 14 | +# |
| 15 | +# 1. Redistributions of source code must retain the above copyright |
| 16 | +# notice, this list of conditions and the following disclaimer. |
| 17 | +# |
| 18 | +# 2. Redistributions in binary form must reproduce the above copyright |
| 19 | +# notice, this list of conditions and the following disclaimer in the |
| 20 | +# documentation and/or other materials provided with the distribution. |
| 21 | +# |
| 22 | +# 3. Neither the name of the California Institute of Technology nor |
| 23 | +# the names of its contributors may be used to endorse or promote |
| 24 | +# products derived from this software without specific prior |
| 25 | +# written permission. |
| 26 | +# |
| 27 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 28 | +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 29 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 30 | +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CALTECH |
| 31 | +# OR THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 32 | +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 33 | +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 34 | +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 35 | +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 36 | +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 37 | +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 38 | +# SUCH DAMAGE. |
| 39 | +# |
| 40 | +# $Id$ |
| 41 | + |
| 42 | +"""Control System Library |
| 43 | +
|
| 44 | +The Python Control System Library (control) provides common functions |
| 45 | +for analyzing and designing feedback control systems. |
| 46 | +
|
| 47 | +Common functions |
| 48 | +---------------- |
| 49 | +tf create a transfer function from num, den coefficients |
| 50 | +ss create a state space system from A, B, C, D matrices |
| 51 | +pzk create a transfer function from pole, zero, gain |
| 52 | +frd create a system description as frequency response |
| 53 | +bode generate a Bode plot for a linear I/O system |
| 54 | +nyquist generate a Nyquist plot for a linear I/O system |
| 55 | +lqr linear quadratic regulator |
| 56 | +lqe linear quadratic estimator |
| 57 | +""" |
| 58 | + |
| 59 | +try: |
| 60 | + __CONTROL_SETUP__ |
| 61 | +except NameError: |
| 62 | + __CONTROL_SETUP__ = False |
| 63 | + |
| 64 | +if __CONTROL_SETUP__: |
| 65 | + import sys as _sys |
| 66 | + _sys.stderr.write('Running from control source directory.\n') |
| 67 | + del _sys |
| 68 | +else: |
| 69 | + |
| 70 | + # Import functions from within the control system library |
| 71 | + # Should probably only import the exact functions we use... |
| 72 | + from .bdalg import series, parallel, negate, feedback |
| 73 | + from .delay import pade |
| 74 | + from .dtime import sample_system |
| 75 | + from .freqplot import bode_plot, nyquist_plot, gangof4_plot |
| 76 | + from .freqplot import bode, nyquist, gangof4 |
| 77 | + from .lti import issiso, timebase, timebaseEqual, isdtime, isctime |
| 78 | + from .margins import stability_margins, phase_crossover_frequencies |
| 79 | + from .mateqn import lyap, dlyap, care, dare |
| 80 | + from .modelsimp import hsvd, modred, balred, era, markov |
| 81 | + from .nichols import nichols_plot, nichols |
| 82 | + from .phaseplot import phase_plot, box_grid |
| 83 | + from .rlocus import root_locus |
| 84 | + from .statefbk import place, lqr, ctrb, obsv, gram, acker |
| 85 | + from .statesp import StateSpace |
| 86 | + from .timeresp import forced_response, initial_response, step_response, \ |
| 87 | + impulse_response |
| 88 | + from .xferfcn import TransferFunction |
| 89 | + from .ctrlutil import unwrap, issys |
| 90 | + from .frdata import FRD |
| 91 | + from .canonical import canonical_form, reachable_form |
| 92 | + |
| 93 | + # Exceptions |
| 94 | + from .exception import * |
| 95 | + |
| 96 | + # Import some of the more common (and benign) MATLAB shortcuts |
| 97 | + # By default, don't import conflicting commands here |
| 98 | + #! TODO (RMM, 4 Nov 2012): remove MATLAB dependencies from __init__.py |
| 99 | + #! |
| 100 | + #! Eventually, all functionality should be in modules *other* than matlab. |
| 101 | + #! This will allow inclusion of the matlab module to set up a different set |
| 102 | + #! of defaults from the main package. At that point, the matlab module will |
| 103 | + #! allow provide compatibility with MATLAB but no package functionality. |
| 104 | + #! |
| 105 | + from .matlab import ss, tf, ss2tf, tf2ss, drss |
| 106 | + from .matlab import pole, zero, evalfr, freqresp, dcgain |
| 107 | + from .matlab import nichols, rlocus, margin |
| 108 | + # bode and nyquist come directly from freqplot.py |
| 109 | + from .matlab import step, impulse, initial, lsim |
| 110 | + from .matlab import ssdata, tfdata |
| 111 | + |
| 112 | +# The following is to use Numpy's testing framework |
| 113 | +# Tests go under directory tests/, benchmarks under directory benchmarks/ |
| 114 | + from numpy.testing import Tester |
| 115 | + test = Tester().test |
| 116 | + bench = Tester().bench |
0 commit comments