summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--digital/avr/modules/path/Makefile.module1
-rw-r--r--digital/avr/modules/path/README25
-rw-r--r--digital/avr/modules/path/avrconfig.h38
-rw-r--r--digital/avr/modules/path/path.c (renamed from digital/io/src/path.c)21
-rw-r--r--digital/avr/modules/path/path.h (renamed from digital/io/src/path.h)20
-rw-r--r--digital/avr/modules/path/test/Makefile12
-rw-r--r--digital/avr/modules/path/test/avrconfig.h39
-rw-r--r--digital/avr/modules/path/test/test_path.c (renamed from digital/io/src/test_path.c)12
-rw-r--r--digital/io/src/Makefile8
-rw-r--r--digital/io/src/avrconfig.h10
-rw-r--r--digital/io/src/main.c2
-rw-r--r--digital/io/src/move_cb.c2
-rw-r--r--digital/io/src/simu.host.c1
-rw-r--r--digital/io/src/simu.host.h7
14 files changed, 165 insertions, 33 deletions
diff --git a/digital/avr/modules/path/Makefile.module b/digital/avr/modules/path/Makefile.module
new file mode 100644
index 00000000..9d537233
--- /dev/null
+++ b/digital/avr/modules/path/Makefile.module
@@ -0,0 +1 @@
+path_SOURCES = path.c
diff --git a/digital/avr/modules/path/README b/digital/avr/modules/path/README
new file mode 100644
index 00000000..618e4b79
--- /dev/null
+++ b/digital/avr/modules/path/README
@@ -0,0 +1,25 @@
+avr.path - Path finding module.
+
+Path finding among obstacles represented as circles. See modules README for
+more details about AVR modules.
+
+
+Copyright (C) 2008 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.
diff --git a/digital/avr/modules/path/avrconfig.h b/digital/avr/modules/path/avrconfig.h
new file mode 100644
index 00000000..9f25d772
--- /dev/null
+++ b/digital/avr/modules/path/avrconfig.h
@@ -0,0 +1,38 @@
+#ifndef avrconfig_h
+#define avrconfig_h
+/* avrconfig.h - Path module configuration template. */
+/* avr.path - Path finding module. {{{
+ *
+ * Copyright (C) 2008 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.
+ *
+ * }}} */
+
+/* path - Path finding module. */
+/** Report path found for debug. */
+#define AC_PATH_REPORT defined (HOST)
+/** Report function name. */
+#define AC_PATH_REPORT_CALLBACK path_report
+/** Number of possible obstacles. */
+#define AC_PATH_OBSTACLES_NB 2
+/** Number of points per obstacle. */
+#define AC_PATH_OBSTACLES_POINTS_NB 8
+
+#endif /* avrconfig_h */
diff --git a/digital/io/src/path.c b/digital/avr/modules/path/path.c
index 0cd8e331..30cc03f8 100644
--- a/digital/io/src/path.c
+++ b/digital/avr/modules/path/path.c
@@ -1,5 +1,5 @@
/* path.c - Find a path between obstables. */
-/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+/* avr.path - Path finding module. {{{
*
* Copyright (C) 2008 Nicolas Schodet
*
@@ -24,17 +24,20 @@
* }}} */
#include "common.h"
-#include "path.h"
-#include "simu.host.h"
-
#include "modules/math/fixed/fixed.h"
#include "modules/utils/utils.h"
+#include "path.h"
+
+#ifdef HOST
+# include <stdio.h>
+#endif
+
/** Number of possible obstacles. */
-#define PATH_OBSTACLES_NB 2
+#define PATH_OBSTACLES_NB AC_PATH_OBSTACLES_NB
/** Number of points per obstacle. */
-#define PATH_OBSTACLES_POINTS_NB 8
+#define PATH_OBSTACLES_POINTS_NB AC_PATH_OBSTACLES_POINTS_NB
/** Angle between obstacles points. */
#define PATH_OBSTACLES_POINTS_ANGLE ((1L << 24) / PATH_OBSTACLES_POINTS_NB)
@@ -287,7 +290,7 @@ path_update (void)
path_compute_points ();
path_compute_arcs ();
path_dijkstra ();
-#if defined (HOST)
+#if AC_PATH_REPORT
uint8_t len, i;
uint16_t points[PATH_POINTS_NB * 2];
len = 0;
@@ -296,8 +299,8 @@ path_update (void)
points[len++] = path.points[i].x;
points[len++] = path.points[i].y;
}
- simu_send_path (points, len, path.obstacles, PATH_OBSTACLES_NB);
-#endif
+ AC_PATH_REPORT_CALLBACK (points, len, path.obstacles, PATH_OBSTACLES_NB);
+#endif /* AC_PATH_REPORT */
}
/** Retrieve first path point coordinates. Return 0 on failure. */
diff --git a/digital/io/src/path.h b/digital/avr/modules/path/path.h
index a314fcec..8255bf65 100644
--- a/digital/io/src/path.h
+++ b/digital/avr/modules/path/path.h
@@ -1,7 +1,7 @@
#ifndef path_h
#define path_h
/* path.h */
-/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+/* avr.path - Path finding module. {{{
*
* Copyright (C) 2008 Nicolas Schodet
*
@@ -62,4 +62,22 @@ path_update (void);
uint8_t
path_get_next (uint16_t *x, uint16_t *y);
+#if AC_PATH_REPORT
+
+/** Report computed path. */
+void
+AC_PATH_REPORT_CALLBACK (uint16_t *points, uint8_t len,
+ struct path_obstacle_t *obstacles,
+ uint8_t obstacles_nb);
+
+#endif
+
+#ifdef HOST
+
+/** Output graph in Graphviz format. */
+void
+path_print_graph (void);
+
+#endif
+
#endif /* path_h */
diff --git a/digital/avr/modules/path/test/Makefile b/digital/avr/modules/path/test/Makefile
new file mode 100644
index 00000000..698ee538
--- /dev/null
+++ b/digital/avr/modules/path/test/Makefile
@@ -0,0 +1,12 @@
+BASE = ../../..
+HOST_PROGS = test_path
+test_path_SOURCES = test_path.c
+MODULES = path math/fixed utils
+CONFIGFILE = avrconfig.h
+# atmega8, atmega8535, atmega128...
+AVR_MCU = atmega128
+# -O2 : speed
+# -Os : size
+OPTIMIZE = -O2
+
+include $(BASE)/make/Makefile.gen
diff --git a/digital/avr/modules/path/test/avrconfig.h b/digital/avr/modules/path/test/avrconfig.h
new file mode 100644
index 00000000..476fee86
--- /dev/null
+++ b/digital/avr/modules/path/test/avrconfig.h
@@ -0,0 +1,39 @@
+#ifndef avrconfig_h
+#define avrconfig_h
+/* avrconfig.h - Path module configuration template. */
+/* avr.path - Path finding module. {{{
+ *
+ * Copyright (C) 2008 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.
+ *
+ * }}} */
+
+/* path - Path finding module. */
+/** Report path found for debug. */
+#define AC_PATH_REPORT defined (HOST)
+/** Report function name. */
+#define AC_PATH_REPORT_CALLBACK path_report
+/** Number of possible obstacles. */
+#define AC_PATH_OBSTACLES_NB 2
+/** Number of points per obstacle. */
+#define AC_PATH_OBSTACLES_POINTS_NB 8
+
+
+#endif /* avrconfig_h */
diff --git a/digital/io/src/test_path.c b/digital/avr/modules/path/test/test_path.c
index 1ec8c533..8b88e5d7 100644
--- a/digital/io/src/test_path.c
+++ b/digital/avr/modules/path/test/test_path.c
@@ -1,5 +1,5 @@
/* test_path.c */
-/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
+/* avr.path - Path finding module. {{{
*
* Copyright (C) 2008 Nicolas Schodet
*
@@ -23,14 +23,10 @@
*
* }}} */
#include "common.h"
-#include "path.h"
-#include "simu.host.h"
+#include "modules/path/path.h"
#include <stdio.h>
-void
-path_print_graph (void);
-
int
main (void)
{
@@ -49,8 +45,8 @@ main (void)
}
void
-simu_send_path (uint16_t *points, uint8_t len,
- struct path_obstacle_t *obstacles, uint8_t obstacles_nb)
+path_report (uint16_t *points, uint8_t len,
+ struct path_obstacle_t *obstacles, uint8_t obstacles_nb)
{
}
diff --git a/digital/io/src/Makefile b/digital/io/src/Makefile
index e230bc89..f668777f 100644
--- a/digital/io/src/Makefile
+++ b/digital/io/src/Makefile
@@ -1,6 +1,5 @@
BASE = ../../avr
PROGS = io
-HOST_PROGS = test_path
io_SOURCES = main.c asserv.c servo.avr.c eeprom.avr.c trap.c sharp.c \
switch.avr.c chrono.c \
simu.host.c \
@@ -8,11 +7,8 @@ io_SOURCES = main.c asserv.c servo.avr.c eeprom.avr.c trap.c sharp.c \
getsamples.c getsamples_fsm.c getsamples_cb.c \
gutter_fsm.c gutter_cb.c gutter.c \
move.c move_fsm.c move_cb.c \
- top.c top_fsm.c top_cb.c \
- path.c
-test_path_SOURCES = test_path.c path.c
-MODULES = proto uart twi utils adc math/fixed
-test_path_MODULES = math/fixed
+ top.c top_fsm.c top_cb.c
+MODULES = proto uart twi utils adc math/fixed path
CONFIGFILE = avrconfig.h
# atmega8, atmega8535, atmega128...
AVR_MCU = atmega128
diff --git a/digital/io/src/avrconfig.h b/digital/io/src/avrconfig.h
index f24fae76..fe2208a3 100644
--- a/digital/io/src/avrconfig.h
+++ b/digital/io/src/avrconfig.h
@@ -89,6 +89,16 @@
/** Activate slave part. */
#define AC_TWI_SLAVE_ENABLE 0
+/* path - Path finding module. */
+/** Report path found for debug. */
+#define AC_PATH_REPORT defined (HOST)
+/** Report function name. */
+#define AC_PATH_REPORT_CALLBACK simu_send_path
+/** Number of possible obstacles. */
+#define AC_PATH_OBSTACLES_NB 2
+/** Number of points per obstacle. */
+#define AC_PATH_OBSTACLES_POINTS_NB 8
+
/* io - io/ai board. */
/** TWI address of the io board. */
#define AC_IO_TWI_ADDRESS 2
diff --git a/digital/io/src/main.c b/digital/io/src/main.c
index 05fb68b5..3203675d 100644
--- a/digital/io/src/main.c
+++ b/digital/io/src/main.c
@@ -27,6 +27,7 @@
#include "modules/uart/uart.h"
#include "modules/proto/proto.h"
#include "modules/utils/utils.h"
+#include "modules/path/path.h"
/* AVR include, non HOST */
#ifndef HOST
@@ -46,7 +47,6 @@
#include "chrono.h" /* chrono_end_match */
#include "gutter.h" /* gutter_generate_wait_finished_event */
#include "sharp.h" /* sharp module */
-#include "path.h" /* path module */
#include "playground.h"
#include "io.h"
diff --git a/digital/io/src/move_cb.c b/digital/io/src/move_cb.c
index a70e61ab..ec5f6715 100644
--- a/digital/io/src/move_cb.c
+++ b/digital/io/src/move_cb.c
@@ -26,7 +26,6 @@
#include "fsm.h"
#include "move_cb.h"
-#include "path.h"
#include "asserv.h"
#include "playground.h"
#include "move.h"
@@ -34,6 +33,7 @@
#include "main.h" /* main_post_event_for_top_fsm */
#include "modules/math/fixed/fixed.h" /* fixed_* */
+#include "modules/path/path.h"
#include "debug.host.h"
diff --git a/digital/io/src/simu.host.c b/digital/io/src/simu.host.c
index cce7711b..99870e74 100644
--- a/digital/io/src/simu.host.c
+++ b/digital/io/src/simu.host.c
@@ -32,6 +32,7 @@
#include "modules/host/host.h"
#include "modules/host/mex.h"
#include "modules/adc/adc.h"
+#include "modules/path/path.h"
enum
{
diff --git a/digital/io/src/simu.host.h b/digital/io/src/simu.host.h
index 8e0243d1..bbd5c218 100644
--- a/digital/io/src/simu.host.h
+++ b/digital/io/src/simu.host.h
@@ -27,8 +27,6 @@
#ifdef HOST
-#include "path.h"
-
/** Hooked, initialise the host simulation. */
void
main_timer_init (void);
@@ -53,11 +51,6 @@ switch_get_color (void);
uint8_t
switch_get_jack (void);
-/** Send computed path. */
-void
-simu_send_path (uint16_t *points, uint8_t len,
- struct path_obstacle_t *obstacles, uint8_t obstacles_nb);
-
#endif /* defined (HOST) */
#endif /* simu_host_h */