This commit is contained in:
Michael Fogleman 2017-04-01 21:27:44 -04:00
parent db643f92c1
commit cacd430c7d
4 changed files with 28 additions and 9 deletions

0
axi/config.py Normal file
View File

View File

@ -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)

View File

@ -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):

View File

@ -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):