def main():
    rospy.init_node('smach_usecase_step_04')
    polygon_big = turtle_actionlib.msg.ShapeGoal(edges=11, radius=4.0)
    polygon_small = turtle_actionlib.msg.ShapeGoal(edges=6, radius=0.5)
    sm0 = StateMachine(outcomes=['succeeded', 'aborted', 'preempted'])
    with sm0:
        StateMachine.add('RESET', ServiceState('reset', std_srvs.srv.Empty), {'succeeded': 'SPAWN'})
        StateMachine.add('SPAWN', ServiceState('spawn', turtlesim.srv.Spawn, request=turtlesim.srv.SpawnRequest(0.0, 0.0, 0.0, 'turtle2')), {'succeeded': 'TELEPORT1'})
        StateMachine.add('TELEPORT1', ServiceState('turtle1/teleport_absolute', turtlesim.srv.TeleportAbsolute, request=turtlesim.srv.TeleportAbsoluteRequest(5.0, 1.0, 0.0)), {'succeeded': 'TELEPORT2'})
        StateMachine.add('TELEPORT2', ServiceState('turtle2/teleport_absolute', turtlesim.srv.TeleportAbsolute, request=turtlesim.srv.TeleportAbsoluteRequest(9.0, 5.0, 0.0)), {'succeeded': 'BIG'})
        StateMachine.add('BIG', SimpleActionState('turtle_shape1', turtle_actionlib.msg.ShapeAction, goal=polygon_big), {'succeeded': 'SMALL'})
        StateMachine.add('SMALL', SimpleActionState('turtle_shape2', turtle_actionlib.msg.ShapeAction, goal=polygon_small))
    sis = IntrospectionServer('smach_usecase_01', sm0, '/USE_CASE')
    sis.start()
    smach.set_preempt_handler(sm0)
    smach_thread = threading.Thread(target=sm0.execute)
    smach_thread.start()
    rospy.spin()
def main():
    rospy.init_node('smach_usecase_step_04')
    polygon_big = turtle_actionlib.msg.ShapeGoal(edges=11, radius=4.0)
    polygon_small = turtle_actionlib.msg.ShapeGoal(edges=6, radius=0.5)
    sm0 = StateMachine(outcomes=['succeeded', 'aborted', 'preempted'])
    with sm0:
        StateMachine.add('RESET', ServiceState('reset', std_srvs.srv.Empty), {'succeeded': 'SPAWN'})
        StateMachine.add('SPAWN', ServiceState('spawn', turtlesim.srv.Spawn, request=turtlesim.srv.SpawnRequest(0.0, 0.0, 0.0, 'turtle2')), {'succeeded': 'TELEPORT1'})
        StateMachine.add('TELEPORT1', ServiceState('turtle1/teleport_absolute', turtlesim.srv.TeleportAbsolute, request=turtlesim.srv.TeleportAbsoluteRequest(5.0, 1.0, 0.0)), {'succeeded': 'TELEPORT2'})
        StateMachine.add('TELEPORT2', ServiceState('turtle2/teleport_absolute', turtlesim.srv.TeleportAbsolute, request=turtlesim.srv.TeleportAbsoluteRequest(9.0, 5.0, 0.0)), {'succeeded': 'BIG'})
        StateMachine.add('BIG', SimpleActionState('turtle_shape1', turtle_actionlib.msg.ShapeAction, goal=polygon_big), {'succeeded': 'SMALL'})
        StateMachine.add('SMALL', SimpleActionState('turtle_shape2', turtle_actionlib.msg.ShapeAction, goal=polygon_small))
    sis = IntrospectionServer('smach_usecase_01', sm0, '/USE_CASE')
    sis.start()
    smach.set_preempt_handler(sm0)
    smach_thread = threading.Thread(target=sm0.execute)
    smach_thread.start()
    rospy.spin()