From cacd430c7ddc655d5be07a63c9180b57fb8e08d6 Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Sat, 1 Apr 2017 21:27:44 -0400 Subject: [PATCH] updates --- axi/config.py | 0 axi/device.py | 19 ++++++++++++------- axi/drawing.py | 15 +++++++++++++-- axi/planner.py | 3 +++ 4 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 axi/config.py diff --git a/axi/config.py b/axi/config.py new file mode 100644 index 0000000..e69de29 diff --git a/axi/device.py b/axi/device.py index 5540f34..9b9d89b 100644 --- a/axi/device.py +++ b/axi/device.py @@ -20,13 +20,13 @@ PEN_UP_POSITION = 60 PEN_UP_SPEED = 150 PEN_UP_DELAY = 0 -PEN_DOWN_POSITION = 40 +PEN_DOWN_POSITION = 50 PEN_DOWN_SPEED = 150 PEN_DOWN_DELAY = 0 -ACCELERATION = 4 -MAX_VELOCITY = 2 -CORNER_FACTOR = 0.001 +ACCELERATION = 8 +MAX_VELOCITY = 4 +CORNER_FACTOR = 0.005 VID_PID = '04D8:FD92' @@ -157,18 +157,23 @@ class Device(object): self.run_plan(plan) def run_drawing(self, drawing): - planner = self.make_planner() self.pen_up() position = (0, 0) for path in drawing.paths: self.run_path([position, path[0]]) - plan = planner.plan(path) self.pen_down() - self.run_plan(plan) + self.run_path(path) self.pen_up() position = path[-1] self.run_path([position, (0, 0)]) + def plan_drawing(self, drawing): + result = [] + planner = self.make_planner() + for path in drawing.all_paths: + result.append(planner.plan(path)) + return result + # pen functions def pen_up(self): delta = abs(self.pen_up_position - self.pen_down_position) diff --git a/axi/drawing.py b/axi/drawing.py index a01bd82..37ce1ec 100644 --- a/axi/drawing.py +++ b/axi/drawing.py @@ -38,6 +38,17 @@ class Drawing(object): x1, y1, x2, y2 = self.bounds return y2 - y1 + @property + def all_paths(self): + result = [] + position = (0, 0) + for path in self.paths: + result.append([position, path[0]]) + result.append(path) + position = path[-1] + result.append([position, (0, 0)]) + return result + def simplify_paths(self, tolerance): return Drawing(simplify_paths(self.paths, tolerance)) @@ -50,8 +61,8 @@ class Drawing(object): # def remove_duplicates(self): # return Drawing(util.remove_duplicates(self.paths)) - def add(self, other): - self.paths.extend(other.paths) + def add(self, drawing): + self.paths.extend(drawing.paths) self._bounds = None def transform(self, func): diff --git a/axi/planner.py b/axi/planner.py index 51245c9..62a712b 100644 --- a/axi/planner.py +++ b/axi/planner.py @@ -15,6 +15,9 @@ class Planner(object): return constant_acceleration_plan( points, self.acceleration, self.max_velocity, self.corner_factor) + def plan_all(self, paths): + return [self.plan(path) for path in paths] + # a plan is a motion profile generated by the planner class Plan(object): def __init__(self, blocks):