summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorJérémy Dufour2008-04-28 13:34:25 +0200
committerJérémy Dufour2008-04-28 13:34:25 +0200
commit58f4889ac44c051c8db43f1f0a2f6a857e3be08a (patch)
tree66f4e670e78886cbbdc59341124d209b3f518aef /digital
parent5ef11e951e6b056aee44d64d5c1b9451b0753997 (diff)
* digital/io/src
- top FSM now directly go to the ice distributor after two "loops" (because there are no more sample/ice in the other distributors).
Diffstat (limited to 'digital')
-rw-r--r--digital/io/src/top.fsm6
-rw-r--r--digital/io/src/top_cb.c32
2 files changed, 30 insertions, 8 deletions
diff --git a/digital/io/src/top.fsm b/digital/io/src/top.fsm
index 5a8e78b1..9c1e6509 100644
--- a/digital/io/src/top.fsm
+++ b/digital/io/src/top.fsm
@@ -119,6 +119,10 @@ GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR:
with the move FSM
MOVE_AWAY_FROM_GUTTER_BORDER:
- move_fsm_finished -> GO_TO_SAMPLE_DISTRIBUTOR
+ 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
diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c
index 2e5fa5c5..55b1077f 100644
--- a/digital/io/src/top_cb.c
+++ b/digital/io/src/top_cb.c
@@ -129,9 +129,11 @@ top__GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR__get_samples_fsm_finished (void)
fsm_branch_t
top__GO_TO_ADVERSE_ICE_DISTRIBUTOR__move_fsm_finished (void)
{
- /* Start the get samples FSM with the correct angle */
- /* TODO: where to put the ice?! */
- getsamples_start (PG_DISTRIBUTOR_ICE_ADVERSE_A, 1);
+ /* Start the get samples FSM with the correct angle to get only two
+ * samples. The problem is this should depend on the time we have until
+ * the end of match */
+ uint8_t bitfield = _BV (out_right_box) | _BV (middle_right_box);
+ getsamples_start (PG_DISTRIBUTOR_ICE_ADVERSE_A, bitfield);
return top_next (GO_TO_ADVERSE_ICE_DISTRIBUTOR, move_fsm_finished);
}
@@ -241,18 +243,34 @@ top__GET_ICE_FROM_OUR_ICE_DISTRIBUTOR__get_samples_fsm_finished (void)
/*
* MOVE_AWAY_FROM_GUTTER_BORDER =move_fsm_finished=>
- * => GO_TO_SAMPLE_DISTRIBUTOR
+ * first_loop => GO_TO_SAMPLE_DISTRIBUTOR
* go to our sample ditributor to try the same strategy again
* reset internal data
+ * 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
*/
fsm_branch_t
top__MOVE_AWAY_FROM_GUTTER_BORDER__move_fsm_finished (void)
{
/* We have finished a loop */
top_fsm_loop_count_++;
- /* Start the move FSM */
- move_start (PG_DISTRIBUTOR_SAMPLE_OUR_X, PG_DISTRIBUTOR_SAMPLE_OUR_Y);
- return top_next (MOVE_AWAY_FROM_GUTTER_BORDER, move_fsm_finished);
+ if (top_fsm_loop_count_ < 2)
+ {
+ /* Two first loops, normal behaviour (our sample distributor, them
+ * ice) */
+ /* Start the move FSM */
+ move_start (PG_DISTRIBUTOR_SAMPLE_OUR_X, PG_DISTRIBUTOR_SAMPLE_OUR_Y);
+ return top_next_branch (MOVE_AWAY_FROM_GUTTER_BORDER, move_fsm_finished, first_loop);
+ }
+ else
+ {
+ /* Second loops, ice only */
+ /* Start the move FSM */
+ move_start (PG_DISTRIBUTOR_ICE_ADVERSE_X, PG_DISTRIBUTOR_ICE_ADVERSE_Y);
+ return top_next_branch (MOVE_AWAY_FROM_GUTTER_BORDER, move_fsm_finished, second_loop);
+ }
}
/*