In my project, I use the same (Move → LookAheadQueue.flush → Toolhead._process_moves )logic as in klipper, and I added a line of LOG before trapq_append
if(move->_is_kinematic_move) {
trapq_append(
_trapq.get(),
next_move_time,
move->_accel_t, move->_cruise_t, move->_decel_t,
move->_start_position.x, move->_start_position.y, move->_start_position.z,
move->_axes_r.x, move->_axes_r.y, move->_axes_r.z,
move->_start_v, move->_cruise_v, move->_accel
);
LOG_DEBUG("move start time %lf max_start_V2(%lf) max_smoothed_V2(%lf) start_pos(%lf %lf %lf) end_pos(%lf %lf %lf) startV(%lf)accelT(%lf)accelD(%lf) cruiseV(%lf)cruiseT(%lf)cruiseD(%lf) decelV(%lf)decelT(%lf)decelD(%lf)", next_move_time , move->_max_start_v2 , move->_max_smoothed_v2 , move->_start_position.x , move->_start_position.y , move->_start_position.z , move->_end_position.x , move->_end_position.y , move->_end_position.z , move->_start_v , move->_accel_t , move->_accel_d , move->_cruise_v , move->_cruise_t , move->_cruise_d , move->_end_v , move->_decel_t , move->_decel_d);
}
In a piece of random motion testing, I get the following logs
[DEBUG] move start time 272.140100 max_start_V2(25000000.000000) max_smoothed_V2(25000000.000000) start_pos(7647.000000 8538.000000 6159.000000) end_pos(5151.000000 2535.000000 2134.000000) startV(5000.000000)accelT(0.000000)accelD(0.000000) cruiseV(5000.000000)cruiseT(1.263923)cruiseD(6319.615183) decelV(3425.297623)decelT(0.314940)decelD(1326.733619)
[DEBUG] move start time 273.718964 max_start_V2(11732663.806655) max_smoothed_V2(5866331.903328) start_pos(5151.000000 2535.000000 2134.000000) end_pos(4339.000000 1692.000000 2215.000000) startV(3425.297623)accelT(0.299474)accelD(1250.000000) cruiseV(4922.668362)cruiseT(-0.015588)cruiseD(-76.733619) decelV(4922.668362)decelT(0.000000)decelD(0.000000)
move start time
is the movement start time
max_start_V2
is the limit of Move’s maximum start speed.
max_smoothed_V2
is Move’s limited maximum smoothed velocity
start_pos
is the 3D coordinates of the starting point of Move.
end_pos
is the target 3D coordinate of the Move.
(startV, accelT, accelD)
corresponds to the start velocity, acceleration time and distance of the acceleration phase.
(cruiseV, cruiseT, cruiseD)
corresponds to the speed, time, and distance of the uniform motion phase.
(decelV, decelT, decelD)
corresponds to the velocity, time and distance of the deceleration phase.
The logs from the above show that the cruise speed is overly greedy causing the distance of motion in the acceleration phase to exceed the distance of motion of the target, which in turn generates the wrong cruise_t and cruise_d