Dateien nach "dennis_nodes/tutel_nodes_max_value_pure_variations" hochladen

This commit is contained in:
2024-02-27 16:49:04 +01:00
parent 74cb3b4b70
commit baa0fbcdbe
@@ -203,8 +203,8 @@ class tutel():
if self.depth_counter == 0:
#pass
self.last_depth = 10.0
self.x = (0,0)
self.y = (0,0)
#self.x = (0,0)
#self.y = (0,0)
#self.number_of_operations = 0
#x and y are swapped, because
print(str(self.top_left[0]) + " " + str(self.top_right[0]) + " " + str(self.top_left[1]) + " " + str(self.bottom_right[1]))
@@ -276,6 +276,16 @@ class tutel():
self.bottom_right = (int(self.bottom_right[0]), int(self.bottom_right[1]))
self.bottom_left = (int(self.bottom_left[0]), int(self.bottom_left[1]))
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
if self.top_left[0] < self.top_right[0]: self.x = (self.top_left[0],self.top_right[0])
else: self.x = (self.top_right[0],self.top_left[0])
if self.top_left[1] < self.bottom_left[1]: self.y = (self.top_left[1],self.bottom_left[1])
else: self.y = (self.bottom_left[1],self.top_left[1])
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
if self.bottom_left[0] < self.top_left[0]: self.x = (self.bottom_left[0],self.top_left[0])
else: self.x = (self.top_left[0],self.bottom_left[0])
if self.bottom_left[1] < self.bottom_right[1]: self.y = (self.bottom_left[1],self.bottom_right[1])
else: self.y = (self.bottom_right[1],self.bottom_left[1])
cv2.line(image, self.top_left, self.top_right, (0,255,0), 2)
cv2.line(image, self.top_right, self.bottom_right, (0,255,0), 2)
cv2.line(image, self.bottom_right, self.bottom_left, (0,255,0), 2)
@@ -284,26 +294,28 @@ class tutel():
self.depth_state = True
#self.last_marker_position = ((self.top_left), (self.bottom_right))
if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
print("ATTACK")
self.t.linear.x = 0.15 * self.vel_fac
self.t.angular.z = 0.0 * self.vel_fac
self.pub.publish(self.t)
elif(self.top_right[0] < thresh_left or
self.bottom_right[0] < thresh_left):
print("LEFT")
self.t.linear.x = 0.0 * self.vel_fac
self.t.angular.z = 0.2 * self.vel_fac
self.pub.publish(self.t)
elif(self.top_left[0] > thresh_right or
self.bottom_left[0] > thresh_right):
print("RIGHT")
self.t.linear.x = 0.0 * self.vel_fac
self.t.angular.z = -0.2 * self.vel_fac
self.pub.publish(self.t)
#if ((self.top_left[0] > thresh_left and self.top_left[0] < thresh_right) or
#(self.top_right[0] > thresh_left and self.top_right[0] < thresh_right) or
#(self.bottom_left[0] > thresh_left and self.bottom_left[0] < thresh_right) or
#(self.bottom_right[0] > thresh_left and self.bottom_right[0] < thresh_right)):
#print("ATTACK")
#self.t.linear.x = 0.15 * self.vel_fac
#self.t.angular.z = 0.0 * self.vel_fac
#self.pub.publish(self.t)
#elif(self.top_right[0] < thresh_left or
#self.bottom_right[0] < thresh_left):
#print("LEFT")
#self.t.linear.x = 0.0 * self.vel_fac
#self.t.angular.z = 0.2 * self.vel_fac
#self.pub.publish(self.t)
#elif(self.top_left[0] > thresh_right or
#self.bottom_left[0] > thresh_right):
#print("RIGHT")
#self.t.linear.x = 0.0 * self.vel_fac
#self.t.angular.z = -0.2 * self.vel_fac
#self.pub.publish(self.t)
marker_x = ((x[0] + (x[1]-x[0])//2 - 5), (x[0] + (x[1]-x[0])//2 + 5))
if int(self.w / 2) > self.top_left[0]:
self.position = POSITIONS[0]
elif self.w - int(self.w / 2) < self.top_left[0]: