本文整理汇总了Python中pid.PID.execute_pid方法的典型用法代码示例。如果您正苦于以下问题:Python PID.execute_pid方法的具体用法?Python PID.execute_pid怎么用?Python PID.execute_pid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pid.PID
的用法示例。
在下文中一共展示了PID.execute_pid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: integrate
# 需要导入模块: from pid import PID [as 别名]
# 或者: from pid.PID import execute_pid [as 别名]
def integrate(self, n, state, dt):
pid = PID(kp=self.kp, ki=self.ki, kd=self.kd, angle=self.pidAngle, dt=dt)
history = np.array([state])
theta = Robot._get_gyroscope(state[2])
for i in range(n):
self.u = pid.execute_pid(theta)
state = rk4(self.dynamics, state, i, dt)
theta = Robot._get_gyroscope(Robot._get_gyroscope(state[2]))
history = np.append(history, [state], axis=0)
return history
示例2: execute_kalman_filter
# 需要导入模块: from pid import PID [as 别名]
# 或者: from pid.PID import execute_pid [as 别名]
def execute_kalman_filter(self, n, state, dt):
pid = PID(kp=self.kp, ki=self.ki, kd=self.kd, angle=self.pidAngle, dt=dt)
history = np.array([state])
theta = state[2]
x = state
h = np.matrix([
[1, 0, 0, 0],
[0, 1, 0, 0]
])
p = np.matrix([
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
])
q = np.matrix([
[1, 0, 0, 0],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1]
])
r = np.matrix([
[10**-3, 0],
[0, 10**-3]
])
for i in range(n):
z = (h * x) + np.matrix([[np.random.randn()*0.001], [np.random.randn()*0.001]])
u = pid.execute_pid(theta)
x = (self.A * x) + (self.B * u)
p = (self.A * p * self.A.T) + q
y = z - (h * x)
s = (h * p * h.T) + r
k = p * h.T * np.linalg.inv(s)
x = x + (k * y)
p = (np.eye(4) - (k * h))*p
theta = x[2]
history = np.append(history, [x], axis=0)
return history