Go to the documentation of this file.00001 import roslib; roslib.load_manifest('iri_wam_smach')
00002 import rospy
00003 import smach
00004 import smach_ros
00005
00006 from st_get_joints_from_pose import GetJointsFromPose
00007 from st_wam_move_in_joints import MoveWamInJoints
00008
00009 class SM_WAM_MoveFromPose():
00010 """
00011 State machine to move the WAM given a pose.
00012
00013 It is composed by two steps:
00014 1. Use inverse kinematics to convert pose to joints
00015 2. Call to the move action using the joints
00016
00017 @type move_service : str
00018 @param move_service : URI of move in joinst wam service
00019 @type ik_service : str
00020 @param ik_service : URI of inverse kinematic service
00021 @type pose_st : PoseStamped [input_key]
00022 @param pose_st : Pose to move the
00023 """
00024
00025 def __init__(self, move_service, ik_service = None):
00026 self.sm = smach.StateMachine(outcomes=['success','aborted','no_kinematic_solution'],
00027 input_keys=['pose_st'])
00028 self.ik_service = ik_service
00029 self.move_service = move_service
00030
00031 if (self.ik_service == None):
00032 rospy.logfatal("No IK service provided to SM_WAM_MoveFromPose()")
00033
00034 def build_sm(self):
00035 with self.sm:
00036 smach.StateMachine.add('POSE_TO_JOINTS', GetJointsFromPose(self.ik_service),
00037 transitions = {'success' : 'MOVE_IN_JOINTS',
00038 'empty' : 'success',
00039 'no_kinematic_solution' : 'no_kinematic_solution'},
00040 remapping = {'pose_st' : 'pose_st',
00041 'joints_to_position' : 'sm_joints'})
00042
00043 smach.StateMachine.add('MOVE_IN_JOINTS', MoveWamInJoints(self.move_service),
00044 transitions = {'success' : 'success',
00045 'fail' : 'aborted'},
00046 remapping = { 'joints_to_position' : 'sm_joints'})
00047
00048 return self.sm