]> rtime.felk.cvut.cz Git - eurobot/public.git/blob - src/robofsm/strategy_opp_oranges.cc
robomon: Implement motor simulation
[eurobot/public.git] / src / robofsm / strategy_opp_oranges.cc
1 #include "common-states.h"
2 #include "robot.h"
3 #include "eb2010misc.h"
4 #include <ul_log.h>
5
6 UL_LOG_CUST(ulogd_strategy_opp_oranges); /* Log domain name = ulogd + name of the file */
7
8 static FSM_STATE_DECL(pick_our_oranges);
9
10 FSM_STATE(start_opp_oranges)
11 {
12         switch (FSM_EVENT) {
13                 case EV_ENTRY:
14                         start_entry();
15 #ifdef COMPETITION
16                         ul_logmsg("waiting for start\n");
17                         FSM_TIMER(1000);
18                         break;
19 #endif
20                 case EV_START:
21                         start_go();
22                         FSM_TRANSITION(pick_our_oranges);
23                         break;
24                 case EV_TIMER:
25                         FSM_TIMER(1000);
26                         start_timer();
27                         break;
28                 case EV_EXIT:
29                         start_exit();
30                         break;
31                 case EV_SWITCH_STRATEGY:
32                         FSM_TRANSITION(start_six_oranges);
33                         break;
34                 default:;
35         }
36 }
37
38
39 #undef FSM_STATE_VISIBILITY
40 #define FSM_STATE_VISIBILITY static
41
42 FSM_STATE_DECL(unload_oranges);
43 FSM_STATE_DECL(pick_opp_oranges);
44 FSM_STATE_DECL(opp_corns);
45
46 FSM_STATE(pick_our_oranges)
47 {
48         switch (FSM_EVENT) {
49         case EV_ENTRY:  SUBFSM_TRANSITION(approach_the_slope, new slope_approach_style(MINE, NEAR_PLAYGROUND_BOUNDARY)); break;
50         case EV_RETURN: FSM_TRANSITION(unload_oranges); break;
51         default: break;
52         }
53 }
54
55 FSM_STATE(unload_oranges)
56 {
57         switch (FSM_EVENT) {
58         case EV_ENTRY:  SUBFSM_TRANSITION(to_cntainer_and_unld, NULL); break;
59         /* FIXME: do something more meaningfull the next time */
60         case EV_RETURN: FSM_TRANSITION(pick_opp_oranges); break;
61         default: break;
62         }
63 }
64
65 FSM_STATE(pick_opp_oranges)
66 {
67         switch (FSM_EVENT) {
68         case EV_ENTRY:  SUBFSM_TRANSITION(approach_the_slope, new slope_approach_style(OPPONENTS, NEAR_PLAYGROUND_BOUNDARY)); break;
69         case EV_RETURN: FSM_TRANSITION(unload_oranges); break;
70         default: break;
71         }
72 }
73
74 FSM_STATE(opp_corns)
75 {
76         switch (FSM_EVENT) {
77         case EV_ENTRY:  SUBFSM_TRANSITION(approach_next_corn, NULL); break;
78         case EV_RETURN: FSM_TRANSITION(opp_corns); break;
79         default: break;
80         }
81 }