@@ -81,6 +81,7 @@ def subscribe(self, img_topic, depth_topic):
81
81
'delete_selection' , DeleteSelection , self .delete_selection_callback )
82
82
self .move_server = rospy .Service (
83
83
'move_objects' , MoveObjects , self .move_objects_callback )
84
+ self .grasp_pub = rospy .Publisher ('grasp_data' , GraspData , queue_size = 1 )
84
85
85
86
def detect_objects_in_region (self , msg ):
86
87
self .selection_manager .update ([msg ])
@@ -99,6 +100,8 @@ def move_objects_callback(self, req):
99
100
response .success = True
100
101
response .message = '{} source objects detected.' .format (len (mission ))
101
102
rospy .loginfo ('mission generated, executing mission.' )
103
+ # response.object_data = [x.make_msg() for x in mission]
104
+ # self.grasp_pub.publish([x.make_msg() for x in mission])
102
105
try :
103
106
self .robot_interface .pick_and_place_mission (mission )
104
107
except :
@@ -161,9 +164,9 @@ def region_selection_callback(self, req):
161
164
grasp_data = []
162
165
for gp in grasp_points :
163
166
grasp_datum = GraspData ()
164
- grasp_datum .center .x = gp .center [0 ]
165
- grasp_datum .center .y = gp .center [1 ]
166
- grasp_datum .radius = gp .radius
167
+ grasp_datum .position .x = gp .position [0 ]
168
+ grasp_datum .position .y = gp .position [1 ]
169
+ grasp_datum .diameter = gp .diameter
167
170
grasp_datum .angle = gp .angle
168
171
grasp_datum .height = gp .height
169
172
grasp_data .append (grasp_datum )
@@ -294,7 +297,7 @@ def detect_fingertip(self, img):
294
297
295
298
def detect_object (self , img ):
296
299
objects = []
297
- threshed = my_threshold (img , 15 , 150 )
300
+ threshed = my_threshold (img , 5 , 150 )
298
301
mask = np .zeros (img .shape , dtype = np .uint8 )
299
302
mask [threshed > 0 ] = 255
300
303
dst = img .copy ()
@@ -304,7 +307,8 @@ def detect_object(self, img):
304
307
merge_list = lambda l1 , l2 : l2 if not l1 else (l1 if not l2 else np .concatenate ((l1 , l2 )))
305
308
object_contours = []
306
309
if len (contours ) != 0 :
307
- contours = filter (lambda c : cv2 .contourArea (c ) > 400 and cv2 .contourArea (c ) < 1500 , contours )
310
+ # print([cv2.contourArea(c) for c in contours])
311
+ contours = filter (lambda c : cv2 .contourArea (c ) > 400 and cv2 .contourArea (c ) < 3000 , contours )
308
312
debug_img = dst .copy ()
309
313
objects = self .object_detector .update (contours , dst , debug_img )
310
314
debug_img = self .object_detector .debug_img
0 commit comments