summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/getsamples.fsm
blob: 0628448b47456725b7f5847fdbfa0bfb56f02050 (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
# Get samples FSM
# A general remark on this FSM: it is not its responsibility to put the bot in
# front of the distributor, it the responsibility of the top FSM using the
# move FSM.
# For example, the top FSM will order the bot to move in front of the
# distributor using the move FSM. Then, when it is arrived, it will the get
# sample FSM that will ensure we well placed (in term of angle for example).
get_samples
  Get samples from the distributor

States:
 IDLE
  waiting for the beginning of the get samples FSM
 FACE_DISTRIBUTOR
  face the distributor
 OPEN_INPUT_HOLE
  move the arm to let the samples enter into the bot by the input hole
 APPROACH_DISTRIBUTOR
  make the bot move forward in order to be in contact with the distributor
 TAKE_SAMPLES
  take one or more samples
 MOVE_AWAY_FROM_DISTRIBUTOR
  move the bot away from the distributor by going backward
 CLOSE_INPUT_HOLE
  put the arm back in front of the input hole to prevent sample to enter
 MOVE_BACKWARD_FROM_DISTRIBUTOR
  move a little bit backward from the distributor

Events:
 start
  initialize the FSM
# For the moment, this event is currently not managed.
# TODO: manage it
 bot_move_failed
  the bot movement failed (blocked by something for example)
 bot_move_succeed
  the bot has finished to moved and arrived at the desired position
 arm_move_succeed
  the arm has reached the desired position
 arm_pass_noted_position
  the arm has just passed the 'noted' position
 wait_finished
  we have wait the desired time

IDLE:
 start -> FACE_DISTRIBUTOR
  do a goto angle to make the bot facing the distributor

FACE_DISTRIBUTOR:
 bot_move_succeed -> OPEN_INPUT_HOLE
  move the arm to open the input hole

OPEN_INPUT_HOLE:
 arm_move_succeed -> APPROACH_DISTRIBUTOR
  start approaching the distributor now

APPROACH_DISTRIBUTOR:
 bot_move_succeed -> MOVE_BACKWARD_FROM_DISTRIBUTOR
  move a little bit backward from the distributor

MOVE_BACKWARD_FROM_DISTRIBUTOR:
 bot_move_succeed -> TAKE_SAMPLES
  start taking some samples

TAKE_SAMPLES:
 arm_pass_noted_position: more -> .
  prepare the classification of the taken sample
  take a new one
 arm_pass_noted_position: no_more -> MOVE_AWAY_FROM_DISTRIBUTOR
  go backward

MOVE_AWAY_FROM_DISTRIBUTOR:
 bot_move_succeed -> CLOSE_INPUT_HOLE
  close input hole
  setup a close timeout

CLOSE_INPUT_HOLE:
 arm_move_succeed -> IDLE
  tell the top FSM we have finished
 wait_finished -> IDLE
  timed out, give up