if (!strcmp_P(res->arg1, PSTR("our_orange")))
bit = STRAT_CONF_OUR_ORANGE;
+ else if (!strcmp_P(res->arg1, PSTR("wait_obstacle")))
+ bit = STRAT_CONF_WAIT_OBSTACLE;
if (on)
strat_conf.flags |= bit;
prog_char str_strat_conf2_arg0[] = "strat_conf";
parse_pgm_token_string_t cmd_strat_conf2_arg0 = TOKEN_STRING_INITIALIZER(struct cmd_strat_conf2_result, arg0, str_strat_conf2_arg0);
-prog_char str_strat_conf2_arg1[] = "our_orange";
+prog_char str_strat_conf2_arg1[] = "our_orange#wait_obstacle";
parse_pgm_token_string_t cmd_strat_conf2_arg1 = TOKEN_STRING_INITIALIZER(struct cmd_strat_conf2_result, arg1, str_strat_conf2_arg1);
prog_char str_strat_conf2_arg2[] = "on#off";
parse_pgm_token_string_t cmd_strat_conf2_arg2 = TOKEN_STRING_INITIALIZER(struct cmd_strat_conf2_result, arg2, str_strat_conf2_arg2);
DO_POS | DO_BD | DO_POWER;
strat_db_init();
+ strat_conf.prev_wait_obstacle = -5;
strat_conf_dump(__FUNCTION__);
strat_db_dump(__FUNCTION__);
}
return;
printf_P(PSTR("-- conf --\r\n"));
- printf_P(PSTR("opp_orange = %d\n"), strat_conf.opp_orange);
- printf_P(PSTR("orphan_tomato = %d\n"), strat_conf.orphan_tomato);
printf_P(PSTR("our_orange = %s\n"),
(strat_conf.flags & STRAT_CONF_OUR_ORANGE) ? "y":"n");
+ printf_P(PSTR("wait_obstacle = %s\n"),
+ (strat_conf.flags & STRAT_CONF_WAIT_OBSTACLE) ? "y":"n");
+ printf_P(PSTR("opp_orange = %d\n"), strat_conf.opp_orange);
+ printf_P(PSTR("orphan_tomato = %d\n"), strat_conf.orphan_tomato);
}
void strat_event_enable(void)
strat_set_acc(ACC_DIST, ACC_ANGLE);
strat_set_speed(SPEED_CLITOID_SLOW, SPEED_ANGLE_SLOW);
+ l1:
err = line2line(0, LINE_UP, 2, LINE_R_DOWN, TRAJ_FLAGS_NO_NEAR);
+ if (err == END_OBSTACLE &&
+ strat_conf.flags & STRAT_CONF_WAIT_OBSTACLE &&
+ time_get_s() > strat_conf.prev_wait_obstacle + 5) {
+ strat_conf.prev_wait_obstacle = time_get_s();
+ time_wait_ms(2000);
+ goto l1;
+ }
if (!TRAJ_SUCCESS(err))
return err;
+ l2:
err = line2line(2, LINE_R_DOWN, 2, LINE_R_UP, TRAJ_FLAGS_NO_NEAR);
+ if (err == END_OBSTACLE &&
+ strat_conf.flags & STRAT_CONF_WAIT_OBSTACLE &&
+ time_get_s() > strat_conf.prev_wait_obstacle + 5) {
+ strat_conf.prev_wait_obstacle = time_get_s();
+ time_wait_ms(2000);
+ goto l2;
+ }
if (!TRAJ_SUCCESS(err)) {
return err;
}
/* do all lines of circuit */
for (idx = 1; idx < len; idx ++) {
+ retry:
linenum = circuit_wpline[idx].line_num;
dir = circuit_wpline[idx].dir;
__FUNCTION__, prev_linenum, prev_dir, linenum, dir);
err = line2line(prev_linenum, prev_dir, linenum, dir,
TRAJ_FLAGS_NO_NEAR);
+
+ /* in some cases it is better to wait that obstacle is
+ * gone before starting to avoid it */
+ if (err == END_OBSTACLE &&
+ strat_conf.flags & STRAT_CONF_WAIT_OBSTACLE &&
+ time_get_s() > strat_conf.prev_wait_obstacle + 5) {
+ strat_conf.prev_wait_obstacle = time_get_s();
+ time_wait_ms(2000);
+ goto retry;
+ }
if (!TRAJ_SUCCESS(err))
goto fail;