code cleanup
This commit is contained in:
@@ -34,7 +34,7 @@ Follow these steps to install Shake&Tune on your printer:
|
|||||||
|
|
||||||
# motor_freq:
|
# motor_freq:
|
||||||
# /!\ This option has limitations in stock Klipper and is best used with DangerKlipper /!\
|
# /!\ 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
|
# composite shapers. This requires the `[input_shaper]` config
|
||||||
# section to be defined in your printer.cfg file to work.
|
# section to be defined in your printer.cfg file to work.
|
||||||
# motor_freq_x:
|
# motor_freq_x:
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ from ..helpers.motors_config_parser import Motor, MotorsConfigParser
|
|||||||
from ..shaketune_config import ShakeTuneConfig
|
from ..shaketune_config import ShakeTuneConfig
|
||||||
from .graph_creator import GraphCreator
|
from .graph_creator import GraphCreator
|
||||||
|
|
||||||
|
DEFAULT_LOW_FREQ_MAX = 30
|
||||||
PEAKS_DETECTION_THRESHOLD = 0.05
|
PEAKS_DETECTION_THRESHOLD = 0.05
|
||||||
PEAKS_RELATIVE_HEIGHT_THRESHOLD = 0.04
|
PEAKS_RELATIVE_HEIGHT_THRESHOLD = 0.04
|
||||||
CURVE_SIMILARITY_SIGMOID_K = 0.5
|
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]:
|
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:
|
if lowfreq_max:
|
||||||
ConsoleOutput.print(
|
ConsoleOutput.print(
|
||||||
@@ -151,7 +152,7 @@ def compute_motor_profiles(freqs: np.ndarray, psds: dict, measured_angles: Optio
|
|||||||
motor_profiles = {}
|
motor_profiles = {}
|
||||||
conv_filter = np.ones(20) / 20
|
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:
|
for angle in measured_angles:
|
||||||
sum_curve = np.sum(np.array([psds[angle][speed] for speed in psds[angle]]), axis=0)
|
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')
|
motor_profiles[angle] = np.convolve(sum_curve / len(psds[angle]), conv_filter, mode='same')
|
||||||
|
|||||||
@@ -99,11 +99,6 @@ class MotorResonanceFilter:
|
|||||||
a3 = a1 * K * K
|
a3 = a1 * K * K
|
||||||
motor_filter_A = [a1, a2, a3]
|
motor_filter_A = [a1, a2, a3]
|
||||||
motor_filter_T = [0.0, 0.375 * t_d, 0.75 * t_d]
|
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:
|
else:
|
||||||
# In stock Klipper, the pulse train is too small for most shapers
|
# 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
|
# to be convolved. So we need to use the ZV shaper instead for the
|
||||||
|
|||||||
Reference in New Issue
Block a user