diff --git a/ugs-platform/ugs-platform-surfacescanner/src/main/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScanner.java b/ugs-platform/ugs-platform-surfacescanner/src/main/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScanner.java index 6397a83de6..406c7c7a40 100644 --- a/ugs-platform/ugs-platform-surfacescanner/src/main/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScanner.java +++ b/ugs-platform/ugs-platform-surfacescanner/src/main/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScanner.java @@ -27,7 +27,6 @@ This file is part of Universal Gcode Sender (UGS). import com.willwinder.universalgcodesender.model.UnitUtils.Units; import com.willwinder.universalgcodesender.model.events.ProbeEvent; import com.willwinder.universalgcodesender.utils.AutoLevelSettings; -import static com.willwinder.universalgcodesender.utils.MathUtils.isEqual; import java.util.Deque; import java.util.LinkedList; @@ -163,14 +162,6 @@ public void reset() { public void probeEvent(final Position p) { Position expectedProbePosition = pendingPositions.pop(); Position probedPosition = p.getPositionIn(expectedProbePosition.getUnits()); - - // The position reported from the controller might lack some precision on the X/Y position. - // We therefore need to lower the precision when checking the probed X/Y axes - double delta = 0.1; - if (!isEqual(probedPosition.getX(), expectedProbePosition.getX(), delta) || !isEqual(probedPosition.getY(), expectedProbePosition.getY(), delta)) { - reset(); - throw new RuntimeException(String.format("Unexpected probe location, expected %s to be %s", probedPosition, expectedProbePosition)); - } Position settingsOffset = settings.getAutoLevelProbeOffset().getPositionIn(getPreferredUnits()); expectedProbePosition.setX(expectedProbePosition.getX() + settingsOffset.getX()); diff --git a/ugs-platform/ugs-platform-surfacescanner/src/test/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScannerTest.java b/ugs-platform/ugs-platform-surfacescanner/src/test/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScannerTest.java index 4c10f7e500..d26514358b 100644 --- a/ugs-platform/ugs-platform-surfacescanner/src/test/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScannerTest.java +++ b/ugs-platform/ugs-platform-surfacescanner/src/test/java/com/willwinder/ugs/platform/surfacescanner/SurfaceScannerTest.java @@ -9,7 +9,8 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.mockito.Mockito.when; public class SurfaceScannerTest { @@ -87,7 +88,18 @@ public void probeEventShouldAllowForSomePrecisionErrorsFromController() { Position third = new Position(surfaceScanner.getNextProbePoint().get()); third.setY(third.getY() + 0.11); - assertThrows(RuntimeException.class, () -> surfaceScanner.probeEvent(createProbePoint(third, UnitUtils.Units.MM, 1))); + surfaceScanner.probeEvent(createProbePoint(third, UnitUtils.Units.MM, 3)); + + Position fourth = new Position(surfaceScanner.getNextProbePoint().get()); + third.setY(fourth.getY() - 0.11); + surfaceScanner.probeEvent(createProbePoint(third, UnitUtils.Units.MM, 4)); + + Position[][] probePositionGrid = surfaceScanner.getProbePositionGrid(); + assertEquals(2, probePositionGrid.length); + assertEquals(new Position(0, 0, 1.0, UnitUtils.Units.MM), probePositionGrid[0][0]); + assertEquals(new Position(0, 1, 2.0, UnitUtils.Units.MM), probePositionGrid[0][1]); + assertEquals(new Position(1, 0, 4.0, UnitUtils.Units.MM), probePositionGrid[1][0]); + assertEquals(new Position(1, 1, 3.0, UnitUtils.Units.MM), probePositionGrid[1][1]); }