diff --git a/README.md b/README.md index df367c7..fb85c22 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Follow these steps to install Shake&Tune on your printer: # motor_freq: # /!\ This option has limitations in stock Klipper and is best used with DangerKlipper /!\ - # Frequencies of X and Y motor resonances to filter them using + # Frequencies of X and Y motor resonances to filter them by using # composite shapers. This requires the `[input_shaper]` config # section to be defined in your printer.cfg file to work. # motor_freq_x: diff --git a/shaketune/graph_creators/vibrations_graph_creator.py b/shaketune/graph_creators/vibrations_graph_creator.py index 2765b06..599f7d8 100644 --- a/shaketune/graph_creators/vibrations_graph_creator.py +++ b/shaketune/graph_creators/vibrations_graph_creator.py @@ -39,6 +39,7 @@ from ..helpers.motors_config_parser import Motor, MotorsConfigParser from ..shaketune_config import ShakeTuneConfig from .graph_creator import GraphCreator +DEFAULT_LOW_FREQ_MAX = 30 PEAKS_DETECTION_THRESHOLD = 0.05 PEAKS_RELATIVE_HEIGHT_THRESHOLD = 0.04 CURVE_SIMILARITY_SIGMOID_K = 0.5 @@ -115,7 +116,7 @@ def calc_freq_response(data) -> Tuple[np.ndarray, np.ndarray]: def find_motor_characteristics(motor: str, freqs: np.ndarray, psd: np.ndarray) -> Tuple[float, float, int]: - motor_fr, motor_zeta, motor_res_idx, lowfreq_max = compute_mechanical_parameters(psd, freqs, 30) + motor_fr, motor_zeta, motor_res_idx, lowfreq_max = compute_mechanical_parameters(psd, freqs, DEFAULT_LOW_FREQ_MAX) if lowfreq_max: ConsoleOutput.print( @@ -151,7 +152,7 @@ def compute_motor_profiles(freqs: np.ndarray, psds: dict, measured_angles: Optio motor_profiles = {} conv_filter = np.ones(20) / 20 - # Creating the PSD motor profiles for each angles by summing the PSDs for each speeds + # Creating the PSD motor profiles for each angle by summing the PSDs for each speed for angle in measured_angles: sum_curve = np.sum(np.array([psds[angle][speed] for speed in psds[angle]]), axis=0) motor_profiles[angle] = np.convolve(sum_curve / len(psds[angle]), conv_filter, mode='same') diff --git a/shaketune/motor_res_filter.py b/shaketune/motor_res_filter.py index 01f283e..7b804fb 100644 --- a/shaketune/motor_res_filter.py +++ b/shaketune/motor_res_filter.py @@ -99,11 +99,6 @@ class MotorResonanceFilter: a3 = a1 * K * K motor_filter_A = [a1, a2, a3] motor_filter_T = [0.0, 0.375 * t_d, 0.75 * t_d] - - combined_filter_A, combined_filter_T = MotorResonanceFilter.convolve_shapers( - (axis_shaper_A, axis_shaper_T), - (motor_filter_A, motor_filter_T), - ) else: # In stock Klipper, the pulse train is too small for most shapers # to be convolved. So we need to use the ZV shaper instead for the @@ -114,10 +109,10 @@ class MotorResonanceFilter: motor_filter_A = [1.0, K] motor_filter_T = [0.0, 0.5 * t_d] - combined_filter_A, combined_filter_T = MotorResonanceFilter.convolve_shapers( - (axis_shaper_A, axis_shaper_T), - (motor_filter_A, motor_filter_T), - ) + combined_filter_A, combined_filter_T = MotorResonanceFilter.convolve_shapers( + (axis_shaper_A, axis_shaper_T), + (motor_filter_A, motor_filter_T), + ) shaper.A = combined_filter_A shaper.T = combined_filter_T