Bewegungsablauf überarbeitet.
t.angular ist ein Skalar von "RADIAN per minute" und nicht "DEGREE per minute"
Sollte ein neuer Tiefenwert unrealistisch sein, so behalten wir den alten bei ->Ausreißer werden gefiltert
Der Marker mit der ID = 0 wird nicht mehr betrachtet, da Tische im richtigen Winkel ein Muster haben, welches aruco als Marker identifiziert.
This commit is contained in:
2024-02-22 01:43:33 +01:00
parent 20c6e06801
commit 40d7c1035e
+33 -15
View File
@@ -106,31 +106,44 @@ class tutel():
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
if corners:
self.target_id = ids[0]
for id_x in ids:
if id_x != 0:
self.target_id = id_x
break
self.search = False
if self.search:
self.t.linear.x = 0.0 * self.vel_fac
self.t.angular.z = 0.2 * self.vel_fac
if(time.time() - self.search_time) > 31.5:
self.search_time = time.time()
#start = time.time()
if (time.time() - self.search_time) < 10 and self.search:
if (time.time() - self.search_time) < 34.415925:
self.t.linear.x = 0.0 * self.vel_fac
self.t.angular.z = 0.2 * self.vel_fac
self.pub.publish(self.t)
#self.movement_counter += 1
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
if corners:
self.target_id = ids[0]
for id_x in ids:
if id_x != 0:
self.target_id = id_x
break
self.search = False
else:
self.t.linear.x = 0.2 * self.vel_fac
self.t.angular.z = 0.0 * self.vel_fac
self.pub.publish(self.t)
self.t.linear.x = 0.0 * self.vel_fac
self.pub.publish(self.t)
self.search_time = time.time()
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
if corners:
self.target_id = ids[0]
for id_x in ids:
if id_x != 0:
self.target_id = id_x
break
self.search = False
else:
if corners:
self.movement_counter = 0
#self.movement_counter = 0
x = np.where(ids == self.target_id)
if len(x[0]) > 0:
fitting_corners = corners[x[0][0]]
@@ -141,12 +154,12 @@ class tutel():
if self.position is POSITIONS[0]:
cv2.rectangle(rgb_image, (0,0), (20, self.h), (0,0,255), cv2.FILLED)
self.t.linear.x = 0.0 * self.vel_fac
self.t.angular.z = 0.3 * self.vel_fac
self.t.angular.z = -0.3 * self.vel_fac
self.pub.publish(self.t)
elif self.position is POSITIONS[1]:
cv2.rectangle(rgb_image, (self.w-20,0), (self.w, self.h), (0,0,255), cv2.FILLED)
self.t.linear.x = 0.0 * self.vel_fac
self.t.angular.z = -0.3 * self.vel_fac
self.t.angular.z = 0.3 * self.vel_fac
self.pub.publish(self.t)
#some additional info on screen
@@ -189,7 +202,10 @@ class tutel():
for j in range(y[0], y[1]):
if depth_image[j][i] > self.maxMinDepth:
depth_values.append(depth_image[j][i])
self.last_depth = max(depth_values)
if len(depth_values)>0 and max(depth_values) in range(self.last_depth-100, self.last_depth+100):
self.last_depth = max(depth_values)
else:
self.last_depth = self.last_depth
print(self.depth_counter, self.last_depth, self.number_of_operations)
self.number_of_operations = 0
#cv2.imshow("Tutel_Depth", depth_image)
@@ -204,7 +220,7 @@ class tutel():
self.depth_state = False
self.last_depth = 10.0
start = time.time()
while (time.time() - start) < 3:
while (time.time() - start) < 3.5:
self.pub.publish(self.t)
self.t.linear.x = 0.0 * self.vel_fac
self.pub.publish(self.t)
@@ -224,17 +240,19 @@ 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]))
cv2.line(image, self.top_left, self.bottom_right, (0,255,0), 2)
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)
cv2.line(image, self.bottom_left, self.top_left, (0,255,0), 2)
self.depth_state = True
self.last_marker_position = ((self.top_left), (self.bottom_right))
#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)):
#self.t.linear.x = 0.1 * self.vel_fac
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
@@ -262,7 +280,7 @@ class tutel():
def main():
if len(sys.argv) != 4:
print("Please give the following arguments <turtlebot-navi-topic> and <camera-img-topic> and <camera-depth-topic>")
print("Like: marker_attack.py /cmd_vel_mux/input/navi /camera/rgb/image_raw /camera/depth/image_raw")
print("Like: tutel_max_value_pure.py /cmd_vel_mux/input/navi /camera/color/image_raw /camera/depth/image_raw")
return 1
ic = tutel(str(sys.argv[1]),str(sys.argv[2]),str(sys.argv[3]))
try: