There's no reason to distinguish between an EndstopError and a
CommandError, so just use CommandError.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
The "status" and "printing_time" are now available in the
"idle_timeout" module, so no need to report them from toolhead.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a helper function for submitting relative movements. This
function will also automatically ensure gcode.reset_last_position() is
called.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Generate a "toolhead:set_position" event on a call to
toolhead.set_position() and use that event to automatically call
gcode.reset_last_position().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If self.kin_flush_delay changes after a G4 dwell command (or other
non-kinematic time update) then it could lead to "internal step
compression" errors. Make sure to handle this case in
flush_step_generation().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rename try_load_module() so that it uses consistent naming for
"printer objects". Change the function to raise an error by default
if the specified module does not exist.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some stepper motor drivers do not respond well to rapid "step +
direction change + step" events. In particular, it is believed this
can cause "over current" events on the tmc2208 drivers when they are
in "stealthchop" mode. Detect these events and remove them from the
generated step times.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Some stepper motor drivers do not respond well to rapid "step +
direction change + step" events. In particular, it is believed this
can cause "over current" events on the tmc2208 drivers when they are
in "stealthchop" mode. Detect these events and remove them from the
generated step times.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update the endstop code to return its trigger completion object during
home_start(). Update the toolhead class to take a completion object
(instead of creating its own). This reduces the number of
intermediate callbacks needed during a homing operation.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add a mechanism for obtaining the print_time via a callback instead of
by flushing the look-ahead queue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that the extruder lookahead method is no longer used it can be
removed from the toolhead and extruder classes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add support for kinematic functions that calculate step times based on
a range of the motion queue. This requires adding additional pause
times when fully flushing the motion queue.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Update code that modifies the low-level kinematics handlers to first
call toolhead.flush_step_generation().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Don't transition to the normal movement state if there aren't any
moves actually ready to be processed.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Directly disable all the stepper motors on a global motor_off() from
the StepperEnable() class in stepper_enable.py. This simplifies the
toolhead and kinematic classes.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Calculate the ratio of axis distance to total move distance (axis_d /
move_d) and store in a new member variable axes_r. This avoids
needing to recalculate the value in other code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Only track a single acceleration movement in a 'struct move' instance.
Break the classic trapezoid movement (accel, cruise, decel) into three
separate movements. This simplifies the calculation logic.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Load all items from the look-ahead queue into the trapezoid velocity
queue, and then flush that queue by time. This prevents the host cpu
from being starved on very long moves (which may require a large
number of steps to be generated). It also improves the overall
performance.
With the batch flushing logic in place, it is no longer necessary to
split homing moves up.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that all callers use the trapq system to queue moves, it is no
longer necessary to individually allocate and fill a 'struct move'.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that all kinematics use the trapq system, there is no need to call
into the kinematics on each g-code move.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add support for building a list of moves in the trapq.c code. Update
the toolhead code so that moves generated from the look-ahead code are
added to that list.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
When reducing the maximum speed due to the max_accel_to_decel setting,
move velocity limits must still be propagated. Otherwise, the
trapezoid move planner may produce moves with velocity jumps.
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
During a "drip feed" move, both the move's maximum speed and maximum
acceleration may be limited by the kinematics.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
It's not necessary to fully build up the look-ahead queue prior to
starting a "drip move" homing operation. Instead, allow the
look-ahead queue to flush normally.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If the homing move is exceptionally long, it could take a long time
for the host to process the look-ahead queue. Delay the print_time
calculation until moves are ready to be sent.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Now that homing is implemented via "drip moves", it is no longer
necessary to move the print_time backwards.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Rework the low-level implementation of homing movement. The existing
mechanism buffers all homing movement into the micro-controller prior
to starting the home. Replace with a system that buffers all movement
into the host look-ahead buffer and then "drip feed" those moves to
the micro-controllers. Then clear the host look-ahead buffer when all
endstops trigger.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
If commands are slowly fed to the printer it could cause the number of
queued commands to grow without bound. Be sure to pause the incoming
command stream even if the lookahead queue is empty.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Add "gcode_position" named tuple to gcode.get_status(). Add a
"position" named tuple to toolhead.get_status().
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>