From 878d0fc33d940d5d02fc65dfd0e56798c97de18d Mon Sep 17 00:00:00 2001 From: zer0 Date: Tue, 4 May 2010 22:13:29 +0200 Subject: [PATCH] mark tomato as taken when we go on it --- projects/microb2010/mainboard/strat.c | 39 +++- projects/microb2010/mainboard/strat_avoid.c | 189 +++++++++++++++++--- 2 files changed, 200 insertions(+), 28 deletions(-) diff --git a/projects/microb2010/mainboard/strat.c b/projects/microb2010/mainboard/strat.c index 3ef6675..0405844 100644 --- a/projects/microb2010/mainboard/strat.c +++ b/projects/microb2010/mainboard/strat.c @@ -155,18 +155,33 @@ void strat_exit(void) #endif } -/* called periodically (10ms) */ -void strat_event(void *dummy) +/* mark tomato as not present */ +static void check_tomato(void) +{ + int16_t x, y; + uint8_t i, j; + + x = position_get_x_s16(&mainboard.pos); + y = position_get_y_s16(&mainboard.pos); + + if (xycoord_to_ijcoord(&x, &y, &i, &j) < 0) + return; + + if (strat_db.wp_table[i][j].type != WP_TYPE_TOMATO) + return; + + strat_db.wp_table[i][j].present = 0; +} + +/* mark corn as not present and give correct commands to the cobboard + * for spickles */ +static void check_corn(void) { uint8_t flags; int8_t lcob_near, rcob_near; uint8_t lcob, rcob; uint8_t lidx, ridx; - /* ignore when strat is not running */ - if (strat_running == 0) - return; - /* read sensors from ballboard */ IRQ_LOCK(flags); lcob = ballboard.lcob; @@ -255,9 +270,19 @@ void strat_event(void *dummy) else i2c_cobboard_deploy(I2C_RIGHT_SIDE); } +} + +/* called periodically (10ms) */ +void strat_event(void *dummy) +{ + /* ignore when strat is not running */ + if (strat_running == 0) + return; + check_tomato(); + check_corn(); /* limit speed when opponent is near */ - strat_limit_speed(); + //strat_limit_speed(); } diff --git a/projects/microb2010/mainboard/strat_avoid.c b/projects/microb2010/mainboard/strat_avoid.c index eb14b88..61151ff 100644 --- a/projects/microb2010/mainboard/strat_avoid.c +++ b/projects/microb2010/mainboard/strat_avoid.c @@ -88,20 +88,20 @@ const struct wp_coord butterfly_tab[] = { { .i = 8, .j = 5, }, { .i = 7, .j = 4, }, { .i = 6, .j = 4, }, - { .i = 5, .j = 4, }, - { .i = 4, .j = 5, }, - { .i = 3, .j = 5, }, - { .i = 2, .j = 6, }, - { .i = 1, .j = 6, }, - { .i = 1, .j = 5, }, - { .i = 1, .j = 4, }, - { .i = 1, .j = 3, }, - { .i = 1, .j = 2, }, - { .i = 1, .j = 1, }, - { .i = 2, .j = 2, }, - { .i = 3, .j = 2, }, - { .i = 4, .j = 3, }, { .i = 5, .j = 3, }, + { .i = 4, .j = 4, }, + { .i = 3, .j = 2, }, + { .i = 2, .j = 2, }, + { .i = 1, .j = 1, }, + { .i = 1, .j = 2, }, + { .i = 1, .j = 3, }, + { .i = 1, .j = 4, }, + { .i = 1, .j = 5, }, + { .i = 1, .j = 6, }, + { .i = 2, .j = 6, }, + { .i = 3, .j = 5, }, + { .i = 4, .j = 5, }, + { .i = 5, .j = 4, }, { .i = 6, .j = 4, }, { .i = 7, .j = 3, }, { .i = 8, .j = 3, }, @@ -115,13 +115,13 @@ const struct wp_coord butterfly_tab[] = { { .i = 11, .j = 6, }, }; -const struct circuit butterfly = { +const struct circuit butterfly_circuit = { .name = "butterfly", .len = sizeof(butterfly_tab)/sizeof(struct wp_coord), .path = butterfly_tab, }; -const struct wp_coord small_tab[] = { +const struct wp_coord losange_tab[] = { { .i = 11, .j = 6, }, { .i = 10, .j = 6, }, { .i = 9, .j = 5, }, @@ -133,16 +133,163 @@ const struct wp_coord small_tab[] = { { .i = 11, .j = 6, }, }; -const struct circuit small = { - .name = "small", - .len = sizeof(small)/sizeof(struct wp_coord), - .path = small_tab, +const struct circuit losange_circuit = { + .name = "losange", + .len = sizeof(losange_tab)/sizeof(struct wp_coord), + .path = losange_tab, +}; + +const struct wp_coord triangle_tab[] = { + { .i = 11, .j = 6, }, + { .i = 10, .j = 6, }, + { .i = 9, .j = 5, }, + { .i = 8, .j = 5, }, + { .i = 7, .j = 4, }, + { .i = 6, .j = 4, }, + { .i = 7, .j = 3, }, + { .i = 8, .j = 3, }, + { .i = 9, .j = 2, }, + { .i = 10, .j = 2, }, + { .i = 11, .j = 1, }, + { .i = 11, .j = 2, }, + { .i = 11, .j = 3, }, + { .i = 11, .j = 4, }, + { .i = 11, .j = 5, }, + { .i = 11, .j = 6, }, +}; + +const struct circuit triangle_circuit = { + .name = "triangle", + .len = sizeof(triangle_tab)/sizeof(struct wp_coord), + .path = triangle_tab, +}; + +const struct wp_coord answer_d_tab[] = { + { .i = 11, .j = 6, }, + { .i = 11, .j = 5, }, + { .i = 11, .j = 4, }, + { .i = 11, .j = 3, }, + { .i = 11, .j = 2, }, + { .i = 11, .j = 1, }, + { .i = 10, .j = 2, }, + { .i = 9, .j = 2, }, + { .i = 8, .j = 3, }, + { .i = 9, .j = 3, }, + { .i = 10, .j = 4, }, + { .i = 11, .j = 4, }, + { .i = 11, .j = 5, }, + { .i = 11, .j = 6, }, +}; + +const struct circuit answer_d_circuit = { + .name = "answer_d", + .len = sizeof(answer_d_tab)/sizeof(struct wp_coord), + .path = answer_d_tab, +}; + +const struct wp_coord h_lambda_tab[] = { + { .i = 11, .j = 6, }, + { .i = 10, .j = 6, }, + { .i = 9, .j = 5, }, + { .i = 8, .j = 5, }, + { .i = 7, .j = 4, }, + { .i = 6, .j = 4, }, + { .i = 5, .j = 3, }, + { .i = 5, .j = 4, }, + { .i = 5, .j = 5, }, + { .i = 5, .j = 6, }, + { .i = 6, .j = 6, }, + { .i = 7, .j = 5, }, + { .i = 8, .j = 5, }, + { .i = 9, .j = 5, }, + { .i = 10, .j = 6, }, + { .i = 11, .j = 6, }, +}; + +const struct circuit h_lambda_circuit = { + .name = "h_lambda", + .len = sizeof(h_lambda_tab)/sizeof(struct wp_coord), + .path = h_lambda_tab, +}; + +const struct wp_coord asym_butterfly_tab[] = { + { .i = 11, .j = 6, }, + { .i = 10, .j = 6, }, + { .i = 9, .j = 5, }, + { .i = 8, .j = 5, }, + { .i = 7, .j = 4, }, + { .i = 6, .j = 4, }, + { .i = 5, .j = 3, }, + { .i = 4, .j = 3, }, + { .i = 3, .j = 2, }, + { .i = 3, .j = 3, }, + { .i = 3, .j = 4, }, + { .i = 3, .j = 5, }, + { .i = 4, .j = 5, }, + { .i = 5, .j = 4, }, + { .i = 6, .j = 4, }, + { .i = 7, .j = 3, }, + { .i = 8, .j = 3, }, + { .i = 9, .j = 2, }, + { .i = 10, .j = 2, }, + { .i = 11, .j = 1, }, + { .i = 11, .j = 2, }, + { .i = 11, .j = 3, }, + { .i = 11, .j = 4, }, + { .i = 11, .j = 5, }, + { .i = 11, .j = 6, }, +}; + +const struct circuit asym_butterfly_circuit = { + .name = "asym_butterfly", + .len = sizeof(asym_butterfly_tab)/sizeof(struct wp_coord), + .path = asym_butterfly_tab, +}; + +const struct wp_coord big_h_lambda_tab[] = { + { .i = 11, .j = 6, }, + { .i = 10, .j = 6, }, + { .i = 9, .j = 5, }, + { .i = 8, .j = 5, }, + { .i = 7, .j = 4, }, + { .i = 6, .j = 4, }, + { .i = 5, .j = 4, }, + { .i = 4, .j = 5, }, + { .i = 3, .j = 5, }, + { .i = 2, .j = 6, }, + { .i = 1, .j = 6, }, + { .i = 1, .j = 5, }, + { .i = 1, .j = 4, }, + { .i = 1, .j = 3, }, + { .i = 1, .j = 2, }, + { .i = 1, .j = 1, }, + { .i = 2, .j = 2, }, + { .i = 3, .j = 2, }, + { .i = 4, .j = 3, }, + { .i = 5, .j = 3, }, + { .i = 6, .j = 4, }, + { .i = 7, .j = 4, }, + { .i = 8, .j = 5, }, + { .i = 9, .j = 5, }, + { .i = 10, .j = 6, }, + { .i = 11, .j = 6, }, +}; + +const struct circuit big_h_lambda_circuit = { + .name = "big_h_lambda", + .len = sizeof(big_h_lambda_tab)/sizeof(struct wp_coord), + .path = big_h_lambda_tab, }; /* list of all possible circuits */ const struct circuit *circuits[] = { - &butterfly, - &small, + &butterfly_circuit, + &losange_circuit, + &triangle_circuit, + &answer_d_circuit, + &h_lambda_circuit, + &asym_butterfly_circuit, + &big_h_lambda_circuit, NULL, }; -- 2.39.5