call_deliver.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 
00003 import roslib; roslib.load_manifest('pr2_delivery')
00004 import rospy
00005 import actionlib
00006 import geometry_msgs.msg
00007 import tf.transformations
00008 from pr2_delivery.msg import DeliverAction, DeliverGoal
00009 
00010 import yaml
00011 import os
00012 
00013 def pose_from_yaml(filename):
00014     stream = open( filename )
00015     pose_dict = yaml.load( stream )
00016     
00017     pose = geometry_msgs.msg.PoseStamped()
00018     pose.header.stamp = rospy.Time.now()
00019     pose.header.frame_id = '/map'
00020     
00021     pose.pose.position.x = pose_dict['pose']['position']['x']
00022     pose.pose.position.y = pose_dict['pose']['position']['y']
00023     pose.pose.position.z = pose_dict['pose']['position']['z']
00024     
00025     pose.pose.orientation.x = pose_dict['pose']['orientation']['x']
00026     pose.pose.orientation.y = pose_dict['pose']['orientation']['y']
00027     pose.pose.orientation.z = pose_dict['pose']['orientation']['z']
00028     pose.pose.orientation.w = pose_dict['pose']['orientation']['w']
00029     
00030     return pose
00031 
00032 if __name__ == '__main__':
00033     rospy.loginfo("starting...")
00034     rospy.init_node('deliver_test_client')
00035     client = actionlib.SimpleActionClient('deliver', DeliverAction)
00036     rospy.loginfo("waiting for action server...")
00037     client.wait_for_server()
00038 
00039     data_dir = rospy.get_param("~data_dir")
00040     rospy.loginfo("Using %s as data directory"%(data_dir))
00041 
00042     goal = DeliverGoal()
00043     # Fill in goal here.
00044     goal.get_object_pose = pose_from_yaml(os.path.join(data_dir,'get_object_pose.yaml'))
00045     goal.give_object_pose = pose_from_yaml(os.path.join(data_dir,'give_object_pose.yaml'))
00046     goal.return_home_pose = pose_from_yaml(os.path.join(data_dir,'return_home_pose.yaml'))
00047 
00048     rospy.loginfo("sending goal.")
00049     client.send_goal(goal)
00050     client.wait_for_result(rospy.Duration.from_sec(50.0))
00051     rospy.loginfo("got action finished.")
00052     rospy.sleep(50)


pr2_delivery
Author(s): Dave Hershberger, Maintainer=Devon Ash
autogenerated on Sat Jun 8 2019 19:56:27