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 from trajectory import *
00026 from trajectory import ZYONZGetArcTrajectory
00027
00028
00029 def construct_main_sm():
00030
00031 sm = StateMachine(outcomes = ['succeeded','aborted'])
00032
00033 user_position = [ 3.0, 3.0, 3.0 ]
00034 user_quaternion = quaternion_from_euler(math.pi/8, 0, 0, 'rxyz')
00035
00036 sm.userdata.pose_st = PoseStamped();
00037 sm.userdata.pose_st.header.frame_id = '/wam_link0';
00038 sm.userdata.pose_st.pose.position.x = user_position[0]
00039 sm.userdata.pose_st.pose.position.y = user_position[1]
00040 sm.userdata.pose_st.pose.position.z = user_position[2]
00041 sm.userdata.pose_st.pose.orientation.x = user_quaternion[0]
00042 sm.userdata.pose_st.pose.orientation.y = user_quaternion[1]
00043 sm.userdata.pose_st.pose.orientation.z = user_quaternion[2]
00044 sm.userdata.pose_st.pose.orientation.w = user_quaternion[3]
00045 sm.userdata.distance = 0.3
00046 sm.userdata.num_views = 10
00047
00048
00049 with sm:
00050 smach.StateMachine.add('GET_TRAJECTORY', ZYONZGetArcTrajectory(),
00051 transitions = {'success' : 'succeeded',
00052 'fail' : 'aborted'},
00053 remapping = {'pose_st' : 'pose_st',
00054 'distance' : 'distance',
00055 'num_views' : 'num_views',
00056 'list_pose' : 'list_pose'})
00057
00058 return sm
00059
00060 def main():
00061 rospy.init_node("base_probing_sm")
00062 sm_main = construct_main_sm()
00063
00064
00065 sis = smach_ros.IntrospectionServer('zyonz_smach_base_probing', sm_main,
00066 '/zyonz_image_based_leaf_probing')
00067
00068 sis.start()
00069
00070 outcome = sm_main.execute()
00071
00072 rospy.spin()
00073 sis.stop()
00074
00075 if __name__ == "__main__":
00076 main()