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


Python Navigation.move_to_shelf方法代碼示例

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


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

示例1: Milestone1GUI

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

#.........這裏部分代碼省略.........
        if not rotate_count:
            rotate_count = 2
        topic_name = '/base_controller/command'
        base_publisher = rospy.Publisher(topic_name, Twist)

        twist_msg = Twist()
        twist_msg.linear = Vector3(0.0, 0.0, 0.0)
        twist_msg.angular = Vector3(0.0, 0.0, 0.5)
        start_time = rospy.get_rostime()
        while rospy.get_rostime() < start_time + rospy.Duration(15.0 * rotate_count):
            base_publisher.publish(twist_msg)

    def navigate_to_shelf(self, marker_id = None):
        # Move forward, place book on the shelf, and move back
        if marker_id is None or marker_id is False:
            marker_id = self.marker_perception.get_marker_id()
        rospy.loginfo("marker id returned by get_marker_id is: " + str(marker_id))
        if marker_id is False:
            rospy.loginfo("wuuuuuuuut")
        if marker_id is None:
            self._sound_client.say("I don't think I am holding a book "
                    "right now")
            rospy.logwarn("Navigate to shelf called when marker id is None")
            return
              
        book = self.book_map.get(unicode(marker_id))
        if book is None:
            self._sound_client.say("The book that I am holding is unknown "
                    "to me")
            rospy.logwarn("Navigate to shelf called when marker id is not in database")
            return
        x = book.getXCoordinate()
        y = book.getYCoordinate()
        self.navigation.move_to_shelf(x, y)

    # Ye Olde Dropping way of putting a book on the shelf. Deprecating.
    def drop_on_shelf(self):
        self.saved_r_arm_pose = Milestone1GUI.PLACE_ON_SHELF_R_POS
        self.move_arm('r', 4.0, True)  # Increase these numbers for slower movement
        self.move_base(True)
        self.r_gripper.open_gripper(True)
        self.saved_r_arm_pose = Milestone1GUI.RELEASE_BOOK_R_POS
        self.move_arm('r', 2.0, True)  # Increase these numbers for slower movement
        self.move_base(False)
        self.marker_perception.reset_marker_id()

    def place_on_shelf(self):
        self.saved_r_arm_pose = Milestone1GUI.PLACE_ON_SHELF_R_POS
        self.move_arm('r', 4.0, True)  # Increase these numbers for slower movement
        self.move_base(True)
        self.saved_r_arm_pose = Milestone1GUI.LOWER_ON_SHELF_R_POS
        self.move_arm('r', 2.0, True)  # Increase these numbers for slower movement
        self.r_gripper.open_gripper(True)
        self.move_base(False)
        self.marker_perception.reset_marker_id()

    def give_information(self):
        marker_id = self.marker_perception.get_marker_id()
        rospy.loginfo("marker id returned by get_marker_id is: " + str(marker_id))
        if marker_id is not None:
            book = self.book_map.get(unicode(marker_id))
            if book is None:
                rospy.logwarn("Give information called when marker id is not in database")
                self._sound_client.say("The book that I am holding is unknown to me")
            else:
                self._sound_client.say(book.getInformation())
開發者ID:vjampala,項目名稱:cse481,代碼行數:70,代碼來源:milestone1.py


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