本文整理汇总了Python中pid.PID.setIntegral方法的典型用法代码示例。如果您正苦于以下问题:Python PID.setIntegral方法的具体用法?Python PID.setIntegral怎么用?Python PID.setIntegral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pid.PID
的用法示例。
在下文中一共展示了PID.setIntegral方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: CF_Controller
# 需要导入模块: from pid import PID [as 别名]
# 或者: from pid.PID import setIntegral [as 别名]
#.........这里部分代码省略.........
self.fly.linear.y = self.m_pidY.update(self.hover_position[2], cf_trans[2])
self.last_depth = cf_trans[2]
# use camera -y position
# calculate PID control value for Crazyflie z control
self.fly.linear.z = self.m_pidZ.update((self.camera_height - cf_trans[1]),
(self.camera_height - self.hover_position[1]))
# record values to log file
rospy.loginfo("hover_position %f %f %f", self.hover_position[0], self.hover_position[1],
self.hover_position[2])
rospy.loginfo("Velocity msg published x %f y %f z % f", self.fly.linear.x, self.fly.linear.y,
self.fly.linear.z)
##### Takeoff ########
# increase the thrust (z) value in the command velocity message until takeoff is achieved
#
elif self._cf_state == 'takeoff':
self.fly.linear.x = 0.0 # set cmd_vel x and y to 0
self.fly.linear.y = 0.0
rospy.loginfo("new upper limit %f", self.takeoff_position[1]-25)
# increase thrust until position is 25 pixels above the takeoff position
# (in camera -y direction)
if (cf_trans[1] < (self.takeoff_position[1]-25)) or (self.thrust > 50000):
# when 25 pixels above the takeoff position is achieved,
# reset controllers; log values and achievement; change state to flight
self._pidReset()
rospy.loginfo("Takeoff thrust %f, ki %f", self.thrust, self.m_pidZ.set_ki())
self.m_pidZ.setIntegral((self.thrust - 1500.0)/ self.m_pidZ.set_ki())
rospy.loginfo("Takeoff achieved!")
self._cf_state = 'flight'
self.thrust = 0.0
# if position has not been achieved; increase thrust (z) value in command velocity;
# calculation is based on delta time (time elapsed) and fudge factor;
# slow but steady increments that decrease above 36000
else:
if self.thrust < 36000:
self.thrust += 10000 * dt * self.ff
else:
self.thrust += 3000 * dt * self.ff
self.fly.linear.z = self.thrust
rospy.loginfo("Takeoff Thrust value %f", self.fly.linear.z)
# print thrust values and command velocity values to screen for debugging
print "Thrust is %f" % self.thrust
print "Velocity msg published x %f y %f z % f" % (self.fly.linear.x, self.fly.linear.y,
self.fly.linear.z)
##### Land ########
elif self._cf_state == 'land':
# reduce pitch and roll to zero maintain thrust at 30000 for Crazyflie landing
self.fly.linear.x = 0.0
self.fly.linear.y = 0.0
self.fly.linear.z = 30000.0
self.thrust = 30000.0
# log achievement and change state to idle
rospy.loginfo("Landing achieved!")