door_sequence_service.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 import roslib; roslib.load_manifest('door_executive')
00003 
00004 import sys
00005 
00006 import rospy
00007 from std_srvs.srv import Empty, EmptyResponse
00008 from door_manipulation_tools.srv import RobotPosture
00009 from checkerboard_detector2.srv import Set, SetRequest
00010 
00011 def service_call_sequence(req = None):
00012       service_names = []
00013       service_names.append('handle_detection_on')
00014       service_names.append('handle_detection_off')
00015       service_names.append('search_and_track_handle_on')
00016       service_names.append('search_and_track_handle_off')
00017       service_names.append('robot_pose')
00018       service_names.append('unlatch_door')
00019       resp = EmptyResponse()
00020       for service_name in service_names:
00021         rospy.loginfo('Waiting for ' + service_name)
00022         rospy.wait_for_service(service_name)
00023 
00024       try:
00025           start_handle_detection = rospy.ServiceProxy('handle_detection_on', Empty)
00026           rospy.loginfo('calling handle_detection_on')
00027           start_handle_detection()
00028 
00029           start_search_and_track = rospy.ServiceProxy('search_and_track_handle_on', Empty)
00030           rospy.loginfo('calling search_and_track_handle_on')
00031           start_search_and_track()
00032 
00033           robot_pose_client= rospy.ServiceProxy('robot_pose', RobotPosture)
00034           rospy.loginfo('calling robot_pose')
00035           robot_pose_client(['left tuck'])
00036 
00037           unlatch_client = rospy.ServiceProxy('unlatch_door', Empty)
00038           rospy.loginfo('calling unlatch_door')
00039           resp = unlatch_client ()
00040 
00041           rospy.loginfo('calling robot_pose')
00042           robot_pose_client(['left tuck'])
00043           #robot_pose_client(['left up', 'right up'])
00044           #robot_pose_client(['left tuck', 'right tuck'])
00045 
00046       except rospy.ServiceException, e:
00047           print "Service call failed: %s"%e
00048       finally:
00049           stop_search_and_track= rospy.ServiceProxy('search_and_track_handle_off', Empty)
00050           rospy.loginfo('calling search_and_track_handle_off')
00051           stop_search_and_track()
00052             
00053           stop_handle_detection = rospy.ServiceProxy('handle_detection_off', Empty)
00054           rospy.loginfo('calling handle_detection_off')
00055           stop_handle_detection()
00056 
00057       return resp
00058 
00059 if __name__ == "__main__":
00060   rospy.init_node('door_opening_script')
00061   s = rospy.Service('start_door_opening_sequence', Empty, service_call_sequence)
00062   rospy.loginfo( "Ready to start door opening sequence")
00063   rospy.spin()
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends


door_executive
Author(s): Felix Endres
autogenerated on Wed Dec 26 2012 16:05:32