door_sequence_service_checkerboard.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
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('set_detect_checkerboard')
00014       service_names.append('search_and_track_checkerboard_on')
00015       service_names.append('search_and_track_checkerboard_off')
00016       service_names.append('robot_pose')
00017       service_names.append('unlatch_door')
00018       resp = None
00019       for service_name in service_names:
00020         rospy.loginfo('Waiting for ' + service_name)
00021         rospy.wait_for_service(service_name)
00022 
00023       try:
00024           detect_checkerboard = rospy.ServiceProxy('set_detect_checkerboard', Set)
00025           rospy.loginfo('calling set_detect_checkerboard')
00026           setactive = SetRequest()
00027           setactive.active = True
00028           detect_checkerboard(setactive)
00029 
00030           start_search_and_track = rospy.ServiceProxy('search_and_track_checkerboard_on', Empty)
00031           rospy.loginfo('calling search_and_track_checkerboard_on')
00032           start_search_and_track()
00033 
00034           robot_pose_client= rospy.ServiceProxy('robot_pose', RobotPosture)
00035           rospy.loginfo('calling robot_pose')
00036           resp = robot_pose_client(['left tuck'])
00037 
00038           unlatch_client = rospy.ServiceProxy('unlatch_door', Empty)
00039           rospy.loginfo('calling unlatch_door')
00040           resp = unlatch_client ()
00041 
00042           #swinger_client = rospy.ServiceProxy('swing_door', Empty)
00043           #rospy.loginfo('calling swing_door')
00044           #resp = swinger_client ()
00045 
00046           rospy.loginfo('calling set_detect_checkerboard')
00047           setinactive = SetRequest()
00048           setinactive.active = False
00049           detect_checkerboard(setinactive)
00050 
00051           rospy.loginfo('calling robot_pose')
00052           resp = robot_pose_client(['left tuck'])
00053           #robot_pose_client(['left up', 'right up'])
00054           #robot_pose_client(['left tuck', 'right tuck'])
00055 
00056       except rospy.ServiceException, e:
00057           print "Service call failed: %s"%e
00058       finally:
00059           stop_search_and_track= rospy.ServiceProxy('search_and_track_checkerboard_off', Empty)
00060           rospy.loginfo('calling search_and_track_checkerboard_off')
00061           resp = stop_search_and_track()
00062             
00063       return resp
00064 
00065 if __name__ == "__main__":
00066   rospy.init_node('door_opening_script')
00067   s = rospy.Service('start_door_opening_sequence_with_checkerboard', Empty, service_call_sequence)
00068   rospy.loginfo( "Ready to start door opening sequence")
00069   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