From 850cc292ac7ea847f6be2afcdc5bae89418cabda Mon Sep 17 00:00:00 2001 From: Nicolas Schodet Date: Mon, 30 May 2011 23:42:52 +0200 Subject: digital/io-hub: add path finding --- digital/io-hub/tools/io_hub/mex.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'digital/io-hub/tools/io_hub/mex.py') diff --git a/digital/io-hub/tools/io_hub/mex.py b/digital/io-hub/tools/io_hub/mex.py index 66060ea1..8d758382 100644 --- a/digital/io-hub/tools/io_hub/mex.py +++ b/digital/io-hub/tools/io_hub/mex.py @@ -121,6 +121,24 @@ class Mex: m.push ('L', self.contacts) self.node.send (m) + class Path (Observable): + """Path finding algorithm report. + + - path: sequence of (x, y) coordinates (millimeters). + + """ + + def __init__ (self, node, instance): + Observable.__init__ (self) + self.path = [ ] + node.register (instance + ':path', self.__handle) + + def __handle (self, msg): + self.path = [ ] + while len (msg) >= 4: + self.path.append (msg.pop ('hh')) + self.notify () + class PosReport (Observable): """General purpose position report. @@ -149,5 +167,6 @@ class Mex: self.__contact_pack = self.Contact.Pack (node, instance) self.contact = tuple (self.Contact (self.__contact_pack, i) for i in range (CONTACT_NB)) + self.path = self.Path (node, instance) self.pos_report = self.PosReport (node, instance) -- cgit v1.2.3