From e93c0b1ae95cb338199c1cf7f180ac11beb5e798 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 15 May 2010 07:47:31 +0200 Subject: digital/io/src: go unloading if next food is far away --- digital/io/src/top.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'digital') diff --git a/digital/io/src/top.c b/digital/io/src/top.c index 7222bcc1..250c9f30 100644 --- a/digital/io/src/top.c +++ b/digital/io/src/top.c @@ -32,6 +32,8 @@ #include "chrono.h" #include "playground.h" +#include "modules/utils/utils.h" + uint8_t top_food; /** Maximum elements to load before unloading. */ @@ -59,6 +61,13 @@ top_collect (uint8_t force) return 0; vect_t food_v; food_pos (top_food, &food_v); + /* If loaded an next ball is far away, go unload. */ + if (loader_elements + && UTILS_ABS (food_v.x - robot_position.v.x) > 1000) + { + move_start_noangle (PG_VECT (2625, 253), 0, 0); + return 0; + } move_start_noangle (food_v, 0, food_shorten (top_food)); return 1; } -- cgit v1.2.3