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

@ -45,20 +45,21 @@ void GcodeSuite::G42() {
return;
}
// Move to current_position, as modified by I, J, P parameters
destination = current_position;
if (hasI) destination.x = _GET_MESH_X(ix);
if (hasJ) destination.y = _GET_MESH_Y(iy);
#if HAS_BED_PROBE
#if HAS_PROBE_XY_OFFSET
if (parser.boolval('P')) {
if (hasI) destination.x -= probe_offset.x;
if (hasJ) destination.y -= probe_offset.y;
if (hasI) destination.x -= probe_offset_xy.x;
if (hasJ) destination.y -= probe_offset_xy.y;
}
#endif
const feedRate_t fval = parser.linearval('F'),
fr_mm_s = fval > 0 ? MMM_TO_MMS(fval) : 0.0f;
fr_mm_s = MMM_TO_MMS(fval > 0 ? fval : 0.0f);
// SCARA kinematic has "safe" XY raw moves
#if IS_SCARA

View File

@ -228,7 +228,7 @@ G29_TYPE GcodeSuite::G29() {
ABL_VAR xy_int8_t meshCount;
#endif
ABL_VAR xy_float_t probe_position_lf, probe_position_rb;
ABL_VAR xy_pos_t probe_position_lf, probe_position_rb;
ABL_VAR xy_float_t gridSpacing = { 0, 0 };
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
@ -403,14 +403,13 @@ G29_TYPE GcodeSuite::G29() {
}
else {
probe_position_lf.set(
parser.seenval('L') ? (int)RAW_X_POSITION(parser.value_linear_units()) : (_MAX(x_min, X_CENTER - (X_BED_SIZE) / 2) + MIN_PROBE_EDGE_LEFT),
parser.seenval('F') ? (int)RAW_Y_POSITION(parser.value_linear_units()) : (_MAX(y_min, Y_CENTER - (Y_BED_SIZE) / 2) + MIN_PROBE_EDGE_FRONT)
parser.seenval('L') ? RAW_X_POSITION(parser.value_linear_units()) : x_min,
parser.seenval('F') ? RAW_Y_POSITION(parser.value_linear_units()) : y_min
);
probe_position_rb.set(
parser.seenval('R') ? (int)RAW_X_POSITION(parser.value_linear_units()) : (_MIN(x_max, probe_position_lf.x + X_BED_SIZE) - MIN_PROBE_EDGE_RIGHT),
parser.seenval('B') ? (int)RAW_Y_POSITION(parser.value_linear_units()) : (_MIN(y_max, probe_position_lf.y + Y_BED_SIZE) - MIN_PROBE_EDGE_BACK)
parser.seenval('R') ? RAW_X_POSITION(parser.value_linear_units()) : x_max,
parser.seenval('B') ? RAW_Y_POSITION(parser.value_linear_units()) : y_max
);
SERIAL_ECHOLN("Set Trail 1");
}
if (
@ -911,8 +910,8 @@ G29_TYPE GcodeSuite::G29() {
planner.force_unapply_leveling(converted); // use conversion machinery
// Use the last measured distance to the bed, if possible
if ( NEAR(current_position.x, probePos.x - probe_offset.x)
&& NEAR(current_position.y, probePos.y - probe_offset.y)
if ( NEAR(current_position.x, probePos.x - probe_offset_xy.x)
&& NEAR(current_position.y, probePos.y - probe_offset_xy.y)
) {
const float simple_z = current_position.z - measured_z;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted.z, " Discrepancy ", simple_z - converted.z);

View File

@ -133,7 +133,7 @@
destination.set(safe_homing_xy, current_position.z);
#if HOMING_Z_WITH_PROBE
destination -= probe_offset;
destination -= probe_offset_xy;
#endif
if (position_is_reachable(destination)) {

View File

@ -77,8 +77,8 @@ void GcodeSuite::M48() {
xy_float_t next_pos = current_position;
const xy_pos_t probe_pos = {
parser.linearval('X', next_pos.x + probe_offset.x),
parser.linearval('Y', next_pos.y + probe_offset.y)
parser.linearval('X', next_pos.x + probe_offset_xy.x),
parser.linearval('Y', next_pos.y + probe_offset_xy.y)
};
if (!position_is_reachable_by_probe(probe_pos)) {
@ -166,8 +166,9 @@ void GcodeSuite::M48() {
while (angle < 0.0) angle += 360.0; // outside of this range. It looks like they behave correctly with
// numbers outside of the range, but just to be safe we clamp them.
next_pos.set(probe_pos.x - probe_offset.x + cos(RADIANS(angle)) * radius,
probe_pos.y - probe_offset.y + sin(RADIANS(angle)) * radius);
const xy_pos_t noz_pos = probe_pos - probe_offset_xy;
next_pos.set(noz_pos.x + cos(RADIANS(angle)) * radius,
noz_pos.y + sin(RADIANS(angle)) * radius);
#if DISABLED(DELTA)
LIMIT(next_pos.x, X_MIN_POS, X_MAX_POS);

View File

@ -39,8 +39,9 @@
* E Engage the probe for each probe (default 1)
*/
void GcodeSuite::G30() {
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset.x),
parser.linearval('Y', current_position.y + probe_offset.y) };
const xy_pos_t pos = { parser.linearval('X', current_position.x + probe_offset_xy.x),
parser.linearval('Y', current_position.y + probe_offset_xy.y) };
if (!position_is_reachable_by_probe(pos)) return;

View File

@ -37,32 +37,49 @@ void GcodeSuite::M851() {
// Show usage with no parameters
if (!parser.seen("XYZ")) {
SERIAL_ECHOLNPAIR_P(PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR, probe_offset.z);
SERIAL_ECHOLNPAIR_P(
#if HAS_PROBE_XY_OFFSET
PSTR(MSG_PROBE_OFFSET " X"), probe_offset.x, SP_Y_STR, probe_offset.y, SP_Z_STR
#else
PSTR(MSG_PROBE_OFFSET " X0 Y0 Z")
#endif
, probe_offset.z
);
return;
}
// Start with current offsets and modify
xyz_pos_t offs = probe_offset;
// Assume no errors
bool ok = true;
if (parser.seenval('X')) {
const float x = parser.value_float();
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
offs.x = x;
else {
SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
ok = false;
}
#if HAS_PROBE_XY_OFFSET
if (WITHIN(x, -(X_BED_SIZE), X_BED_SIZE))
offs.x = x;
else {
SERIAL_ECHOLNPAIR("?X out of range (-", int(X_BED_SIZE), " to ", int(X_BED_SIZE), ")");
ok = false;
}
#else
if (x) SERIAL_ECHOLNPAIR("?X must be 0 (NOZZLE_AS_PROBE)."); // ...but let 'ok' stay true
#endif
}
if (parser.seenval('Y')) {
const float y = parser.value_float();
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
offs.y = y;
else {
SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
ok = false;
}
#if HAS_PROBE_XY_OFFSET
if (WITHIN(y, -(Y_BED_SIZE), Y_BED_SIZE))
offs.y = y;
else {
SERIAL_ECHOLNPAIR("?Y out of range (-", int(Y_BED_SIZE), " to ", int(Y_BED_SIZE), ")");
ok = false;
}
#else
if (y) SERIAL_ECHOLNPAIR("?Y must be 0 (NOZZLE_AS_PROBE)."); // ...but let 'ok' stay true
#endif
}
if (parser.seenval('Z')) {