summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNicolas Schodet2011-05-02 22:48:05 +0200
committerNicolas Schodet2011-05-02 23:41:01 +0200
commit092057218111adb25119f0099c5ad951a5b10d69 (patch)
treedfd424b020beab0c23f16e54db933e5142ea5ac8 /digital
parente1fe5825a148f6713d20c90c10f8f1aea0cdc47c (diff)
digital/{ai,io}: move defines to ai
Diffstat (limited to 'digital')
-rw-r--r--digital/ai/src/common/debug.host.h (renamed from digital/io/src/debug.host.h)10
-rw-r--r--digital/ai/src/common/defs.h (renamed from digital/io/src/defs.h)12
-rw-r--r--digital/ai/src/common/playground.h64
-rw-r--r--digital/io/src/Makefile2
-rw-r--r--digital/io/src/bot.h14
-rw-r--r--digital/io/src/init.c4
-rw-r--r--digital/io/src/main.c4
-rw-r--r--digital/io/src/playground.h96
-rw-r--r--digital/io/src/playground_2010.h46
-rw-r--r--digital/io/src/radar.c3
-rw-r--r--digital/io/src/switch.avr.c2
-rw-r--r--digital/io/src/switch.h3
-rw-r--r--digital/io/src/top.c1
13 files changed, 136 insertions, 125 deletions
diff --git a/digital/io/src/debug.host.h b/digital/ai/src/common/debug.host.h
index 4930b937..3fb7e23f 100644
--- a/digital/io/src/debug.host.h
+++ b/digital/ai/src/common/debug.host.h
@@ -1,7 +1,7 @@
#ifndef debug_host_h
#define debug_host_h
/* debug.host.h */
-/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+/* ai - Robot Artificial Intelligence. {{{
*
* Copyright (C) 2008 Dufour Jérémy
*
@@ -26,17 +26,17 @@
* }}} */
/**
- * @file Debug printf functions.
+ * Debug printf functions.
* This module include a macro to add some debug functions to printf a message
* under host target. It does nothing under avr target.
*/
#ifdef HOST
-#include <stdio.h>
-#define DPRINTF(format, args...) \
+# include <stdio.h>
+# define DPRINTF(format, args...) \
do { fprintf (stderr, (format), ## args); } while (0)
#else /* HOST */
-#define DPRINTF(format, args...)
+# define DPRINTF(format, args...)
#endif /* HOST */
#endif /* debug_host_h */
diff --git a/digital/io/src/defs.h b/digital/ai/src/common/defs.h
index d80ff96d..f16e9e52 100644
--- a/digital/io/src/defs.h
+++ b/digital/ai/src/common/defs.h
@@ -1,7 +1,7 @@
#ifndef defs_h
#define defs_h
/* defs.h */
-/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+/* ai - Robot Artificial Intelligence. {{{
*
* Copyright (C) 2010 Nicolas Schodet
*
@@ -43,4 +43,14 @@ typedef struct position_t position_t;
/** Convert degrees to an angle usable in position_t. */
#define POSITION_A_DEG(a) G_ANGLE_UF016_DEG (a)
+/** Team color, determine the start zone side. */
+enum team_color_e
+{
+ TEAM_COLOR_LEFT = 0,
+ TEAM_COLOR_RIGHT = 1
+};
+
+/** Current team color, to be read at start up. */
+extern enum team_color_e team_color;
+
#endif /* defs_h */
diff --git a/digital/ai/src/common/playground.h b/digital/ai/src/common/playground.h
new file mode 100644
index 00000000..18c81ecf
--- /dev/null
+++ b/digital/ai/src/common/playground.h
@@ -0,0 +1,64 @@
+#ifndef playground_h
+#define playground_h
+/* playground.h */
+/* ai - Robot Artificial Intelligence. {{{
+ *
+ * Copyright (C) 2011 Nicolas Schodet
+ *
+ * APBTeam:
+ * Web: http://apbteam.org/
+ * Email: team AT apbteam DOT org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+#include "defs.h"
+
+/**
+ * Define playground constant data and playground macro to define position and
+ * angle depending of the current team color.
+ */
+
+/** Playground width, mm. */
+#define PG_WIDTH 3000
+
+/** Playground length, mm. */
+#define PG_LENGTH 2100
+
+/** Distance to playground borders for general movements, mm. */
+#define PG_BORDER_DISTANCE 250
+
+/** Return X coordinate, applying symmetry according to team color. */
+#define PG_X(x) (team_color ? (x) : PG_WIDTH - (x))
+
+/** Same as PG_Y, but for Y coordinate. Actually nothing is done, there is no
+ * symmetry. */
+#define PG_Y(y) (y)
+
+/** Return an angle, applying symmetry according to team color. Takes degrees as
+ * input. */
+#define PG_A_DEG(a) \
+ (team_color ? POSITION_A_DEG (a) : POSITION_A_DEG (180 - (a)))
+
+/** Initialiser for position_t applying symmetry according to color. Takes
+ * degrees for angle. */
+#define PG_POSITION_DEG(x, y, a) \
+ { { PG_X (x), PG_Y (y) }, PG_A_DEG (a) }
+
+/** Initialiser for vect_t applying symmetry according to color. */
+#define PG_VECT(x, y) \
+ (vect_t) { PG_X (x), PG_Y (y) }
+
+#endif /* playground_h */
diff --git a/digital/io/src/Makefile b/digital/io/src/Makefile
index 8e9a6888..7ac4eefe 100644
--- a/digital/io/src/Makefile
+++ b/digital/io/src/Makefile
@@ -12,7 +12,7 @@ io_SOURCES = main.c servo.avr.c eeprom.avr.c pwm.c \
# Modules needed for IO.
MODULES = proto uart twi utils adc math/fixed math/geometry path/astar \
trace flash spi
-AI_MODULES = twi_master
+AI_MODULES = twi_master common
# Configuration file.
CONFIGFILE = avrconfig.h
# IO board use an ATMega128.
diff --git a/digital/io/src/bot.h b/digital/io/src/bot.h
index 06f6559b..01515574 100644
--- a/digital/io/src/bot.h
+++ b/digital/io/src/bot.h
@@ -128,18 +128,4 @@
/** Gate stroke in steps. */
#define BOT_GATE_STROKE_STEP -0x203e
-/**
- * Definition of the colors.
- */
-enum team_color_e
-{
- RED_TEAM = 0,
- BLUE_TEAM = 1
-};
-
-/**
- * Our color.
- */
-extern enum team_color_e bot_color;
-
#endif /* bot_h */
diff --git a/digital/io/src/init.c b/digital/io/src/init.c
index 4cb2bcd9..58c94333 100644
--- a/digital/io/src/init.c
+++ b/digital/io/src/init.c
@@ -28,7 +28,7 @@
#include "fsm.h"
#include "asserv.h"
#include "init.h"
-#include "playground.h"
+#include "playground_2010.h"
#include "main.h"
#include "bot.h"
#include "switch.h"
@@ -107,7 +107,7 @@ FSM_TRANS (INIT_WAIT_FIRST_JACK_OUT,
/* Initialize trace module (erase the flash). */
trace_init ();
/* Get the color. */
- bot_color = switch_get_color ();
+ team_color = switch_get_color ();
return FSM_NEXT (INIT_WAIT_FIRST_JACK_OUT, jack_removed_from_bot);
}
diff --git a/digital/io/src/main.c b/digital/io/src/main.c
index dc98d12d..b29d1fea 100644
--- a/digital/io/src/main.c
+++ b/digital/io/src/main.c
@@ -54,7 +54,7 @@
#include "radar.h"
#include "chrono.h" /* chrono_end_match */
#include "pwm.h"
-#include "playground.h"
+#include "playground_2010.h"
#include "contact.h"
#include "init.h"
#include "move.h"
@@ -76,7 +76,7 @@ static void main_loop (void);
/**
* Our color.
*/
-enum team_color_e bot_color;
+enum team_color_e team_color;
/** Maximum number of events in post queue. */
#define MAIN_POST_EVENT_QUEUE_SIZE 8
diff --git a/digital/io/src/playground.h b/digital/io/src/playground.h
deleted file mode 100644
index 5c251ce5..00000000
--- a/digital/io/src/playground.h
+++ /dev/null
@@ -1,96 +0,0 @@
-#ifndef playground_h
-#define playground_h
-// playground.h
-// io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
-//
-// Copyright (C) 2008 Dufour Jérémy
-//
-// Robot APB Team/Efrei 2004.
-// Web: http://assos.efrei.fr/robot/
-// Email: robot AT efrei DOT fr
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-//
-// }}}
-
-/**
- * @file Some defines for the playground.
- * For example, you can find the size of the table, the positions of the
- * distributors, ...
- * A few important remarks:
- * - the (0,0) position is the bottom left position on the table (when you
- * see it with the two start zone at the top of the scheme).
- */
-
-#include "defs.h"
-#include "bot.h"
-
-/**
- * The width of the table, in millimeters.
- */
-#define PG_WIDTH 3000
-
-/**
- * The length of the table, in millimeters.
- */
-#define PG_LENGTH 2100
-
-/**
- * The distance from table border for movements.
- */
-#define PG_BORDER_DISTANCE 250
-
-/**
- * Considering there is a symmetry axis on X, this macro will compute the
- * value for on the X axis depending on the color.
- */
-#define PG_X(x) (bot_color ? (x) : PG_WIDTH - (x))
-
-/** Same as PG_Y, but for Y coordinate. Actually nothing is done, there is no
- * symmetry. */
-#define PG_Y(y) (y)
-
-/**
- * Considering there is a symmetry axis on X, this macro will compute the
- * value of the angle depending on the color.
- *
- * Takes degrees as input.
- */
-#define PG_A_DEG(a) \
- (bot_color ? POSITION_A_DEG (a) : POSITION_A_DEG (180 - (a)))
-
-/** Initialiser for position_t applying symmetry according to color. Takes
- * degrees for angle. */
-#define PG_POSITION_DEG(x, y, a) \
- { { PG_X (x), PG_Y (y) }, PG_A_DEG (a) }
-
-/** Initialiser for vect_t applying symmetry according to color. */
-#define PG_VECT(x, y) \
- (vect_t) { PG_X (x), PG_Y (y) }
-
-/**
- * Start zone.
- */
-#define PG_START_ZONE_LENGTH 500
-#define PG_START_ZONE_WIDTH 500
-
-/** Size of the unclimbable slope zone (Eurobot 2010). */
-#define PG_SLOPE_WIDTH (500 + 519 + 500)
-#define PG_SLOPE_LENGTH (500 + 22)
-
-/** Start of field zone. */
-#define PG_FIELD_Y_MAX 1128
-
-#endif // playground_h
diff --git a/digital/io/src/playground_2010.h b/digital/io/src/playground_2010.h
new file mode 100644
index 00000000..11682c5e
--- /dev/null
+++ b/digital/io/src/playground_2010.h
@@ -0,0 +1,46 @@
+#ifndef playground_2010_h
+#define playground_2010_h
+/* playground_2010.h */
+/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+ *
+ * Copyright (C) 2008 Dufour Jérémy
+ *
+ * APBTeam:
+ * Web: http://apbteam.org/
+ * Email: team AT apbteam DOT org
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * }}} */
+#include "playground.h"
+
+/**
+ * Eurobot 2010 specific defines.
+ */
+
+/**
+ * Start zone.
+ */
+#define PG_START_ZONE_LENGTH 500
+#define PG_START_ZONE_WIDTH 500
+
+/** Size of the unclimbable slope zone. */
+#define PG_SLOPE_WIDTH (500 + 519 + 500)
+#define PG_SLOPE_LENGTH (500 + 22)
+
+/** Start of field zone. */
+#define PG_FIELD_Y_MAX 1128
+
+#endif /* playground_2010_h */
diff --git a/digital/io/src/radar.c b/digital/io/src/radar.c
index 1ba2a437..1ac982c7 100644
--- a/digital/io/src/radar.c
+++ b/digital/io/src/radar.c
@@ -25,7 +25,8 @@
#include "common.h"
#include "radar.h"
-#include "playground.h"
+#include "playground_2010.h"
+#include "bot.h"
#include "usdist.h"
#include "modules/math/geometry/geometry.h"
diff --git a/digital/io/src/switch.avr.c b/digital/io/src/switch.avr.c
index 659b597a..9907a86f 100644
--- a/digital/io/src/switch.avr.c
+++ b/digital/io/src/switch.avr.c
@@ -22,10 +22,10 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* }}} */
+#include "common.h"
#include "switch.h"
-#include "common.h"
#include "modules/utils/utils.h" /* set_bit */
#include "io.h" /* PORT/PIN, bit_is_set */
diff --git a/digital/io/src/switch.h b/digital/io/src/switch.h
index ac8d7dbc..9a804d1b 100644
--- a/digital/io/src/switch.h
+++ b/digital/io/src/switch.h
@@ -29,8 +29,7 @@
* @file Module to manage 'switchs'. For example, colors selector and jack.
*/
-#include "bot.h"
-#include "common.h"
+#include "defs.h"
/**
* Initialize the switch module.
diff --git a/digital/io/src/top.c b/digital/io/src/top.c
index bc6eb20e..e899d718 100644
--- a/digital/io/src/top.c
+++ b/digital/io/src/top.c
@@ -35,6 +35,7 @@
#include "move.h"
#include "chrono.h"
#include "playground.h"
+#include "bot.h"
#include "modules/utils/utils.h"