code cleanup
This commit is contained in:
@@ -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')
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user