# -*- coding: utf-8 -*-
"""
Created on Jun 2 2021

@author: Alex
"""

from pyro.dynamic import massspringdamper
from pyro.control import linear


# Plant
m = 1
b = 1

plant = massspringdamper.FloatingSingleMass(m,b)

#Controller
kp  = 2
ki  = 0
kd  = 0
tau = 0.01

pid = linear.PIDController(kp,ki,kd,tau)

pid.rbar[0] = 2 # set point


closed_loop_sys = pid + plant

#closed_loop_sys.compute_trajectory( tf = 30 )
#closed_loop_sys.plot_trajectory('y')
#closed_loop_sys.animate_simulation()

closed_loop_sys.compute_trajectory( tf = 10 , solver = 'odeint' )
closed_loop_sys.plot_trajectory('xu')
#closed_loop_sys.animate_simulation()