当前位置: 首页>>代码示例>>Python>>正文


Python ConsistencyCheck.add方法代码示例

本文整理汇总了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()
开发者ID:jheidel,项目名称:software,代码行数:17,代码来源:navigate.py

示例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
开发者ID:zhaohongqiang,项目名称:software,代码行数:47,代码来源:track.py


注:本文中的mission.framework.helpers.ConsistencyCheck.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。