This commit is contained in:
wuchangji 2022-06-29 17:27:23 +08:00
parent 096383e67a
commit 1cd52dbccb
10 changed files with 19 additions and 57 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 43 KiB

After

Width:  |  Height:  |  Size: 45 KiB

View file

@ -49,19 +49,19 @@ def take_photo():
def cut_photo():
path_red = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/red'
path_red = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/red'
for i, j, k in os.walk(path_red):
file_len_red = len(k)
path_gray = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/gray'
path_gray = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/gray'
for i, j, k in os.walk(path_gray):
file_len_gray = len(k)
path_green = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/green'
path_green = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/green'
for i, j, k in os.walk(path_green):
file_len_green = len(k)
path_blue = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/blue'
path_blue = '/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/blue'
for i, j, k in os.walk(path_blue):
file_len_blue = len(k)
print("请截取要识别的部分")
@ -95,19 +95,19 @@ def cut_photo():
cv2.imshow('crop', crop)
# 选择红桶文件夹
if kw == 'red':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/red/goal{}.jpeg'.format(str(file_len_red + 1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/red/goal{}.jpeg'.format(str(file_len_red + 1)),crop)
print('Saved')
# 选择灰桶文件夹
elif kw == 'gray':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/gray/goal{}.jpeg'.format(str(file_len_gray+1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/gray/goal{}.jpeg'.format(str(file_len_gray+1)),crop)
print('Saved')
# 选择绿桶文件夹
elif kw == 'green':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/green/goal{}.jpeg'.format(str(file_len_green+1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/green/goal{}.jpeg'.format(str(file_len_green+1)),crop)
print('Saved')
# 选择蓝桶文件夹
elif kw == 'blue':
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/res/blue/goal{}.jpeg'.format(str(file_len_blue+1)),crop)
cv2.imwrite('/home/ubuntu/catkin_ws/src/mycobot_ros/mycobot_ai/myPalletizer_260/res/blue/goal{}.jpeg'.format(str(file_len_blue+1)),crop)
print('Saved')
# 退出

View file

@ -148,9 +148,9 @@ class Object_detect(Movement):
time.sleep(3)
# send coordinates to move mypal260
self.mc.send_coords([x, y, 160, -82.17], 20, 0)
self.mc.send_coords([x, y, 160, 0], 20, 0) # -82.17
time.sleep(1.5)
self.mc.send_coords([x, y, 90, -82.17], 20, 0)
self.mc.send_coords([x, y, 90, 0], 20, 0)
time.sleep(1.5)
# open pump
@ -162,28 +162,13 @@ class Object_detect(Movement):
self.mc.send_angle(2, 0, 20)
time.sleep(0.3)
self.mc.send_angle(3, -5, 20)
self.mc.send_angle(3, -15, 20)
time.sleep(2)
# self.pub_angles(self.move_angles[2], 20)
# time.sleep(3)
# self.pub_marker(
# self.move_coords[2][0]/1000.0, self.move_coords[2][1]/1000.0, self.move_coords[2][2]/1000.0)
# self.pub_angles(self.move_angles[1], 20)
# time.sleep(1.5)
# self.pub_marker(
# self.move_coords[3][0]/1000.0, self.move_coords[3][1]/1000.0, self.move_coords[3][2]/1000.0)
# self.pub_angles(self.move_angles[0], 20)
# time.sleep(2)
# self.pub_marker(
# self.move_coords[4][0]/1000.0, self.move_coords[4][1]/1000.0, self.move_coords[4][2]/1000.0)
self.mc.send_coords(self.move_coords[color], 20, 0)
self.mc.send_coords(self.move_coords[color], 20, 1)
self.pub_marker(self.move_coords[color][0]/1000.0, self.move_coords[color]
[1]/1000.0, self.move_coords[color][2]/1000.0)
time.sleep(3)
time.sleep(4.5)
# close pump
if self.raspi:
@ -201,7 +186,7 @@ class Object_detect(Movement):
# self.pub_angles(self.move_angles[0], 20)
self.mc.send_angles(self.move_angles[1], 20)
time.sleep(3)
time.sleep(1.5)
# decide whether grab cube
def decide_move(self, x, y, color):

View file

@ -158,7 +158,7 @@ class Object_detect(Movement):
self.mc.send_coords([x, y, 160, -82.17], 20, 2)
time.sleep(2.5)
# self.pub_coords([x, y, 90, -178.9, -1.57, -66], 25, 1)
self.mc.send_coords([x, y, 99, -82.17], 20, 1)
self.mc.send_coords([x, y, 90, -82.17], 20, 1)
time.sleep(1.5)
# open pump
@ -169,23 +169,6 @@ class Object_detect(Movement):
time.sleep(0.3)
self.mc.send_angle(3, -18, 20)
time.sleep(2)
# self.pub_angles(self.move_angles[2], 20)
# time.sleep(3)
# self.pub_marker(self.move_coords[2][0] / 1000.0,
# self.move_coords[2][1] / 1000.0,
# self.move_coords[2][2] / 1000.0)
# self.pub_angles(self.move_angles[1], 20)
# time.sleep(1.5)
# self.pub_marker(self.move_coords[3][0] / 1000.0,
# self.move_coords[3][1] / 1000.0,
# self.move_coords[3][2] / 1000.0)
# self.pub_angles(self.move_angles[0], 20)
# time.sleep(1.5)
# self.pub_marker(self.move_coords[4][0] / 1000.0,
# self.move_coords[4][1] / 1000.0,
# self.move_coords[4][2] / 1000.0)
print(self.move_coords[color])
# self.pub_coords(self.move_coords[color], 20, 1)
@ -199,9 +182,7 @@ class Object_detect(Movement):
# close pump
self.gpio_status(False)
time.sleep(4)
# self.pub_marker(self.move_coords[color][0] / 1000.0 + 0.04,
# self.move_coords[color][1] / 1000.0 - 0.02)
# self.pub_angles(self.move_angles[0], 20)
self.mc.send_angles(self.move_angles[1], 20)
time.sleep(3)
@ -220,10 +201,6 @@ class Object_detect(Movement):
# init mycobot
def run(self):
# for _ in range(5):
# self.pub_angles([-26.11, -6.94, -55.01, -24.16, 0, -15], 20)
# print(_)
# time.sleep(0.5)
self.mc = MyPalletizer("/dev/ttyAMA0",1000000) # ok
if not self.raspi:
self.pub_pump(False, self.Pin)

View file

@ -100,8 +100,8 @@ mc = MyPalletizer("/dev/ttyAMA0", 1000000)
# mc.send_angles([-47.1, 10.19, -10.1, -76.37],25) # above the red bucket; coords:[127.3, -137.1, 219.2, -29.26]
# time.sleep(1.5)
# mc.send_angles([0,0,-15,0],25)
# time.sleep(2)
mc.send_angles([0,0,0,0],25)
time.sleep(2)
# mc.send_coords([141.2, -142.0, 206.2, -26.8],25,1) # above the red bucket
# time.sleep(2)
@ -116,12 +116,12 @@ mc = MyPalletizer("/dev/ttyAMA0", 1000000)
# print(mc.get_angles())
# print(mc.get_coords())
# mc.release_all_servos()
# while True:
# print("angles:%s"%mc.get_angles())
# print("coords:%s"%mc.get_coords())
# print("\n")
# mc.release_all_servos()
# mc.set_servo_calibration(1)
# mc.set_servo_calibration(2)
# mc.set_servo_calibration(3)