summaryrefslogtreecommitdiff
path: root/digital/avr/modules/path/test
diff options
context:
space:
mode:
authorNicolas Schodet2009-08-18 01:55:12 +0200
committerNicolas Schodet2009-08-18 01:55:12 +0200
commit3c8372708ae4c9676c7102358b6858117dae2c78 (patch)
tree797c890d61d5ff730c0346fbd6137dea4878bf4c /digital/avr/modules/path/test
parent1145f47faf3c4841c89446e6730ecea2eea4c290 (diff)
* digital/avr/modules/path (closes #81):
- added escaping to avoid being blocked if inside an obstacle. - added obstacle factor to avoid a zone.
Diffstat (limited to 'digital/avr/modules/path/test')
-rw-r--r--digital/avr/modules/path/test/test_path.c21
-rw-r--r--digital/avr/modules/path/test/test_path.py24
2 files changed, 30 insertions, 15 deletions
diff --git a/digital/avr/modules/path/test/test_path.c b/digital/avr/modules/path/test/test_path.c
index 87c049d7..218a3183 100644
--- a/digital/avr/modules/path/test/test_path.c
+++ b/digital/avr/modules/path/test/test_path.c
@@ -32,12 +32,14 @@ void
syntax (void)
{
fprintf (stderr,
- "test_path borders source destination [obstacles (0-%d)]\n"
+ "test_path borders source destination escape_factor"
+ " [obstacles (0-%d)]\n"
" borders: xmin,ymin,xmax,ymax\n"
" source, destination: x,y\n"
- " obstacles: x,y,r\n"
- "example: test_path 0,0,1500,1500 300,750 1200,750 600,680,100"
- " 900,820,100\n",
+ " obstacles: x,y,r,f\n"
+ "example: test_path 0,0,1500,1500 300,750 1200,750 0"
+ " 600,680,100,0"
+ " 900,820,100,10\n",
AC_PATH_OBSTACLES_NB);
exit (1);
}
@@ -67,7 +69,7 @@ read_tab (const char *s, int *tab, int n)
int
main (int argc, char **argv)
{
- if (argc < 4 || argc > 4 + AC_PATH_OBSTACLES_NB)
+ if (argc < 5 || argc > 5 + AC_PATH_OBSTACLES_NB)
syntax ();
int tab[4];
read_tab (argv[1], tab, 4);
@@ -75,11 +77,14 @@ main (int argc, char **argv)
read_tab (argv[2], tab, 2);
read_tab (argv[3], tab + 2, 2);
path_endpoints (tab[0], tab[1], tab[2], tab[3]);
+ read_tab (argv[4], tab, 1);
+ if (tab[0])
+ path_escape (tab[0]);
int i;
- for (i = 0; i + 4 < argc; i++)
+ for (i = 0; i + 5 < argc; i++)
{
- read_tab (argv[4 + i], tab, 3);
- path_obstacle (i, tab[0], tab[1], tab[2], 1);
+ read_tab (argv[5 + i], tab, 4);
+ path_obstacle (i, tab[0], tab[1], tab[2], tab[3], 1);
}
path_update ();
path_print_graph ();
diff --git a/digital/avr/modules/path/test/test_path.py b/digital/avr/modules/path/test/test_path.py
index f4654519..58939ff6 100644
--- a/digital/avr/modules/path/test/test_path.py
+++ b/digital/avr/modules/path/test/test_path.py
@@ -29,9 +29,10 @@ from simu.inter.drawable import *
from subprocess import Popen, PIPE
class Obstacle:
- def __init__ (self, pos, radius):
+ def __init__ (self, pos, radius, factor):
self.pos = pos
self.radius = radius
+ self.factor = factor
def move (self, pos):
self.pos = pos
@@ -45,6 +46,7 @@ class Area (Drawable):
self.border = None
self.src = None
self.dst = None
+ self.escape = 0
self.obstacles = [ ]
self.path = [ ]
self.points = { }
@@ -56,7 +58,8 @@ class Area (Drawable):
self.draw_rectangle (self.border_min, self.border_max, fill = 'white')
for o in self.obstacles:
if o.pos is not None:
- self.draw_circle (o.pos, o.radius, fill = 'gray25')
+ self.draw_circle (o.pos, o.radius,
+ fill = o.factor and 'gray50' or 'gray25')
if self.src is not None:
self.draw_circle (self.src, 10, fill = 'green')
if self.dst is not None:
@@ -72,14 +75,14 @@ class Area (Drawable):
def test (self):
self.src = (300, 750)
self.dst = (1200, 750)
- self.obstacles.append (Obstacle ((600, 680), 100))
- self.obstacles.append (Obstacle ((900, 820), 100))
+ self.obstacles.append (Obstacle ((600, 680), 100, 0))
+ self.obstacles.append (Obstacle ((900, 820), 100, 5))
def update (self):
args = [ [ self.border_min[0], self.border_min[1], self.border_max[0],
- self.border_max[1] ], self.src, self.dst ]
+ self.border_max[1] ], self.src, self.dst, (self.escape, ) ]
for o in self.obstacles:
- args.append ([o.pos[0], o.pos[1], o.radius])
+ args.append ([o.pos[0], o.pos[1], o.radius, o.factor])
args = [ ','.join (str (ai) for ai in a) for a in args ]
args[0:0] = [ './test_path.host' ]
p = Popen (args, stdout = PIPE)
@@ -141,6 +144,10 @@ class TestPath (Frame):
variable = self.arcsVar, command = self.arcs_toggle,
text = 'Arcs', indicatoron = True)
self.arcsButton.pack (side = 'top')
+ self.escapeScale = Scale (self.rightFrame, label = 'Escape',
+ orient = 'horizontal', from_ = 0, to = 16,
+ command = self.escape_changed)
+ self.escapeScale.pack (side = 'top')
self.areaview = AreaView (border_min, border_max, self)
self.areaview.pack (expand = True, fill = 'both')
self.areaview.bind ('<1>', self.click)
@@ -183,9 +190,12 @@ class TestPath (Frame):
def arcs_toggle (self):
self.areaview.area.draw_arcs = self.arcsVar.get () != 0
- print self.areaview.area.draw_arcs
self.areaview.area.draw ()
+ def escape_changed (self, value):
+ self.areaview.area.escape = value
+ self.update ()
+
if __name__ == '__main__':
app = TestPath ((0, 0), (1500, 1500))
app.mainloop ()