homing_override: Allow moves prior to homing an axis
Add support for disabling homing checks via the homing_override mechanism. This may be useful to move an axis prior to homing it. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
01bb4b291e
commit
1a67902858
|
@ -294,6 +294,14 @@
|
||||||
# contained in this list of commands then it will invoke the normal
|
# contained in this list of commands then it will invoke the normal
|
||||||
# homing procedure for the printer. The commands listed here must
|
# homing procedure for the printer. The commands listed here must
|
||||||
# home all axes. This parameter must be provided.
|
# home all axes. This parameter must be provided.
|
||||||
|
#set_position_x:
|
||||||
|
#set_position_y:
|
||||||
|
#set_position_z:
|
||||||
|
# If specified, the position to set the printer to (in mm, relative
|
||||||
|
# to the coordinate system specified in the config file) prior to
|
||||||
|
# running the above g-code commands. Setting this may be useful if
|
||||||
|
# an axis must move prior to invoking the normal G28 mechanism for
|
||||||
|
# that axis. The default is to not force a position for the axis.
|
||||||
|
|
||||||
|
|
||||||
# Replicape support - see the generic-replicape.cfg file for further
|
# Replicape support - see the generic-replicape.cfg file for further
|
||||||
|
|
|
@ -32,14 +32,16 @@ class CartKinematics:
|
||||||
return list(self.steppers)
|
return list(self.steppers)
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
return [s.mcu_stepper.get_commanded_position() for s in self.steppers]
|
return [s.mcu_stepper.get_commanded_position() for s in self.steppers]
|
||||||
def set_position(self, newpos):
|
def set_position(self, newpos, homing_axes):
|
||||||
for i in StepList:
|
for i in StepList:
|
||||||
self.steppers[i].set_position(newpos[i])
|
s = self.steppers[i]
|
||||||
|
s.set_position(newpos[i])
|
||||||
|
if i in homing_axes:
|
||||||
|
self.limits[i] = (s.position_min, s.position_max)
|
||||||
def home(self, homing_state):
|
def home(self, homing_state):
|
||||||
# Each axis is homed independently and in order
|
# Each axis is homed independently and in order
|
||||||
for axis in homing_state.get_axes():
|
for axis in homing_state.get_axes():
|
||||||
s = self.steppers[axis]
|
s = self.steppers[axis]
|
||||||
self.limits[axis] = (s.position_min, s.position_max)
|
|
||||||
# Determine moves
|
# Determine moves
|
||||||
if s.homing_positive_dir:
|
if s.homing_positive_dir:
|
||||||
pos = s.position_endstop - 1.5*(
|
pos = s.position_endstop - 1.5*(
|
||||||
|
|
|
@ -40,15 +40,17 @@ class CoreXYKinematics:
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
pos = [s.mcu_stepper.get_commanded_position() for s in self.steppers]
|
pos = [s.mcu_stepper.get_commanded_position() for s in self.steppers]
|
||||||
return [0.5 * (pos[0] + pos[1]), 0.5 * (pos[0] - pos[1]), pos[2]]
|
return [0.5 * (pos[0] + pos[1]), 0.5 * (pos[0] - pos[1]), pos[2]]
|
||||||
def set_position(self, newpos):
|
def set_position(self, newpos, homing_axes):
|
||||||
pos = (newpos[0] + newpos[1], newpos[0] - newpos[1], newpos[2])
|
pos = (newpos[0] + newpos[1], newpos[0] - newpos[1], newpos[2])
|
||||||
for i in StepList:
|
for i in StepList:
|
||||||
self.steppers[i].set_position(pos[i])
|
s = self.steppers[i]
|
||||||
|
s.set_position(pos[i])
|
||||||
|
if i in homing_axes:
|
||||||
|
self.limits[i] = (s.position_min, s.position_max)
|
||||||
def home(self, homing_state):
|
def home(self, homing_state):
|
||||||
# Each axis is homed independently and in order
|
# Each axis is homed independently and in order
|
||||||
for axis in homing_state.get_axes():
|
for axis in homing_state.get_axes():
|
||||||
s = self.steppers[axis]
|
s = self.steppers[axis]
|
||||||
self.limits[axis] = (s.position_min, s.position_max)
|
|
||||||
# Determine moves
|
# Determine moves
|
||||||
if s.homing_positive_dir:
|
if s.homing_positive_dir:
|
||||||
pos = s.position_endstop - 1.5*(
|
pos = s.position_endstop - 1.5*(
|
||||||
|
|
|
@ -71,7 +71,7 @@ class DeltaKinematics:
|
||||||
"Delta max build radius %.2fmm (moves slowed past %.2fmm and %.2fmm)"
|
"Delta max build radius %.2fmm (moves slowed past %.2fmm and %.2fmm)"
|
||||||
% (math.sqrt(self.max_xy2), math.sqrt(self.slow_xy2),
|
% (math.sqrt(self.max_xy2), math.sqrt(self.slow_xy2),
|
||||||
math.sqrt(self.very_slow_xy2)))
|
math.sqrt(self.very_slow_xy2)))
|
||||||
self.set_position([0., 0., 0.])
|
self.set_position([0., 0., 0.], ())
|
||||||
def get_steppers(self, flags=""):
|
def get_steppers(self, flags=""):
|
||||||
return list(self.steppers)
|
return list(self.steppers)
|
||||||
def _cartesian_to_actuator(self, coord):
|
def _cartesian_to_actuator(self, coord):
|
||||||
|
@ -83,17 +83,18 @@ class DeltaKinematics:
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
spos = [s.mcu_stepper.get_commanded_position() for s in self.steppers]
|
spos = [s.mcu_stepper.get_commanded_position() for s in self.steppers]
|
||||||
return self._actuator_to_cartesian(spos)
|
return self._actuator_to_cartesian(spos)
|
||||||
def set_position(self, newpos):
|
def set_position(self, newpos, homing_axes):
|
||||||
pos = self._cartesian_to_actuator(newpos)
|
pos = self._cartesian_to_actuator(newpos)
|
||||||
for i in StepList:
|
for i in StepList:
|
||||||
self.steppers[i].set_position(pos[i])
|
self.steppers[i].set_position(pos[i])
|
||||||
self.limit_xy2 = -1.
|
self.limit_xy2 = -1.
|
||||||
|
if tuple(homing_axes) == StepList:
|
||||||
|
self.need_home = False
|
||||||
def home(self, homing_state):
|
def home(self, homing_state):
|
||||||
# All axes are homed simultaneously
|
# All axes are homed simultaneously
|
||||||
homing_state.set_axes([0, 1, 2])
|
homing_state.set_axes([0, 1, 2])
|
||||||
endstops = [es for s in self.steppers for es in s.get_endstops()]
|
endstops = [es for s in self.steppers for es in s.get_endstops()]
|
||||||
s = self.steppers[0] # Assume homing speed same for all steppers
|
s = self.steppers[0] # Assume homing speed same for all steppers
|
||||||
self.need_home = False
|
|
||||||
# Initial homing
|
# Initial homing
|
||||||
homing_speed = min(s.homing_speed, self.max_z_velocity)
|
homing_speed = min(s.homing_speed, self.max_z_velocity)
|
||||||
homepos = [0., 0., self.max_z, None]
|
homepos = [0., 0., self.max_z, None]
|
||||||
|
|
|
@ -6,16 +6,29 @@
|
||||||
|
|
||||||
class HomingOverride:
|
class HomingOverride:
|
||||||
def __init__(self, config):
|
def __init__(self, config):
|
||||||
printer = config.get_printer()
|
self.printer = config.get_printer()
|
||||||
|
self.start_pos = [config.getfloat('set_position_' + a, None)
|
||||||
|
for a in 'xyz']
|
||||||
self.script = config.get('gcode')
|
self.script = config.get('gcode')
|
||||||
self.in_script = False
|
self.in_script = False
|
||||||
self.gcode = printer.lookup_object('gcode')
|
self.gcode = self.printer.lookup_object('gcode')
|
||||||
self.gcode.register_command("G28", self.cmd_G28)
|
self.gcode.register_command("G28", self.cmd_G28)
|
||||||
def cmd_G28(self, params):
|
def cmd_G28(self, params):
|
||||||
if self.in_script:
|
if self.in_script:
|
||||||
# Was called recursively - invoke the real G28 command
|
# Was called recursively - invoke the real G28 command
|
||||||
self.gcode.cmd_G28(params)
|
self.gcode.cmd_G28(params)
|
||||||
return
|
return
|
||||||
|
# Calculate forced position (if configured)
|
||||||
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
pos = toolhead.get_position()
|
||||||
|
homing_axes = []
|
||||||
|
for axis, loc in enumerate(self.start_pos):
|
||||||
|
if loc is not None:
|
||||||
|
pos[axis] = loc
|
||||||
|
homing_axes.append(axis)
|
||||||
|
toolhead.set_position(pos, homing_axes=homing_axes)
|
||||||
|
self.gcode.reset_last_position()
|
||||||
|
# Perform homing
|
||||||
try:
|
try:
|
||||||
self.in_script = True
|
self.in_script = True
|
||||||
self.gcode.run_script(self.script)
|
self.gcode.run_script(self.script)
|
||||||
|
|
|
@ -78,7 +78,9 @@ class Homing:
|
||||||
raise EndstopError(error)
|
raise EndstopError(error)
|
||||||
def home(self, forcepos, movepos, endstops, speed, second_home=False):
|
def home(self, forcepos, movepos, endstops, speed, second_home=False):
|
||||||
# Alter kinematics class to think printer is at forcepos
|
# Alter kinematics class to think printer is at forcepos
|
||||||
self.toolhead.set_position(self._fill_coord(forcepos))
|
homing_axes = [axis for axis in range(3) if forcepos[axis] is not None]
|
||||||
|
self.toolhead.set_position(
|
||||||
|
self._fill_coord(forcepos), homing_axes=homing_axes)
|
||||||
# Add a CPU delay when homing a large axis
|
# Add a CPU delay when homing a large axis
|
||||||
if not second_home:
|
if not second_home:
|
||||||
est_move_d = sum([abs(forcepos[i]-movepos[i])
|
est_move_d = sum([abs(forcepos[i]-movepos[i])
|
||||||
|
|
|
@ -312,10 +312,10 @@ class ToolHead:
|
||||||
# Movement commands
|
# Movement commands
|
||||||
def get_position(self):
|
def get_position(self):
|
||||||
return list(self.commanded_pos)
|
return list(self.commanded_pos)
|
||||||
def set_position(self, newpos):
|
def set_position(self, newpos, homing_axes=()):
|
||||||
self._flush_lookahead()
|
self._flush_lookahead()
|
||||||
self.commanded_pos[:] = newpos
|
self.commanded_pos[:] = newpos
|
||||||
self.kin.set_position(newpos)
|
self.kin.set_position(newpos, homing_axes)
|
||||||
def move(self, newpos, speed):
|
def move(self, newpos, speed):
|
||||||
speed = min(speed, self.max_velocity)
|
speed = min(speed, self.max_velocity)
|
||||||
move = Move(self, self.commanded_pos, newpos, speed)
|
move = Move(self, self.commanded_pos, newpos, speed)
|
||||||
|
|
Loading…
Reference in New Issue