summaryrefslogtreecommitdiff
path: root/digital/io/src/cylinder.fsm
blob: 2fcf06c4b6c33b9b1bd65000f834aa12af64b59c (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
# Cylinder FSM
# Control the puck's entrance
cylinder

States:
 IDLE
  waiting for init
 WAIT_FOR_JACK_IN
  waiting for jack
 INIT
  initializing cylinder to a good position (open)
 WAIT_A_PUCK
  waiting a puck enter in cylinder
 TURN_PLUS_3
  turn cylinder to 3 positions after
 WAIT_FOR_BRIDGE_READY
  waiting for the bridge is ready
 TURN_PLUS_1
  turn cylinder to 1 position after
 TURN_PLUS_1_LOOP
  turn cylinder to 1 position after
 TURN_MINUS_1
  turn cylinder to 1 position before to prevent new puck enter in the robot
 WAIT_FOR_PUCKS_RELEASE
  waiting for pucks release from the lift
 TURN_PLUS_1_AGAIN
  open the puck entrance

Events:
 start
  start event
 jack_inserted_into_bot
  the init signal
 new_puck
  there is a puck in position 1
 move_done
  cylinder move finished
 bridge_ready
  bridge ready to get a new puck
 bot_empty
  all pucks released
 state_timeout

IDLE:
 start -> WAIT_FOR_JACK_IN
  we wait the jack before moving anything

WAIT_FOR_JACK_IN:
 jack_inserted_into_bot -> INIT
  we init the cylinder position

INIT:
 move_done -> WAIT_A_PUCK
  the cylinder is ready to get pucks

WAIT_A_PUCK:
 new_puck -> TURN_PLUS_3
  turn cylinder 3 position after

TURN_PLUS_3:
 move_done -> WAIT_FOR_BRIDGE_READY
  bridge full, waiting for Bison Fute's clearance

WAIT_FOR_BRIDGE_READY:
 bridge_ready: no_puck_bo -> TURN_PLUS_1
  bridge clear, and no other puck on cylinder
 bridge_ready: puck_bo -> TURN_PLUS_1_LOOP
  bridge clear, an another puck is in the cylinder

TURN_PLUS_1_LOOP:
 move_done: ok_for_other_puck -> WAIT_FOR_BRIDGE_READY
  we test bo again
 move_done: not_ok_for_other_puck -> WAIT_FOR_PUCKS_RELEASE
  bot full, eject hypothetical puck and close the cylinder

TURN_PLUS_1:
 move_done: ok_for_other_puck -> WAIT_A_PUCK
  cylinder empty and ready for new puck
 move_done: not_ok_for_other_puck -> TURN_MINUS_1
  bot full, closing cylinder

TURN_MINUS_1:
 move_done -> WAIT_FOR_PUCKS_RELEASE
  cylinder close, you shall not pass (but try again later)

WAIT_FOR_PUCKS_RELEASE:
 bot_empty -> TURN_PLUS_1_AGAIN

TURN_PLUS_1_AGAIN:
 move_done -> WAIT_A_PUCK
  cylinder ready