Go to the documentation of this file.00001
00002
00003 import roslib; roslib.load_manifest('cob_pick_place_action')
00004 import rospy
00005 import actionlib
00006 import random
00007 from math import pi
00008 from tf.transformations import *
00009
00010 from geometry_msgs.msg import PoseStamped
00011 import simple_moveit_interface as smi_
00012 import cob_pick_place_action.msg
00013
00014
00015 def setup_environment():
00016 psi = smi_.get_planning_scene_interface()
00017 rospy.sleep(1.0)
00018
00019 smi_.clear_objects()
00020
00021
00022 smi_.add_ground()
00023
00024
00025 pose = PoseStamped()
00026 pose.header.frame_id = "/base_footprint"
00027 pose.header.stamp = rospy.Time.now()
00028 pose.pose.position.x = -0.9
00029 pose.pose.position.y = 0
00030 pose.pose.position.z = 0.39
00031 pose.pose.orientation.x = 0
00032 pose.pose.orientation.y = 0
00033 pose.pose.orientation.z = 0
00034 pose.pose.orientation.w = 1
00035 psi.add_box("bookcase", pose, size=(0.5, 1.5, 0.78))
00036
00037 rospy.sleep(1.0)
00038
00039
00040 def cob_pick_action_client():
00041 pick_action_client = actionlib.SimpleActionClient('cob_pick_action', cob_pick_place_action.msg.CobPickAction)
00042
00043 pick_action_client.wait_for_server()
00044
00045 setup_environment()
00046
00047
00048 goal = cob_pick_place_action.msg.CobPickGoal()
00049 goal.object_class = 18
00050 goal.object_name = "yellowsaltcube"
00051
00052
00053
00054
00055
00056 goal.object_pose.header.stamp = rospy.Time.now()
00057 goal.object_pose.header.frame_id = "base_footprint"
00058
00059
00060
00061
00062 goal.object_pose.pose.position.x = -0.7
00063 goal.object_pose.pose.position.y = 0.0
00064 goal.object_pose.pose.position.z = 0.78
00065 goal.object_pose.pose.orientation.x, goal.object_pose.pose.orientation.y, goal.object_pose.pose.orientation.z, goal.object_pose.pose.orientation.w = quaternion_from_euler(0,0,0)
00066
00067
00068
00069 goal.grasp_database = "OpenRAVE"
00070 goal.support_surface = "bookcase"
00071
00072
00073 pick_action_client.send_goal(goal)
00074
00075
00076 finished_before_timeout=pick_action_client.wait_for_result(rospy.Duration(300, 0))
00077
00078 if finished_before_timeout:
00079 state=pick_action_client.get_state()
00080 print "Action finished: %s"%state
00081
00082 return state
00083
00084 if __name__ == '__main__':
00085 try:
00086
00087
00088 rospy.init_node('CobPickAction_client_py')
00089 result = cob_pick_action_client()
00090 except rospy.ROSInterruptException:
00091 print "program interrupted before completion"