Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <labust_mission/labustMission.hpp>
00044 #include <labust_mission/primitiveManager.hpp>
00045 #include <labust_mission/missionExecution.hpp>
00046
00047 #include <tinyxml2.h>
00048
00049 #include <decision_making/SynchCout.h>
00050 #include <decision_making/BT.h>
00051 #include <decision_making/FSM.h>
00052 #include <decision_making/ROSTask.h>
00053 #include <decision_making/DecisionMaking.h>
00054
00055 using namespace decision_making;
00056 using namespace tinyxml2;
00057
00058
00059
00060
00061
00062 EventQueue* mainEventQueue;
00063 labust::mission::MissionExecution* ME = NULL;
00064
00065 struct MainEventQueue{
00066 MainEventQueue(){ mainEventQueue = new RosEventQueue(); }
00067 ~MainEventQueue(){ delete mainEventQueue; }
00068 };
00069
00070
00071
00072
00073
00074
00075 FSM(MissionSelect)
00076 {
00077 FSM_STATES
00078 {
00079
00080 Wait_state,
00081 Dispatcher_state,
00082 placeholder_state,
00083
00084 go2point_FA_state,
00085 dynamic_positioning_state,
00086 course_keeping_state,
00087
00088
00089
00090 }
00091 FSM_START(Wait_state);
00092 FSM_BGN
00093 {
00094 FSM_STATE(Wait_state)
00095 {
00096 ROS_ERROR("Mission waiting...");
00097
00098 FSM_ON_STATE_EXIT_BGN{
00099
00100 ROS_ERROR("Starting mission...");
00102
00103
00105 ME->oldPosition.north = ME->state.position.north;
00106 ME->oldPosition.east = ME->state.position.east;
00107 ME->oldPosition.depth = ME->state.position.depth;
00108
00109 }FSM_ON_STATE_EXIT_END
00110
00111 FSM_TRANSITIONS
00112 {
00113 FSM_ON_EVENT("/START_DISPATCHER", FSM_NEXT(Dispatcher_state));
00114 }
00115 }
00116 FSM_STATE(Dispatcher_state)
00117 {
00118 ROS_ERROR("Dispatcher active");
00119 ME->missionActive = true;
00120 ME->requestPrimitive();
00121
00122 FSM_TRANSITIONS
00123 {
00124 FSM_ON_EVENT("/STOP", FSM_NEXT(Wait_state));
00125 FSM_ON_EVENT("/PLACEHOLDER", FSM_NEXT(placeholder_state));
00126 FSM_ON_EVENT("/GO2POINT_FA", FSM_NEXT(go2point_FA_state));
00127 FSM_ON_EVENT("/DYNAMIC_POSITIONING", FSM_NEXT(dynamic_positioning_state));
00128
00129
00130
00131
00132 }
00133 }
00134 FSM_STATE(placeholder_state)
00135 {
00136 ROS_ERROR("Placeholder active");
00137
00138 FSM_TRANSITIONS
00139 {
00140 FSM_ON_EVENT("/STOP", FSM_NEXT(Wait_state));
00141 FSM_ON_EVENT("/PRIMITIVE_FINISHED", FSM_NEXT(Dispatcher_state));
00142 FSM_ON_EVENT("/TIMEOUT", FSM_NEXT(Dispatcher_state));
00143 }
00144 }
00145 FSM_STATE(go2point_FA_state)
00146 {
00147 ROS_ERROR("go2point_FA primitive active");
00148
00149 ME->go2point_FA_state();
00150
00151 FSM_ON_STATE_EXIT_BGN{
00152
00153 ME->CM.go2point_FA(false,0,0,0,0,0,0);
00154
00155 }FSM_ON_STATE_EXIT_END
00156
00157 FSM_TRANSITIONS
00158 {
00159 FSM_ON_EVENT("/STOP", FSM_NEXT(Wait_state));
00160 FSM_ON_EVENT("/PRIMITIVE_FINISHED", FSM_NEXT(Dispatcher_state));
00161 FSM_ON_EVENT("/TIMEOUT", FSM_NEXT(Dispatcher_state));
00162
00163 }
00164 }
00165 FSM_STATE(dynamic_positioning_state)
00166 {
00167 ROS_ERROR("dynamic_positioning primitive active");
00168
00169 ME->dynamic_postitioning_state();
00170
00171 FSM_ON_STATE_EXIT_BGN{
00172
00173 ME->CM.dynamic_positioning(false,0,0,0);
00174
00175 }FSM_ON_STATE_EXIT_END
00176
00177 FSM_TRANSITIONS
00178 {
00179 FSM_ON_EVENT("/STOP", FSM_NEXT(Wait_state));
00180 FSM_ON_EVENT("/PRIMITIVE_FINISHED", FSM_NEXT(Dispatcher_state));
00181 FSM_ON_EVENT("/TIMEOUT", FSM_NEXT(Dispatcher_state));
00182 }
00183 }
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267 }
00268 FSM_END
00269 }
00270
00271
00272
00273
00274
00275
00276 int main(int argc, char** argv){
00277
00278 ros::init(argc, argv, "ControllerFSM");
00279 ros_decision_making_init(argc, argv);
00280 ros::NodeHandle nh;
00281
00282
00283 labust::mission::MissionExecution MissExec(nh);
00284 ME = &MissExec;
00285
00286
00287 MainEventQueue meq;
00288
00289
00290 ros::AsyncSpinner spinner(2);
00291 spinner.start();
00292 FsmMissionSelect(NULL, mainEventQueue);
00293 spinner.stop();
00294
00295 return 0;
00296 }
00297
00298
00299