X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fstrat.c;h=2c6042828a6b74e1593388d8e8b7acdfc5acc315;hp=e08c4af38c9bea93bc8c3e8d6002e86edb756756;hb=9d056416278ae5d772a0fc1f7d2d11a4461fb673;hpb=b28db6087ed5fdab0bda8f23417ef7098d2a9ae5 diff --git a/projects/microb2010/mainboard/strat.c b/projects/microb2010/mainboard/strat.c index e08c4af..2c60428 100644 --- a/projects/microb2010/mainboard/strat.c +++ b/projects/microb2010/mainboard/strat.c @@ -100,6 +100,9 @@ void strat_conf_dump(const char *caller) /* call it just before launching the strat */ void strat_init(void) { + position_set(&mainboard.pos, 298.16, + COLOR_Y(308.78), COLOR_A(70.00)); + /* XXX init rollers, .. */ strat_db_init(); @@ -144,17 +147,25 @@ void strat_exit(void) /* called periodically */ void strat_event(void *dummy) { -#if 0 - /* pack or deploy spickle */ - if (strat_infos.status.flags & STRAT_STATUS_LHARVEST) { - if (sensor_get(S_LCOB_PRESENT)) { - if (sensor_get(S_LCOB_WHITE)) - i2c_ballboard_set_mode(); - else - ; - } - } -#endif + uint8_t flags; + uint8_t lcob, rcob; + + IRQ_LOCK(flags); + lcob = ballboard.lcob; + ballboard.lcob = I2C_COB_NONE; + rcob = ballboard.rcob; + ballboard.rcob = I2C_COB_NONE; + IRQ_UNLOCK(flags); + + if (lcob == I2C_COB_WHITE) + DEBUG(E_USER_STRAT, "lcob white"); + if (lcob == I2C_COB_BLACK) + DEBUG(E_USER_STRAT, "lcob black"); + if (rcob == I2C_COB_WHITE) + DEBUG(E_USER_STRAT, "rcob white"); + if (rcob == I2C_COB_BLACK) + DEBUG(E_USER_STRAT, "rcob black"); + /* limit speed when opponent is close */ strat_limit_speed(); } @@ -163,9 +174,29 @@ static uint8_t strat_beginning(void) { uint8_t err; + strat_set_acc(ACC_DIST, ACC_ANGLE); +#ifdef HOST_VERSION + strat_set_speed(600, SPEED_ANGLE_FAST); +#else + /* 250 */ strat_set_speed(250, SPEED_ANGLE_FAST); +#endif + + // strat_set_speed(600, 60); /* OK */ + strat_set_speed(250, 28); /* OK */ + + trajectory_d_a_rel(&mainboard.traj, 1000, COLOR_A(20)); + err = WAIT_COND_OR_TRAJ_END(trajectory_angle_finished(&mainboard.traj), + TRAJ_FLAGS_STD); + + strat_set_acc(ACC_DIST, ACC_ANGLE); + +#if 1 l1: + if (get_cob_count() >= 5) + strat_set_speed(600, SPEED_ANGLE_FAST); + err = line2line(LINE_UP, 0, LINE_R_DOWN, 2); if (!TRAJ_SUCCESS(err)) { trajectory_hardstop(&mainboard.traj); @@ -174,6 +205,9 @@ static uint8_t strat_beginning(void) } l2: + if (get_cob_count() >= 5) + strat_set_speed(600, SPEED_ANGLE_FAST); + err = line2line(LINE_R_DOWN, 2, LINE_R_UP, 2); if (!TRAJ_SUCCESS(err)) { trajectory_hardstop(&mainboard.traj); @@ -182,12 +216,30 @@ static uint8_t strat_beginning(void) } l3: + if (get_cob_count() >= 5) + strat_set_speed(600, SPEED_ANGLE_FAST); + err = line2line(LINE_R_UP, 2, LINE_UP, 5); if (!TRAJ_SUCCESS(err)) { trajectory_hardstop(&mainboard.traj); time_wait_ms(2000); goto l3; } +#else + strat_set_speed(600, SPEED_ANGLE_FAST); + err = line2line(LINE_UP, 0, LINE_R_DOWN, 3); + err = line2line(LINE_R_DOWN, 3, LINE_R_UP, 2); + err = line2line(LINE_R_UP, 2, LINE_R_DOWN, 2); + err = line2line(LINE_R_DOWN, 2, LINE_R_UP, 3); + err = line2line(LINE_R_UP, 3, LINE_UP, 5); + err = line2line(LINE_UP, 5, LINE_L_DOWN, 2); + err = line2line(LINE_L_DOWN, 2, LINE_L_UP, 1); + err = line2line(LINE_L_UP, 1, LINE_L_DOWN, 1); + err = line2line(LINE_L_DOWN, 1, LINE_DOWN, 0); + wait_ms(500); + trajectory_hardstop(&mainboard.traj); + return END_TRAJ; +#endif trajectory_hardstop(&mainboard.traj);