example_get_list_of_stamped_poses_from_csv_file.py
Go to the documentation of this file.
00001 #!/usr/bin/python
00002 import roslib; roslib.load_manifest('iri_common_smach')
00003 import rospy
00004 import smach
00005 import smach_ros
00006 
00007 from iri_common_smach.st_get_list_of_stamped_poses_from_csv_file import GetListOfPoseStampedFromCsvFile
00008 
00009 import csv
00010 
00011 class PrintOutData(smach.State):
00012     """
00013     PRINTS OUT THE INPUT DATA 
00014    
00015     @type  data: anything that can be printed 
00016     @param data: variable to be printed 
00017 
00018     """
00019     def __init__(self):
00020         smach.State.__init__(self,
00021                              outcomes = ['success'],
00022                              input_keys = ['data'],
00023                              output_keys = [ ])
00024 
00025     def execute(self, userdata):
00026         rospy.loginfo('Executing PrintOutData')
00027         
00028         print userdata.data
00029         return 'success'
00030 
00031 
00032 
00033 def construct_main_sm():
00034     # MAIN STATE MACHINE
00035     sm = smach.StateMachine(outcomes = ['succeeded','aborted'])
00036 
00037     with sm:
00038             smach.StateMachine.add('GET_LIST_OF_POSE', GetListOfPoseStampedFromCsvFile('./list_of_stamped_poses.csv'),
00039                                    transitions = {'success' : 'PRINT_LIST_OF_POSES',
00040                                                   'fail'    : 'aborted',},
00041                                    remapping   = {'list_of_stpose' : 'list'})
00042 
00043             smach.StateMachine.add('PRINT_LIST_OF_POSES', PrintOutData(),
00044                                    transitions = {'success' : 'succeeded'},
00045                                    remapping   = {'data' : 'list'})
00046 
00047     return sm
00048 
00049 def main():
00050     rospy.init_node("get_list_of_stamped_poses_from_csv_file")
00051     sm_main = construct_main_sm()
00052 
00053     # Run state machine introspection server for smach viewer
00054     sis = smach_ros.IntrospectionServer('get_list_of_stamped_poses_from_csv_file', sm_main,
00055                                         '/get_list_of_stamped_poses_from_csv_file')
00056 
00057     sis.start()
00058 
00059     outcome = sm_main.execute()
00060 
00061     rospy.spin()
00062     sis.stop()
00063 
00064 if __name__ == "__main__":
00065     main()
00066 


iri_common_smach
Author(s): Jose Luis Rivero
autogenerated on Fri Dec 6 2013 21:05:19