當前位置: 首頁>>代碼示例>>Python>>正文


Python Navigation.wander_and_search_target方法代碼示例

本文整理匯總了Python中navigation.Navigation.wander_and_search_target方法的典型用法代碼示例。如果您正苦於以下問題:Python Navigation.wander_and_search_target方法的具體用法?Python Navigation.wander_and_search_target怎麽用?Python Navigation.wander_and_search_target使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在navigation.Navigation的用法示例。


在下文中一共展示了Navigation.wander_and_search_target方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Driver

# 需要導入模塊: from navigation import Navigation [as 別名]
# 或者: from navigation.Navigation import wander_and_search_target [as 別名]

#.........這裏部分代碼省略.........
        elif (status == "CONE_IN_RANGE"):
          self.change_state(State.COLLECT_acquire_cone)

      # ---- Collect Acquire Cone ----

      elif (self.state == State.COLLECT_acquire_cone):
        self.arduino.close_claw()

        ping = self.arduino.get_ping()
        if (ping <= constants.PING_CONE_THRESHOLD and ping != 0):
          if (self.ready_to_deliver == True):
            self.change_state(State.DELIVER_spin_and_search_target)
            self.ready_to_deliver = False
          else:
            print("Waiting for inter-bot command to deliver...")
        else:
          self.change_state(State.COLLECT_open_claw)

      # ---- Collect Open Claw ----

      elif (self.state == State.COLLECT_open_claw):
        self.arduino.open_claw()
        self.change_state(State.COLLECT_approach_cone)

      # ---- Deliver Spin and Search Target ----

      elif (self.state == State.DELIVER_spin_and_search_target):
        if (self.start_time == None):
          self.start_time = time.time()

        if (time.time() - self.start_time >= constants.SPIN_TIME):
          self.start_time = None
          self.navigation.stop()
          self.change_state(State.DELIVER_wander_and_search_target)
        # TODO: Use signatures with pixy
        else:
          status = self.navigation.spin_and_search_target()
          if (status == "TARGET_FOUND"):
            self.start_time = None
            self.change_state(State.DELIVER_approach_target)

      # ---- Deliver Wander and Search Target ----

      elif (self.state == State.DELIVER_wander_and_search_target):
        if (self.start_time == None):
          self.start_time = time.time()

        if (time.time() - self.start_time >= constants.WANDER_TIME):
          self.start_time = None
          self.navigation.stop()
          self.change_state(State.DELIVER_spin_and_search_target)
        # TODO: Use signatures with pixy
        else:
          status = self.navigation.wander_and_search_target()
          if (status == "TARGET_FOUND"):
            self.start_time = None
            self.change_state(State.DELIVER_approach_target)

      # ---- Deliver Approach Target ----

      elif (self.state == State.DELIVER_approach_target):
        status = self.navigation.approach_target()
        if (status == "LOST_TARGET"):
          self.change_state(State.DELIVER_wander_and_search_target)
        elif (status == "TARGET_IN_RANGE"):
          self.change_state(State.DELIVER_verify_target)
開發者ID:zacharylawrence,項目名稱:ENEE408I-Team-9,代碼行數:70,代碼來源:driver.py


注:本文中的navigation.Navigation.wander_and_search_target方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。