Go to the documentation of this file.00001
00002 #include <iostream>
00003
00004 #include <ros/ros.h>
00005
00006 #include <decision_making/SynchCout.h>
00007 #include <decision_making/BT.h>
00008 #include <decision_making/FSM.h>
00009 #include <decision_making/ROSTask.h>
00010 #include <decision_making/DecisionMaking.h>
00011
00012 using namespace std;
00013 using namespace decision_making;
00014
00015 bool MissionLoaded;
00016 FSM(MissionActive)
00017 {
00018 FSM_STATES
00019 {
00020 MissionSpooling,
00021 MissionPaused,
00022 MissionAborted,
00023 MissionFinished,
00024 }
00025 FSM_START(MissionSpooling);
00026 FSM_BGN
00027 {
00028 FSM_STATE(MissionSpooling)
00029 {
00030 FSM_TRANSITIONS
00031 {
00032 FSM_ON_EVENT("/CompleteMission", FSM_NEXT(MissionFinished));
00033 FSM_ON_EVENT("/AbortMission", FSM_NEXT(MissionAborted));
00034 FSM_ON_EVENT("/PauseMission", FSM_NEXT(MissionPaused));
00035 }
00036 }
00037 FSM_STATE(MissionPaused)
00038 {
00039 FSM_TRANSITIONS
00040 {
00041 FSM_ON_EVENT("/CompleteMission", FSM_NEXT(MissionFinished));
00042 FSM_ON_EVENT("/AbortMission", FSM_NEXT(MissionAborted));
00043 FSM_ON_EVENT("/ResumeMission", FSM_NEXT(MissionSpooling));
00044 }
00045 }
00046 FSM_STATE(MissionAborted)
00047 {
00048 FSM_TRANSITIONS
00049 {
00050 FSM_ON_EVENT("/StartMission", FSM_NEXT(MissionSpooling));
00051 }
00052 }
00053 FSM_STATE(MissionFinished)
00054 {
00055 FSM_TRANSITIONS
00056 {
00057 FSM_ON_EVENT("/StartMission", FSM_NEXT(MissionSpooling));
00058 }
00059 }
00060 }
00061 FSM_END
00062 }
00063
00064 FSM(Mission_ON)
00065 {
00066 FSM_STATES
00067 {
00068 NoMissionLoaded,
00069 MissionPending,
00070 MissionActive
00071 }
00072 FSM_START(NoMissionLoaded);
00073 FSM_BGN
00074 {
00075 FSM_STATE(NoMissionLoaded)
00076 {
00077 FSM_TRANSITIONS
00078 {
00079 FSM_ON_EVENT("/MissionLoaded", FSM_NEXT(MissionPending));
00080 }
00081 }
00082 FSM_STATE(MissionPending)
00083 {
00084 FSM_TRANSITIONS
00085 {
00086
00087 FSM_ON_EVENT("/DeleteMission", FSM_NEXT(NoMissionLoaded));
00088 FSM_ON_EVENT("/ClearMissionBuffer", FSM_NEXT(NoMissionLoaded));
00089 FSM_ON_EVENT("/not_MissionLoaded", FSM_NEXT(NoMissionLoaded));
00090
00091 FSM_ON_EVENT("/StartMission", FSM_NEXT(MissionActive));
00092 }
00093 }
00094 FSM_STATE(MissionActive)
00095 {
00096 FSM_CALL_FSM(MissionActive)
00097 FSM_TRANSITIONS
00098 {
00099
00100 FSM_ON_EVENT("/DeleteMission", FSM_NEXT(NoMissionLoaded));
00101 FSM_ON_EVENT("/Stendby", FSM_NEXT(NoMissionLoaded));
00102 FSM_ON_EVENT("/ClearMissionBuffer", FSM_NEXT(NoMissionLoaded));
00103 FSM_ON_EVENT("not_MissionLoaded", FSM_NEXT(NoMissionLoaded));
00104 }
00105 }
00106
00107 }
00108 FSM_END
00109 }
00110
00111 FSM(Mission)
00112 {
00113 FSM_STATES
00114 {
00115 OFF,
00116 ON
00117 }
00118 FSM_START(OFF);
00119 FSM_BGN
00120 {
00121 FSM_STATE(OFF)
00122 {
00123 FSM_TRANSITIONS
00124 {
00125 FSM_ON_EVENT("/SystemActivation", FSM_NEXT(ON));
00126 }
00127 }
00128 FSM_STATE(ON)
00129 {
00130 FSM_CALL_FSM(Mission_ON)
00131 FSM_TRANSITIONS
00132 {
00133 FSM_ON_EVENT("/PowerOff", FSM_NEXT(OFF));
00134 }
00135 }
00136
00137 }
00138 FSM_END
00139 }
00140
00141 int main(int argc, char** argv){
00142
00143 ros::init(argc, argv, "fsm_mission");
00144 ros_decision_making_init(argc, argv);
00145
00146 ros::AsyncSpinner spinner(2);
00147 spinner.start();
00148
00149 ROS_INFO("Starting mission...");
00150 FsmMission(NULL, new RosEventQueue());
00151
00152 spinner.stop();
00153
00154 return 0;
00155 }
00156
00157