test_world_model_with_scene_recognition.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 '''
4 Copyright (c) 2016, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Meissner Pascal, Schleicher Ralf, Stoeckle Patrick, Trautmann Jeremias
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
8 
9 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
10 
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.
12 
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.
14 
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.
16 '''
17 
18 PKG = 'asr_world_model'
19 
20 import unittest
21 import rospy
22 from asr_msgs.msg import AsrObject
23 from asr_world_model.srv import PushFoundObject, PushFoundObjectRequest, GetFoundObjectList
24 from asr_recognizer_prediction_ism.srv import FindScenes, FindScenesRequest, GetPointCloud
25 from std_srvs.srv import Empty
26 from geometry_msgs.msg import Pose, PoseWithCovariance
27 
28 class WorldModelTest(unittest.TestCase):
29 
30  def setUp(self):
31  rospy.init_node("test_world_model", anonymous=True)
32 
33  try:
34  rospy.wait_for_service('/env/asr_world_model/push_found_object', timeout=5)
35  rospy.wait_for_service('/env/asr_world_model/empty_found_object_list', timeout=5)
36  rospy.wait_for_service('/env/asr_world_model/env/asr_world_model/get_found_object_list', timeout=5)
37  rospy.wait_for_service('/asr_object_database/object_type', timeout=5)
38  except rospy.exceptions.ROSException, e:
39  rospy.loginfo('Could not reach service' + e.message)
40 
42 
43  world_model_reset = rospy.ServiceProxy('/env/asr_world_model/empty_found_object_list', Empty)
44  world_model_reset()
45 
46  req = PushFoundObjectRequest()
47  detected_pbd_object = AsrObject()
48  detected_pbd_object.type = 'CoffeeBox'
49  detected_pbd_object.header.frame_id = '/camera_left_frame'
50  detected_pbd_object.identifier = ''
51  detected_pbd_object.providedBy = 'textured'
52  detected_pbd_object.colorName = 'textured'
53  detected_pbd_object.meshResourcePath = 'package://asr_object_database/rsc/databases/textured_objects/CoffeeBox/CoffeeBox.dae'
54 
55  detected_pose = Pose()
56  detected_pose.position.x = 1
57  detected_pose.position.y = 2
58  detected_pose.position.z = 3
59  detected_pose.orientation.w = 0.695641823146944
60  detected_pose.orientation.x = -0.702895791692416
61  detected_pose.orientation.y = -0.102411625776331
62  detected_pose.orientation.z = 0.107386306462868
63 
64  detected_pose_with_c = PoseWithCovariance()
65  detected_pose_with_c.pose = detected_pose
66 
67  detected_pbd_object.sampledPoses.append(detected_pose_with_c)
68 
69  push_found_object = rospy.ServiceProxy('/env/asr_world_model/push_found_object', PushFoundObject)
70  push_found_object(detected_pbd_object)
71 
72  get_found_objects = rospy.ServiceProxy('/env/asr_world_model/get_found_object_list', GetFoundObjectList)
73  resp = get_found_objects()
74  self.assertEqual(len(resp.object_list), 1)
75 
76  for found_object in resp.object_list:
77  self.assertEqual(len(found_object.sampledPoses), 1)
78 
79 
80  find_scenes = rospy.ServiceProxy('/rp_ism_node/find_scenes', FindScenes)
81  find_scenes_req = FindScenesRequest()
82  for pbd_object in resp.object_list:
83  find_scenes_req.objects.append(pbd_object)
84  find_scenes(find_scenes_req)
85 
86  rp_ism_node_predict = rospy.ServiceProxy('/rp_ism_node/get_point_cloud', GetPointCloud)
87  rp_ism_node_predict()
88 
89 
90 if __name__ == '__main__':
91  import rostest
92  rostest.rosrun(PKG, 'test_world_model', WorldModelTest)


asr_world_model
Author(s): Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Meißner Pascal, Schleicher Ralf, Stöckle Patrick, Trautmann Jeremias
autogenerated on Thu Jan 9 2020 07:20:01