4 Copyright (c) 2016, Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Karrenbauer Oliver, Marek Felix, Meissner Pascal, Stroh Daniel, Trautmann Jeremias 7 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 9 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 11 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 13 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 20 import recognition_for_grasping.srv
21 from asr_msgs.msg
import AsrObject
22 from asr_world_model.srv
import PushFoundObject, PushFoundObjectList
23 import asr_aruco_marker_recognition.srv
24 import asr_fake_object_recognition.srv
25 from asr_world_model.srv
import GetRecognizerName
26 import asr_descriptor_surface_based_recognition.srv
36 rospy.wait_for_service(
37 '/asr_descriptor_surface_based_recognition/get_recognizer',
39 descriptor_recognizer = rospy.ServiceProxy(
40 '/asr_descriptor_surface_based_recognition/get_recognizer',
41 asr_descriptor_surface_based_recognition.srv.GetRecognizer)
42 except (rospy.exceptions.ROSException, rospy.ServiceException)
as e:
43 rospy.logwarn(
"Service error with descriptor recognizer")
45 descriptor_recognizer(search_objects, 1,
False)
46 rospy.loginfo(
'Detection started for ' + str(search_objects))
51 rospy.wait_for_service(
52 '/asr_aruco_marker_recognition/get_recognizer',
54 marker_recognizer = rospy.ServiceProxy(
55 '/asr_aruco_marker_recognition/get_recognizer',
56 asr_aruco_marker_recognition.srv.GetRecognizer)
58 except (rospy.exceptions.ROSException, rospy.ServiceException)
as e:
59 rospy.logwarn(
"Service error with marker recognizer")
61 rospy.loginfo(
'Marker recognition started.')
69 rospy.wait_for_service(
'/recognition_manager/get_recognizer',
71 recognizer = rospy.ServiceProxy(
72 '/recognition_manager/get_recognizer',
73 recognition_for_grasping.srv.GetRecognizer)
74 except (rospy.exceptions.ROSException, rospy.ServiceException)
as e:
75 rospy.logwarn(
"Service error with recognition manager")
81 recognizer(str(search_objects), str(type),
False)
82 rospy.loginfo(
'Detection started for ' + str(search_objects))
86 release_descriptor_recognizer =
None 88 release_descriptor_recognizer = rospy.ServiceProxy(
89 '/asr_descriptor_surface_based_recognition/release_recognizer',
90 asr_descriptor_surface_based_recognition.srv.ReleaseRecognizer)
91 except rospy.ServiceException, e:
92 rospy.logwarn(
"Error calling the release recognizer services for descriptor recognition.")
94 release_descriptor_recognizer(search_objects)
95 rospy.loginfo(str(search_objects)+
" released.")
99 clear_all_descriptor_recognizers =
None 101 clear_all_descriptor_recognizers = rospy.ServiceProxy(
102 '/asr_descriptor_surface_based_recognition/clear_all_recognizers',
103 asr_descriptor_surface_based_recognition.srv.ClearAllRecognizers)
104 except rospy.ServiceException, e:
105 rospy.logwarn(
"Error calling the clear all recognizers service for descriptor recognition.")
107 clear_all_descriptor_recognizers()
108 rospy.loginfo(
"All descriptor recognizers released.")
112 release_recognizer =
None 114 release_recognizer = rospy.ServiceProxy(
115 '/recognition_manager/release_recognizer',
116 recognition_for_grasping.srv.ReleaseRecognizer)
117 except rospy.ServiceException, e:
118 rospy.logwarn(
"Error calling the release recognizer services for recognition manager.")
121 release_recognizer(str(search_objects), str(type),
"/stereo/objects")
122 rospy.loginfo(str(search_objects)+
" released.")
126 clear_all_recognizers =
None 128 clear_all_recognizers = rospy.ServiceProxy(
129 '/recognition_manager/clear_all_recognizers',
130 recognition_for_grasping.srv.ClearAllRecognizers)
131 except rospy.ServiceException, e:
132 rospy.logwarn(
"Error calling the clear all recognizers service for recognition manager.")
135 clear_all_recognizers(
"/stereo/objects")
136 rospy.loginfo(
"All rfg recognizers released.")
141 release_marker_recognizer = rospy.ServiceProxy(
142 '/asr_aruco_marker_recognition/release_recognizer',
143 asr_aruco_marker_recognition.srv.ReleaseRecognizer)
144 except rospy.ServiceException, e:
145 rospy.logwarn(
"Error calling the release recognizer services for marker recognition.")
147 release_marker_recognizer()
148 rospy.loginfo(
'Marker recognition stopped.')
152 rospy.init_node(
'recognition_manual_manager')
154 while not rospy.is_shutdown():
155 command_string = raw_input(
'Enter a valid command, f.e start,Smacks,textured :')
156 command_array = command_string.split(
',')
158 if command_array[0] ==
'start':
159 if command_array[1] ==
'markers':
160 manager.start_markers()
161 elif command_array[2] ==
'descriptor':
162 manager.start_recognizers_descriptor(command_array[1])
163 elif command_array[2]
in 'textured segmentable':
164 manager.start_recognizers_rfg(command_array[1],command_array[2])
166 rospy.loginfo(
'invalid command')
168 elif command_array[0] ==
'stop':
169 if command_array[1] ==
'markers':
170 manager.stop_markers()
171 elif command_array[1] ==
'all':
172 manager.stop_all_recognizers_rfg()
173 manager.stop_all_recognizers_descriptor()
174 manager.stop_markers()
175 elif command_array[2] ==
'descriptor':
176 manager.stop_recognizers_descriptor(command_array[1])
177 elif command_array[2]
in 'textured segmentable':
178 manager.stop_recognizers_rfg(command_array[1],command_array[2])
180 rospy.loginfo(
'invalid command')
183 rospy.loginfo(
'invalid command')
187 if __name__ ==
'__main__':
def stop_recognizers_rfg(self, search_objects, type)
def start_recognizers_descriptor(self, search_objects)
def stop_all_recognizers_descriptor(self)
def stop_recognizers_descriptor(self, search_objects)
def stop_all_recognizers_rfg(self)
def start_recognizers_rfg(self, search_objects, type)