示例#1
0
def test_pickup_easy(u):
    mask_img = cv2.imread('mask.pbm')
    # move arm out of the way of the camera
    u.arm_target("X", 0)
    u.arm_target("Y", u.arm_max("Y"))
    while u.arm_should_be_moving("X") or u.arm_should_be_moving("Y"): pass
    time.sleep(1)
    if new_crotch_img2 is not None:
       curr_crotch_img = new_crotch_img2
     
       # Do the nasty, should apply mask to image.
       mask_img = cv2.resize(mask_img, (curr_crotch_img.shape[1], curr_crotch_img.shape[0]))
       #curr_crotch_img = np.concatenate((curr_crotch_img, mask_img), axis=1)
       #curr_crotch_img = Image.blend(curr_crotch_img, mask_img, 0.5)
       #curr_crotch_img = cv2.addWeighted(curr_crotch_img, 0.5, mask_img, 0.5, 0)
       curr_crotch_img = np.bitwise_and(curr_crotch_img, mask_img)
#---------------------------
       cv2.imshow('nipple', curr_crotch_img)


       rospy.loginfo("image success")
       xy = grab.identify_easy_sample(curr_crotch_img)
       rospy.loginfo("coordinates: " + str(xy))
       if xy:
          rospy.loginfo("a sample has been detected")
          while xy is not None:
             grab.pick_up_at(u,xy)
             u.arm_target("X", 0)
             u.arm_target("Y", u.arm_max("Y"))
             while u.arm_should_be_moving("X") or u.arm_should_be_moving("Y"): pass
             xy = grab.identify_easy_sample(new_crotch_img2)
       else:
          rospy.loginfo("no sample detected")
    grab.place_sample(u,1)
示例#2
0
def test_pickup_easy(u):
    # move arm out of the way of the camera
    u.arm_target("X", 0)
    u.arm_target("Y", u.arm_max("Y"))
    while u.arm_should_be_moving("X") or u.arm_should_be_moving("Y"): pass
    time.sleep(1)
    if new_crotch_img2 is not None:
       curr_crotch_img = new_crotch_img2
       rospy.loginfo("image success")
       xy = grab.identify_easy_sample(curr_crotch_img)
       rospy.loginfo("coordinates: " + str(xy))
       if xy:
          rospy.loginfo("a sample has been detected")
          grab.pick_up_at(u,xy)
          grab.place_sample(u,1)
       else:
          rospy.loginfo("no sample detected")
示例#3
0
def test_pickup_easy(u):
    # move arm out of the way of the camera
    u.arm_target("X", 0)
    u.arm_target("Y", u.arm_max("Y"))
    while u.arm_should_be_moving("X") or u.arm_should_be_moving("Y"):
        pass
    time.sleep(1)
    if new_crotch_img2 is not None:
        curr_crotch_img = new_crotch_img2
        rospy.loginfo("image success")
        xy = grab.identify_easy_sample(curr_crotch_img)
        rospy.loginfo("coordinates: " + str(xy))
        if xy:
            rospy.loginfo("a sample has been detected")
            grab.pick_up_at(u, xy)
            grab.place_sample(u, 1)
        else:
            rospy.loginfo("no sample detected")