From 29433741458368289f8aa68ab49ff1545ecec5dc Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 1 May 2010 01:11:13 +0200 Subject: digital/io/src: init FSM simplifications thanks to new twi_master module --- digital/io/src/ai_init_cb.c | 45 +++++++-------------------------------------- digital/io/src/init.fsm | 22 +++++----------------- 2 files changed, 12 insertions(+), 55 deletions(-) diff --git a/digital/io/src/ai_init_cb.c b/digital/io/src/ai_init_cb.c index aa4d58df..5e8ea937 100644 --- a/digital/io/src/ai_init_cb.c +++ b/digital/io/src/ai_init_cb.c @@ -103,40 +103,19 @@ ai__INIT_WAIT_FOR_HANDS_OUT__state_timeout (void) /* * INIT_GO_TO_THE_WALL =bot_move_succeed=> - * => INIT_SET_Y_POSITION + * => INIT_GO_AWAY_FROM_THE_WALL * reset the Y position of the bot. + * reset the angular position of the bot. + * move away from the wall (linear move). */ fsm_branch_t ai__INIT_GO_TO_THE_WALL__bot_move_succeed (void) { asserv_set_y_position (PG_Y (PG_LENGTH - BOT_SIZE_FRONT)); - return ai_next (INIT_GO_TO_THE_WALL, bot_move_succeed); -} - -/* - * INIT_SET_Y_POSITION =asserv_last_cmd_ack=> - * => INIT_SET_ANGULAR_POSITION - * reset the angular position of the bot. - */ -fsm_branch_t -ai__INIT_SET_Y_POSITION__asserv_last_cmd_ack (void) -{ - /* We are facing top border. */ asserv_set_angle_position (PG_A_DEG (90)); - return ai_next (INIT_SET_Y_POSITION, asserv_last_cmd_ack); -} - -/* - * INIT_SET_ANGULAR_POSITION =asserv_last_cmd_ack=> - * => INIT_GO_AWAY_FROM_THE_WALL - * move away from the wall (linear move). - */ -fsm_branch_t -ai__INIT_SET_ANGULAR_POSITION__asserv_last_cmd_ack (void) -{ /* Move away from the border. */ asserv_move_linearly (- INIT_DIST); - return ai_next (INIT_SET_ANGULAR_POSITION, asserv_last_cmd_ack); + return ai_next (INIT_GO_TO_THE_WALL, bot_move_succeed); } /* @@ -178,27 +157,17 @@ ai__INIT_WAIT_AFTER_ROTATION__state_timeout (void) /* * INIT_GO_TO_THE_WALL_AGAIN =bot_move_succeed=> - * => INIT_SET_X_POSITION + * => INIT_GO_AWAY_FROM_THE_WALL_AGAIN * reset the X position of the bot. + * move away from the wall (linear move). */ fsm_branch_t ai__INIT_GO_TO_THE_WALL_AGAIN__bot_move_succeed (void) { asserv_set_x_position (PG_X (BOT_SIZE_FRONT)); - return ai_next (INIT_GO_TO_THE_WALL_AGAIN, bot_move_succeed); -} - -/* - * INIT_SET_X_POSITION =asserv_last_cmd_ack=> - * => INIT_GO_AWAY_FROM_THE_WALL_AGAIN - * move away from the wall (linear move). - */ -fsm_branch_t -ai__INIT_SET_X_POSITION__asserv_last_cmd_ack (void) -{ /* Move away from the border. */ asserv_move_linearly (- INIT_DIST); - return ai_next (INIT_SET_X_POSITION, asserv_last_cmd_ack); + return ai_next (INIT_GO_TO_THE_WALL_AGAIN, bot_move_succeed); } /* diff --git a/digital/io/src/init.fsm b/digital/io/src/init.fsm index 86c08610..f780ba45 100644 --- a/digital/io/src/init.fsm +++ b/digital/io/src/init.fsm @@ -19,15 +19,13 @@ States: wait the jack to be removed from the bot for the first time. INIT_WAIT_SECOND_JACK_IN wait for the jack to be inserted into the bot for the second time. - INIT_WAIT_FOR_HANDS_OUT[timeout=450] + INIT_WAIT_FOR_HANDS_OUT[timeout=225] just wait for operator hands to be removed from the jack. INIT_GO_TO_THE_WALL go to the wall for the first time. - INIT_SET_Y_POSITION + INIT_GO_AWAY_FROM_THE_WALL reset the Y position of the bot. - INIT_SET_ANGULAR_POSITION reset the angular position of the bot. - INIT_GO_AWAY_FROM_THE_WALL go backward from the wall for a specific distance. INIT_FACE_OTHER_WALL make the bot face the other wall. @@ -35,9 +33,8 @@ States: make sure rotation is really finished before continuing. INIT_GO_TO_THE_WALL_AGAIN go to the wall for the second time. - INIT_SET_X_POSITION - reset the X position of the bot. INIT_GO_AWAY_FROM_THE_WALL_AGAIN + reset the X position of the bot. go backward from the wall for a specific distance. INIT_GO_TO_START_POSITION go to the start position. @@ -72,15 +69,9 @@ INIT_WAIT_FOR_HANDS_OUT: fuck the wall in front. INIT_GO_TO_THE_WALL: - bot_move_succeed -> INIT_SET_Y_POSITION + bot_move_succeed -> INIT_GO_AWAY_FROM_THE_WALL reset the Y position of the bot. - -INIT_SET_Y_POSITION: - asserv_last_cmd_ack -> INIT_SET_ANGULAR_POSITION reset the angular position of the bot. - -INIT_SET_ANGULAR_POSITION: - asserv_last_cmd_ack -> INIT_GO_AWAY_FROM_THE_WALL move away from the wall (linear move). INIT_GO_AWAY_FROM_THE_WALL: @@ -96,11 +87,8 @@ INIT_WAIT_AFTER_ROTATION: fuck the wall in front. INIT_GO_TO_THE_WALL_AGAIN: - bot_move_succeed -> INIT_SET_X_POSITION + bot_move_succeed -> INIT_GO_AWAY_FROM_THE_WALL_AGAIN reset the X position of the bot. - -INIT_SET_X_POSITION: - asserv_last_cmd_ack -> INIT_GO_AWAY_FROM_THE_WALL_AGAIN move away from the wall (linear move). INIT_GO_AWAY_FROM_THE_WALL_AGAIN: -- cgit v1.2.3