From: Filip Jares Date: Fri, 24 Apr 2009 20:57:21 +0000 (+0200) Subject: MAIN FSM: empty decide_what_next and deposit_at_acropolis states created X-Git-Tag: eb2009~19^2~10 X-Git-Url: http://rtime.felk.cvut.cz/gitweb/eurobot/public.git/commitdiff_plain/88ec56d2f9fabc6a99e0b360d667be9fcd3f08c4 MAIN FSM: empty decide_what_next and deposit_at_acropolis states created and obsolete states removed from switch statements --- diff --git a/src/robofsm/competition.cc b/src/robofsm/competition.cc index 58b07b5c..0b9f6188 100644 --- a/src/robofsm/competition.cc +++ b/src/robofsm/competition.cc @@ -262,7 +262,9 @@ void robot_goto_puck_in_grid(int nx, int ny, int phi) FSM_STATE_DECL(init); FSM_STATE_DECL(wait_for_start); /* strategies related states */ +FSM_STATE_DECL(decide_what_next); FSM_STATE_DECL(collect_free_pucks); +FSM_STATE_DECL(deposit_at_acropolis); /* movement states */ FSM_STATE_DECL(simple_construction_zone_approach); FSM_STATE_DECL(approach_our_static_dispenser); @@ -356,6 +358,59 @@ FSM_STATE(wait_for_start) * STRATEGIES RELATED STATES ************************************************************************/ +FSM_STATE(decide_what_next) +{ + switch (FSM_EVENT) { + case EV_ENTRY: + if(robot.pucks_inside == pucks_at_once) { + ; // + } else { + if(robot.pucks_inside < pucks_at_once && free_puck_to_try_to_get_next < 6) { + FSM_TRANSITION(collect_free_pucks); + } + } + break; + case EV_MOTION_DONE: + case EV_ACTION_DONE: + case EV_RETURN: + case EV_TIMER: + case EV_LASER_POWER: + case EV_GOAL_NOT_REACHABLE: + case EV_SHORT_TIME_TO_END: + case EV_STACK_FULL: + case EV_ACTION_ERROR: + case EV_PUCK_REACHABLE: + case EV_START: + DBG_PRINT_EVENT("unhandled event"); + break; + case EV_EXIT: + break; + } +} + +FSM_STATE(deposit_at_acropolis) +{ + switch (FSM_EVENT) { + case EV_ENTRY: + break; + case EV_MOTION_DONE: + case EV_ACTION_DONE: + case EV_RETURN: + case EV_TIMER: + case EV_LASER_POWER: + case EV_GOAL_NOT_REACHABLE: + case EV_SHORT_TIME_TO_END: + case EV_STACK_FULL: + case EV_ACTION_ERROR: + case EV_PUCK_REACHABLE: + case EV_START: + DBG_PRINT_EVENT("unhandled event"); + break; + case EV_EXIT: + break; + } +} + static void robot_goto_next_puck_in_sequence(int lot, int puck_number) { robot_goto_puck_in_grid( @@ -379,28 +434,15 @@ FSM_STATE(collect_free_pucks) case EV_RETURN: switch(FSM_EVENT_RET_VAL) { case LOAD_SUCCESS: + free_puck_to_try_to_get_next++; printf(">>>>>> Loading the puck succeeded\n"); - if(free_puck_to_try_to_get_next<4) { - free_puck_to_try_to_get_next++; - robot_goto_next_puck_in_sequence(lot, free_puck_to_try_to_get_next); - } break; case LOAD_FAIL: printf(">>>>>> Loading the puck FAILED\n"); - if(free_puck_to_try_to_get_next<6) { // FIXME: test number of pucks loaded!! - free_puck_to_try_to_get_next++; - robot_goto_next_puck_in_sequence(lot, free_puck_to_try_to_get_next); - } else { - // FIXME (TODO): transition to next strategy state - } break; } break; case EV_PUCK_REACHABLE: - robot_stop(); - printf("-----reached some free puck, hopefully no. %d\n", free_puck_to_try_to_get_next); - SUBFSM_TRANSITION(load_the_puck, NULL); - break; case EV_ACTION_DONE: case EV_TIMER: case EV_LASER_POWER: @@ -636,11 +678,9 @@ FSM_STATE() case EV_ACTION_DONE: case EV_RETURN: case EV_TIMER: - case EV_OBSTRUCTION_AHEAD: case EV_LASER_POWER: case EV_GOAL_NOT_REACHABLE: case EV_SHORT_TIME_TO_END: - case EV_ENEMY_AHEAD: case EV_STACK_FULL: case EV_ACTION_ERROR: case EV_PUCK_REACHABLE: