summaryrefslogtreecommitdiff
path: root/digital/io/src/top.fsm
blob: 9c1e65099d66ebf19dde71624e41afc5f8228855 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# Top FSM.
# Some remarks on this FSM.
# Maybe we can make only one state for the all the GO_TO_*DISTRIBUTOR. It is
# more complicated, but it can be cleaner...
# We do not manage some cases like, we have not get any balls from any
# distributors.
top
  Top FSM that call others FSM

States:
 IDLE
  waiting for the beginning of the top FSM
 WAIT_JACK_IN
  waiting for the jack to be inserted into the bot
 WAIT_JACK_OUT
  waiting for the jack to be removed from the bot
 CONFIGURE_ASSERV
  configuring the asserv board
 MOVE_AWAY_FROM_START_BORDER
  move the bot away from the border of the start point to be able to turn
  freely
 GO_TO_SAMPLE_DISTRIBUTOR
  go to our distributor of samples (using the move FSM)
 GO_TO_OUR_ICE_DISTRIBUTOR
  go to our ice distributor (using the move FSM)
 GO_TO_ADVERSE_ICE_DISTRIBUTOR
  go to the adverse ice distributor (using the move FSM)
 GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR
  get samples from the samples distributor (using the get samples FSM)
 GET_ICE_FROM_OUR_ICE_DISTRIBUTOR
  get ice from our ice distributor (using the get samples FSM)
 GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR
  get ice from adverse ice distributor (using the get samples FSM)
 GO_TO_GUTTER
  go to the gutter (using the move FSM)
 DROP_OFF_BALLS_TO_GUTTER
  drop all the balls contained in the bot into the gutter (using the gutter
  FSM)
 MOVE_AWAY_FROM_GUTTER_BORDER
  move the bot away from the border of the gutter to be able to turn freely

Events:
 start
  initialize the FSM
 get_samples_fsm_finished
  when the get samples FSM returns
 move_fsm_finished
  when the move FSM returns
 gutter_fsm_finished
  when the gutter FSM returns
 jack_inserted_into_bot
  the jack is inserted into the bot
 jack_removed_from_bot
  the jack is removed from the bot
 settings_acknowledged
  the asserv board has acknowledged the settings sent

IDLE:
 start -> WAIT_JACK_IN
  wait for the jack to be inserted into the bot

WAIT_JACK_IN:
 jack_inserted_into_bot -> WAIT_JACK_OUT
  wait for the jack to be removed from the bot

WAIT_JACK_OUT:
 jack_removed_from_bot -> CONFIGURE_ASSERV
  the match start, start the chronometer
  we should also initialize all the subsystems of IO (get our color, ...)
  set the settings of the asserv board (especially the position)

CONFIGURE_ASSERV:
 settings_acknowledged -> MOVE_AWAY_FROM_START_BORDER
  move the bot away from the border to be able to turn freely

MOVE_AWAY_FROM_START_BORDER:
 move_fsm_finished -> GO_TO_SAMPLE_DISTRIBUTOR
  order the bot to move to our samples distributors with the move FSM

GO_TO_SAMPLE_DISTRIBUTOR:
 move_fsm_finished -> GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR
  we are now in front of our samples distributor, launch the get samples FSM

GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR:
 get_samples_fsm_finished -> GO_TO_OUR_ICE_DISTRIBUTOR
  we have finished to get our samples, let's go to our ice distributor with
  the move FSM

GO_TO_OUR_ICE_DISTRIBUTOR:
 move_fsm_finished -> GET_ICE_FROM_OUR_ICE_DISTRIBUTOR
  we are now in front of our ice distributor, launch the get samples FSM

GET_ICE_FROM_OUR_ICE_DISTRIBUTOR:
 get_samples_fsm_finished: full -> GO_TO_GUTTER
  we have finished to get ice from our distributor and we have no more space
  left, let's go the gutter with the move FSM
 get_samples_fsm_finished: not full -> GO_TO_ADVERSE_ICE_DISTRIBUTOR
  we have finished to get ice from our distributor and we have some space
  left, let's go the adverse ice distributor with the move FSM

GO_TO_GUTTER:
 move_fsm_finished -> DROP_OFF_BALLS_TO_GUTTER
  we are now at the gutter, let's drop all ours balls into it with the gutter
  FSM

DROP_OFF_BALLS_TO_GUTTER:
 gutter_fsm_finished -> MOVE_AWAY_FROM_GUTTER_BORDER
  we have finished to drop off all the balls, let's move away from the gutter
  to move freely

GO_TO_ADVERSE_ICE_DISTRIBUTOR:
 move_fsm_finished -> GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR
  we are now in front of the adverse ice distributor, launch the get samples
  FSM

GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR:
 get_samples_fsm_finished -> GO_TO_GUTTER
  we have finished to get ice. Even if we are not full, let's go to the gutter
  with the move FSM

MOVE_AWAY_FROM_GUTTER_BORDER:
 move_fsm_finished: first_loop -> GO_TO_SAMPLE_DISTRIBUTOR
  go to our sample ditributor to try the same strategy again
  reset internal data
 move_fsm_finished: second_loop -> GO_TO_ADVERSE_ICE_DISTRIBUTOR
  there is no more sample nor ice in our distributors, let's try the one of
  the opponent
  reset internal data