Exemplo n.º 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)
Exemplo n.º 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")
Exemplo n.º 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")
Exemplo n.º 4
0
def vid():
    rospy.init_node('vid', anonymous=False)
    rospy.loginfo('node initialized')
    rospy.Subscriber('crotch/image/image_raw', Image, handle_img)
    rate = rospy.Rate(10)
    u = uniboard.Uniboard("/dev/ttyUSB1")
    u.arm_home()

    # MOVE FORWARD X meters
    u.motor_left(0.1)
    u.motor_right(0.1)
    time.sleep(9)
    u.motor_left(0)
    u.motor_right(0)

    # PICK UP SAMPLE
    if TEST_PIT:
        # 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)
            else:
                rospy.loginfo("no sample detected")
    else:
        pick_up_center(u)

    # MOVE BACKWARD X meters
    u.motor_left(-0.1)
    u.motor_right(-0.1)
    time.sleep(8.9)
    u.motor_left(0)
    u.motor_right(0)
Exemplo n.º 5
0
def vid():
    rospy.init_node('vid', anonymous=False)
    rospy.loginfo('node initialized')    
    rospy.Subscriber('crotch/image/image_raw', Image, handle_img)
    rate = rospy.Rate(10)
    u = uniboard.Uniboard("/dev/ttyUSB1")
    u.arm_home()

    # MOVE FORWARD X meters
    u.motor_left(0.1)
    u.motor_right(0.1)
    time.sleep(9)
    u.motor_left(0)
    u.motor_right(0)
    
    # PICK UP SAMPLE
    if TEST_PIT:
       # 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)
          else:
             rospy.loginfo("no sample detected")
    else:
       pick_up_center(u)
        
    # MOVE BACKWARD X meters
    u.motor_left(-0.1)
    u.motor_right(-0.1)
    time.sleep(8.9)
    u.motor_left(0)
    u.motor_right(0)