예제 #1
0
파일: Test.py 프로젝트: jorgeecardona/tesis
sys = Linear()

# Define the sizes of the state and the input
x = sys.state(3)
u = sys.input(2)

# Define functions that can't be defined as functions above, i.e.
# f(y,x_1,x_2,x_3,...,x_n) = g(y,x_1,x_2,x_3,...,x_n)
# The method receive the name of the function, the f(y,x_1,x_2,...,x_n) 
# function, the g(y,x_1,x_2,...,x_n) function, and a list with tuples 
# representing the args that call the function (this is a hack, 
# because the actual matching system is not as good as i want).

beta = sys.function(
    "beta",
    lambda y,x: l * sin(y) - 4*r, # f(y, x_1, x_2, x_3. ... , x_n)
    lambda y,x: 2 * x * cos(y), # g(y, x_1, x_2, x_3, ... , x_n)
    [(x[0],)]
    )

# State function
sys.f(Matrix(
        [x[1],
         9.81 - 2 * T(rho(L(beta(x[0])),x[2])) * sin(beta(x[0]))/M_p - k_f * x[1] / M_p,
         A * r * (rho_e * u[0] - rho(L(beta(x[0])),x[2]) * u[1] )
         ])
      )

# Output function
sys.h(Matrix([x[0]]))

# Linearization!!!