Go to the documentation of this file.00001
00002 import roslib
00003 roslib.load_manifest('rfid_demos')
00004 import rospy
00005
00006 import smach
00007 from smach_ros import SimpleActionState, ServiceState, IntrospectionServer
00008 import actionlib
00009
00010 import sm_rfid_explore
00011 import sm_next_best_vantage
00012 import sm_rfid_delivery
00013 from geometry_msgs.msg import PoseStamped
00014 from move_base_msgs.msg import MoveBaseAction
00015
00016
00017 def full_delivery():
00018
00019 sm = smach.StateMachine(outcomes=['succeeded','aborted','preempted'],
00020 input_keys = [ 'tagid', 'explore_radius' ])
00021
00022
00023 with sm:
00024 sm_search = sm_rfid_explore.sm_search()
00025 smach.StateMachine.add(
00026 'RFID_SEARCH',
00027 sm_search,
00028 remapping = { 'tagid' : 'tagid',
00029 'explore_radius' : 'explore_radius',
00030 'explore_rfid_reads' : 'explore_rfid_reads' },
00031 transitions={'succeeded':'BEST_VANTAGE'})
00032
00033 sm_vantage = sm_next_best_vantage.sm_best_vantage()
00034 smach.StateMachine.add(
00035 'BEST_VANTAGE',
00036 sm_vantage,
00037 remapping = { 'tagid' : 'tagid',
00038 'rfid_reads' : 'explore_rfid_reads' },
00039 transitions = {'succeeded':'DELIVERY'})
00040
00041 sm_delivery = sm_rfid_delivery.sm_delivery()
00042 smach.StateMachine.add(
00043 'DELIVERY',
00044 sm_delivery,
00045 remapping = { 'tagid' : 'tagid'},
00046 transitions = { 'succeeded': 'succeeded' })
00047
00048
00049
00050 return sm
00051
00052
00053 if __name__ == '__main__':
00054 rospy.init_node('smach_example_state_machine')
00055
00056 sm = full_delivery()
00057
00058 sis = IntrospectionServer('RFID_full_delivery', sm, '/SM_ROOT_FULL_DELIVERY')
00059 sis.start()
00060 rospy.sleep(3.0)
00061
00062 sm.userdata.tagid = 'person '
00063 sm.userdata.explore_radius = 2.7
00064 outcome = sm.execute()
00065
00066 rospy.spin()
00067 sis.stop()
00068
00069
00070