mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-11 16:57:51 -06:00
Implement calculating final time of movement commands
This includes accelerations, jerks, proper joints, all that sort of thing. Contributes to issue CURA-5561.
This commit is contained in:
parent
515b286230
commit
4e7f8a268f
1 changed files with 18 additions and 0 deletions
|
@ -70,6 +70,15 @@ def calc_acceleration_distance(init_speed: float, target_speed: float, accelerat
|
|||
return 0.0
|
||||
return (target_speed ** 2 - init_speed ** 2) / (2 * acceleration)
|
||||
|
||||
## Gives the time it needs to accelerate from an initial speed to reach a final
|
||||
# distance.
|
||||
def calc_acceleration_time_from_distance(initial_feedrate: float, distance: float, acceleration: float) -> float:
|
||||
discriminant = initial_feedrate ** 2 - 2 * acceleration * -distance
|
||||
#If the discriminant is negative, we're moving in the wrong direction.
|
||||
#Making the discriminant 0 then gives the extremum of the parabola instead of the intersection.
|
||||
discriminant = max(0, discriminant)
|
||||
return (-initial_feedrate + math.sqrt(discriminant)) / acceleration
|
||||
|
||||
|
||||
def calc_travel_time(p0, p1, init_speed: float, target_speed: float, acceleration: float) -> float:
|
||||
pass
|
||||
|
@ -473,6 +482,15 @@ class CommandBuffer:
|
|||
current.calculate_trapezoid(current._entry_speed / current._nominal_feedrate, MINIMUM_PLANNER_SPEED / current._nominal_feedrate)
|
||||
current._recalculate = False
|
||||
|
||||
#Fifth pass: Compute time for movement commands.
|
||||
for cmd in self._all_commands:
|
||||
if cmd.estimated_exec_time_in_ms >= 0:
|
||||
continue #Not a movement command.
|
||||
plateau_distance = cmd._decelerate_after - cmd._accelerate_until
|
||||
cmd.estimated_exec_time_in_ms = calc_acceleration_time_from_distance(cmd._initial_feedrate, cmd._accelerate_until, cmd._acceleration)
|
||||
cmd.estimated_exec_time_in_ms += plateau_distance / cmd._nominal_feedrate
|
||||
cmd.estimated_exec_time_in_ms += calc_acceleration_time_from_distance(cmd._final_feedrate, (cmd._distancd - cmd._decelerate_after), cmd._acceleration)
|
||||
|
||||
for idx, cmd in enumerate(self._all_commands):
|
||||
cmd_count += 1
|
||||
if idx > cmd0_idx or idx == 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue