4 Copyright (c) 2016, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Meissner Pascal, Schleicher Ralf, Stoeckle Patrick, 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. 18 PKG =
'asr_world_model' 22 from asr_msgs.msg
import AsrObject
23 from asr_world_model.srv
import PushFoundObject, PushFoundObjectRequest, GetFoundObjectList
24 from geometry_msgs.msg
import Pose
25 from std_srvs.srv
import Empty
26 from geometry_msgs.msg
import Pose, PoseWithCovariance
31 rospy.init_node(
"test_world_model", anonymous=
True)
33 rospy.wait_for_service(
'/env/asr_world_model/push_found_object', timeout=5)
34 rospy.wait_for_service(
'/env/asr_world_model/empty_found_object_list', timeout=5)
35 rospy.wait_for_service(
'/env/asr_world_model/env/asr_world_model/get_found_object_list', timeout=5)
36 rospy.wait_for_service(
'/asr_object_database/object_type', timeout=5)
37 except rospy.exceptions.ROSException, e:
38 rospy.loginfo(
'Could not reach service' + e.message)
42 world_model_reset = rospy.ServiceProxy(
'/env/asr_world_model/empty_found_object_list', Empty)
45 req = PushFoundObjectRequest()
46 detected_pbd_object = AsrObject()
47 detected_pbd_object.type =
'CoffeeBox' 48 detected_pbd_object.header.frame_id =
'camera_left_frame' 49 detected_pbd_object.identifier =
'' 50 detected_pbd_object.providedBy =
'textured' 51 detected_pbd_object.colorName =
'textured' 52 detected_pbd_object.meshResourcePath =
'package://asr_object_database/rsc/databases/textured_objects/CoffeeBox/CoffeeBox.dae' 54 detected_pose = Pose()
55 detected_pose.position.x = 1
56 detected_pose.position.y = 2
57 detected_pose.position.z = 3
58 detected_pose.orientation.w = 0.695641823146944
59 detected_pose.orientation.x = -0.702895791692416
60 detected_pose.orientation.y = -0.102411625776331
61 detected_pose.orientation.z = 0.107386306462868
63 detected_pose_with_c = PoseWithCovariance()
64 detected_pose_with_c.pose = detected_pose
66 detected_pbd_object.sampledPoses.append(detected_pose_with_c)
68 push_found_object = rospy.ServiceProxy(
'/env/asr_world_model/push_found_object', PushFoundObject)
69 push_found_object(detected_pbd_object)
71 get_found_objects = rospy.ServiceProxy(
'/env/asr_world_model/get_found_object_list', GetFoundObjectList)
72 resp = get_found_objects()
73 self.assertEqual(len(resp.object_list), 1)
75 for found_object
in resp.object_list:
76 self.assertEqual(len(found_object.sampledPoses), 1)
78 if __name__ ==
'__main__':
80 rostest.rosrun(PKG,
'test_world_model', WorldModelTest)
def test_world_model_with_1_object(self)