diff --git a/klippy/extras/auto_wcs.py b/klippy/extras/auto_wcs.py index a238fde7ad0f..c7f6ddb443f6 100644 --- a/klippy/extras/auto_wcs.py +++ b/klippy/extras/auto_wcs.py @@ -25,14 +25,8 @@ def __init__(self, config): [0., 0., 0.], [0., 0., 0.] ] - self.probe_backlash_x = 0. - self.probe_backlash_y = 0. - self.probe_backlash_y_2 = 0. - self.tooling_radius = 0. - self.tooling_radius_2 = 0. self.adjust_angle = 10 / RAD_TO_DEG self.gcode = self.printer.lookup_object('gcode') - self.printer.register_event_handler("klippy:ready", self._handle_ready) self.gcode.register_command( 'SAVE_WCS_CALC_POINT', self.cmd_SAVE_WCS_CALC_POINT, desc=self.cmd_SAVE_WCS_CALC_POINT_help) @@ -42,15 +36,6 @@ def __init__(self, config): self.gcode.register_command( 'SET_AUTO_WCS', self.cmd_SET_AUTO_WCS, desc=self.cmd_CALC_WCS_PARAMS_help) - self.gcode.register_command( - 'GET_RADIUS_TOOLING', self.cmd_GET_RADIUS_TOOLING, - desc=self.cmd_GET_RADIUS_TOOLING_help) - - def _handle_ready(self): - save_variables = self.printer.lookup_object('save_variables') - self.probe_backlash_x = save_variables.allVariables.get('probe_backlash_x', 0.) - self.probe_backlash_y = save_variables.allVariables.get('probe_backlash_y', 0.) - self.probe_backlash_y_2 = save_variables.allVariables.get('probe_backlash_y_2', 0.) def _calc_wcs_old_sensor(self, thickness, adj, gcmd): thickness = thickness / 2.0 @@ -95,53 +80,10 @@ def _calc_wcs_2_new_sensor(self, thickness, adj, gcmd): thickness = thickness / 2. len_thickness = 10. x = (self.point_coords[8][0] + self.point_coords[9][0]) / 2. - y = ((self.point_coords[5][1] + self.point_coords[6][1]) / 2.) - thickness + y = (self.point_coords[5][1] + self.point_coords[6][1]) / 2. - thickness z = self.point_coords[4][2] - (len_thickness - adj) return x, y, z - def calculate_probe_backlash(self, x1, y1, y2): - self.probe_backlash_x = abs(self.point_coords[3][0] - (x1 + 55)) - self.probe_backlash_y = abs(self.point_coords[5][1] - y2) - self.probe_backlash_y_2 = abs(self.point_coords[1][1] - (y1 - 5)) - - def cmd_GET_RADIUS_TOOLING(self, gcmd): - x1, y1 = self.point_coords[1][0] + self.probe_backlash_x, self.point_coords[1][1] - x2, y2 = self.point_coords[0][0], self.point_coords[0][1] + self.probe_backlash_y - x3, y3 = self.point_coords[2][0] - self.probe_backlash_x, self.point_coords[2][1] - c = (x1-x2)**2 + (y1-y2)**2 - a = (x2-x3)**2 + (y2-y3)**2 - b = (x3-x1)**2 + (y3-y1)**2 - s = 2*(a*b + b*c + c*a) - (a*a + b*b + c*c) - px = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3) / s - py = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3) / s - ar = a**0.5 - br = b**0.5 - cr = c**0.5 - r = ar*br*cr / ((ar+br+cr)*(-ar+br+cr)*(ar-br+cr)*(ar+br-cr))**0.5 - self.tooling_radius = r - gcmd.respond_info('radius_tooling_1= %s, centr_tool(%s;%s)' % (self.tooling_radius, px, py)) - self.get_radius_2(gcmd) - return px, py, r - cmd_GET_RADIUS_TOOLING_help = "command for get the tooling radius from measuring points." - - def get_radius_2(self, gcmd): - x1, y1 = self.point_coords[1][0] + self.probe_backlash_x, self.point_coords[1][1] - x2, y2 = self.point_coords[0][0], self.point_coords[0][1] + self.probe_backlash_y_2 - x3, y3 = self.point_coords[2][0] - self.probe_backlash_x, self.point_coords[2][1] - c = (x1-x2)**2 + (y1-y2)**2 - a = (x2-x3)**2 + (y2-y3)**2 - b = (x3-x1)**2 + (y3-y1)**2 - s = 2*(a*b + b*c + c*a) - (a*a + b*b + c*c) - px = (a*(b+c-a)*x1 + b*(c+a-b)*x2 + c*(a+b-c)*x3) / s - py = (a*(b+c-a)*y1 + b*(c+a-b)*y2 + c*(a+b-c)*y3) / s - ar = a**0.5 - br = b**0.5 - cr = c**0.5 - r = ar*br*cr / ((ar+br+cr)*(-ar+br+cr)*(ar-br+cr)*(ar+br-cr))**0.5 - self.tooling_radius_2 = r - gcmd.respond_info('radius_tooling_2= %s, centr_tool(%s;%s)' % (self.tooling_radius_2, px, py)) - return px, py, r - def cmd_SAVE_WCS_CALC_POINT(self, gcmd): point_idx = gcmd.get_int('POINT', 0) coords = gcmd.get('COORDS', None) @@ -160,6 +102,7 @@ def cmd_SAVE_WCS_CALC_POINT(self, gcmd): cmd_SAVE_WCS_CALC_POINT_help = "Save point for WCS calculation" + def cmd_CALC_WCS_PARAMS(self, gcmd): #todo: get thickness default 10 thickness = gcmd.get_float('THICKNESS', 10.) @@ -168,7 +111,6 @@ def cmd_CALC_WCS_PARAMS(self, gcmd): if sensor_version: x, y, z = self._calc_wcs_new_sensor(thickness, adjustment_coeff, gcmd) x2, y2, z2 = self._calc_wcs_2_new_sensor(thickness, adjustment_coeff, gcmd) - self.calculate_probe_backlash(x, y, y2) delta_y = y - y2 delta_z = z - z2 avg_delta = (delta_y + delta_z) / 2.0 @@ -206,12 +148,7 @@ def cmd_SET_AUTO_WCS(self, gcmd): def get_status(self, eventtime=None): return { - "wcs": self.wcs, - "probe_backlash_x": self.probe_backlash_x, - "probe_backlash_y": self.probe_backlash_y, - "probe_backlash_y_2": self.probe_backlash_y_2, - 'tooling_radius': self.tooling_radius, - 'tooling_radius_2': self.tooling_radius_2 + "wcs": self.wcs } def load_config(config): diff --git a/stereotech_config/filament_control.cfg b/stereotech_config/filament_control.cfg index a03ead5f5671..27620eceae6e 100644 --- a/stereotech_config/filament_control.cfg +++ b/stereotech_config/filament_control.cfg @@ -26,7 +26,7 @@ gcode: {% set sensor = params.SENSOR %} {% if printer[printer.toolhead.extruder].can_extrude %} M400 - M117 try_do_extrude + M117 try_do_extrude_{printer["gcode_macro TRY_DO_EXTRUDE"].retries_count} EXTRUDE_WITH_CURRENT_TEMP M400 EXTRUDE_WITH_COOLING_AND_HEATING SENSOR={sensor} @@ -57,7 +57,7 @@ gcode: M117 resume_after_trigered_sensor RESUME {% else %} - M117 failed_try_do_extrude + M117 all_attempt_extrude_failed {action_respond_info('All extruding attempt completed failed.')} {% if sensor == 'extruder_sensor' %} SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=0 @@ -89,6 +89,7 @@ gcode: {% set triggered_extruder = printer["gcode_macro CONTINUE_PRINT_WITH_EXTRUDER"].triggered_extruder|int %} {% if triggered_extruder == 0 %} {action_respond_info('Printing continued with extruder 2.')} + M117 resume_print_another_extruder SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=1 SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE=0 diff --git a/stereotech_config/filament_control_2.cfg b/stereotech_config/filament_control_2.cfg index c4c573239422..55cea976db96 100644 --- a/stereotech_config/filament_control_2.cfg +++ b/stereotech_config/filament_control_2.cfg @@ -68,6 +68,7 @@ gcode: SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 {% endif %} #Set timeout and wait for user + M117 all_attempt_extrude_failed UPDATE_DELAYED_GCODE ID=TURN_OFF_EXTRUDERS_DELAYED DURATION=300 SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=1 SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=1 @@ -95,6 +96,7 @@ gcode: G10 L2 P0 R1 Z-{reset_value} {% endif %} {% else %} + M117 recover_extrusion_by_offset_attempt_{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made + 1} {% if printer.gcode_move.current_wcs == 0 %} SET_GCODE_OFFSET Z_ADJUST={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} MOVE=1 {% else %} @@ -131,6 +133,7 @@ gcode: SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=use_cooldown VALUE=0 CHECK_FILAMENT_MOTION_SENSOR SENSOR={sensor} {% else %} + M117 try_do_extrude_{printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made + 1} M400 G4 P3000 LOAD_MATERIAL @@ -148,6 +151,7 @@ gcode: {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} {% if filament_detected %} {action_respond_info('Extruding attempt completed successfully, resuming printing.')} + M117 resume_after_trigered_sensor RESUME {% else %} UPDATE_DELAYED_GCODE ID=RECOVER_EXTRUSION_DELAY DURATION=1 @@ -164,6 +168,7 @@ gcode: SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_SECOND_EXTRUDER VARIABLE=enabled VALUE=0 {% else %} + M117 resume_print_another_extruder SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_SECOND_EXTRUDER VARIABLE=enabled VALUE=1 SET_GCODE_OFFSET X_ADJUST=-25.0 MOVE=1 ENABLE_CONSTRAIN ENABLE=1 diff --git a/stereotech_config/probe.cfg b/stereotech_config/probe.cfg index cf2a54148267..847a4ddfa66e 100644 --- a/stereotech_config/probe.cfg +++ b/stereotech_config/probe.cfg @@ -138,19 +138,19 @@ gcode: SET_A_OFFSET_POINT POINT=1 CALC_A_AXIS_OFFSET - ;PROBE_TEMPLATE_POINT POINT=CZ - ;SET_B_COMPENSATION_POINT POINT=0 - ;PROBE_TEMPLATE_POINT POINT=CZ1 - ;SET_B_COMPENSATION_POINT POINT=1 - ;PROBE_TEMPLATE_POINT POINT=AZ - ;SET_B_COMPENSATION_POINT POINT=2 - ;PROBE_TEMPLATE_POINT POINT=BZ - ;SET_B_COMPENSATION_POINT POINT=3 - ;PROBE_TEMPLATE_POINT POINT=AX - ;SET_B_COMPENSATION_POINT POINT=4 - ;PROBE_TEMPLATE_POINT POINT=BX - ;SET_B_COMPENSATION_POINT POINT=5 - ;CALC_B_AXIS_COMPENSATION ENABLE=0 + PROBE_TEMPLATE_POINT POINT=CZ + SET_B_COMPENSATION_POINT POINT=0 + PROBE_TEMPLATE_POINT POINT=CZ1 + SET_B_COMPENSATION_POINT POINT=1 + PROBE_TEMPLATE_POINT POINT=AZ + SET_B_COMPENSATION_POINT POINT=2 + PROBE_TEMPLATE_POINT POINT=BZ + SET_B_COMPENSATION_POINT POINT=3 + PROBE_TEMPLATE_POINT POINT=AX + SET_B_COMPENSATION_POINT POINT=4 + PROBE_TEMPLATE_POINT POINT=BX + SET_B_COMPENSATION_POINT POINT=5 + CALC_B_AXIS_COMPENSATION ENABLE=0 ; skew corection ; xy skew @@ -350,8 +350,6 @@ gcode: {% set template_thickness = printer.save_variables.variables.template_thickness|default(10.0)|float %} {% set auto_wcs_adj = printer.save_variables.variables.auto_wcs_adj|default(0.3)|float %} CALC_WCS_PARAMS THICKNESS={ template_thickness } ADJUSTMENT={ auto_wcs_adj } SENSOR_VERSION={probe_sensor_version} - SAVE_PROBE_BACKLASH - PROBE_TEMPLATE_POINT POINT=AY SET_C_ALIGN_POINT POINT=0 PROBE_TEMPLATE_POINT POINT=BY @@ -360,19 +358,6 @@ gcode: MOVE_TO_AUTO_WCS {% endif %} -[gcode_macro SAVE_PROBE_BACKLASH] -description: this macros save the sensor backlash. -gcode: - {% set probe_backlash_x = printer.auto_wcs.probe_backlash_x %} - {% set probe_backlash_y = printer.auto_wcs.probe_backlash_y %} - {% set probe_backlash_y_2 = printer.auto_wcs.probe_backlash_y_2 %} - SAVE_VARIABLE VARIABLE=probe_backlash_x VALUE={probe_backlash_x} - SAVE_VARIABLE VARIABLE=probe_backlash_y VALUE={probe_backlash_y} - SAVE_VARIABLE VARIABLE=probe_backlash_y_2 VALUE={probe_backlash_y_2} - {action_respond_info('save probe_backlash_x=%s' % probe_backlash_x)} - {action_respond_info('save probe_backlash_y=%s' % probe_backlash_y)} - {action_respond_info('save probe_backlash_y_2=%s' % probe_backlash_y_2)} - [gcode_macro MOVE_TO_AUTO_WCS] gcode: {% set set_xy = params.XY|default(0) %} @@ -407,6 +392,7 @@ gcode: {% endif %} {% endif %} + [gcode_macro ADJUST_PROBE_OFFSET_XY] gcode: {% if printer["gcode_button five_axis_module"].state == "PRESSED" %} @@ -453,7 +439,6 @@ gcode: {% endif %} [gcode_macro AUTO_BASEMENT_WCS] -description: This macro performs move based on the required measuring(wcs1_z, wcs2_y, wcs2_z), and takes measurements. gcode: {% set wcs = params.WCS|default(0)|int %} {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} @@ -478,6 +463,7 @@ gcode: {% else %} PROBE {% endif %} + PROBE G0 Z150 F3600 [gcode_macro AUTO_BASEMENT_WCS_MOVE] @@ -587,7 +573,6 @@ gcode: G0 Z150 F3600 [gcode_macro ADJUST_BASEMENT_WCS] -description: macro needed for set wcs based selected mode the manager calibrate. gcode: {% set wcs = params.WCS|default(0)|int %} {% set point = printer.probe.last_result %} diff --git a/stereotech_config/probe_2.cfg b/stereotech_config/probe_2.cfg index 2be0c21367e5..49fc78d092d4 100644 --- a/stereotech_config/probe_2.cfg +++ b/stereotech_config/probe_2.cfg @@ -116,19 +116,19 @@ gcode: SET_A_OFFSET_POINT POINT=1 CALC_A_AXIS_OFFSET - ;PROBE_TEMPLATE_POINT POINT=CZ - ;SET_B_COMPENSATION_POINT POINT=0 - ;PROBE_TEMPLATE_POINT POINT=CZ1 - ;SET_B_COMPENSATION_POINT POINT=1 - ;PROBE_TEMPLATE_POINT POINT=AZ - ;SET_B_COMPENSATION_POINT POINT=2 - ;PROBE_TEMPLATE_POINT POINT=BZ - ;SET_B_COMPENSATION_POINT POINT=3 - ;PROBE_TEMPLATE_POINT POINT=AX - ;SET_B_COMPENSATION_POINT POINT=4 - ;PROBE_TEMPLATE_POINT POINT=BX - ;SET_B_COMPENSATION_POINT POINT=5 - ;CALC_B_AXIS_COMPENSATION ENABLE=0 + PROBE_TEMPLATE_POINT POINT=CZ + SET_B_COMPENSATION_POINT POINT=0 + PROBE_TEMPLATE_POINT POINT=CZ1 + SET_B_COMPENSATION_POINT POINT=1 + PROBE_TEMPLATE_POINT POINT=AZ + SET_B_COMPENSATION_POINT POINT=2 + PROBE_TEMPLATE_POINT POINT=BZ + SET_B_COMPENSATION_POINT POINT=3 + PROBE_TEMPLATE_POINT POINT=AX + SET_B_COMPENSATION_POINT POINT=4 + PROBE_TEMPLATE_POINT POINT=BX + SET_B_COMPENSATION_POINT POINT=5 + CALC_B_AXIS_COMPENSATION ENABLE=0 ; skew corection ; xy skew @@ -322,7 +322,6 @@ gcode: {% set template_thickness = printer.save_variables.variables.template_thickness|default(10.0)|float %} {% set auto_wcs_adj = printer.save_variables.variables.auto_wcs_adj|default(0.3)|float %} CALC_WCS_PARAMS THICKNESS={ template_thickness } ADJUSTMENT={ auto_wcs_adj } SENSOR_VERSION=1 - SAVE_PROBE_BACKLASH PROBE_TEMPLATE_POINT POINT=AY SET_C_ALIGN_POINT POINT=0 PROBE_TEMPLATE_POINT POINT=BY @@ -331,19 +330,6 @@ gcode: MOVE_TO_AUTO_WCS {% endif %} -[gcode_macro SAVE_PROBE_BACKLASH] -description: this macros save the sensor backlash. -gcode: - {% set probe_backlash_x = printer.auto_wcs.probe_backlash_x %} - {% set probe_backlash_y = printer.auto_wcs.probe_backlash_y %} - {% set probe_backlash_y_2 = printer.auto_wcs.probe_backlash_y_2 %} - SAVE_VARIABLE VARIABLE=probe_backlash_x VALUE={probe_backlash_x} - SAVE_VARIABLE VARIABLE=probe_backlash_y VALUE={probe_backlash_y} - SAVE_VARIABLE VARIABLE=probe_backlash_y_2 VALUE={probe_backlash_y_2} - {action_respond_info('probe_backlash_x=%s' % probe_backlash_x)} - {action_respond_info('probe_backlash_y=%s' % probe_backlash_y)} - {action_respond_info('probe_backlash_y_2=%s' % probe_backlash_y_2)} - [gcode_macro MOVE_TO_AUTO_WCS] gcode: {% set set_xy = params.XY|default(0) %} @@ -425,7 +411,6 @@ gcode: {% endif %} [gcode_macro AUTO_BASEMENT_WCS] -description: This macro performs move based on the required measuring(wcs1_z, wcs2_y, wcs2_z), and takes measurements. gcode: {% set wcs = params.WCS|default(0)|int %} {% set probe_sensor_version = printer.save_variables.variables.probe_sensor_version|default(0)|int %} @@ -443,6 +428,7 @@ gcode: {% else %} PROBE {% endif %} + PROBE G0 Z150 F3600 [gcode_macro AUTO_BASEMENT_WCS_MOVE] @@ -552,7 +538,6 @@ gcode: G0 Z150 F3600 [gcode_macro ADJUST_BASEMENT_WCS] -description: macro needed for set wcs based selected mode the manager calibrate. gcode: {% set wcs = params.WCS|default(0)|int %} {% set point = printer.probe.last_result %}