本文整理汇总了Python中mission.framework.helpers.ConsistencyCheck.add方法的典型用法代码示例。如果您正苦于以下问题:Python ConsistencyCheck.add方法的具体用法?Python ConsistencyCheck.add怎么用?Python ConsistencyCheck.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mission.framework.helpers.ConsistencyCheck
的用法示例。
在下文中一共展示了ConsistencyCheck.add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IdentifyGate
# 需要导入模块: from mission.framework.helpers import ConsistencyCheck [as 别名]
# 或者: from mission.framework.helpers.ConsistencyCheck import add [as 别名]
class IdentifyGate(Task):
"""
Finish when we can see a good enough amount of the gate
"""
min_bbar_width = 0.15
def on_first_run(self, vision):
self.seen_cons_check = ConsistencyCheck(4, 5)
def on_run(self, vision):
self.seen_cons_check.add(vision.bottom is not None and \
# (vision.left is not None or vision.right is not None) and \
bbar_width_ratio(vision) >= self.min_bbar_width)
if self.seen_cons_check.check():
self.finish()
示例2: __init__
# 需要导入模块: from mission.framework.helpers import ConsistencyCheck [as 别名]
# 或者: from mission.framework.helpers.ConsistencyCheck import add [as 别名]
class ConsistentObject:
"""
Consistency-check an object's existence
Inputted objects must have an x and y field
"""
def __init__(self, seen_cons_check=(2, 3), unseen_cons_check=(5, 6)):
self.last_obj = None
self.tracking = False
self.seen_cons_check = ConsistencyCheck(*seen_cons_check)
self.unseen_cons_check = ConsistencyCheck(*unseen_cons_check)
def map(self, obj):
"""
Call with a valid object to count as "seeing the object", or with None
to count as "not seeing the object"
"""
if obj is not None:
self.last_obj = obj
if self.tracking:
self.unseen_cons_check.add(False)
else:
self.seen_cons_check.add(True)
if self.seen_cons_check.check():
self.tracking = True
self.seen_cons_check.clear()
self.unseen_cons_check.clear()
else:
if self.tracking:
self.unseen_cons_check.add(True)
if self.unseen_cons_check.check():
self.tracking = False
self.seen_cons_check.clear()
self.unseen_cons_check.clear()
self.last_obj = None
else:
self.seen_cons_check.add(False)
self.last_obj = None
if self.tracking:
return self.last_obj
else:
return None