本文整理汇总了Python中Model.Model.closed_loop方法的典型用法代码示例。如果您正苦于以下问题:Python Model.closed_loop方法的具体用法?Python Model.closed_loop怎么用?Python Model.closed_loop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.closed_loop方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: linspace
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import closed_loop [as 别名]
pass
opc['[CLP_AB]Program:DeviceN.pyInit'] = True
t = numpy.array(range(0, n_t)) * Ts
# time = linspace(0,10,n_t)
# instantiate the plant that will be used, it should be a subclass of Plant
plant = PlantOPC(opc,'[CLP_AB]position','[CLP_AB]speed',init_pos)
model = Model(n, A, B, C, D, Ak, Bk, Ck, Q, R, Kp, Ki, epsilon, Ts, plant)
start = time.clock()
t_old = start
times_p = []
for i in range(0, n_t):
y_out[i] = model.closed_loop(y_topo[i],y_fundo[i])
#time.sleep(0.1)
plant.kill()
print("Total simulation time: {}s".format(time.clock() - start))
y_out_phased = y_out[5:n_t]
t_out_phased = t[0:n_t-5]
##plt.plot(t, y_out[0:n_t], label='out')
plt.plot(t_out_phased,y_out_phased, label='out_n')
plt.plot(t, y_fundo[0:n_t], label='ref fundo')
plt.plot(t, y_topo[0:n_t], label='ref topo (in)')
plt.legend(loc=4)
plt.xlabel('time (s)')
plt.ylabel('position (m)')
plt.title('Position of cart - close loop')
plt.grid(True)
示例2: PlantOrig
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import closed_loop [as 别名]
file_topo.close()
file_fundo.close()
n_t = 70
t = numpy.array(range(0, n_t)) * Ts
y_out = numpy.zeros(n_t)
y_out_open_loop = numpy.zeros(n_t)
# instantiate the plant that will be used, it should be a subclass of Plant
plant = PlantOrig()
model = Model(n, A, B, C, D, Ak, Bk, Ck, Q, R, Kp, Ki, epsilon, Ts, plant)
plantNew = PlantOrig()
start = time.clock()
for k in range(n_t):
y_out[k] = model.closed_loop(y_topo[k], y_fundo[k])
y_out_open_loop[k] = plantNew.compute_y(y_topo[k])
print("Total simulation time: {}s".format(time.clock() - start))
plt.plot(t, y_out[0:n_t], label='out')
plt.plot(t, y_fundo[0:n_t], label='ref fundo')
plt.plot(t, y_topo[0:n_t], label='ref topo (in)')
plt.plot(t, y_out_open_loop[0:n_t], label='out open loop')
plt.legend()
plt.xlabel('time (s)')
plt.ylabel('position (m)')
plt.title('Position of cart')
plt.grid(True)
plt.show()