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


Python Gripper.position方法代碼示例

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


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

示例1: put

# 需要導入模塊: from baxter_interface import Gripper [as 別名]
# 或者: from baxter_interface.Gripper import position [as 別名]
def put(object, count):

    tf_listener = tf.TransformListener()

    robot = moveit_commander.RobotCommander()
    scene = moveit_commander.PlanningSceneInterface()
    gripper_left = Gripper("left")
    gripper_right = Gripper("right")
    group_left = moveit_commander.MoveGroupCommander("left_arm")
    group_right = moveit_commander.MoveGroupCommander("right_arm")
    group_left.set_planner_id('RRTConnectkConfigDefault')
    group_right.set_planner_id('RRTConnectkConfigDefault')

    # parameters
    no_detection = False
    drop_lemon = True
    press_faucet = False
    place_cup = False
    gripper_position_threshold = 4.6
    # count = 3 # number of lemon slices

    # clean the scene
    # scene.remove_world_object()

    # forward kinematic object
    kin = baxter_kinematics('left')
    

    while True:
        
        
        rospy.sleep(1)
        # initial pose
        initial_pose = Pose()
        # initial_pose.orientation.x = 0.9495
        # initial_pose.orientation.y = 0.017127
        # initial_pose.orientation.z = -0.31322
        # initial_pose.orientation.w = 0.0071202
        # initial_pose.orientation.x = 0.37
        # initial_pose.orientation.y = 0.93
        # initial_pose.orientation.z = 0.0
        # initial_pose.orientation.w = 0.0
        initial_pose.orientation.y = 1.0
        initial_pose.position.x = 0.0
        initial_pose.position.y = 0.88
        initial_pose.position.z = 0.214 
        rospy.sleep(1)
        execute_valid_plan(group_left, initial_pose)

        if count == 0:
            rospy.loginfo("Finish the task")
            break

        if no_detection:
            rospy.loginfo("No detection")
            break

        rospy.loginfo("Time to kill the process")

        start_time = rospy.get_time()
        while (rospy.get_time() - start_time < 3.0):
            if rospy.is_shutdown():
                no_detection = True
                press_faucet = False
                break


        rospy.loginfo("Looking for the detected pose")


        start_time = rospy.get_time()

        while not rospy.is_shutdown():

            if(rospy.get_time() - start_time > 4.0):
                no_detection = True
                break
            try:
                tf_listener.waitForTransform('/base', '/circle', rospy.Time(0), rospy.Duration(1.0))
                break
            except (tf.Exception, tf.ConnectivityException, tf.LookupException):
                continue

        if not no_detection:
            time_delay = rospy.get_time() - tf_listener.getLatestCommonTime('/circle' , '/base').to_sec()
            rospy.loginfo("The time delay for the detection is: %f sec" , time_delay)
            if(time_delay > 3.0):
                rospy.loginfo("Time delay of the detection exceeds 2.0 second. Stop the process")
                break

            trans, rot = tf_listener.lookupTransform('/base', '/circle', rospy.Time(0))

            rospy.loginfo(trans)

            # move to the position that is above the lime
            above_pose = get_pose_with_sleep(group_left)
            above_pose.pose.position.x = trans[0]
            above_pose.pose.position.y = trans[1]

            #plan = plan_with_orientation_lock(group_left, above_pose, side = "left", tolerance=1000)
#.........這裏部分代碼省略.........
開發者ID:YZHANGFPE,項目名稱:circle_detection,代碼行數:103,代碼來源:pick_up_lime.py


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