4 Copyright (c) 2016, Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Marek Felix, Meissner Pascal, Trautmann Jeremias, Wittenbeck Valerij 8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 10 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 12 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. 14 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. 16 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. 28 from asr_msgs.msg
import AsrObject, AsrViewport
29 from geometry_msgs.msg
import (Pose, PoseWithCovariance,
30 PoseWithCovarianceStamped, Point, Quaternion, PoseStamped)
31 from asr_world_model.srv
import PushFoundObject, PushFoundObjectList, GetMissingObjectList, PushViewport
32 from common.evaluation_decorators
import *
33 from object_detectors_manager
import ObjectDetectorsManager
34 import state_acquisition
38 Tries to detect given searched_object_types in current_camera_pose. 39 If no current_camera_pose is given, it is determined via tf. 43 detected_objects = set()
45 missing_pbd_typeAndId = []
47 current_camera_pose =
None 49 global numberOfObjectDetectionRuns
50 numberOfObjectDetectionRuns = 0
51 global numberOfAllSearchedObjectTypes
52 numberOfAllSearchedObjectTypes = 0
57 outcomes=[
'found_objects',
'aborted',
'no_objects_found'],
58 input_keys=[
'searched_object_types'],
59 output_keys=[
'detected_objects'])
64 if not any(typeAndId.type == data.type
and typeAndId.identifier == data.identifier
for typeAndId
in self.missing_pbd_typeAndId):
65 rospy.loginfo(
"Object with id " + data.identifier +
" and type " + data.type +
" is not missing in any scene, we look for.")
67 if not any(object.type == data.type
and object.identifier == data.identifier
for object
in self.detected_objects):
69 rospy.loginfo(
"Received at least one estimate for object with type=" + data.type +
" and id=" + data.identifier)
70 if ( len(data.sampledPoses) == 0 ):
71 rospy.logerr(
"ObjectDetection got AsrObject message, not containing any poses.")
78 is_valid = (abs(data.sampledPoses[0].pose.position.x) < 0.4
and 79 abs(data.sampledPoses[0].pose.position.y) < 0.4
and 80 data.sampledPoses[0].pose.position.z < self.fcp*1.1
and 81 data.sampledPoses[0].pose.position.z > self.ncp*0.9)
83 rospy.loginfo(
"An object estimate for "+str(data.type)+
" rejected, since classified as outlier.")
88 rospy.logdebug(
"Pushing object estimate " + str(data.type) +
" into return lists and world model lists.")
89 self.detected_objects.add(data)
92 rospy.loginfo(
'Init OBJECT_DETECTION')
96 self.
ncp = rospy.get_param(
"/nbv/ncp")
97 self.
fcp = rospy.get_param(
"/nbv/fcp")
98 self.
fovx = rospy.get_param(
"/nbv/fovx")
99 self.
fovy = rospy.get_param(
"/nbv/fovy")
101 rospy.logwarn(
"Could not get parameters from nbv")
111 rospy.loginfo(
'Executing OBJECT_DETECTION')
116 if not 'searched_object_types' in userdata:
117 userdata.detected_objects = []
118 return 'no_objects_found' 119 if not userdata.searched_object_types:
120 return 'no_objects_found' 130 if not isinstance(userdata.searched_object_types, list):
137 rospy.wait_for_service(
'/env/asr_world_model/push_viewport', timeout=5)
138 push_viewport = rospy.ServiceProxy(
139 '/env/asr_world_model/push_viewport', PushViewport)
140 viewport = AsrViewport()
143 viewport.ncp = self.
ncp 144 viewport.fcp = self.
fcp 145 viewport.fovx = self.
fovx 146 viewport.fovy = self.
fovy 147 push_viewport(viewport)
149 except (rospy.ServiceException, rospy.exceptions.ROSException), e:
150 rospy.logwarn(str(e))
151 rospy.logwarn(
"service exception from world_model")
155 rospy.wait_for_service(
'/env/asr_world_model/get_missing_object_list', timeout=5)
156 get_missing_object_list =rospy.ServiceProxy(
157 '/env/asr_world_model/get_missing_object_list', GetMissingObjectList)
160 except (rospy.ServiceException, rospy.exceptions.ROSException), e:
161 rospy.logwarn(str(e))
162 rospy.logwarn(
"service exception from world_model")
163 return 'no_objects_found' 167 mode = rospy.get_param(
"/scene_exploration_sm/mode");
168 if mode == 4
or mode == 5:
173 global numberOfObjectDetectionRuns
174 global numberOfAllSearchedObjectTypes
175 numberOfObjectDetectionRuns += 1
177 rospy.loginfo(
"Number of object detections: " + str(numberOfObjectDetectionRuns))
178 rospy.loginfo(
"Number of all searched_object_types: " + str(numberOfAllSearchedObjectTypes))
179 rospy.loginfo(
"Average number of searched_object_types per run: " + str((1.0 * numberOfAllSearchedObjectTypes / numberOfObjectDetectionRuns)))
187 rospy.loginfo(
"All requested recognizers should now publish to " +
"/stereo/objects")
190 future = time() + wait_time
191 sub = rospy.Subscriber(
'/stereo/objects',
194 while (time() < future):
200 rospy.loginfo(
"stop recog send aborted")
203 rospy.loginfo(
"All recognizers are shut down.")
207 return 'no_objects_found' 210 rospy.loginfo(
"Pushing the following estimates to world_model.")
213 rospy.loginfo(
"Got object estimate with type " + output_object.type +
" and id " + output_object.identifier +
" provided by " + output_object.providedBy)
214 rospy.loginfo(
"Its position is " 215 +
"x: " + str(output_object.sampledPoses[0].pose.position.x)
216 +
" y: " + str(output_object.sampledPoses[0].pose.position.y)
217 +
" z: " + str(output_object.sampledPoses[0].pose.position.z) +
" and its orientation is " 218 +
"x: " + str(output_object.sampledPoses[0].pose.orientation.x)
219 +
" y: " + str(output_object.sampledPoses[0].pose.orientation.y)
220 +
" z: " + str(output_object.sampledPoses[0].pose.orientation.z)
221 +
" w: " + str(output_object.sampledPoses[0].pose.orientation.w))
223 rospy.wait_for_service(
'/env/asr_world_model/push_found_object_list',
225 push_found_objects = rospy.ServiceProxy(
226 '/env/asr_world_model/push_found_object_list', PushFoundObjectList)
228 except (rospy.exceptions.ROSException, rospy.ServiceException)
as e:
229 rospy.logwarn(
"Could not find world_model service")
233 return 'found_objects'
def execute(self, userdata)
list missing_pbd_typeAndId
def detection_callback(self, data)