Skip to content

Commit

Permalink
Remove check for returned XY coordinate when probing (#2632)
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler authored Oct 29, 2024
1 parent 8910a84 commit 8ce4608
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]);
}


Expand Down

0 comments on commit 8ce4608

Please sign in to comment.