$search
00001 #!/usr/bin/env python 00002 00003 ################################################################# 00004 ##\file 00005 # 00006 # \note 00007 # Copyright (c) 2012 \n 00008 # University of Bedfordshire \n\n 00009 # 00010 ################################################################# 00011 # 00012 # \note 00013 # Project name: care-o-bot 00014 # \note 00015 # ROS stack name: srs_public 00016 # \note 00017 # ROS package name: srs_symbolic_grounding 00018 # 00019 # \author 00020 # Author: Beisheng Liu, email:beisheng.liu@beds.ac.uk 00021 # \author 00022 # Supervised by: Dayou Li, email:dayou.li@beds.ac.uk 00023 # 00024 # \date Date of creation: Mar 2012 00025 # 00026 # \brief 00027 # test client for symbol_grounding_grasp_base_pose_experimental_server 00028 # 00029 ################################################################# 00030 # 00031 # Redistribution and use in source and binary forms, with or without 00032 # modification, are permitted provided that the following conditions are met: 00033 # 00034 # - Redistributions of source code must retain the above copyright 00035 # notice, this list of conditions and the following disclaimer. \n 00036 # - Redistributions in binary form must reproduce the above copyright 00037 # notice, this list of conditions and the following disclaimer in the 00038 # documentation and/or other materials provided with the distribution. \n 00039 # - Neither the name of the University of Bedfordshire nor the names of its 00040 # contributors may be used to endorse or promote products derived from 00041 # this software without specific prior written permission. \n 00042 # 00043 # This program is free software: you can redistribute it and/or modify 00044 # it under the terms of the GNU Lesser General Public License LGPL as 00045 # published by the Free Software Foundation, either version 3 of the 00046 # License, or (at your option) any later version. 00047 # 00048 # This program is distributed in the hope that it will be useful, 00049 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00050 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00051 # GNU Lesser General Public License LGPL for more details. 00052 # 00053 # You should have received a copy of the GNU Lesser General Public 00054 # License LGPL along with this program. 00055 # If not, see <http://www.gnu.org/licenses/>. 00056 # 00057 ################################################################# 00058 import roslib; roslib.load_manifest('srs_symbolic_grounding') 00059 00060 from srs_symbolic_grounding.srv import * 00061 from srs_symbolic_grounding.msg import * 00062 from geometry_msgs.msg import * 00063 import rospy 00064 import tf 00065 from srs_msgs.msg import SRSSpatialInfo 00066 import math 00067 00068 def symbol_grounding_grasp_base_pose_experimental_client(target_obj_pose, parent_obj_geometry, furniture_geometry_list): 00069 00070 00071 rospy.wait_for_service('symbol_grounding_grasp_base_pose_experimental') 00072 symbol_grounding_grasp_base_pose_experimental = rospy.ServiceProxy('symbol_grounding_grasp_base_pose_experimental', SymbolGroundingGraspBasePoseExperimental) 00073 00074 try: 00075 resp1 = symbol_grounding_grasp_base_pose_experimental(target_obj_pose, parent_obj_geometry, furniture_geometry_list) 00076 return resp1 00077 00078 except rospy.ServiceException, e: 00079 print "Service call failed: %s" %e 00080 00081 00082 ''' 00083 def getWorkspaceOnMap(): 00084 #print 'test get all workspace (furnitures basically here) from map' 00085 try: 00086 requestNewTask = rospy.ServiceProxy('get_workspace_on_map', GetWorkspaceOnMap) 00087 resp2 = requestNewTask('ipa-kitchen-map', True) 00088 return resp2 00089 except rospy.ServiceException, e: 00090 print "Service call failed: %s"%e 00091 00092 ''' 00093 00094 00095 00096 if __name__ == "__main__": 00097 00098 00099 00100 target_obj_pose = Pose() 00101 00102 target_obj_pose.position.x = 0.64 00103 target_obj_pose.position.y = 0.9 00104 target_obj_pose.position.z = 0.8 00105 target_obj_pose.orientation.x = 0 00106 target_obj_pose.orientation.y = 0 00107 target_obj_pose.orientation.z = 0 00108 target_obj_pose.orientation.w = 1 00109 00110 00111 #workspace_info = getWorkspaceOnMap() 00112 00113 parent_obj_geometry = SRSSpatialInfo() 00114 00115 ''' 00116 parent_obj_geometry.pose.position.x = workspace_info.objectsInfo[0].pose.position.x 00117 parent_obj_geometry.pose.position.y = workspace_info.objectsInfo[0].pose.position.y 00118 parent_obj_geometry.pose.position.z = workspace_info.objectsInfo[0].pose.position.z 00119 parent_obj_geometry.pose.orientation.x = workspace_info.objectsInfo[0].pose.orientation.x 00120 parent_obj_geometry.pose.orientation.y = workspace_info.objectsInfo[0].pose.orientation.y 00121 parent_obj_geometry.pose.orientation.z = workspace_info.objectsInfo[0].pose.orientation.z 00122 parent_obj_geometry.pose.orientation.w = workspace_info.objectsInfo[0].pose.orientation.w 00123 parent_obj_geometry.l = workspace_info.objectsInfo[0].l 00124 parent_obj_geometry.w = workspace_info.objectsInfo[0].w 00125 parent_obj_geometry.h = workspace_info.objectsInfo[0].h 00126 ''' 00127 00128 parent_obj_geometry.pose.position.x = -3.3 00129 parent_obj_geometry.pose.position.y = 0.5 00130 parent_obj_geometry.pose.position.z = 1.0 00131 parent_obj_geometry.pose.orientation.x = 0 00132 parent_obj_geometry.pose.orientation.y = 0 00133 parent_obj_geometry.pose.orientation.z = 0 00134 parent_obj_geometry.pose.orientation.w = 1.0 00135 00136 parent_obj_geometry.l = 2.0 00137 parent_obj_geometry.w = 1.0 00138 parent_obj_geometry.h = 0.85 00139 00140 00141 00142 00143 furniture_geometry_list = list() 00144 #furniture_geometry_list = workspace_info.objectsInfo 00145 #rospy.loginfo(workspace_info.objectsInfo[6]) 00146 00147 00148 print "Requesting reachability and grasp base pose." 00149 result = symbol_grounding_grasp_base_pose_experimental_client(target_obj_pose, parent_obj_geometry, furniture_geometry_list) 00150 print result 00151 #print math.atan(0.26 / 0.7) 00152 00153 00154 00155