FSM_STATE(recognize)
{
+ static int camera_delay = 0;
+
switch(FSM_EVENT) {
case EV_ENTRY:
act_camera_recognize(robot.target_color);
FSM_TIMER(1000);
break;
case EV_TIMER:
- FSM_TIMER(1000);
+ if (++camera_delay > 10) {
+ // waiting for 10 seconds now, return back
+ DBG_PRINT_EVENT("camera: No response!");
+ ROBOT_LOCK(camera_result);
+ robot.target_valid = false;
+ ROBOT_UNLOCK(camera_result);
+ SUBFSM_RET(NULL);
+ } else {
+ FSM_TIMER(1000);
+ }
break;
case EV_CAMERA_DONE:
act_camera_off();
}
break;
case EV_EXIT:
+ camera_delay = 0;
break;
}
}