sm_rfid_full_deliver.py
Go to the documentation of this file.
00001 #! /usr/bin/python
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     # Create a SMACH state machine
00019     sm = smach.StateMachine(outcomes=['succeeded','aborted','preempted'],
00020                             input_keys = [ 'tagid', 'explore_radius' ])
00021 
00022     # Open the container
00023     with sm:
00024         sm_search = sm_rfid_explore.sm_search()
00025         smach.StateMachine.add(
00026             'RFID_SEARCH',  # outcomes: succeded, aborted, preempted
00027             sm_search,
00028             remapping = { 'tagid' : 'tagid',  # input
00029                           'explore_radius' : 'explore_radius',   # input
00030                           'explore_rfid_reads' : 'explore_rfid_reads' }, # output
00031             transitions={'succeeded':'BEST_VANTAGE'})
00032 
00033         sm_vantage = sm_next_best_vantage.sm_best_vantage()
00034         smach.StateMachine.add(
00035             'BEST_VANTAGE', # outcomes: succeeded, aborted, preempted
00036             sm_vantage,
00037             remapping = { 'tagid' : 'tagid', # input
00038                           'rfid_reads' : 'explore_rfid_reads' }, # input
00039             transitions = {'succeeded':'DELIVERY'})
00040 
00041         sm_delivery = sm_rfid_delivery.sm_delivery()
00042         smach.StateMachine.add(
00043             'DELIVERY', # outcomes: succeeded, aborted, preempted
00044             sm_delivery,
00045             remapping = { 'tagid' : 'tagid'}, #input
00046             transitions = { 'succeeded': 'succeeded' })
00047             
00048 
00049     # Execute SMACH plan
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 


rfid_demos
Author(s): Travis Deyle
autogenerated on Wed Nov 27 2013 11:50:51