Fix MIN_PROBE_EDGE bug in default ABL G29 (#16367)

This commit is contained in:
Jason Smith
2020-01-03 17:46:26 -06:00
committed by Scott Lahteine
parent d7aee3b7b6
commit 3cade6245e
17 changed files with 175 additions and 110 deletions

View File

@ -2354,7 +2354,12 @@ void MarlinSettings::reset() {
#if HAS_BED_PROBE
constexpr float dpo[XYZ] = NOZZLE_TO_PROBE_OFFSET;
static_assert(COUNT(dpo) == 3, "NOZZLE_TO_PROBE_OFFSET must contain offsets for X, Y, and Z.");
LOOP_XYZ(a) probe_offset[a] = dpo[a];
#if HAS_PROBE_XY_OFFSET
LOOP_XYZ(a) probe_offset[a] = dpo[a];
#else
probe_offset.x = probe_offset.y = 0;
probe_offset.z = dpo[Z_AXIS];
#endif
#endif
//
@ -3102,9 +3107,16 @@ void MarlinSettings::reset() {
say_units(true);
}
CONFIG_ECHO_START();
SERIAL_ECHOLNPAIR_P(PSTR(" M851 X"), LINEAR_UNIT(probe_offset.x),
SP_Y_STR, LINEAR_UNIT(probe_offset.y),
SP_Z_STR, LINEAR_UNIT(probe_offset.z));
SERIAL_ECHOLNPAIR_P(
#if HAS_PROBE_XY_OFFSET
PSTR(" M851 X"), LINEAR_UNIT(probe_offset_xy.x),
SP_Y_STR, LINEAR_UNIT(probe_offset_xy.y),
SP_Z_STR
#else
PSTR(" M851 X0 Y0 Z")
#endif
, LINEAR_UNIT(probe_offset.z)
);
#endif
/**

View File

@ -91,13 +91,7 @@ void recalc_delta_settings() {
#endif
float delta_calibration_radius() {
return FLOOR((DELTA_PRINTABLE_RADIUS - (
#if HAS_BED_PROBE
_MAX(HYPOT(probe_offset.x, probe_offset.y), MIN_PROBE_EDGE)
#else
MIN_PROBE_EDGE
#endif
)) * calibration_radius_factor);
return FLOOR((DELTA_PRINTABLE_RADIUS - _MAX(HYPOT(probe_offset_xy.x, probe_offset_xy.y), MIN_PROBE_EDGE)) * calibration_radius_factor);
}
/**

View File

@ -291,6 +291,7 @@ void homeaxis(const AxisEnum axis);
*/
#if IS_KINEMATIC // (DELTA or SCARA)
#if HAS_SCARA_OFFSET
extern abc_pos_t scara_home_offset; // A and B angular offsets, Z mm offset
#endif
@ -315,13 +316,25 @@ void homeaxis(const AxisEnum axis);
}
#if HAS_BED_PROBE
// Return true if the both nozzle and the probe can reach the given point.
// Note: This won't work on SCARA since the probe offset rotates with the arm.
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
&& position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
}
#endif
#if HAS_PROBE_XY_OFFSET
// Return true if the both nozzle and the probe can reach the given point.
// Note: This won't work on SCARA since the probe offset rotates with the arm.
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
&& position_is_reachable(rx, ry, ABS(MIN_PROBE_EDGE));
}
#else
FORCE_INLINE bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx, ry, MIN_PROBE_EDGE);
}
#endif
#endif // HAS_BED_PROBE
#else // CARTESIAN
@ -340,6 +353,7 @@ void homeaxis(const AxisEnum axis);
inline bool position_is_reachable(const xy_pos_t &pos) { return position_is_reachable(pos.x, pos.y); }
#if HAS_BED_PROBE
/**
* Return whether the given position is within the bed, and whether the nozzle
* can reach the position required to put the probe at the given position.
@ -348,11 +362,12 @@ void homeaxis(const AxisEnum axis);
* nozzle must be be able to reach +10,-10.
*/
inline bool position_is_reachable_by_probe(const float &rx, const float &ry) {
return position_is_reachable(rx - probe_offset.x, ry - probe_offset.y)
return position_is_reachable(rx - probe_offset_xy.x, ry - probe_offset_xy.y)
&& WITHIN(rx, probe_min_x() - slop, probe_max_x() + slop)
&& WITHIN(ry, probe_min_y() - slop, probe_max_y() + slop);
}
#endif
#endif // HAS_BED_PROBE
#endif // CARTESIAN

