def GotNuts(): cap = capture() p = cap.FindSingleWhiteBack() #Not Found Object print(p) if p[2] == 0: return False else: return True
def rollhead(): global arm_cul_position rollband = -33 for i in range(10): filepath = CheckPath() cap = capture() cap.StudyData(filepath) clockwise = arm_cul_position[0] + rollband angle_ctrl(0, clockwise) time.sleep(0.5) OriginalPosition()
def gotoCatchPosition(): global arm_cul_position downLeft() distance_high_limit = 6.8 distance_low_limit = 6.2 x_position_lmt = 25 y_position_lmt = 25 cap = capture() p = [100, 100, 10] while (abs(p[0]) >= x_position_lmt) or (abs( p[1]) >= y_position_lmt) or (abs(p[2]) >= distance_high_limit): p = cap.FindSingleWhiteBack() if p[2] > 7: angle_right = arm_cul_position[3] + 15 angle_m = arm_cul_position[1] + 16 angle_ctrl(3, angle_right) angle_ctrl(1, angle_m) elif p[2] > 6.6: angle_right = arm_cul_position[3] + 5 angle_m = arm_cul_position[1] + 6 angle_ctrl(3, angle_right) angle_ctrl(1, angle_m) #elif p[2] ==0: # print(p) # break else: pass #Base Position angle_base = arm_cul_position[2] - p[1] for i in range(3): angle_ctrl(2, angle_base) #Right Position if arm_cul_position[3] > 1300: angle_right = arm_cul_position[3] + int(p[0] / 2) angle_left = arm_cul_position[4] + 5 else: angle_right = arm_cul_position[3] - int(p[0] / 2) angle_left = arm_cul_position[4] - 5 for i in range(3): angle_ctrl(3, angle_right) angle_ctrl(4, angle_left) #distance Position if p[2] < distance_low_limit: UpArmByLeft(cap) print(p) print("end of arm")
def test3(): while True: #taka a capture and search a face cls = capture() rect = cls.faceThread() if rect is not None: w = rect[0] + int(rect[3] / 2) - 160 h = rect[1] + int(rect[3] / 2) - 120 angle_w = arm_cul_position[5] - w angle_h = arm_cul_position[1] - h for i in range(3): angle_ctrl(5, angle_w) angle_ctrl(1, angle_h)
def MoveToTarget(): global arm_cul_position gosa = 20 cap = capture() p = [100, 100, 10] while (abs(p[0]) >= gosa) or (abs(p[1]) >= gosa): p = cap.FindSingleWhiteBack() angle_w = arm_cul_position[2] - p[1] for i in range(2): angle_ctrl(2, angle_w) angle_h = arm_cul_position[3] - int(p[0] / 2) for i in range(2): angle_ctrl(3, angle_h) #print(p) return 1
def gotoCatch(): global arm_cul_position right_limit = 1300 sw = 1000 num = 2000 angle_right = arm_cul_position[3] + 220 angle_m = arm_cul_position[1] + 300 for i in range(3): angle_ctrl(3, angle_right) angle_ctrl(1, angle_m) while True: angle_right = arm_cul_position[3] + 11 angle_m = arm_cul_position[1] + 15 angle_ctrl(3, angle_right) angle_ctrl(1, angle_m) if angle_right > right_limit: break cls = capture() if angle_right > 1000: rect = cls.getPeanutsWithPic2(num) else: rect = cls.getPeanutsWithPic(num) print(num) num = num + 1 if rect is not None: print("base") print(rect[0]) if abs(rect[0]) > 1: angle_base = arm_cul_position[2] - rect[0] for i in range(3): angle_ctrl(2, angle_base) else: pass if abs(rect[1]) > 1: print("middle") print(rect[1]) angle_middle = arm_cul_position[1] - rect[1] for i in range(3): angle_ctrl(1, angle_middle) else:
def findPeanuts(): #num = 1000 while True: #taka a capture and search a peanuts cls = capture() rect = cls.getPeanuts() #rect = cls.getPeanutsWithPic(num) #num = num +1 if rect is not None: print(rect[0]) print(rect[1]) if abs(rect[0]) > 1: angle_w = arm_cul_position[2] - rect[0] for i in range(3): angle_ctrl(2,angle_w) else: pass if abs(rect[1]) > 1: angle_h = arm_cul_position[3] + rect[1] for i in range(3): angle_ctrl(3,angle_h) else: break
def Test01(num): a = capture() return a.captureTest(num)
def gotoPosition(): global arm_cul_position hight_limit = 6.4 low_limit = 6.4 cls = capture() lmt = 15 downLeft() while True: p = cls.FindSingleWhiteBack() if p[2] == hight_limit: break #over low limit case elif p[2] < low_limit: UpArmByLeft(cls) if p[2] > 7: angle_right = arm_cul_position[3] + 50 angle_m = arm_cul_position[1] + 60 angle_ctrl(3, angle_right) angle_ctrl(1, angle_m) else: angle_right = arm_cul_position[3] + 10 angle_m = arm_cul_position[1] + 13 angle_ctrl(3, angle_right) angle_ctrl(1, angle_m) if p[2] <= 6.7: lmt = 12 time.sleep(0.2) while True: time.sleep(0.2) p2 = cls.FindSingleWhiteBack() print(p2) if abs(p2[1]) > lmt: angle_base = arm_cul_position[2] - p2[1] for i in range(3): angle_ctrl(2, angle_base) if abs(p2[0]) > lmt: if arm_cul_position[3] > 1300: angle_right = arm_cul_position[3] + int(p2[0] / 2) else: angle_right = arm_cul_position[3] - int(p2[0] / 2) for i in range(3): angle_ctrl(3, angle_right) if abs(p2[0]) <= lmt and abs(p2[1]) <= lmt: break #filepath = CheckPath() #cls.StudyWhiteBack(filepath) catchAndGo() break
def OneCall(): #filepath = CheckPath() cap = capture() img = cap.FindMultiObject() cls.GetTypeOfNuts(img, logits, images_placeholder, keep_prob, sess)
def OneCall(): filepath = CheckPath() cap = capture() cap.StudyData(filepath) cls.GetTypeOfNuts(filepath, logits, images_placeholder, keep_prob, sess)