本文整理汇总了Python中pid.PID.feedback方法的典型用法代码示例。如果您正苦于以下问题:Python PID.feedback方法的具体用法?Python PID.feedback怎么用?Python PID.feedback使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pid.PID
的用法示例。
在下文中一共展示了PID.feedback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: MyAlgorithm
# 需要导入模块: from pid import PID [as 别名]
# 或者: from pid.PID import feedback [as 别名]
#.........这里部分代码省略.........
if self.current_strat == "STRAT_WALL_1":
if not self.strat_complete:
# Apply the strat to the movement. In this case STRAT_WALL_1
self.cmdvel.sendCMDVel(0.1,2,0,0,0,0)
time.sleep(2)
self.strat_complete = True
print "STRAT_COMPLETE"
if len(contours) < 1:
# Wall not found, search it
self.cmdvel.sendCMDVel(0,0,0,0,0,-0.2)
None
else:
# if area < 5000:
# print "EVITO!!"
# self.cmdvel.sendCMDVel(0,3,0,0,0,0)
# time.sleep(2)
#s = "area"+str(c)
#cv2.putText(droneImage, s, (cX - 20, cY - 20), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 255), 2)
# calculate the error for STRAT_WALL_1
centerx = width/2.0
# We want to look at the wall during the movement
dist = -((cX-centerx)/centerx)
# We have to maintain a security distance with the wall to avoid collision.
depth = -((h-ideal_height_wall_1))
# print dist
#print h
# calculate the speeds through PIDs
velX = self.pidX.feedback(depth)
velY = self.pidY.feedback(depth)
velRot= self.pidRot.feedback(dist)
#print velX, velY, velRot
area = cv2.contourArea(c)
# print area
# if the wall is too close, we wait till it gets further away
if area > self.prev_area:
# print (area/1000, ">", self.prev_area/1000, " ACERCANDOSE")
self.cmdvel.sendCMDVel(0,0,0,0,0,velRot)
None
else:
# print (area/1000, "<", self.prev_area/1000, " ALEJANDOSE")
self.cmdvel.sendCMDVel(velX, velY ,0,0,0,velRot)
None
#print "-------------------------------------"
self.prev_area = area
#print ("@@@@@@@@@@@@@@@@@@@@@@@@@@", self.pose.getPose3d().yaw)
if self.stage_done(droneImage, "RED_HSV", 105):
self.current_strat = strats[1]
self.strat_complete = False
elif self.current_strat == "STRAT_WALL_2":
if not self.strat_complete:
print "On second strat!"
# Position the drone looking at front