summaryrefslogtreecommitdiff
path: root/digital
diff options
context:
space:
mode:
authorNicolas Schodet2009-06-11 23:59:15 +0200
committerNicolas Schodet2009-06-11 23:59:15 +0200
commit39c427bfce5dfc2dc7037e3f4a80dca78c10db47 (patch)
tree16694d8215d76fc9453e9dbf676b2753bc59e3ff /digital
parent4dfa6d669a891d46bbfc95dcfeaf94ebf8dbeb6b (diff)
* digital/avr/modules/path:
- fixed minor typos. - added arcs display in test.
Diffstat (limited to 'digital')
-rw-r--r--digital/avr/modules/path/path.h2
-rw-r--r--digital/avr/modules/path/path.txt2
-rw-r--r--digital/avr/modules/path/test/test_path.c4
-rw-r--r--digital/avr/modules/path/test/test_path.py36
4 files changed, 39 insertions, 5 deletions
diff --git a/digital/avr/modules/path/path.h b/digital/avr/modules/path/path.h
index 8255bf65..6f41b1d0 100644
--- a/digital/avr/modules/path/path.h
+++ b/digital/avr/modules/path/path.h
@@ -46,7 +46,7 @@ void
path_endpoints (int16_t sx, int16_t sy, int16_t dx, int16_t dy);
/** Set up an obstacle at given position with the given radius and validity
- * period. */
+ * period, use 0xffff for infinite validity. */
void
path_obstacle (uint8_t i, int16_t x, int16_t y, uint16_t r, uint16_t valid);
diff --git a/digital/avr/modules/path/path.txt b/digital/avr/modules/path/path.txt
index 0881e1f6..0d87f3d6 100644
--- a/digital/avr/modules/path/path.txt
+++ b/digital/avr/modules/path/path.txt
@@ -40,7 +40,7 @@ This interface only gives you the first point of the path because it is
assumed that the path will not be up to date any more once the mobile arrives
at the first point. This will change in the future.
-when the path is updated, a user callback can be called by the path module to
+When the path is updated, a user callback can be called by the path module to
report the found path. It receives the list of points of the path and the
list of obstacles. The callback is defined in the ``avrconfig.h`` file.
diff --git a/digital/avr/modules/path/test/test_path.c b/digital/avr/modules/path/test/test_path.c
index beb0a6a6..87c049d7 100644
--- a/digital/avr/modules/path/test/test_path.c
+++ b/digital/avr/modules/path/test/test_path.c
@@ -35,7 +35,9 @@ syntax (void)
"test_path borders source destination [obstacles (0-%d)]\n"
" borders: xmin,ymin,xmax,ymax\n"
" source, destination: x,y\n"
- " obstacles: x,y,r\n",
+ " obstacles: x,y,r\n"
+ "example: test_path 0,0,1500,1500 300,750 1200,750 600,680,100"
+ " 900,820,100\n",
AC_PATH_OBSTACLES_NB);
exit (1);
}
diff --git a/digital/avr/modules/path/test/test_path.py b/digital/avr/modules/path/test/test_path.py
index 328f6333..f4654519 100644
--- a/digital/avr/modules/path/test/test_path.py
+++ b/digital/avr/modules/path/test/test_path.py
@@ -25,7 +25,7 @@
import re
from Tkinter import *
-from inter.drawable import *
+from simu.inter.drawable import *
from subprocess import Popen, PIPE
class Obstacle:
@@ -47,6 +47,9 @@ class Area (Drawable):
self.dst = None
self.obstacles = [ ]
self.path = [ ]
+ self.points = { }
+ self.arcs = [ ]
+ self.draw_arcs = True
def draw (self):
self.reset ()
@@ -58,6 +61,10 @@ class Area (Drawable):
self.draw_circle (self.src, 10, fill = 'green')
if self.dst is not None:
self.draw_circle (self.dst, 10, fill = 'red')
+ if self.draw_arcs and self.arcs:
+ fmt = dict (fill = 'gray75')
+ for a in self.arcs:
+ self.draw_line (self.points[a[0]], self.points[a[1]], **fmt)
if len (self.path) > 1:
fmt = dict (fill = 'blue', arrow = LAST)
self.draw_line (*self.path, **fmt)
@@ -79,12 +86,23 @@ class Area (Drawable):
output = p.communicate ()[0]
del p
output = output.split ('\n')
- r = re.compile ('^// (\d+), (\d+)$')
+ r = re.compile ('^// (-?\d+), (-?\d+)$')
+ r_point = re.compile ('^ (\d+) .* pos = "(-?\d+),(-?\d+)"')
+ r_arc = re.compile ('^ (-?\d+) -- (-?\d+) .* label = "(\d+)"')
self.path = [ ]
+ self.points = { }
+ self.arcs = [ ]
for line in output:
m = r.match (line)
if m is not None:
self.path.append (tuple (int (s) for s in m.groups ()))
+ m = r_point.match (line)
+ if m is not None:
+ self.points[int (m.group (1))] = tuple (int (s)
+ for s in m.group (2, 3))
+ m = r_arc.match (line)
+ if m is not None:
+ self.arcs.append (tuple (int (s) for s in m.groups ()))
class AreaView (DrawableCanvas):
@@ -117,12 +135,20 @@ class TestPath (Frame):
self.rightFrame.pack (side = 'right', fill = 'y')
self.quitButton = Button (self.rightFrame, text = 'Quit', command = self.quit)
self.quitButton.pack (side = 'top', fill = 'x')
+ self.arcsVar = IntVar ()
+ self.arcsVar.set (1)
+ self.arcsButton = Checkbutton (self.rightFrame,
+ variable = self.arcsVar, command = self.arcs_toggle,
+ text = 'Arcs', indicatoron = True)
+ self.arcsButton.pack (side = 'top')
self.areaview = AreaView (border_min, border_max, self)
self.areaview.pack (expand = True, fill = 'both')
self.areaview.bind ('<1>', self.click)
def clear (self):
self.areaview.area.path = [ ]
+ self.areaview.area.points = { }
+ self.areaview.area.arcs = [ ]
self.areaview.area.draw ()
def update (self):
@@ -146,6 +172,7 @@ class TestPath (Frame):
dy = obj[0][1] - pos[1]
if dx * dx + dy * dy < obj[1] * obj[1]:
self.move = obj[2]
+ break
if self.move is not None:
self.move (None)
self.clear ()
@@ -154,6 +181,11 @@ class TestPath (Frame):
self.update ()
self.move = None
+ def arcs_toggle (self):
+ self.areaview.area.draw_arcs = self.arcsVar.get () != 0
+ print self.areaview.area.draw_arcs
+ self.areaview.area.draw ()
+
if __name__ == '__main__':
app = TestPath ((0, 0), (1500, 1500))
app.mainloop ()