input_shaper: Fixed tracking of step_generation_scan_time
Signed-off-by: Dmitry Butyugin <dmbutyugin@google.com>
This commit is contained in:
parent
345934bd68
commit
e15bad4844
|
@ -144,8 +144,8 @@ defs_kin_extruder = """
|
||||||
"""
|
"""
|
||||||
|
|
||||||
defs_kin_shaper = """
|
defs_kin_shaper = """
|
||||||
double input_shaper_get_step_generation_window(int n, double a[]
|
double input_shaper_get_step_generation_window(
|
||||||
, double t[]);
|
struct stepper_kinematics *sk);
|
||||||
int input_shaper_set_shaper_params(struct stepper_kinematics *sk, char axis
|
int input_shaper_set_shaper_params(struct stepper_kinematics *sk, char axis
|
||||||
, int n, double a[], double t[]);
|
, int n, double a[], double t[]);
|
||||||
int input_shaper_set_sk(struct stepper_kinematics *sk
|
int input_shaper_set_sk(struct stepper_kinematics *sk
|
||||||
|
|
|
@ -210,16 +210,11 @@ input_shaper_set_shaper_params(struct stepper_kinematics *sk, char axis
|
||||||
}
|
}
|
||||||
|
|
||||||
double __visible
|
double __visible
|
||||||
input_shaper_get_step_generation_window(int n, double a[], double t[])
|
input_shaper_get_step_generation_window(struct stepper_kinematics *sk)
|
||||||
{
|
{
|
||||||
struct shaper_pulses sp;
|
struct input_shaper *is = container_of(sk, struct input_shaper, sk);
|
||||||
init_shaper(n, a, t, &sp);
|
return is->sk.gen_steps_pre_active > is->sk.gen_steps_post_active
|
||||||
if (!sp.num_pulses)
|
? is->sk.gen_steps_pre_active : is->sk.gen_steps_post_active;
|
||||||
return 0.;
|
|
||||||
double window = -sp.pulses[0].t;
|
|
||||||
if (sp.pulses[sp.num_pulses-1].t > window)
|
|
||||||
window = sp.pulses[sp.num_pulses-1].t;
|
|
||||||
return window;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct stepper_kinematics * __visible
|
struct stepper_kinematics * __visible
|
||||||
|
|
|
@ -70,10 +70,6 @@ class AxisInputShaper:
|
||||||
ffi_lib.input_shaper_set_shaper_params(
|
ffi_lib.input_shaper_set_shaper_params(
|
||||||
sk, self.axis.encode(), self.n, self.A, self.T)
|
sk, self.axis.encode(), self.n, self.A, self.T)
|
||||||
return success
|
return success
|
||||||
def get_step_generation_window(self):
|
|
||||||
ffi_main, ffi_lib = chelper.get_ffi()
|
|
||||||
return ffi_lib.input_shaper_get_step_generation_window(self.n,
|
|
||||||
self.A, self.T)
|
|
||||||
def disable_shaping(self):
|
def disable_shaping(self):
|
||||||
if self.saved is None and self.n:
|
if self.saved is None and self.n:
|
||||||
self.saved = (self.n, self.A, self.T)
|
self.saved = (self.n, self.A, self.T)
|
||||||
|
@ -109,7 +105,6 @@ class InputShaper:
|
||||||
def connect(self):
|
def connect(self):
|
||||||
self.toolhead = self.printer.lookup_object("toolhead")
|
self.toolhead = self.printer.lookup_object("toolhead")
|
||||||
# Configure initial values
|
# Configure initial values
|
||||||
self.old_delay = 0.
|
|
||||||
self._update_input_shaping(error=self.printer.config_error)
|
self._update_input_shaping(error=self.printer.config_error)
|
||||||
def _get_input_shaper_stepper_kinematics(self, stepper):
|
def _get_input_shaper_stepper_kinematics(self, stepper):
|
||||||
# Lookup stepper kinematics
|
# Lookup stepper kinematics
|
||||||
|
@ -131,10 +126,7 @@ class InputShaper:
|
||||||
return is_sk
|
return is_sk
|
||||||
def _update_input_shaping(self, error=None):
|
def _update_input_shaping(self, error=None):
|
||||||
self.toolhead.flush_step_generation()
|
self.toolhead.flush_step_generation()
|
||||||
new_delay = max([s.get_step_generation_window() for s in self.shapers])
|
ffi_main, ffi_lib = chelper.get_ffi()
|
||||||
self.toolhead.note_step_generation_scan_time(new_delay,
|
|
||||||
old_delay=self.old_delay)
|
|
||||||
self.old_delay = new_delay
|
|
||||||
kin = self.toolhead.get_kinematics()
|
kin = self.toolhead.get_kinematics()
|
||||||
failed_shapers = []
|
failed_shapers = []
|
||||||
for s in kin.get_steppers():
|
for s in kin.get_steppers():
|
||||||
|
@ -143,11 +135,16 @@ class InputShaper:
|
||||||
is_sk = self._get_input_shaper_stepper_kinematics(s)
|
is_sk = self._get_input_shaper_stepper_kinematics(s)
|
||||||
if is_sk is None:
|
if is_sk is None:
|
||||||
continue
|
continue
|
||||||
|
old_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
|
||||||
for shaper in self.shapers:
|
for shaper in self.shapers:
|
||||||
if shaper in failed_shapers:
|
if shaper in failed_shapers:
|
||||||
continue
|
continue
|
||||||
if not shaper.set_shaper_kinematics(is_sk):
|
if not shaper.set_shaper_kinematics(is_sk):
|
||||||
failed_shapers.append(shaper)
|
failed_shapers.append(shaper)
|
||||||
|
new_delay = ffi_lib.input_shaper_get_step_generation_window(is_sk)
|
||||||
|
if old_delay != new_delay:
|
||||||
|
self.toolhead.note_step_generation_scan_time(new_delay,
|
||||||
|
old_delay)
|
||||||
if failed_shapers:
|
if failed_shapers:
|
||||||
error = error or self.printer.command_error
|
error = error or self.printer.command_error
|
||||||
raise error("Failed to configure shaper(s) %s with given parameters"
|
raise error("Failed to configure shaper(s) %s with given parameters"
|
||||||
|
|
Loading…
Reference in New Issue