From e2046a06ee91772f0fa7ac8f139044a8a0620098 Mon Sep 17 00:00:00 2001 From: Jérémy Dufour Date: Thu, 24 Apr 2008 00:58:22 +0200 Subject: * digital/io/src - add an event to move away the bot from the gutter (to be able to turn freely) ; - move an event in the source file to ease merge. --- digital/io/src/top.fsm | 23 +++++++++++++------- digital/io/src/top_cb.c | 56 +++++++++++++++++++++++++++++++------------------ 2 files changed, 51 insertions(+), 28 deletions(-) (limited to 'digital') diff --git a/digital/io/src/top.fsm b/digital/io/src/top.fsm index 24a3b1fd..5a8e78b1 100644 --- a/digital/io/src/top.fsm +++ b/digital/io/src/top.fsm @@ -16,8 +16,9 @@ States: waiting for the jack to be removed from the bot CONFIGURE_ASSERV configuring the asserv board - MOVE_AWAY_FROM_BORDER - move the bot away from the border to be able to turn freely + MOVE_AWAY_FROM_START_BORDER + move the bot away from the border of the start point to be able to turn + freely GO_TO_SAMPLE_DISTRIBUTOR go to our distributor of samples (using the move FSM) GO_TO_OUR_ICE_DISTRIBUTOR @@ -35,6 +36,8 @@ States: DROP_OFF_BALLS_TO_GUTTER drop all the balls contained in the bot into the gutter (using the gutter FSM) + MOVE_AWAY_FROM_GUTTER_BORDER + move the bot away from the border of the gutter to be able to turn freely Events: start @@ -67,10 +70,10 @@ WAIT_JACK_OUT: set the settings of the asserv board (especially the position) CONFIGURE_ASSERV: - settings_acknowledged -> MOVE_AWAY_FROM_BORDER + settings_acknowledged -> MOVE_AWAY_FROM_START_BORDER move the bot away from the border to be able to turn freely -MOVE_AWAY_FROM_BORDER: +MOVE_AWAY_FROM_START_BORDER: move_fsm_finished -> GO_TO_SAMPLE_DISTRIBUTOR order the bot to move to our samples distributors with the move FSM @@ -101,10 +104,9 @@ GO_TO_GUTTER: FSM DROP_OFF_BALLS_TO_GUTTER: - gutter_fsm_finished -> GO_TO_SAMPLE_DISTRIBUTOR - we have finished to drop off all the balls, let's go to our sample - ditributor to try the same strategy again - reset internal data + gutter_fsm_finished -> MOVE_AWAY_FROM_GUTTER_BORDER + we have finished to drop off all the balls, let's move away from the gutter + to move freely GO_TO_ADVERSE_ICE_DISTRIBUTOR: move_fsm_finished -> GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR @@ -115,3 +117,8 @@ GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR: get_samples_fsm_finished -> GO_TO_GUTTER we have finished to get ice. Even if we are not full, let's go to the gutter with the move FSM + +MOVE_AWAY_FROM_GUTTER_BORDER: + move_fsm_finished -> GO_TO_SAMPLE_DISTRIBUTOR + go to our sample ditributor to try the same strategy again + reset internal data diff --git a/digital/io/src/top_cb.c b/digital/io/src/top_cb.c index 65754f90..fed78ef2 100644 --- a/digital/io/src/top_cb.c +++ b/digital/io/src/top_cb.c @@ -47,16 +47,18 @@ extern uint8_t top_waiting_for_settings_ack_; /* * DROP_OFF_BALLS_TO_GUTTER =gutter_fsm_finished=> - * => GO_TO_SAMPLE_DISTRIBUTOR - * we have finished to drop off all the balls, let's go to our sample - * ditributor to try the same strategy again - * reset internal data + * => MOVE_AWAY_FROM_GUTTER_BORDER + * we have finished to drop off all the balls, let's move away from the gutter + * to move freely */ fsm_branch_t top__DROP_OFF_BALLS_TO_GUTTER__gutter_fsm_finished (void) { - /* Start the move FSM */ - move_start (PG_DISTRIBUTOR_SAMPLE_OUR_X, PG_DISTRIBUTOR_SAMPLE_OUR_Y); + /* Get current position */ + asserv_position_t position; + asserv_get_position (&position); + /* Move away from the gutter */ + move_start (position.x, position.y + BOT_MIN_DISTANCE_TURN_FREE); return top_next (DROP_OFF_BALLS_TO_GUTTER, gutter_fsm_finished); } @@ -82,6 +84,19 @@ top__WAIT_JACK_OUT__jack_removed_from_bot (void) return top_next (WAIT_JACK_OUT, jack_removed_from_bot); } +/* + * MOVE_AWAY_FROM_START_BORDER =move_fsm_finished=> + * => GO_TO_SAMPLE_DISTRIBUTOR + * order the bot to move to our samples distributors with the move FSM + */ +fsm_branch_t +top__MOVE_AWAY_FROM_START_BORDER__move_fsm_finished (void) +{ + /* Start the move FSM to our samples distributor */ + move_start (PG_DISTRIBUTOR_SAMPLE_OUR_X, PG_DISTRIBUTOR_SAMPLE_OUR_Y); + return top_next (MOVE_AWAY_FROM_START_BORDER, move_fsm_finished); +} + /* * GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR =get_samples_fsm_finished=> * => GO_TO_OUR_ICE_DISTRIBUTOR @@ -96,19 +111,6 @@ top__GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR__get_samples_fsm_finished (void) return top_next (GET_SAMPLES_FROM_SAMPLES_DISTRIBUTOR, get_samples_fsm_finished); } -/* - * MOVE_AWAY_FROM_BORDER =move_fsm_finished=> - * => GO_TO_SAMPLE_DISTRIBUTOR - * order the bot to move to our samples distributors with the move FSM - */ -fsm_branch_t -top__MOVE_AWAY_FROM_BORDER__move_fsm_finished (void) -{ - /* Start the move FSM to our samples distributor */ - move_start (PG_DISTRIBUTOR_SAMPLE_OUR_X, PG_DISTRIBUTOR_SAMPLE_OUR_Y); - return top_next (MOVE_AWAY_FROM_BORDER, move_fsm_finished); -} - /* * GO_TO_ADVERSE_ICE_DISTRIBUTOR =move_fsm_finished=> * => GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR @@ -204,6 +206,20 @@ top__GET_ICE_FROM_OUR_ICE_DISTRIBUTOR__get_samples_fsm_finished (void) } } +/* + * MOVE_AWAY_FROM_GUTTER_BORDER =move_fsm_finished=> + * => GO_TO_SAMPLE_DISTRIBUTOR + * go to our sample ditributor to try the same strategy again + * reset internal data + */ +fsm_branch_t +top__MOVE_AWAY_FROM_GUTTER_BORDER__move_fsm_finished (void) +{ + /* 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); +} + /* * GET_ICE_FROM_ADVERSE_ICE_DISTRIBUTOR =get_samples_fsm_finished=> * => GO_TO_GUTTER @@ -231,7 +247,7 @@ top__WAIT_JACK_IN__jack_inserted_into_bot (void) /* * CONFIGURE_ASSERV =settings_acknowledged=> - * => MOVE_AWAY_FROM_BORDER + * => MOVE_AWAY_FROM_START_BORDER * move the bot away from the border to be able to turn freely */ fsm_branch_t -- cgit v1.2.3