summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorJérémy Dufour2009-05-18 13:03:53 +0200
committerJérémy Dufour2009-05-18 13:03:53 +0200
commit734263aa90fa150e1bcfa6bc70d140a35fccdc39 (patch)
tree54ad0c62255df27e217a89e55ba39ab6420f5778 /digital
parentdf86960a8825149382e162e04ef37667f0ebdd37 (diff)
* digital/io/src:
- clean top FSM.
Diffstat (limited to 'digital')
-rw-r--r--digital/io/src/top.fsm43
-rw-r--r--digital/io/src/top_cb.c76
2 files changed, 21 insertions, 98 deletions
diff --git a/digital/io/src/top.fsm b/digital/io/src/top.fsm
index 3e1fb456..f26468fc 100644
--- a/digital/io/src/top.fsm
+++ b/digital/io/src/top.fsm
@@ -1,11 +1,6 @@
# 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 with the Marcel's strategy
+ Main FSM calling other FSM.
States:
IDLE
@@ -14,12 +9,11 @@ States:
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_FORWARD
- move forward
- MOVE_BACKWARD
- move backward
+ GET_PUCK_FROM_THE_GROUND
+ get some pucks from the ground
+ GET_PUCK_FROM_DISTRIBUTOR
+ get some pucks from the distributor
+
Events:
start
@@ -30,32 +24,19 @@ Events:
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
state_timeout
+ timeout in cycle count
+ asserv_last_cmd_ack
+ last command sent to the asserv board has been acquitted
IDLE:
start -> WAIT_JACK_IN
- wait for the jack to be inserted into the bot
+ nothing to do.
WAIT_JACK_IN:
jack_inserted_into_bot -> WAIT_JACK_OUT
- wait for the jack to be removed from the bot
+ configure the asserv board.
WAIT_JACK_OUT:
- jack_removed_from_bot -> CONFIGURE_ASSERV
+ jack_removed_from_bot -> GET_PUCK_FROM_THE_GROUND
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_FORWARD
- move the bot forward
-
-MOVE_FORWARD:
- move_fsm_finished -> MOVE_BACKWARD
- return to initial position (yep it's useless but it's for test)
-
-MOVE_BACKWARD:
- move_fsm_finished -> MOVE_FORWARD
- move forward again
diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c
index 078cc9e9..acad13a5 100644
--- a/digital/io/src/top_cb.c
+++ b/digital/io/src/top_cb.c
@@ -14,75 +14,20 @@
#include "move.h" /* move FSM */
/*
- * 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)
- */
-fsm_branch_t
-top__WAIT_JACK_OUT__jack_removed_from_bot (void)
-{
- /* Set-up our color */
- //bot_color = switch_get_color ();
- /* Start the chronometer */
- chrono_init ();
- /* Reset the position of the bot */
- asserv_set_position (PG_X_START, PG_Y_START, PG_A_START);
- /* Tell the main loop we need to be aware when the asserv acknowledge our
- * settings command */
- //top_waiting_for_settings_ack_ = 1;
- return top_next (WAIT_JACK_OUT, jack_removed_from_bot);
-}
-
-/*
- * MOVE_BACKWARD =move_fsm_finished=>
- * => MOVE_FORWARD
- * move forward again
- */
-fsm_branch_t
-top__MOVE_BACKWARD__move_fsm_finished (void)
-{
- /* Get current position */
- asserv_position_t position;
- asserv_get_position (&position);
- /* FIXME: linear move is better? */
- move_start (position.x, position.y - 1500, 0);
- return top_next (MOVE_BACKWARD, move_fsm_finished);
-}
-
-/*
* IDLE =start=>
* => WAIT_JACK_IN
- * wait for the jack to be inserted into the bot
+ * nothing to do.
*/
fsm_branch_t
top__IDLE__start (void)
{
- //top_fsm_loop_count_ = 0;
return top_next (IDLE, start);
}
/*
- * MOVE_FORWARD =move_fsm_finished=>
- * => MOVE_BACKWARD
- * return to initial position (yep it's useless but it's for test)
- */
-fsm_branch_t
-top__MOVE_FORWARD__move_fsm_finished (void)
-{
- /* Get current position */
- asserv_position_t position;
- asserv_get_position (&position);
- /* FIXME: linear move is better? */
- move_start (position.x, position.y + 1500, 0);
- return top_next (MOVE_FORWARD, move_fsm_finished);
-}
-
-/*
* WAIT_JACK_IN =jack_inserted_into_bot=>
* => WAIT_JACK_OUT
- * wait for the jack to be removed from the bot
+ * configure the asserv board.
*/
fsm_branch_t
top__WAIT_JACK_IN__jack_inserted_into_bot (void)
@@ -91,19 +36,16 @@ top__WAIT_JACK_IN__jack_inserted_into_bot (void)
}
/*
- * CONFIGURE_ASSERV =settings_acknowledged=>
- * => MOVE_FORWARD
- * move the bot forward
+ * WAIT_JACK_OUT =jack_removed_from_bot=>
+ * => GET_PUCK_FROM_THE_GROUND
+ * the match start, start the chronometer
*/
fsm_branch_t
-top__CONFIGURE_ASSERV__settings_acknowledged (void)
+top__WAIT_JACK_OUT__jack_removed_from_bot (void)
{
- /* Get current position */
- asserv_position_t position;
- asserv_get_position (&position);
- /* FIXME: linear move is better? */
- move_start (position.x, position.y - 1500, 0);
- return top_next (CONFIGURE_ASSERV, settings_acknowledged);
+ /* Start the chronometer */
+ chrono_init ();
+ return top_next (WAIT_JACK_OUT, jack_removed_from_bot);
}