【发布时间】:2017-10-06 02:45:55
【问题描述】:
我正在尝试解决这个问题:
U 在哪里
这里:
s=c*e(t)+e_dot(t)
和
e(t)=theta(t)-thetad(t)
和
e_dot(t)=theta_dot(t)-thetad_dot(t)
其中 thetad(theta desired)=sin(t)-- 即要跟踪的信号! 和 thetad_dot=cos(t),J=10,c=0.5,eta=0.5
我首先尝试使用 odeint - 它在 t=0.4 后给出错误,即 theta(上述微分方程的解)下降到 0 并此后保持不变。但是,当我尝试将 mxstep 增加到 5000000 时,我可以在 t=4.3s 之前得到一些正确的图表。
我想得到一个纯正弦图。那就是我希望theta(上述微分方程的解)跟踪thetad,即sin(t)。但在 t=4.3sec 后无法准确跟踪 thetad。在这段时间之后,theta(上述微分方程的解)简单地下降到 0 并停留在那里。
这是我的代码-
from scipy.integrate import odeint
import numpy as np
import matplotlib.pyplot as plt
c=0.5
eta=0.5
def f(Y,t):
x=Y[0]
y=Y[1]
e=x-np.sin(t)
de=y-np.cos(t)
s=c*e+de
return [y,-c*(de)-np.sin(t)-eta*np.sign(s)]
t=np.linspace(0,10,1000)
y0=[0.5,1.0]
sol=odeint(f,y0,t,mxstep=5000000)
#sol=odeint(f,y0,t)
print(sol)
angle=sol[:,0]
omega=sol[:,1]
error=angle-np.sin(t)
derror=omega-np.cos(t)
plt.subplot(4,2,1)
plt.plot(t,angle)
plt.plot(t,error,'r--')
plt.grid()
plt.subplot(4,2,2)
plt.plot(t,omega)
plt.plot(t,derror,'g--')
plt.grid()
plt.subplot(4,2,3)
plt.plot(angle,omega)
plt.grid()
plt.subplot(4,2,4)
plt.plot(error,derror,'b--')
plt.savefig('signum_graph.eps')
plt.show()
【问题讨论】:
标签: python controller ode mode sliding