executive.py
Go to the documentation of this file.
00001 #! /usr/bin/python
00002 #***********************************************************
00003 #* Software License Agreement (BSD License)
00004 #*
00005 #*  Copyright (c) 2009, Willow Garage, Inc.
00006 #*  All rights reserved.
00007 #*
00008 #*  Redistribution and use in source and binary forms, with or without
00009 #*  modification, are permitted provided that the following conditions
00010 #*  are met:
00011 #*
00012 #*   * Redistributions of source code must retain the above copyright
00013 #*     notice, this list of conditions and the following disclaimer.
00014 #*   * Redistributions in binary form must reproduce the above
00015 #*     copyright notice, this list of conditions and the following
00016 #*     disclaimer in the documentation and/or other materials provided
00017 #*     with the distribution.
00018 #*   * Neither the name of Willow Garage, Inc. nor the names of its
00019 #*     contributors may be used to endorse or promote products derived
00020 #*     from this software without specific prior written permission.
00021 #*
00022 #*  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00023 #*  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00024 #*  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00025 #*  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00026 #*  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00027 #*  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00028 #*  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00029 #*  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00030 #*  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 #*  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00032 #*  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00033 #*  POSSIBILITY OF SUCH DAMAGE.
00034 #*
00035 #* Author: Eitan Marder-Eppstein
00036 #***********************************************************
00037 PKG = 'icra_ros_tutorial'
00038 NAME = 'executive'
00039 import roslib; roslib.load_manifest(PKG)
00040 import rospy
00041 import actionlib
00042 from actionlib_msgs.msg import *
00043 import tf
00044 import numpy
00045 from move_base_msgs.msg import MoveBaseAction, MoveBaseGoal
00046 from icra_ros_tutorial.srv import GetCheckerboardPose, GetApproachPose, GrabBox
00047 from geometry_msgs.msg import PoseStamped, Quaternion, Pose, Point
00048 from pr2_common_action_msgs.msg import *
00049 #from pr2_controllers_msgs.msg import *
00050 #from pr2_arm_ik_action.tools import *
00051 #from pr2_plugs_actions.posestampedmath import PoseStampedMath
00052 
00053 def run(argv=None):
00054   rospy.init_node(NAME, anonymous=False)
00055 
00056   print "Waiting for services to come up"
00057   rospy.wait_for_service('wide_get_checkerboard_pose')
00058   rospy.wait_for_service('narrow_get_checkerboard_pose')
00059   rospy.wait_for_service('get_approach_pose')
00060 
00061   try:
00062     print "Building a tf history"
00063     pose_pub = rospy.Publisher("nav_pose", PoseStamped)
00064 
00065     #print "Tucking the arms"
00066     ##tuck the arms
00067     #tuck_arm_client = actionlib.SimpleActionClient('tuck_arms', TuckArmsAction)
00068     #tuck_arm_client.wait_for_server()
00069     #tuck_goal = TuckArmsGoal(True,True)
00070     #tuck_arm_client.send_goal_and_wait(tuck_goal)
00071 
00072     print "Attempting to get the pose of the board"     
00073     #Get the pose of the 3x4 checkerboard
00074     get_checkerboard_pose = rospy.ServiceProxy('wide_get_checkerboard_pose', GetCheckerboardPose)
00075     board_pose = get_checkerboard_pose(5, 4, .08, .08).board_pose
00076 
00077     print "Attempting to get approach pose"
00078     #given the pose of the checkerboard, get a good pose to approach it from
00079     get_approach_pose = rospy.ServiceProxy('get_approach_pose', GetApproachPose)
00080     nav_pose = get_approach_pose(board_pose).nav_pose
00081 
00082     #publish the final pose for debugging purposes
00083     pose_pub.publish(nav_pose)
00084 
00085     print "Waiting for move_base_local"
00086     #OK... our nav_pose is now ready to be sent to the navigation stack as a goal
00087     move_base_client = actionlib.SimpleActionClient('move_base_local', MoveBaseAction)
00088     move_base_client.wait_for_server()
00089     goal = MoveBaseGoal()
00090     goal.target_pose = nav_pose
00091 
00092     print "Attempting to approach table"
00093     #send the goal and wait for the base to get there
00094     move_base_client.send_goal_and_wait(goal)
00095 
00096     #Get the pose of the 5x4 checkerboard on the box
00097     #get_checkerboard_pose = rospy.ServiceProxy('wide_get_checkerboard_pose', GetCheckerboardPose)
00098     #board_pose = get_checkerboard_pose(5, 4, 0.022, 0.022).board_pose
00099 
00100     #Grab the box
00101     #grab_box = rospy.ServiceProxy('grab_box', GrabBox)
00102     #grab_box(board_pose)
00103     
00104 
00105   except rospy.ServiceException, e:
00106     rospy.logerr("The service call to get the checkerboard pose failed: %s" % e)
00107   except tf.Exception, ex:
00108     rospy.logerr("The transform failed: %s" % ex)
00109 
00110 
00111 if __name__ == '__main__':
00112   run()


fall_school_executive
Author(s): Brian Gerkey
autogenerated on Mon Oct 6 2014 09:23:45