Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 import random
00019 from math import pi
00020
00021 import rospy
00022 import actionlib
00023 from geometry_msgs.msg import PoseStamped
00024 from tf.transformations import *
00025 import simple_moveit_interface as smi_
00026 import cob_pick_place_action.msg
00027
00028
00029 def setup_environment():
00030 psi = smi_.get_planning_scene_interface()
00031 rospy.sleep(1.0)
00032
00033
00034 smi_.clear_objects("arm_left_7_link")
00035
00036
00037 smi_.add_ground()
00038
00039
00040 pose = PoseStamped()
00041 pose.header.frame_id = "/base_footprint"
00042 pose.header.stamp = rospy.Time.now()
00043 pose.pose.position.x = -0.9
00044 pose.pose.position.y = 0
00045 pose.pose.position.z = 0.39
00046 pose.pose.orientation.x = 0
00047 pose.pose.orientation.y = 0
00048 pose.pose.orientation.z = 0
00049 pose.pose.orientation.w = 1
00050
00051 psi.add_box("bookcase", pose, size=(0.5, 1.5, 0.78))
00052
00053 rospy.sleep(1.0)
00054
00055
00056 def cob_pick_action_client():
00057 pick_action_client = actionlib.SimpleActionClient('cob_pick_action', cob_pick_place_action.msg.CobPickAction)
00058
00059 pick_action_client.wait_for_server()
00060
00061 setup_environment()
00062
00063
00064 goal = cob_pick_place_action.msg.CobPickGoal()
00065
00066
00067
00068
00069
00070
00071 goal.object_class = 5001
00072 goal.object_name = "pringles"
00073 goal.object_pose.header.stamp = rospy.Time.now()
00074 goal.object_pose.header.frame_id = "base_footprint"
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085 goal.object_pose.pose.position.x = 0.617 + random.uniform(-0.1, 0.1)
00086 goal.object_pose.pose.position.y = 0.589 + random.uniform(-0.1, 0.1)
00087 goal.object_pose.pose.position.z = 0.979 + random.uniform(-0.1, 0.1)
00088 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(random.uniform(-pi/2, pi/2),random.uniform(-pi/2, pi/2),random.uniform(-pi/2, pi/2))
00089
00090 goal.gripper_type = "sdhx"
00091
00092 goal.gripper_side = "left"
00093
00094
00095 goal.grasp_database = "OpenRAVE"
00096
00097
00098 goal.support_surface = "bookcase"
00099
00100
00101 pick_action_client.send_goal(goal)
00102
00103
00104 finished_before_timeout=pick_action_client.wait_for_result(rospy.Duration(300, 0))
00105
00106 if finished_before_timeout:
00107 state=pick_action_client.get_state()
00108 print "Action finished: %s"%state
00109 else:
00110 print "Action did not finish within timeout"
00111 return
00112
00113 if __name__ == '__main__':
00114 try:
00115
00116
00117 rospy.init_node('CobPickAction_client_py')
00118 cob_pick_action_client()
00119 except rospy.ROSInterruptException:
00120 print "program interrupted before completion"