patch
Ausreißer werden gefiltert und nur "realistische" Werte für das Arithmetische Mittel verwendet. Außerdem Ordnung der Ecken kürzer. TEST, wip: -Nach dem finden des markers und dem erreichen der minimal erkennbaren tiefe -> die Tutel fährt noch ~30cm in Richtung des Markers. -Suche verändert. Der Bot dreht sich um 360° und fährt daraufhin 10cm nach vorne wo er sich wieder dreht.
This commit is contained in:
@@ -15,7 +15,7 @@ from cv_bridge import CvBridge, CvBridgeError
|
||||
from geometry_msgs.msg import Twist
|
||||
|
||||
TARGET = 0
|
||||
DEPTH = 550
|
||||
DEPTH = 400
|
||||
POSITIONS = ["left", "right", "middle"]
|
||||
DEVICE = 'dev/ttyACM'
|
||||
BAUD = 9600
|
||||
@@ -103,14 +103,22 @@ class tutel():
|
||||
print(e)
|
||||
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
if self.search:
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
start = time.time()
|
||||
while ((time.time() - start) < 10) or !self.search:
|
||||
self.pub.publish(self.t)
|
||||
(corners, ids, rejected) = cv2.aruco.detectMarkers(rgb_image, self.arucoDict, parameters = self.arucoParams)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.1 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
if corners:
|
||||
self.target_id = ids[0]
|
||||
self.search = False
|
||||
else:
|
||||
if corners:
|
||||
x = np.where(ids == self.target_id)
|
||||
@@ -156,37 +164,41 @@ class tutel():
|
||||
#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]))
|
||||
if (self.top_left[0] - self.bottom_left[0]) in range (-10,10):
|
||||
if self.top_left[0] < self.top_right[0]: x = (self.top_left[0],self.top_right[0])
|
||||
else: x = (self.top_right[0],self.top_left[0])
|
||||
if self.top_left[1] < self.bottom_left[1]: y = (self.top_left[1],self.bottom_left[1])
|
||||
else: y = (self.bottom_left[1],self.top_left[1])
|
||||
x = [(self.top_right[0],self.top_left[0]), (self.top_left[0],self.top_right[0])][self.top_left[0] < self.top_right[0]]
|
||||
y = [(self.bottom_left[1], self.top_left[1]), (self.top_left[1], self.bottom_left[1])][self.top_left[1] < self.bottom_left[1]]
|
||||
elif (self.top_left[0] - self.top_right[0]) in range (-10,10):
|
||||
if self.bottom_left[0] < self.top_left[0]: x = (self.bottom_left[0],self.top_left[0])
|
||||
else: x = (self.top_left[0],self.bottom_left[0])
|
||||
if self.bottom_left[1] < self.bottom_right[1]: y = (self.bottom_left[1],self.bottom_right[1])
|
||||
else: y = (self.bottom_right[1],self.bottom_left[1])
|
||||
x = [(self.bottom_left[0], self.top_left[0]), (self.top_left[0], self.bottom_left[0])][self.bottom_left[0] < self.top_left[0]]
|
||||
y = [(self.bottom_right[1], self.bottom_left[1]), (self.bottom_left[1], self.bottom_right[1])][self.bottom_left[1] < self.bottom_right[1]]
|
||||
cv2.line(depth_image, (x[0],y[0]), (x[1],y[1]), (0,255,0), 2)
|
||||
depth_values = []
|
||||
for i in range(x[0], x[1]):
|
||||
for j in range(y[0], y[1]):
|
||||
if depth_image[j][i] < in range(0, max(depth_image)-10)pass
|
||||
else:
|
||||
self.last_depth += depth_image[j][i]
|
||||
if depth_image[j][i] > self.maxMinDepth:
|
||||
depth_values.append(depth_image[j][i])
|
||||
for k in depth_values:
|
||||
if k > (max(depth_values) - 10):
|
||||
self.last_depth += k
|
||||
self.number_of_operations += 1
|
||||
self.last_depth /= self.number_of_operations
|
||||
self.last_depth [0, self.last_depth / self.number_of_operations][self.number_of_operations > 0]
|
||||
print(self.depth_counter, self.last_depth, self.number_of_operations)
|
||||
self.number_of_operations = 0
|
||||
cv2.imshow("Tutel_Depth", depth_image)
|
||||
if self.last_depth < self.maxMinDepth and self.last_depth != 0:
|
||||
self.depth_counter += 1
|
||||
if self.depth_counter > 0:
|
||||
print("Reached our destination")
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
print("Only a few cm")
|
||||
self.t.linear.x = 0.1 * self.vel_fac
|
||||
self.t.angular.z = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
self.position = POSITIONS[2]
|
||||
self.depth_counter = 0
|
||||
self.depth_state = False
|
||||
self.last_depth = 10.0
|
||||
start = time.time()
|
||||
while (time.time() - start) < 3:
|
||||
self.pub.publish(self.t)
|
||||
self.t.linear.x = 0.0 * self.vel_fac
|
||||
self.pub.publish(self.t)
|
||||
print("We reached our destination")
|
||||
#self.move_arm(self)
|
||||
else:
|
||||
self.depth_counter = 0
|
||||
|
||||
Reference in New Issue
Block a user