X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=blobdiff_plain;f=projects%2Fmicrob2010%2Fmainboard%2Fstrat.c;h=c253e5f63c9f7d06eac6f5d391df44bb27bb6888;hp=6743d370fa6474be6442aeb7004feca85077ae73;hb=78150017ab8c5615af414df706a0525fe7c262ae;hpb=31bb619b1046f561cff432cb116735b1423a8d89 diff --git a/projects/microb2010/mainboard/strat.c b/projects/microb2010/mainboard/strat.c index 6743d37..c253e5f 100644 --- a/projects/microb2010/mainboard/strat.c +++ b/projects/microb2010/mainboard/strat.c @@ -1,6 +1,6 @@ -/* +/* * Copyright Droids, Microb Technology (2009) - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -17,7 +17,7 @@ * * Revision : $Id: strat.c,v 1.6 2009-11-08 17:24:33 zer0 Exp $ * - * Olivier MATZ + * Olivier MATZ */ #include @@ -58,6 +58,7 @@ #include "main.h" #include "strat.h" #include "strat_base.h" +#include "strat_corn.h" #include "strat_utils.h" #include "sensor.h" #include "actuator.h" @@ -70,7 +71,10 @@ struct strat_infos strat_infos = { .conf = { .flags = 0, }, - + /* status */ + .status = { + .flags = 0, + }, }; /*************************************************************/ @@ -108,7 +112,7 @@ void strat_preinit(void) mainboard.flags = DO_ENCODERS | DO_CS | DO_RS | DO_POS | DO_BD | DO_POWER; - i2c_cobboard_mode_init(); + //i2c_cobboard_mode_init(); strat_dump_conf(); strat_dump_infos(__FUNCTION__); } @@ -135,12 +139,14 @@ void strat_dump_infos(const char *caller) * here */ void strat_reset_infos(void) { + init_corn_table(-1, -1); } /* call it just before launching the strat */ void strat_init(void) { /* XXX init rollers, .. */ + strat_reset_infos(); /* we consider that the color is correctly set */ @@ -149,8 +155,12 @@ void strat_init(void) time_reset(); interrupt_traj_reset(); + i2c_cobboard_mode_harvest(I2C_LEFT_SIDE); + i2c_cobboard_mode_harvest(I2C_RIGHT_SIDE); + i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_HARVEST); + /* used in strat_base for END_TIMER */ - mainboard.flags = DO_ENCODERS | DO_CS | DO_RS | + mainboard.flags = DO_ENCODERS | DO_CS | DO_RS | DO_POS | DO_BD | DO_TIMER | DO_POWER; } @@ -174,12 +184,52 @@ 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 /* limit speed when opponent is close */ strat_limit_speed(); } static uint8_t strat_beginning(void) { + uint8_t err; + + strat_set_speed(250, SPEED_ANGLE_FAST); + //init_corn_table(0, 0); + + err = line2line(LINE_UP, 0, LINE_R_DOWN, 2); + err = line2line(LINE_R_DOWN, 2, LINE_R_UP, 2); + err = line2line(LINE_R_UP, 2, LINE_UP, 5); + trajectory_hardstop(&mainboard.traj); + + /* ball ejection */ + trajectory_a_abs(&mainboard.traj, COLOR_A(90)); + i2c_ballboard_set_mode(I2C_BALLBOARD_MODE_EJECT); + time_wait_ms(2000); + + /* half turn */ + trajectory_goto_xy_abs(&mainboard.traj, 2625, COLOR_Y(1847)); + err = wait_traj_end(END_INTR|END_TRAJ); + i2c_cobboard_mode_pack(I2C_LEFT_SIDE); + i2c_cobboard_mode_pack(I2C_RIGHT_SIDE); + trajectory_a_rel(&mainboard.traj, COLOR_A(180)); + err = wait_traj_end(END_INTR|END_TRAJ); + + /* cob ejection */ + trajectory_d_rel(&mainboard.traj, -100); + err = wait_traj_end(END_INTR|END_TRAJ); + i2c_cobboard_mode_eject(); + time_wait_ms(2000); + return END_TRAJ; } @@ -197,7 +247,7 @@ uint8_t strat_main(void) { uint8_t err; - /* do static cols + first temple */ + /* */ err = strat_beginning(); return err;