Go to the documentation of this file.00001
00002
00003 import roslib; roslib.load_manifest('zyonz_apps_base')
00004 import rospy
00005 import smach
00006 import smach_ros
00007 from pprint import pprint
00008 import copy
00009
00010
00011 import os, sys
00012 _root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
00013 sys.path.insert(0, _root_dir)
00014
00015
00016
00017 from smach import StateMachine, CBState, Iterator
00018 from smach_ros import ServiceState
00019 from sensor_msgs.msg import PointCloud2, JointState
00020 from geometry_msgs.msg import Transform, PoseStamped, Pose
00021 from zyonz_msgs.msg import chlorophyll_sampleAction, chlorophyll_sampleGoal, ProbingSteps
00022 from zyonz_msgs.srv import GetProbingStepsResponse
00023 from probing import ZyonzProbingSMFactory
00024
00025 class GetTestMsg(smach.State):
00026 def __init__(self):
00027 smach.State.__init__(self, outcomes=['ok'], output_keys=['msg'])
00028
00029 def execute(self, userdata):
00030 msg = GetProbingStepsResponse()
00031 step = ProbingSteps()
00032 step.probing.header.frame_id = 'yos'
00033 msg.steps.append(step)
00034 step = ProbingSteps()
00035 step.probing.header.frame_id = 'foo'
00036 msg.steps.append(step)
00037 userdata.msg = msg
00038 return 'ok'
00039
00040 def construct_main_sm():
00041
00042 factory = ZyonzProbingSMFactory()
00043 sm_probing = factory.build_sm()
00044
00045 sm = StateMachine(outcomes = ['succeeded','aborted'])
00046
00047 with sm:
00048 smach.StateMachine.add('GET_PROBING_MSG', GetTestMsg(),
00049 transitions = {'ok' : 'ACTION'},
00050 remapping = {'msg' : 'sm_probing_msg'})
00051
00052 smach.StateMachine.add('ACTION', sm_probing,
00053 transitions = {'succeeded' : 'succeeded'},
00054 remapping = {'probing_steps' : 'sm_probing_msg'})
00055
00056 return sm
00057
00058 def main():
00059 rospy.init_node("base_probing_sm")
00060 sm_main = construct_main_sm()
00061
00062
00063 sis = smach_ros.IntrospectionServer('zyonz_smach_base_probing', sm_main,
00064 '/zyonz_image_based_leaf_probing')
00065
00066 sis.start()
00067
00068 outcome = sm_main.execute()
00069
00070 rospy.spin()
00071 sis.stop()
00072
00073 if __name__ == "__main__":
00074 main()