marker working now, seems like light influences the markers pixel calculation. Definitely needs to be checked.
With light on this works. Threshold possibly too big which causes the bot to change the angular.z too slow more tests in next version.
This commit is contained in:
2023-12-06 13:40:12 +01:00
parent b7cd47b2c0
commit 6227d57b55
+42 -6
View File
@@ -80,17 +80,53 @@ class image_converter:
bottom_right = (int(bottom_right[0]), int(bottom_right[1]))
bottom_left = (int(bottom_left[0]), int(bottom_left[1]))
cv2.circle(img, top_left, 10, (0,255,0), -1)
if (top_left[1] or top_right[1] or bottom_left[1] or bottom_right[1]) >= thresh_left and (top_left[1] or top_right[1] or bottom_left[1] or bottom_right[1]) <= thresh_right:
print("###############################")
print(top_left[1])
print(top_right[1])
print(bottom_left[1])
print(bottom_right[1])
print("top_left(",top_left[0],",",top_left[1],")")
print("top_right(",top_right[0],",",top_right[1],")")
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
if ((top_left[0] > thresh_left and top_left[0] < thresh_right) or
(top_right[0] > thresh_left and top_right[0] < thresh_right) or
(bottom_left[0] > thresh_left and bottom_left[0] < thresh_right) or
(bottom_right[0] > thresh_left and bottom_right[0] < thresh_right)):
print("##########################")
print("Object found")
print("top_left(",top_left[0],",",top_left[1],")")
print("top_right(",top_right[0],",",top_right[1],")")
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
print(thresh_left)
print(thresh_right)
print("##############################################")
self.t.linear.x = 0.1
self.pub.publish(self.t)
self.rate.sleep()
elif(top_right[0] < thresh_left or
bottom_right[0] < thresh_left):
print("##########################")
print("Object found")
print("top_left(",top_left[0],",",top_left[1],")")
print("top_right(",top_right[0],",",top_right[1],")")
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
print(thresh_left)
print(thresh_right)
print("##############################################")
self.t.angular.z = 0.2
self.pub.publish(self.t)
self.rate.sleep()
elif(top_left[0] > thresh_right or
bottom_left[0] > thresh_right):
print("##########################")
print("Object found")
print("top_left(",top_left[0],",",top_left[1],")")
print("top_right(",top_right[0],",",top_right[1],")")
print("bottom_left(",bottom_left[0],",",bottom_left[1],")")
print("bottom_right(",bottom_right[0],",",bottom_right[1],")")
print(thresh_left)
print(thresh_right)
print("##############################################")
self.t.angular.z = -0.2
self.pub.publish(self.t)
self.rate.sleep()
#print(corners[0][0])
ids = ids.flatten()