added accel_per_hertz to the graphs
This commit is contained in:
@@ -60,7 +60,7 @@ def axes_shaper_calibration(gcmd, config, st_thread: ShakeTuneThread) -> None:
|
|||||||
|
|
||||||
# Configure the graph creator
|
# Configure the graph creator
|
||||||
creator = st_thread.get_graph_creator()
|
creator = st_thread.get_graph_creator()
|
||||||
creator.configure(scv, max_sm)
|
creator.configure(scv, max_sm, accel_per_hz)
|
||||||
|
|
||||||
# set the needed acceleration values for the test
|
# set the needed acceleration values for the test
|
||||||
toolhead_info = toolhead.get_status(systime)
|
toolhead_info = toolhead.get_status(systime)
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ def compare_belts_responses(gcmd, config, st_thread: ShakeTuneThread) -> None:
|
|||||||
|
|
||||||
toolhead.manual_move(point, feedrate_travel)
|
toolhead.manual_move(point, feedrate_travel)
|
||||||
|
|
||||||
|
# Configure the graph creator
|
||||||
|
creator = st_thread.get_graph_creator()
|
||||||
|
creator.configure(accel_per_hz)
|
||||||
|
|
||||||
# set the needed acceleration values for the test
|
# set the needed acceleration values for the test
|
||||||
toolhead_info = toolhead.get_status(systime)
|
toolhead_info = toolhead.get_status(systime)
|
||||||
old_accel = toolhead_info['max_accel']
|
old_accel = toolhead_info['max_accel']
|
||||||
|
|||||||
@@ -452,7 +452,7 @@ def compute_signal_data(data, max_freq):
|
|||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def belts_calibration(lognames, klipperdir='~/klipper', max_freq=200.0, st_version=None):
|
def belts_calibration(lognames, klipperdir='~/klipper', max_freq=200.0, accel_per_hz=None, st_version='unknown'):
|
||||||
global shaper_calibrate
|
global shaper_calibrate
|
||||||
shaper_calibrate = setup_klipper_import(klipperdir)
|
shaper_calibrate = setup_klipper_import(klipperdir)
|
||||||
|
|
||||||
@@ -538,6 +538,7 @@ def main():
|
|||||||
opts = optparse.OptionParser(usage)
|
opts = optparse.OptionParser(usage)
|
||||||
opts.add_option('-o', '--output', type='string', dest='output', default=None, help='filename of output graph')
|
opts.add_option('-o', '--output', type='string', dest='output', default=None, help='filename of output graph')
|
||||||
opts.add_option('-f', '--max_freq', type='float', default=200.0, help='maximum frequency to graph')
|
opts.add_option('-f', '--max_freq', type='float', default=200.0, help='maximum frequency to graph')
|
||||||
|
opts.add_option('--accel_per_hz', type='float', default=None, help='accel_per_hz used during the measurement')
|
||||||
opts.add_option(
|
opts.add_option(
|
||||||
'-k', '--klipper_dir', type='string', dest='klipperdir', default='~/klipper', help='main klipper directory'
|
'-k', '--klipper_dir', type='string', dest='klipperdir', default='~/klipper', help='main klipper directory'
|
||||||
)
|
)
|
||||||
@@ -547,7 +548,7 @@ def main():
|
|||||||
if options.output is None:
|
if options.output is None:
|
||||||
opts.error('You must specify an output file.png to use the script (option -o)')
|
opts.error('You must specify an output file.png to use the script (option -o)')
|
||||||
|
|
||||||
fig = belts_calibration(args, options.klipperdir, options.max_freq)
|
fig = belts_calibration(args, options.klipperdir, options.max_freq, options.accel_per_hz, 'unknown')
|
||||||
fig.savefig(options.output, dpi=150)
|
fig.savefig(options.output, dpi=150)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -96,6 +96,9 @@ class BeltsGraphCreator(GraphCreator):
|
|||||||
|
|
||||||
self._setup_folder('belts')
|
self._setup_folder('belts')
|
||||||
|
|
||||||
|
def configure(self, accel_per_hz: float = None) -> None:
|
||||||
|
self._accel_per_hz = accel_per_hz
|
||||||
|
|
||||||
def create_graph(self) -> None:
|
def create_graph(self) -> None:
|
||||||
lognames = self._move_and_prepare_files(
|
lognames = self._move_and_prepare_files(
|
||||||
glob_pattern='shaketune-belt_*.csv',
|
glob_pattern='shaketune-belt_*.csv',
|
||||||
@@ -105,6 +108,7 @@ class BeltsGraphCreator(GraphCreator):
|
|||||||
fig = belts_calibration(
|
fig = belts_calibration(
|
||||||
lognames=[str(path) for path in lognames],
|
lognames=[str(path) for path in lognames],
|
||||||
klipperdir=str(self._config.klipper_folder),
|
klipperdir=str(self._config.klipper_folder),
|
||||||
|
accel_per_hz=self._accel_per_hz,
|
||||||
st_version=self._version,
|
st_version=self._version,
|
||||||
)
|
)
|
||||||
self._save_figure_and_cleanup(fig, lognames)
|
self._save_figure_and_cleanup(fig, lognames)
|
||||||
@@ -134,9 +138,10 @@ class ShaperGraphCreator(GraphCreator):
|
|||||||
|
|
||||||
self._setup_folder('shaper')
|
self._setup_folder('shaper')
|
||||||
|
|
||||||
def configure(self, scv: float, max_smoothing: float = None) -> None:
|
def configure(self, scv: float, max_smoothing: float = None, accel_per_hz: float = None) -> None:
|
||||||
self._scv = scv
|
self._scv = scv
|
||||||
self._max_smoothing = max_smoothing
|
self._max_smoothing = max_smoothing
|
||||||
|
self._accel_per_hz = accel_per_hz
|
||||||
|
|
||||||
def create_graph(self) -> None:
|
def create_graph(self) -> None:
|
||||||
if not self._scv:
|
if not self._scv:
|
||||||
@@ -152,6 +157,7 @@ class ShaperGraphCreator(GraphCreator):
|
|||||||
klipperdir=str(self._config.klipper_folder),
|
klipperdir=str(self._config.klipper_folder),
|
||||||
max_smoothing=self._max_smoothing,
|
max_smoothing=self._max_smoothing,
|
||||||
scv=self._scv,
|
scv=self._scv,
|
||||||
|
accel_per_hz=self._accel_per_hz,
|
||||||
st_version=self._version,
|
st_version=self._version,
|
||||||
)
|
)
|
||||||
self._save_figure_and_cleanup(fig, lognames, lognames[0].stem.split('_')[-1])
|
self._save_figure_and_cleanup(fig, lognames, lognames[0].stem.split('_')[-1])
|
||||||
|
|||||||
@@ -294,7 +294,15 @@ def plot_spectrogram(ax, t, bins, pdata, peaks, max_freq):
|
|||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
|
||||||
def shaper_calibration(lognames, klipperdir='~/klipper', max_smoothing=None, scv=5.0, max_freq=200.0, st_version=None):
|
def shaper_calibration(
|
||||||
|
lognames,
|
||||||
|
klipperdir='~/klipper',
|
||||||
|
max_smoothing=None,
|
||||||
|
scv=5.0,
|
||||||
|
max_freq=200.0,
|
||||||
|
accel_per_hz=None,
|
||||||
|
st_version='unknown',
|
||||||
|
):
|
||||||
global shaper_calibrate
|
global shaper_calibrate
|
||||||
shaper_calibrate = setup_klipper_import(klipperdir)
|
shaper_calibrate = setup_klipper_import(klipperdir)
|
||||||
|
|
||||||
@@ -359,19 +367,23 @@ def shaper_calibration(lognames, klipperdir='~/klipper', max_smoothing=None, scv
|
|||||||
dt = datetime.strptime(f'{filename_parts[1]} {filename_parts[2]}', '%Y%m%d %H%M%S')
|
dt = datetime.strptime(f'{filename_parts[1]} {filename_parts[2]}', '%Y%m%d %H%M%S')
|
||||||
title_line2 = dt.strftime('%x %X') + ' -- ' + filename_parts[3].upper().split('.')[0] + ' axis'
|
title_line2 = dt.strftime('%x %X') + ' -- ' + filename_parts[3].upper().split('.')[0] + ' axis'
|
||||||
if compat:
|
if compat:
|
||||||
title_line3 = '| Compatibility mode with older Klipper,'
|
title_line3 = '| Older Klipper version detected, damping ratio'
|
||||||
title_line4 = '| and no custom S&T parameters are used!'
|
title_line4 = '| and SCV are not used for filter recommendations!'
|
||||||
|
title_line5 = f'| Accel per Hz used: {accel_per_hz}' if accel_per_hz is not None else ''
|
||||||
else:
|
else:
|
||||||
title_line3 = '| Square corner velocity: ' + str(scv) + 'mm/s'
|
title_line3 = f'| Square corner velocity: {scv}mm/s'
|
||||||
title_line4 = '| Max allowed smoothing: ' + str(max_smoothing)
|
title_line4 = f'| Max allowed smoothing: {max_smoothing}'
|
||||||
|
title_line5 = f'| Accel per Hz used: {accel_per_hz}' if accel_per_hz is not None else ''
|
||||||
except Exception:
|
except Exception:
|
||||||
ConsoleOutput.print('Warning: CSV filename look to be different than expected (%s)' % (lognames[0]))
|
ConsoleOutput.print('Warning: CSV filename look to be different than expected (%s)' % (lognames[0]))
|
||||||
title_line2 = lognames[0].split('/')[-1]
|
title_line2 = lognames[0].split('/')[-1]
|
||||||
title_line3 = ''
|
title_line3 = ''
|
||||||
title_line4 = ''
|
title_line4 = ''
|
||||||
|
title_line5 = ''
|
||||||
fig.text(0.12, 0.957, title_line2, ha='left', va='top', fontsize=16, color=KLIPPAIN_COLORS['dark_purple'])
|
fig.text(0.12, 0.957, title_line2, ha='left', va='top', fontsize=16, color=KLIPPAIN_COLORS['dark_purple'])
|
||||||
fig.text(0.58, 0.960, title_line3, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple'])
|
fig.text(0.58, 0.965, title_line3, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple'])
|
||||||
fig.text(0.58, 0.946, title_line4, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple'])
|
fig.text(0.58, 0.951, title_line4, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple'])
|
||||||
|
fig.text(0.58, 0.919, title_line5, ha='left', va='top', fontsize=10, color=KLIPPAIN_COLORS['dark_purple'])
|
||||||
|
|
||||||
# Plot the graphs
|
# Plot the graphs
|
||||||
plot_freq_response(
|
plot_freq_response(
|
||||||
@@ -401,6 +413,7 @@ def main():
|
|||||||
opts.add_option(
|
opts.add_option(
|
||||||
'--scv', '--square_corner_velocity', type='float', dest='scv', default=5.0, help='square corner velocity'
|
'--scv', '--square_corner_velocity', type='float', dest='scv', default=5.0, help='square corner velocity'
|
||||||
)
|
)
|
||||||
|
opts.add_option('--accel_per_hz', type='float', default=None, help='accel_per_hz used during the measurement')
|
||||||
opts.add_option(
|
opts.add_option(
|
||||||
'-k', '--klipper_dir', type='string', dest='klipperdir', default='~/klipper', help='main klipper directory'
|
'-k', '--klipper_dir', type='string', dest='klipperdir', default='~/klipper', help='main klipper directory'
|
||||||
)
|
)
|
||||||
@@ -412,7 +425,9 @@ def main():
|
|||||||
if options.max_smoothing is not None and options.max_smoothing < 0.05:
|
if options.max_smoothing is not None and options.max_smoothing < 0.05:
|
||||||
opts.error('Too small max_smoothing specified (must be at least 0.05)')
|
opts.error('Too small max_smoothing specified (must be at least 0.05)')
|
||||||
|
|
||||||
fig = shaper_calibration(args, options.klipperdir, options.max_smoothing, options.scv, options.max_freq)
|
fig = shaper_calibration(
|
||||||
|
args, options.klipperdir, options.max_smoothing, options.scv, options.max_freq, options.accel_per_hz, 'unknown'
|
||||||
|
)
|
||||||
fig.savefig(options.output, dpi=150)
|
fig.savefig(options.output, dpi=150)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user