pick_server_test.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import rospy
00004 import actionlib
00005 import actionlib.msg
00006 from calvin_msgs.msg import PickAndStoreAction, PickAndStoreGoal
00007 from moveit_msgs.msg import CollisionObject
00008 from geometry_msgs.msg import Pose, Point, Quaternion
00009 from shape_msgs.msg import SolidPrimitive
00010 from std_msgs.msg import Header
00011 from std_srvs.srv import Empty
00012 
00013 from moveit_ros_planning_interface import _moveit_move_group_interface
00014 
00015 if __name__ == '__main__':
00016   rospy.init_node('pick_server_test')
00017 
00018   clear_octomap= rospy.ServiceProxy('clear_octomap', Empty)
00019 
00020   co_pub= rospy.Publisher('/collision_object', CollisionObject, queue_size= 5)
00021   rospy.sleep(rospy.Duration.from_sec(1.5))
00022 
00023   co = CollisionObject(
00024     header=Header(1, rospy.Time.now(), 'katana_base_link'),
00025     id='testbox',
00026     primitives=[SolidPrimitive(type=1, dimensions=[0.04, 0.055, 0.08])],
00027     primitive_poses=[Pose(Point(0.425, 0.0, -0.028), Quaternion(0.0, 0.0, 0.0, 1.0))],
00028     operation=CollisionObject.ADD)
00029 
00030   rospy.loginfo("adding testbox")
00031   co_pub.publish( co )
00032   rospy.sleep(rospy.Duration.from_sec(5.0))
00033 
00034   rospy.loginfo("clearing octomap")
00035   clear_octomap()
00036 
00037   rospy.loginfo("trying to pick testbox")
00038   try:
00039     move_group_client = actionlib.SimpleActionClient('/calvin_pick_and_store', PickAndStoreAction)
00040     move_group_client.wait_for_server(rospy.Duration.from_sec(10.0))
00041     move_group_client.send_goal( PickAndStoreGoal(co= co, disable_straight_grasps= True) )
00042     move_group_client.wait_for_result(rospy.Duration.from_sec(0))
00043 
00044     if move_group_client.get_state() != 3:
00045       rospy.logwarn("move group client state is %s", move_group_client.get_state())
00046 
00047   except actionlib.ActionException, e:
00048     rospy.logerr("move_group action failed: %s", e)
00049 
00050   try:
00051     mgi= _moveit_move_group_interface.MoveGroup("arm", "robot_description")
00052     mgi.set_named_target("arm_away")
00053     mgi.move()
00054   except Exception, e:
00055     rospy.logerr("moving back to home pose failed")


calvin_pick_server
Author(s): Michael Stypa
autogenerated on Thu Jun 6 2019 17:38:53