View File

@ -56,8 +56,6 @@
#include "../feature/backlash.h"
#endif
xyz_pos_t probe_offset; // Initialized by settings.load()
#if ENABLED(BLTOUCH)
#include "../feature/bltouch.h"
#endif
@ -86,6 +84,14 @@ xyz_pos_t probe_offset; // Initialized by settings.load()
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
xyz_pos_t probe_offset; // Initialized by settings.load()
#if HAS_PROBE_XY_OFFSET
xyz_pos_t &probe_offset_xy = probe_offset;
#endif
#if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET
@ -698,7 +704,7 @@ float probe_at_point(const float &rx, const float &ry, const ProbePtRaise raise_
xyz_pos_t npos = { rx, ry };
if (probe_relative) {
if (!position_is_reachable_by_probe(npos)) return NAN; // The given position is in terms of the probe
npos -= probe_offset; // Get the nozzle position
npos -= probe_offset_xy; // Get the nozzle position
}
else if (!position_is_reachable(npos)) return NAN; // The given position is in terms of the nozzle

View File

@ -31,6 +31,12 @@
extern xyz_pos_t probe_offset;
#if HAS_PROBE_XY_OFFSET
extern xyz_pos_t &probe_offset_xy;
#else
constexpr xy_pos_t probe_offset_xy{0};
#endif
bool set_probe_deployed(const bool deploy);
#ifdef Z_AFTER_PROBING
void move_z_after_probing();
@ -54,6 +60,7 @@
#else
constexpr xyz_pos_t probe_offset{0};
constexpr xy_pos_t probe_offset_xy{0};
#define DEPLOY_PROBE()
#define STOW_PROBE()
@ -71,13 +78,7 @@
);
inline float probe_radius() {
return printable_radius - (
#if HAS_BED_PROBE
_MAX(MIN_PROBE_EDGE, HYPOT(probe_offset.x, probe_offset.y))
#else
MIN_PROBE_EDGE
#endif
);
return printable_radius - _MAX(MIN_PROBE_EDGE, HYPOT(probe_offset_xy.x, probe_offset_xy.y));
}
#endif
@ -85,10 +86,8 @@
return (
#if IS_KINEMATIC
(X_CENTER) - probe_radius()
#elif ENABLED(NOZZLE_AS_PROBE)
_MAX(MIN_PROBE_EDGE_LEFT, X_MIN_POS)
#else
_MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset.x)
_MAX((X_MIN_BED) + (MIN_PROBE_EDGE_LEFT), (X_MIN_POS) + probe_offset_xy.x)
#endif
);
}
@ -96,10 +95,8 @@
return (
#if IS_KINEMATIC
(X_CENTER) + probe_radius()
#elif ENABLED(NOZZLE_AS_PROBE)
_MAX(MIN_PROBE_EDGE_RIGHT, X_MAX_POS)
#else
_MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset.x)
_MIN((X_MAX_BED) - (MIN_PROBE_EDGE_RIGHT), (X_MAX_POS) + probe_offset_xy.x)
#endif
);
}
@ -107,10 +104,8 @@
return (
#if IS_KINEMATIC
(Y_CENTER) - probe_radius()
#elif ENABLED(NOZZLE_AS_PROBE)
_MIN(MIN_PROBE_EDGE_FRONT, Y_MIN_POS)
#else
_MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset.y)
_MAX((Y_MIN_BED) + (MIN_PROBE_EDGE_FRONT), (Y_MIN_POS) + probe_offset_xy.y)
#endif
);
}
@ -118,10 +113,8 @@
return (
#if IS_KINEMATIC
(Y_CENTER) + probe_radius()
#elif ENABLED(NOZZLE_AS_PROBE)
_MAX(MIN_PROBE_EDGE_BACK, Y_MAX_POS)
#else
_MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset.y)
_MIN((Y_MAX_BED) - (MIN_PROBE_EDGE_BACK), (Y_MAX_POS) + probe_offset_xy.y)
#endif
);
}