本文整理汇总了Python中field.Field.update_pucks方法的典型用法代码示例。如果您正苦于以下问题:Python Field.update_pucks方法的具体用法?Python Field.update_pucks怎么用?Python Field.update_pucks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类field.Field
的用法示例。
在下文中一共展示了Field.update_pucks方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from field import Field [as 别名]
# 或者: from field.Field import update_pucks [as 别名]
def main(args):
if "fake" in args:
board = FakeArduino()
else:
board = Arduino()
cam = Camera()
cam.calibrate()
cam.adj_thresh(2, 20)
shooterlist = setup_shooters(args, board, offset_in = 9.5, field = cam.board_size, dpi = cam.dpi)
if "old" in args:
print "using old program"
while True:
targets = cam.get_targets()
tactical_shoot(shooterlist, targets)
aims = [s.get_aim_line() for s in shooterlist]
cam.display(aims)
board.read()
if (cv2.waitKey(2) >= 0):
break
if "fail" in args:
print "using test program"
while True:
targets = cam.get_targets()
for s in shooterlist:
for t in targets:
s.shoot(t)
aims = [s.get_aim_line() for s in shooterlist]
cam.display(aims)
if cv2.waitKey(2) >= 0:
break
elif "new" in args:
print "using new program"
field = Field()
care = True # try to shoot after failmax fails?
fails = 0
failmax = 10
while True:
pucks = cam.get_pucks()
if not pucks:
pucks = [cam.get_one()]
if not pucks:
if care:
fails += 1
if fails > failmax:
fails = 0
print "Fails exceeded maximum; attempting quickfix"
cam.quickfix(field.get_min_pucks())
#pucks = cam.get_targets()
#pucks = (pucks[0])
else:
continue
else:continue
elif care:
fails = 0
field.update_pucks(pucks)
target = field.get_best_target_pos()
for s in shooterlist:
if s.can_hit(target):
s.shoot(target)
aims = [s.get_aim_line() for s in shooterlist]
cam.display(aims)
if cv2.waitKey(2) >= 0:
break
cam.cleanup()
print "THRESHHOLD WAS: " + str(cam.threshval)