aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/toolhead.py
Commit message (Collapse)AuthorAgeFilesLines
* Isort all klippy codeTomasz Kramkowski2025-08-151-2/+7
|
* Remove logfile supportTomasz Kramkowski2025-08-151-1/+0
|
* Run black on all first party python codeTomasz Kramkowski2025-08-061-155/+285
|
* toolhead: Initial support for adding extra axes to toolhead movesKevin O'Connor2025-05-121-19/+47
| | | | | | | | Add a new add_extra_axes() to support adding additional axes. Once called, toolhead.get_position() will return a list object with more than 4 items, and toolhead.move() requires the same size list. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Only alter XYZ coordinates on set_position() callsKevin O'Connor2025-05-121-1/+1
| | | | | | | It's not valid to alter the extruder position from a call to set_position(), so don't allow callers to attempt that. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Support unregister_step_generator() callKevin O'Connor2025-05-121-0/+3
| | | | | | Allow both registering and unregistering step generation callbacks. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Remove update_move_time() callKevin O'Connor2025-05-121-2/+10
| | | | | | | The toolhead can obtain the underlying extruder trapq via extruder.get_trapq(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* extruder: Rename extruder.move() to extruder.process_move()Kevin O'Connor2025-05-121-1/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* manual_stepper: Implement "drip moves" for manual stepper STOP_ON_ENDSTOPKevin O'Connor2025-04-181-1/+3
| | | | | | | | | | | | | Currently, `MANUAL_STEPPER STOP_ON_ENDSTOP=1` type commands will move until hitting the endstop, but it will still always consume the total amount of move time. That is, following moves can't be started until the total possible time of the homing move is completed. Implement "drip moves" so that the code only schedules the movement in small segments. This allows following movements to be scheduled without a significant delay. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Avoid toolhead.move() and toolhead._process_moves() in drip_move()Kevin O'Connor2025-04-181-37/+48
| | | | | | | Implement move checking and trapq loading directly from drip_move(). This simplifies the interactions between these components. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Avoid LookAheadQueue calling back into toolhead classKevin O'Connor2025-04-181-16/+19
| | | | | | | | | Avoid lookahead.flush() calling back into toolhead._process_moves(). Instead, rename toolhead._process_moves() to toolhead._process_lookahead(), have it call lookahead.flush(), and consistently use it when flushing the lookahead queue. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* garbage_collection: freeze objects on klippy ready (#6794)Branden Cash2025-02-021-1/+1
| | | | | This significantly reduces the amount of data in the generation 2 garbage collection bucket from the initial startup of klipper. Signed-off-by: Branden Cash <203336+ammmze@users.noreply.github.com>
* toolhead: Pass set_position() homing_axes parameter as a stringKevin O'Connor2025-01-211-1/+1
| | | | | | | | Use strings such as "xyz" to specify which axes are to be considered homing during a set_position() call. This makes the parameter a little less cryptic. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* resonance_tester: Added a new sweeping_vibrations resonance test method (#6723)Dmitry Butyugin2024-12-051-3/+10
| | | | | This adds a new resonance test method that can help if a user has some mechanical problems with the printer. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* toolhead: Remove arbitrary constants controlling junction deviationKevin O'Connor2024-11-291-19/+19
| | | | | | | | | | | | | | | | When calculating the junction speed between two moves the code checked for angles greater than 0.999999 or less than -0.999999 to avoid math issues (sqrt of a negative number and/or divide by zero). However, these arbitrary constants could unnecessarily pessimize junction speeds when angles are close to 180 or 0 degrees. Change the code to explicitly check for negative numbers during sqrt and to explicilty check for zero values prior to division. This simplifies the code and avoids unnecessarily reducing some junction speeds. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Use delta_v2 when calculating centripetal forceKevin O'Connor2024-11-291-4/+5
| | | | | | | | | | | As a minor math optimization, it's possible to calculate: .5 * self.move_d * self.accel * tan_theta_d2 using: self.delta_v2 * .25 * tan_theta_d2 because self.delta_v2 is "2. * self.move_d * self.accel". Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com> Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* klippy: remove a few unused variable assignments (#6504)Kamil Domański2024-04-051-1/+0
| | | Signed-off-by: Kamil Domański <kamil@domanski.co>
* toolhead: Populate minimum_cruise_ratio to printer.configfile.settingsKevin O'Connor2024-04-021-6/+7
| | | | | | | | | | | | The default minimum_cruise_ratio setting does not get populated to the printer.configfile.settings information due to the way the max_accel_to_decel backwards compatibility support was implemented. Slightly rework the config reading so that the default for minimum_cruise_ratio is populated there. Reported by @ReXT3D. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Replace max_accel_to_decel with minimum_cruise_ratioKevin O'Connor2024-03-131-18/+29
| | | | | | | | | The user facing max_accel_to_decel setting is complicated and confusing. Replace it with a new minimum_cruise_ratio parameter. Internally this user-facing parameter will calculate the existing low-level "accel_to_decel" mechanism. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rename note_kinematic_activity() to note_mcu_movequeue_activity()Kevin O'Connor2024-01-181-7/+7
| | | | | | Rename this function to make it more clear why it is called. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rename MoveQueue class to LookAheadQueueKevin O'Connor2024-01-181-14/+14
| | | | | | | Rename this class so that is is not confused with the mcu "move queue". Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Extend flushing slightly past required timeKevin O'Connor2024-01-171-3/+5
| | | | | | | | | There is no harm in enabling flushing for a little longer than necessary. In contrast, a slight rounding issue causing a message to not get flushed properly could result in an error. So, extend the flushing time slightly to avoid potential issues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Ensure full kin_flush_delay after flush_step_generation()Kevin O'Connor2024-01-161-3/+4
| | | | | | | | | | | | | | | | | | | | Commit b7b13588 made it possible that the kinematic code could be restarted after a flush_step_generation() call without a sufficient delay. Rename last_sg_flush_time to min_restart_time and use that to ensure _calc_print_time() always pauses kin_flush_delay time since the last flush_step_generation() call. Also, update force_move to invoke flush_step_generation() after any movements. This is needed to ensure there is a sufficient delay should force_move be called on a stepper motor that is part of the toolhead kinematics and is using a step generation "scan time". This fixes possible "internal error in stepcompress" reports when using FORCE_MOVE. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Make sure to flush history when in debug output modeKevin O'Connor2023-12-301-9/+11
| | | | | | | | When in debugging "batch mode", use the existing method of keeping the last 30 seconds of history from the furthest planned move time. This avoids keeping all moves in memory during a batch test. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Avoid calling reactor.monotonic() on each _advance_flush_time()Kevin O'Connor2023-12-301-6/+7
| | | | | | | Move calculation of clear_history_time to the callers of _advance_flush_time() as a minor processing optimization. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Keep stepcompress move history relative to current time (#6439)Francois Chagnon2023-12-301-4/+7
| | | | | Expire history relative to current time rather than last move in history queue Signed-off-by: Francois Chagnon <fc@francoischagnon.net>
* toolhead: Simplify _advance_flush_time() sg_flush_time calculationKevin O'Connor2023-12-261-2/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Fix _calc_print_time() after G4 and SET_PRESSURE_ADVANCEKevin O'Connor2023-12-261-2/+4
| | | | | | | | | | | | Commit b7b13588 changed the internal flush time tracking, but introduced the possibility of motion restart occurring too close to the last motion end in some rare cases. This could result in internal stepcompress errors. Track the last step generation flush time (last_sg_flush_time) and use when recalculating the next print_time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Track separate time for flush_step_generation() and need_flush_timeKevin O'Connor2023-12-161-5/+9
| | | | | | | | Introduce a new step_gen_time variable for flush_step_generation(). This allows need_flush_time to be set to future times without interfering with flush_step_generation(). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Support flushing even while lookahead queue is idleKevin O'Connor2023-12-071-26/+45
| | | | | | | | Track a "NeedPrime" queue state instead of the "Flushed" state, and continue running the background flushing timer as long as there may be data in any of the move queues. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rework flushing to be based on mcu flush timeKevin O'Connor2023-12-071-35/+38
| | | | | | | | | | Rename last_kin_move_time to need_flush_time and rename force_flush_time to last_flush_time to improve variable name clarity. Move low-level flushing to new _advance_flush_time() so that it is possible to flush the queues without needing to advance print_time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Separate out priming flush notification to its own timerKevin O'Connor2023-12-071-4/+21
| | | | | | | | Simplify the code by introducing a separate lookahead priming flush timer. After this change, the flush_timer is not active in any of the special queuing states. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Clarify internal toolhead "stall" and "pause" namingKevin O'Connor2023-12-071-30/+32
| | | | | | | | Clarify the internal naming to make a more clear distinction between "stalling" (input not coming fast enough) and "pausing" (the need to hold up reading of input to avoid buffering too far into the future). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Remove undocumented buffer management config parametersKevin O'Connor2023-12-071-19/+14
| | | | | | | | These internal low-level config parameters were never documented. Going forward, developers may modify them by altering the internal settings in toolhead.py. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* Revert "toolhead: Use dict for step generation flush times. (#6303)"Kevin O'Connor2023-10-211-9/+8
| | | | | | | | | | This reverts commit 6749985302fe002a9cb5672dab9badb11e4e3c36. A defect was found in the above commit (the input shaper code calls note_step_generateion_scan_time() for many steppers, so the input_shaper class can't be used as the index). Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Use dict for step generation flush times. (#6303)Viesturs Zariņš2023-10-191-8/+9
| | | | | Makes the API to extruder and input shaper more robust, avoiding the need to track the old delay. Signed-off-by: Viesturs Zariņš <viesturz@gmail.com>
* toolhead: Flush in chunks from flush_step_generation()Kevin O'Connor2023-01-081-2/+8
| | | | | | | | | If note_kinematic_activity() has a time far in the future it could result in a single flush attempt of that time range. Be sure to break up that range into small chunks using the normal _update_move_time() mechanism. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Rename last_kin_flush_time to force_flush_timeKevin O'Connor2023-01-081-8/+8
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Fix note_kinematic_activity()Kevin O'Connor2023-01-081-1/+1
| | | | | | | | It was possible a note_kinematic_activity() call could increase last_kin_move_time, but _process_moves() could reset it. Fix by making sure _process_moves() only ever increases last_kin_move_time. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Capture current junction_deviation in a Move classDmitry Butyugin2022-10-171-3/+4
| | | | | | | If a maximum acceleration is changed between two consecutive moves, this allows to correctly compute the junction velocity between them. Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
* toolhead: Fix toolhead stop on SET_VELOCITY_LIMIT (#5053)Stephen Hurd2021-12-301-1/+0
| | | | | This fixes issue #5050 Signed-off-by: Stephen Hurd <deuce@synchro.net>
* toolhead: change SET_VELOCITY_LIMIT respond (fixed) (#4620)Stefan Dej2021-08-311-10/+19
| | | | | Returns only the current values if no new ones have been passed. Signed-off-by: Stefan Dej <meteyou@gmail.com>
* Revert "toolhead: change SET_VELOCITY_LIMIT respond behavior"Kevin O'Connor2021-08-241-19/+7
| | | | | | This reverts commit 9f75e348b06f494c0aa4181867b92013f72a9278. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: change SET_VELOCITY_LIMIT respond behaviorstefand2021-08-241-7/+19
| | | | | | Returns only the current values if no new ones have been passed. Signed-off-by: Stefan Dej <meteyou@gmail.com>
* trapq: Store toolhead.set_position() updates in trapq historyKevin O'Connor2021-07-291-1/+3
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* trapq: Rename trapq_free_moves() to trapq_finalize_moves()Kevin O'Connor2021-07-291-4/+4
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Do not limit SET_VELOCITY_LIMIT to values specified in configKevin O'Connor2021-04-301-8/+4
| | | | | | | Allow a larger velocity, accel, and square_corner_velocity than what is specified in the config file. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* stepper: Do not set min_stop_interval in micro-controllerKevin O'Connor2021-04-301-6/+0
| | | | | | | | The min_stop_interval safety check is fragile and leads to a notable amount of complexity. Avoid these issues by not programming this safety check. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Export the print_stalls value via get_status()Kevin O'Connor2021-04-091-0/+1
| | | | Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
* toolhead: Make sure input_shaper movement starts after endstop checkingKevin O'Connor2021-03-291-0/+1
| | | | | | | | | | Add a dwell() to the start of drip_move() to ensure that input_shaper movements scheduled in advance of the nominal move time aren't scheduled prior to the homing start. (Otherwise the stepper may move prior to endstop checking, which can corrupt the "no movement" checks.) Signed-off-by: Kevin O'Connor <kevin@koconnor.net>