Skip to content

Store calibration results - #16

Open
RNGIllSkillz wants to merge 11 commits into
viesturz:mainfrom
RNGIllSkillz:main
Open

Store calibration results#16
RNGIllSkillz wants to merge 11 commits into
viesturz:mainfrom
RNGIllSkillz:main

Conversation

@RNGIllSkillz

Copy link
Copy Markdown
Contributor

Implemented a command TOOL_CALIBRATE_STORE_TOOL_OFFSET that will append results in to a txt file at printer_data/config/tools_calibrate_results/

Command TOOL_CALIBRATE_STORE_TOOL_OFFSET will save calibration result in to a file
@VIN-y

VIN-y commented Jun 22, 2024

Copy link
Copy Markdown
Contributor

Hi guys,

I have been on the fence about how useful this feature is for for a while. Now that I have had a proper thought about. This might actually be pretty handy for a dynamic hardware config, like MissChanger, where the multi-tool-head hardware is designed to be quickly removable.

At the moment, even if I can disconnect all the hardware in less than a minute, I will still need to manually go to the printer.cfg to comment out the tool-head profile, and move the PID and offsets another file. Then, I will have to do all of that in reverse when I want to put them back... This gets old really quickly.

In this context, to have the data being saved in a separate file, from which I can use a script to automatically re-import into printer.cfg, is pretty helpful. Nevertheless, this is not a universal problem for all printer, and the feature set might need to be expanded to do have the automatic re-import function. All of that code will not be relevant to non-dynamic hardware configs, thus will only serve as potential sources of bugs for them.

Therefore, I propose that we put what you got here, and any feature that related to data management into a separate .py file. So, we can have the features, but in an isolated form.

@joseph-greiner

Copy link
Copy Markdown

An option that could be used is a [save_variables] file in Klipper, from each of the tool_calibrate_tool_offset call a separate macro to store and update the offsets:

[save_variables]
filename: ~/printer_data/config/offset-variables.cfg

[gcode_macro save_offsets_to_disk]
gcode:
{% set svv = printer.save_variables.variables %}
{% set tool = params.T|default(1)|int %}
SAVE_VARIABLE VARIABLE=t{tool}_offset_x VALUE=printer.tools_calibrate.last_x_result|round(6)}
SAVE_VARIABLE VARIABLE=t[tool}_offset_y VALUE=printer.tools_calibrate.last_y_result|round(6)}
SAVE_VARIABLE VARIABLE=t{tool}_offset_z VALUE=printer.tools_calibrate.last_z_result|round(6)}

Then you can load them from the file at run time in a macro:
{% set svv = printer.save_variables.variables %}
{% set load_x_offset = svv.t1_offset_x|float %}
{% set load_y_offset = svv.t1_offset_y|float %}
{% set load_z_offset = svv.t1_offset_z|float %}

And adjust your offsets from there.

@russiancatfood

Copy link
Copy Markdown

Same idea, but using the last_result to set Gcode macro variables (since everything in IDEX land is hacked together with macros)

SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_x VALUE={printer.tools_calibrate.last_x_result|round(6)}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_y VALUE={printer.tools_calibrate.last_y_result|round(6)}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_z VALUE={printer.tools_calibrate.last_z_result|round(6)}

@VIN-y

VIN-y commented Jun 24, 2024

Copy link
Copy Markdown
Contributor

[save_variables]

I actually totally forgot that existed. Thanks.
I will see what I can do with it.

@VIN-y

VIN-y commented Jun 26, 2024

Copy link
Copy Markdown
Contributor

I found it.
There is a macro called [gcode_shell_command] that can be installed via KIAUH, which allows me to run bash commands. I just use that to toggle the config for multi-toolhead and single-toolhead.

Only wait if there's an actual temp change, otherwise we will be waiting for no reason.
@Contomo

Contomo commented Mar 11, 2025

Copy link
Copy Markdown
Contributor

An option that could be used is a [save_variables] file in Klipper, from each of the tool_calibrate_tool_offset call a separate macro to store and update the offsets:

[save_variables] filename: ~/printer_data/config/offset-variables.cfg

[gcode_macro save_offsets_to_disk] gcode: {% set svv = printer.save_variables.variables %} {% set tool = params.T|default(1)|int %} SAVE_VARIABLE VARIABLE=t{tool}_offset_x VALUE=printer.tools_calibrate.last_x_result|round(6)} SAVE_VARIABLE VARIABLE=t[tool}_offset_y VALUE=printer.tools_calibrate.last_y_result|round(6)} SAVE_VARIABLE VARIABLE=t{tool}_offset_z VALUE=printer.tools_calibrate.last_z_result|round(6)}

Then you can load them from the file at run time in a macro: {% set svv = printer.save_variables.variables %} {% set load_x_offset = svv.t1_offset_x|float %} {% set load_y_offset = svv.t1_offset_y|float %} {% set load_z_offset = svv.t1_offset_z|float %}

And adjust your offsets from there.

https://github.com/joseph-greiner/klipper_tc_automatic_offset_calibration/tree/main

just linking this here, supposedly this is what requested (and could be modified further as a workaround)

RNGIllSkillz and others added 6 commits March 30, 2025 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants