Go to the documentation of this file.00001 #include "Wandering.h"
00002
00003 FSM(Wandering){
00004 FSM_STATES
00005 {
00006 TurnRandom,
00007 TurnLeft,
00008 TurnRight,
00009 Drive,
00010 Pause,
00011 DriveBackward
00012 }
00013 FSM_START(TurnRandom);
00014 FSM_BGN
00015 {
00016 FSM_STATE(TurnRandom)
00017 {
00018 FSM_CALL_TASK(TurnRandom)
00019 FSM_TRANSITIONS
00020 {
00021 FSM_ON_EVENT("/PAUSE", FSM_NEXT(Pause))
00022 FSM_ON_EVENT("/TIMEOUT_TURN", FSM_NEXT(Drive))
00023 FSM_ON_EVENT("/LEFT_OBSTACLE", FSM_NEXT(Drive))
00024 FSM_ON_EVENT("/RIGHT_OBSTACLE", FSM_NEXT(Drive))
00025 }
00026 }
00027 FSM_STATE(TurnLeft)
00028 {
00029 FSM_CALL_TASK(TurnLeft)
00030 FSM_TRANSITIONS
00031 {
00032 FSM_ON_EVENT("/PAUSE", FSM_NEXT(Pause))
00033 FSM_ON_EVENT("/TIMEOUT_TURN", FSM_NEXT(Drive))
00034 FSM_ON_EVENT("/LEFT_OBSTACLE", FSM_NEXT(Drive))
00035 }
00036 }
00037 FSM_STATE(TurnRight)
00038 {
00039 FSM_CALL_TASK(TurnRight)
00040 FSM_TRANSITIONS
00041 {
00042 FSM_ON_EVENT("/PAUSE", FSM_NEXT(Pause))
00043 FSM_ON_EVENT("/TIMEOUT_TURN", FSM_NEXT(Drive))
00044 FSM_ON_EVENT("/RIGHT_OBSTACLE", FSM_NEXT(Drive))
00045 }
00046 }
00047 FSM_STATE(Drive)
00048 {
00049 FSM_CALL_TASK(Drive)
00050
00051 FSM_TRANSITIONS
00052 {
00053 FSM_ON_EVENT("/PAUSE", FSM_NEXT(Pause))
00054 FSM_ON_EVENT("/FRONT_AND_RIGHT_OBSTACLE", FSM_NEXT(DriveBackward))
00055 FSM_ON_EVENT("/FRONT_AND_LEFT_OBSTACLE", FSM_NEXT(DriveBackward))
00056 FSM_ON_EVENT("/RIGHT_OBSTACLE", FSM_NEXT(TurnLeft))
00057 FSM_ON_EVENT("/LEFT_OBSTACLE", FSM_NEXT(TurnRight))
00058 FSM_ON_EVENT("/FRONT_OBSTACLE", FSM_NEXT(TurnRandom))
00059 FSM_ON_EVENT("/TIMEOUT_DRIVE", FSM_NEXT(TurnRandom))
00060 }
00061 }
00062 FSM_STATE(DriveBackward)
00063 {
00064 FSM_CALL_TASK(DriveBackward)
00065
00066 FSM_TRANSITIONS
00067 {
00068 FSM_ON_EVENT("/TIMEOUT_BACKWARD", FSM_NEXT(TurnRandom))
00069 FSM_ON_EVENT("/PAUSE", FSM_NEXT(Pause))
00070 }
00071 }
00072 FSM_STATE(Pause)
00073 {
00074 FSM_CALL_TASK(StopRobot)
00075
00076 FSM_TRANSITIONS
00077 {
00078 FSM_ON_EVENT("/RESUME", FSM_NEXT(TurnRandom))
00079 }
00080 }
00081 }
00082 FSM_END
00083 }