// robot_set_est_pos_trans(0.15, PLAYGROUND_HEIGHT_M - 0.7, DEG2RAD(180));
off_brush_left();
off_brush_right();
+ brushes_out();
open_bottom_door();
close_back_door();
- FSM_TRANSITION(wait_for_start);
+// FSM_TRANSITION(wait_for_start);
// FSM_TRANSITION(go_to_container);
+ FSM_TRANSITION(get_balls);
break;
default: break;
}
switch (FSM_EVENT) {
case EV_ENTRY:
open_bottom_door();
- set_bagr(140);
+ set_bagr(120);
brushes_drives_in();
-// set_bagr(140);
-// brushes_drives_in();
FSM_TIMER(500);
break;
case EV_TIMER:
if (ball_inside) {
- printf("tady2\n");
ball_inside = 0;
close_bottom_door();
+ off_bagr();
if (robot.carousel_cnt >= CAROUSEL_SIZE) {
- FSM_TRANSITION(go_to_container);
+// printf("go_to_container\n");
+// FSM_TRANSITION(go_to_container);
+ FSM_TRANSITION(deposite_balls);
} else {
FSM_TRANSITION(next_carousel_position);
}
} else if (get_ball_attemps++ < 5) {
- FSM_TIMER(500);
+ FSM_TIMER(1500);
} else {
- FSM_TRANSITION(go_to_container);
+ printf("go_to_container\n");
+// FSM_TRANSITION(go_to_container);
}
break;
case EV_BALL_INSIDE:
if (ball_inside)
break;
- printf("tady1\n");
ball_inside = 1;
robot.carousel[robot.carousel_pos % CAROUSEL_SIZE] = (enum ball_color)robot.cmu.color;
robot.carousel_cnt++;
+ printf("cnt=%d\n", robot.carousel_cnt);
FSM_TIMER(5000);
break;
default: break;
} else if (carousel_attempts < 3) {
FSM_TIMER(1000);
} else {
- FSM_TRANSITION(go_to_container);
+ printf("go_to_container\n");
+// FSM_TRANSITION(go_to_container);
}
break;
default: break;
FSM_STATE(deposite_balls)
{
int carousel_pos = 0;
+ int wait_for_deposition = 0;
switch (FSM_EVENT) {
case EV_ENTRY:
- open_back_door();
set_carousel(carousel_pos++);
// robot.carousel_cnt--;
// if (robot.carousel_cnt <= 0) {
FSM_TIMER(500);
break;
case EV_TIMER:
+ if (!wait_for_deposition) {
+ open_back_door();
+ wait_for_deposition = 1;
+ }
+
+ FSM_TIMER(500);
if (carousel_pos > 4)
- FSM_TRANSITION(go_to_our_white_dispenser);
+ printf("ok\n");
+// FSM_TRANSITION(go_to_our_white_dispenser);
// FSM_TRANSITION(next_carousel_position2);
+ close_back_door();
set_carousel(carousel_pos++);
- FSM_TIMER(500);
break;
default: break;
}