summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--digital/io-hub/src/common/debug_draw.host.c6
-rw-r--r--digital/io-hub/src/common/debug_draw.host.h4
-rw-r--r--digital/io-hub/src/guybrush/strat.c15
-rw-r--r--digital/io-hub/tools/io_hub/mex.py3
-rw-r--r--host/simu/view/debug_draw.py2
5 files changed, 30 insertions, 0 deletions
diff --git a/digital/io-hub/src/common/debug_draw.host.c b/digital/io-hub/src/common/debug_draw.host.c
index ea743bad..a6b7e7ba 100644
--- a/digital/io-hub/src/common/debug_draw.host.c
+++ b/digital/io-hub/src/common/debug_draw.host.c
@@ -74,3 +74,9 @@ debug_draw_point (const vect_t *p, uint8_t color)
mex_msg_push (debug_draw_msg, "Bhhb", 'p', p->x, p->y, color);
}
+void
+debug_draw_number (const vect_t *p, int32_t number)
+{
+ mex_msg_push (debug_draw_msg, "Bhhl", 'n', p->x, p->y, number);
+}
+
diff --git a/digital/io-hub/src/common/debug_draw.host.h b/digital/io-hub/src/common/debug_draw.host.h
index fe46e80a..e9ebb738 100644
--- a/digital/io-hub/src/common/debug_draw.host.h
+++ b/digital/io-hub/src/common/debug_draw.host.h
@@ -53,6 +53,10 @@ debug_draw_segment (const vect_t *p1, const vect_t *p2, uint8_t color);
void
debug_draw_point (const vect_t *p, uint8_t color);
+/** Append a debug number. */
+void
+debug_draw_number (const vect_t *p, int32_t number);
+
#endif
#endif /* debug_draw_host_h */
diff --git a/digital/io-hub/src/guybrush/strat.c b/digital/io-hub/src/guybrush/strat.c
index 47f9c4bc..b5736687 100644
--- a/digital/io-hub/src/guybrush/strat.c
+++ b/digital/io-hub/src/guybrush/strat.c
@@ -33,6 +33,12 @@
#include "asserv.h"
#include "chrono.h"
+#define STRAT_DEBUG_DRAW 0
+
+#if STRAT_DEBUG_DRAW
+#include "debug_draw.host.h"
+#endif
+
/*
* This file implements strategic decisions.
*/
@@ -249,6 +255,9 @@ strat_decision (vect_t *pos)
*pos = strat.prepared_pos;
return strat.last_decision;
}
+#if STRAT_DEBUG_DRAW
+ debug_draw_start ();
+#endif
/* Else compute the best decision. */
uint16_t path_score[STRAT_PLACE_NB];
strat_path_score_prepare (path_score);
@@ -260,7 +269,13 @@ strat_decision (vect_t *pos)
best_score = score;
best_place = i;
}
+#if STRAT_DEBUG_DRAW
+ debug_draw_number (&strat_place[i].pos, score);
+#endif
}
+#if STRAT_DEBUG_DRAW
+ debug_draw_send ();
+#endif
if (best_score != -1)
{
*pos = strat_place[best_place].pos;
diff --git a/digital/io-hub/tools/io_hub/mex.py b/digital/io-hub/tools/io_hub/mex.py
index 989a992c..ba141b99 100644
--- a/digital/io-hub/tools/io_hub/mex.py
+++ b/digital/io-hub/tools/io_hub/mex.py
@@ -245,6 +245,9 @@ class Mex:
elif t == 'p':
x, y, c = msg.pop ('hhb')
self.drawing.append (['point', x, y, c])
+ elif t == 'n':
+ x, y, t = msg.pop ('hhl')
+ self.drawing.append (['text', x, y, str (t)])
else:
raise ValueError
self.notify ()
diff --git a/host/simu/view/debug_draw.py b/host/simu/view/debug_draw.py
index 9c1ea66c..bc82baef 100644
--- a/host/simu/view/debug_draw.py
+++ b/host/simu/view/debug_draw.py
@@ -51,6 +51,8 @@ class DebugDraw (Drawable):
(x - s, y - s), (x + s, y + s),
(x - s, y + s), (x + s, y - s),
(x - s, y - s), fill = self.__colors[d[3]])
+ elif d[0] == 'text':
+ self.draw_text ((d[1], d[2]), text = d[3])
else:
raise ValueError