summaryrefslogtreecommitdiffhomepage
path: root/digital/io-hub/src/robospierre/logistic.c
diff options
context:
space:
mode:
Diffstat (limited to 'digital/io-hub/src/robospierre/logistic.c')
-rw-r--r--digital/io-hub/src/robospierre/logistic.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/digital/io-hub/src/robospierre/logistic.c b/digital/io-hub/src/robospierre/logistic.c
index 1e44d675..35e40efa 100644
--- a/digital/io-hub/src/robospierre/logistic.c
+++ b/digital/io-hub/src/robospierre/logistic.c
@@ -250,6 +250,33 @@ logistic_put_element ()
}
}
+/** If we picked up a tower. */
+static void
+logistic_new_tower ()
+{
+ uint8_t dir_bay, nodir_bay;
+ if (ctx.collect_direction == DIRECTION_FORWARD)
+ {
+ dir_bay = CLAMP_SLOT_FRONT_BOTTOM;
+ nodir_bay = CLAMP_SLOT_BACK_BOTTOM;
+ }
+ else
+ {
+ dir_bay = CLAMP_SLOT_BACK_BOTTOM;
+ nodir_bay = CLAMP_SLOT_FRONT_BOTTOM;
+ }
+ if (ctx.slots[dir_bay] == ELEMENT_TOWER)
+ {
+ ctx.ready = 1;
+ if (ctx.collect_direction == DIRECTION_FORWARD)
+ ctx.collect_direction = DIRECTION_BACKWARD;
+ else
+ ctx.collect_direction = DIRECTION_FORWARD;
+ }
+ if (ctx.slots[nodir_bay] == ELEMENT_TOWER)
+ ctx.ready = 1;
+}
+
/** Examine current state and take a decision. */
static void
logistic_decision (void)
@@ -268,6 +295,11 @@ logistic_decision (void)
if (ctx.prepare == 3)
return;
+ /* We founded a tower ! */
+ logistic_new_tower ();
+ if (ctx.ready)
+ return;
+
/* Check if we really need to prepare something. */
logistic_check_need_prepare ();
@@ -359,7 +391,7 @@ logistic_decision (void)
return;
}
/* We have to prepare an element to put out. */
- else if ((ctx.prepare == 2 || ctx.need_prepare) && ctx.construct_possible)
+ else if (ctx.prepare == 2 && ctx.construct_possible)
{
logistic_put_element ();
}