summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2010-05-14 06:53:40 +0200
committerNicolas Schodet2010-05-14 06:53:40 +0200
commit4bb5b4ac79cb486fef1a05fbdc6baedf51a0b152 (patch)
tree85e554fa1ae71aab00962e2bb0382ff0d3b954a2
parent55b751937aec298da2f055fd9d1f8f622828a78a (diff)
digital/io/src: slow down when not on the grid
-rw-r--r--digital/io/src/ai_move_cb.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/digital/io/src/ai_move_cb.c b/digital/io/src/ai_move_cb.c
index a61a1058..e250d010 100644
--- a/digital/io/src/ai_move_cb.c
+++ b/digital/io/src/ai_move_cb.c
@@ -49,6 +49,13 @@
#define MOVE_LOADER_UNBLOCKING_DISTANCE 70
+/** Used to define a grid. If robot is outside the grid, be careful. */
+#define MOVE_GRID_X 450
+#define MOVE_GRID_X_ORIGIN 150
+#define MOVE_GRID_Y 250
+#define MOVE_GRID_Y_ORIGIN 128
+#define MOVE_GRID_MARGIN 50
+
/** Go to current step, low level function. */
static void
move_go (void)
@@ -170,6 +177,15 @@ move_path_init (void)
path_update ();
found = path_get_next (&dst);
}
+ /* If not on the grid, slow down. */
+ int16_t mx = current_pos.v.x % MOVE_GRID_X;
+ int16_t my = current_pos.v.y % MOVE_GRID_Y;
+ if (mx < MOVE_GRID_X_ORIGIN - MOVE_GRID_MARGIN
+ || mx > MOVE_GRID_X_ORIGIN + MOVE_GRID_MARGIN
+ || my < MOVE_GRID_Y_ORIGIN - MOVE_GRID_MARGIN
+ || my > MOVE_GRID_Y_ORIGIN + MOVE_GRID_MARGIN
+ )
+ move_data.slow = 1;
/* If found, go. */
if (found)
{