當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。