struct wait_and_try_again : TimedState< wait_and_try_again, MotionBase > {
Timer wait_tout;
+ int target_inacc_cnt;
wait_and_try_again(my_context ctx) : base_state(ctx) {
stop();
runTimer(wait_tout, 1000, new evTimer());
+ target_inacc_cnt = 0;
}
sc::result react(const evTimer &) {
switch (recalculate_trajectory()) {
case TARGET_OK: return transit<movement>();
// Target inaccessible because of an obstacle
case TARGET_INACC:
- ul_logerr("Inaccessible\n");
- return transit<wait_and_try_again>();
- /* FIXME (Filip): this could happen forever */
+ if (++target_inacc_cnt < 3) {
+ ul_logerr("Inaccessible\n");
+ runTimer(wait_tout, 1000, new evTimer());
+ /* FIXME (Filip): this could happen forever */
+ } else { /* go away if the point is not accessible, try max. 3x */
+ robot.sched.queue_event(robot.MAIN, new evMotionError());
+ //DBG_PRINT_EVENT("Target inaccessible, go to new target.");
+ return transit<wait_for_command>();
+ }
// Fatal error during planning
case TARGET_ERROR:
robot.sched.queue_event(robot.MAIN, new evMotionDone());