jog vs drawing accel / velocity
This commit is contained in:
parent
0d0a2fa643
commit
d4270b513f
|
@ -26,9 +26,12 @@ PEN_DOWN_POSITION = 45
|
||||||
PEN_DOWN_SPEED = 150
|
PEN_DOWN_SPEED = 150
|
||||||
PEN_DOWN_DELAY = 0
|
PEN_DOWN_DELAY = 0
|
||||||
|
|
||||||
ACCELERATION = 8
|
ACCELERATION = 5
|
||||||
MAX_VELOCITY = 4
|
MAX_VELOCITY = 1
|
||||||
CORNER_FACTOR = 0.0025
|
CORNER_FACTOR = 0.005
|
||||||
|
|
||||||
|
JOG_ACCELERATION = 8
|
||||||
|
JOG_MAX_VELOCITY = 6
|
||||||
|
|
||||||
VID_PID = '04D8:FD92'
|
VID_PID = '04D8:FD92'
|
||||||
|
|
||||||
|
@ -50,6 +53,8 @@ class Device(object):
|
||||||
self.acceleration = ACCELERATION
|
self.acceleration = ACCELERATION
|
||||||
self.max_velocity = MAX_VELOCITY
|
self.max_velocity = MAX_VELOCITY
|
||||||
self.corner_factor = CORNER_FACTOR
|
self.corner_factor = CORNER_FACTOR
|
||||||
|
self.jog_acceleration = JOG_ACCELERATION
|
||||||
|
self.jog_max_velocity = JOG_MAX_VELOCITY
|
||||||
|
|
||||||
for k, v in kwargs.items():
|
for k, v in kwargs.items():
|
||||||
setattr(self, k, v)
|
setattr(self, k, v)
|
||||||
|
@ -79,9 +84,14 @@ class Device(object):
|
||||||
def close(self):
|
def close(self):
|
||||||
self.serial.close()
|
self.serial.close()
|
||||||
|
|
||||||
def make_planner(self):
|
def make_planner(self, jog=False):
|
||||||
return Planner(
|
a = self.acceleration
|
||||||
self.acceleration, self.max_velocity, self.corner_factor)
|
vmax = self.max_velocity
|
||||||
|
cf = self.corner_factor
|
||||||
|
if jog:
|
||||||
|
a = self.jog_acceleration
|
||||||
|
vmax = self.jog_max_velocity
|
||||||
|
return Planner(a, vmax, cf)
|
||||||
|
|
||||||
def readline(self):
|
def readline(self):
|
||||||
return self.serial.readline().strip()
|
return self.serial.readline().strip()
|
||||||
|
@ -95,12 +105,13 @@ class Device(object):
|
||||||
def move(self, dx, dy):
|
def move(self, dx, dy):
|
||||||
self.run_path([(0, 0), (dx, dy)])
|
self.run_path([(0, 0), (dx, dy)])
|
||||||
|
|
||||||
def goto(self, x, y):
|
def goto(self, x, y, jog=False):
|
||||||
|
# TODO: jog if pen up
|
||||||
px, py = self.read_position()
|
px, py = self.read_position()
|
||||||
self.run_path([(px, py), (x, y)])
|
self.run_path([(px, py), (x, y)], jog)
|
||||||
|
|
||||||
def home(self):
|
def home(self):
|
||||||
self.goto(0, 0)
|
self.goto(0, 0, True)
|
||||||
|
|
||||||
# misc commands
|
# misc commands
|
||||||
def version(self):
|
def version(self):
|
||||||
|
@ -153,8 +164,8 @@ class Device(object):
|
||||||
t += step_s
|
t += step_s
|
||||||
# self.wait()
|
# self.wait()
|
||||||
|
|
||||||
def run_path(self, path):
|
def run_path(self, path, jog=False):
|
||||||
planner = self.make_planner()
|
planner = self.make_planner(jog)
|
||||||
plan = planner.plan(path)
|
plan = planner.plan(path)
|
||||||
self.run_plan(plan)
|
self.run_plan(plan)
|
||||||
|
|
||||||
|
@ -163,14 +174,14 @@ class Device(object):
|
||||||
position = (0, 0)
|
position = (0, 0)
|
||||||
bar = Bar(drawing.length, enabled=progress)
|
bar = Bar(drawing.length, enabled=progress)
|
||||||
for path in drawing.paths:
|
for path in drawing.paths:
|
||||||
self.run_path([position, path[0]])
|
self.run_path([position, path[0]], jog=True)
|
||||||
self.pen_down()
|
self.pen_down()
|
||||||
self.run_path(path)
|
self.run_path(path)
|
||||||
self.pen_up()
|
self.pen_up()
|
||||||
position = path[-1]
|
position = path[-1]
|
||||||
bar.increment(path_length(path))
|
bar.increment(path_length(path))
|
||||||
bar.done()
|
bar.done()
|
||||||
self.run_path([position, (0, 0)])
|
self.run_path([position, (0, 0)], jog=True)
|
||||||
|
|
||||||
def plan_drawing(self, drawing):
|
def plan_drawing(self, drawing):
|
||||||
result = []
|
result = []
|
||||||
|
|
Loading…
Reference in New Issue