コード例 #1
0
ファイル: loopshape_out.py プロジェクト: mebach/hummingbird
import sys
sys.path.append('..')  # add parent directory
import pendulumParam as P
import matplotlib.pyplot as plt
from control import TransferFunction as tf
import control as cnt
import numpy as np
import loopshape_in as L_in

P_out = tf([P.ell/2,0,-P.g], [1, 0, 0])

# construct plant as cascade of P_out and closed inner loop
Plant = tf.minreal(P_out* \
                   (L_in.P_in*L_in.C/(1+L_in.P_in*L_in.C)))

PLOT = False
#PLOT = True

if PLOT: plt.figure(3), plt.clf()
mag, phase, omega = cnt.bode(Plant, dB=True,
                             omega=np.logspace(-3, 5),
                             Plot=False)
if PLOT: 
    plt.subplot(2, 1, 1), plt.grid(True)
    plantMagPlot, = plt.semilogx(omega, mag,
                                 label='Plant')
    plt.subplot(2,1,2), plt.grid(True)
    plantPhasePlot, = plt.semilogx(omega, phase,
                                   label='Plant')

#########################################
コード例 #2
0
import satelliteParam as P
sys.path.append('../hw10')  # add parent directory
import satelliteParamHW10 as P10
import matplotlib.pyplot as plt
from control import TransferFunction as tf
import control as cnt
import numpy as np
import loopshape_in as L_in

P_out = tf([P.sigma * P.b, P.b + P.sigma * P.k, P.k], [
    P.sigma * P.Jp, P.Jp + P.b * P10.kd_phi + P.sigma * P.b,
    P.b + P.k * P10.kd_phi + P.sigma * P.k, P.k
])

# construct plant as cascade of P_out and closed inner loop
Plant = tf.minreal(P_out * (L_in.P_in * L_in.Control /
                            (1 + L_in.P_in * L_in.Control)))

PLOT = False
#PLOT = True

if PLOT: plt.figure(3), plt.clf()
mag, phase, omega = cnt.bode(Plant,
                             dB=True,
                             omega=np.logspace(-3, 5),
                             Plot=False)
if PLOT:
    plt.subplot(2, 1, 1), plt.grid(True)
    plantMagPlot, = plt.semilogx(omega, mag, label='Plant')
    plt.subplot(2, 1, 2), plt.grid(True)
    plantPhasePlot, = plt.semilogx(omega, phase, label='Plant')