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);
* 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(
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:
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: