found_object_test.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 import roslib
19 import rospy
20 import numpy
21 import tf
22 import tf2_ros
23 import time
24 
25 from geometry_msgs.msg import (Pose, PoseWithCovariance, PoseWithCovarianceStamped, Point, Quaternion, Twist, Vector3)
26 from asr_msgs.msg import AsrObject
27 from actionlib import *
28 from actionlib.msg import *
29 from asr_robot_model_services.msg import RobotStateMessage
30 from asr_robot_model_services.srv import CalculateCameraPose
31 from asr_next_best_view.srv import TriggerFrustumVisualization
32 from sensor_msgs.msg import JointState
33 from asr_world_model.srv import PushFoundObject, PushFoundObjectList
34 
35 detected_objects = []
36 
38  """
39  Returns camera pose
40  """
41  try:
42  rospy.wait_for_service('/asr_robot_model_services/GetCameraPose', timeout=5)
43  pose = rospy.ServiceProxy('/asr_robot_model_services/GetCameraPose',GetPose)
44  rospy.loginfo(pose().pose)
45  return pose().pose
46  except Exception, e:
47  rospy.logwarn("Couldn't get Camera pose from service call.")
48  rospy.logwarn(e)
49  pass
50 
52  global detected_objects
53  # found object for the first time
54  rospy.loginfo("Found " + data.type)
55 
56  if ( len(data.sampledPoses) == 0 ):
57  rospy.logerr("Got a AsrObject without poses.")
58  sys.exit(1)
59 
60  # Construct FoundObject to push to world_model
61  # objects are transformed to map frame in world_model
62  object = AsrObject()
63  object = data
64  detected_objects.append(object)
65 
66 
67 if __name__ == '__main__':
68  global detected_objects
69  # Initialize the node and name it.
70  rospy.init_node('test_world_model')
71 
72  sub = rospy.Subscriber('/stereo/objects',AsrObject,detection_callback)
73 
74 
75  # Push to found objects in world model
76  rate = rospy.Rate(0.3) # 10hz
77  while not rospy.is_shutdown():
78  try:
79  rospy.wait_for_service('/env/asr_world_model/push_found_object_list',timeout=3)
80  push_found_objects = rospy.ServiceProxy('/env/asr_world_model/push_found_object_list', PushFoundObjectList)
81  push_found_objects(list(detected_objects))
82  detected_objects = []
83  except (rospy.exceptions.ROSException, rospy.ServiceException) as e:
84  rospy.logwarn("Could not find world_model service")
85  sys.exit(1)
86  rate.sleep()
def detection_callback(data)


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