From 73355963b34f3aa6e6d34030787f782aaa868981 Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Sat, 9 Jun 2012 21:04:48 +0200 Subject: digital/io-hub, host/simu: add strat scores as debug draw --- digital/io-hub/src/common/debug_draw.host.c | 6 ++++++ digital/io-hub/src/common/debug_draw.host.h | 4 ++++ digital/io-hub/src/guybrush/strat.c | 15 +++++++++++++++ digital/io-hub/tools/io_hub/mex.py | 3 +++ 4 files changed, 28 insertions(+) (limited to 'digital/io-hub') 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 () -- cgit v1.2.3