summaryrefslogtreecommitdiff
path: root/digital/io/src/init.fsm
blob: f780ba459eba138d82edcaeb7470280e83a11527 (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
# init FSM
# This FSM is used to place the bot at a "start position" for a match. It is
# more precise than a human hand and reset the asserv board to the start
# position.
# Some remarks:
#  - for security reason, we need to insert the jack then removed it, then
#  insert it back. Why? Because it can already be inserted.
#  - other FSM can do a similar thing by using the first jack out to
#  initialize.
init
  place the bot in the start position for a match.

States:
 *INIT_IDLE
  waiting for the beginning of the top FSM.
 INIT_WAIT_FIRST_JACK_IN
  wait for the jack to be inserted into the bot for the first time.
 INIT_WAIT_FIRST_JACK_OUT
  wait the jack to be removed from the bot for the first time.
 INIT_WAIT_SECOND_JACK_IN
  wait for the jack to be inserted into the bot for the second time.
 INIT_WAIT_FOR_HANDS_OUT[timeout=225]
  just wait for operator hands to be removed from the jack.
 INIT_GO_TO_THE_WALL
  go to the wall for the first time.
 INIT_GO_AWAY_FROM_THE_WALL
  reset the Y position of the bot.
  reset the angular position of the bot.
  go backward from the wall for a specific distance.
 INIT_FACE_OTHER_WALL
  make the bot face the other wall.
 INIT_WAIT_AFTER_ROTATION [timeout=100]
  make sure rotation is really finished before continuing.
 INIT_GO_TO_THE_WALL_AGAIN
  go to the wall for the second time.
 INIT_GO_AWAY_FROM_THE_WALL_AGAIN
  reset the X position of the bot.
  go backward from the wall for a specific distance.
 INIT_GO_TO_START_POSITION
  go to the start position.
 INIT_WAIT_SECOND_JACK_OUT
  wait the jack to be removed from the bot for the second time.

Events:
 jack_inserted_into_bot
  the jack is inserted into the bot.
 jack_removed_from_bot
  the jack is removed from the bot.

INIT_IDLE:
 start -> INIT_WAIT_FIRST_JACK_IN
  do nothing.

INIT_WAIT_FIRST_JACK_IN:
 jack_inserted_into_bot -> INIT_WAIT_FIRST_JACK_OUT
  do nothing.

INIT_WAIT_FIRST_JACK_OUT:
 jack_removed_from_bot -> INIT_WAIT_SECOND_JACK_IN
  start trace module.
  get and store the color of the bot.

INIT_WAIT_SECOND_JACK_IN:
 jack_inserted_into_bot -> INIT_WAIT_FOR_HANDS_OUT
  do nothing.

INIT_WAIT_FOR_HANDS_OUT:
 state_timeout -> INIT_GO_TO_THE_WALL
  fuck the wall in front.

INIT_GO_TO_THE_WALL:
 bot_move_succeed -> INIT_GO_AWAY_FROM_THE_WALL
  reset the Y position of the bot.
  reset the angular position of the bot.
  move away from the wall (linear move).

INIT_GO_AWAY_FROM_THE_WALL:
 bot_move_succeed -> INIT_FACE_OTHER_WALL
  turn to face the other wall.

INIT_FACE_OTHER_WALL:
 bot_move_succeed -> INIT_WAIT_AFTER_ROTATION
  nothing to do.

INIT_WAIT_AFTER_ROTATION:
 state_timeout -> INIT_GO_TO_THE_WALL_AGAIN
  fuck the wall in front.

INIT_GO_TO_THE_WALL_AGAIN:
 bot_move_succeed -> INIT_GO_AWAY_FROM_THE_WALL_AGAIN
  reset the X position of the bot.
  move away from the wall (linear move).

INIT_GO_AWAY_FROM_THE_WALL_AGAIN:
 bot_move_succeed -> INIT_GO_TO_START_POSITION
  go to the start position with a go to movement.

INIT_GO_TO_START_POSITION:
 bot_move_succeed -> INIT_WAIT_SECOND_JACK_OUT
  nothing to do, the bot is at the start position.

INIT_WAIT_SECOND_JACK_OUT:
 jack_removed_from_bot -> INIT_IDLE
  tell other FSM the match begins.
  start the chrono.