@Test public void testSensorReadingLess() { when(absoluteDistanceProvider.getAbsoluteDistanceInInches()).thenReturn(DESIRED_DISTANCE_IN_INCHES * -2); boolean isDone = distanceToCommand.update(System.currentTimeMillis()); assertFalse(isDone); verify(drive, times(1)).setDriveMessage(argThat(getArgMatcher(-DRIVER_VALUE, -DRIVER_VALUE))); }
@Override public boolean update(double pNow) { boolean isFinished = false; double deltaDistance = distanceProvider.getAbsoluteDistanceInInches() - goalDistanceInInches; if(Util.epsilonEquals(deltaDistance, 0.0, mEpsilonInches)) { isFinished = true; } else if(deltaDistance > 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(mPower, 0)); isFinished = false; } else if(deltaDistance < 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(-mPower, 0)); } else { isFinished = true; } return isFinished; }
MoveToDistance implements ICommand { @Override public boolean update(double pNow) { boolean isFinished = false; double deltaDistance = distanceProvider.getAbsoluteDistanceInInches() - goalDistanceInInches; if(Util.epsilonEquals(deltaDistance, 0.0, mEpsilonInches)) { isFinished = true; } else if(deltaDistance > 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(mPower, 0)); isFinished = false; } else if(deltaDistance < 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(-mPower, 0)); } else { isFinished = true; } return isFinished; } }
MoveToDistance implements ICommand { @Override public boolean update(double pNow) { boolean isFinished = false; double deltaDistance = distanceProvider.getAbsoluteDistanceInInches() - goalDistanceInInches; if(Util.epsilonEquals(deltaDistance, 0.0, mEpsilonInches)) { isFinished = true; } else if(deltaDistance > 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(mPower, 0)); isFinished = false; } else if(deltaDistance < 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(-mPower, 0)); } else { isFinished = true; } return isFinished; } MoveToDistance(Drive drive, IAbsoluteDistanceProvider distanceProvider, double goalDistanceInInches); }
MoveToDistance implements ICommand { @Override public boolean update(double pNow) { boolean isFinished = false; double deltaDistance = distanceProvider.getAbsoluteDistanceInInches() - goalDistanceInInches; if(Util.epsilonEquals(deltaDistance, 0.0, mEpsilonInches)) { isFinished = true; } else if(deltaDistance > 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(mPower, 0)); isFinished = false; } else if(deltaDistance < 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(-mPower, 0)); } else { isFinished = true; } return isFinished; } MoveToDistance(Drive drive, IAbsoluteDistanceProvider distanceProvider, double goalDistanceInInches); @Override void init(double pNow); @Override void shutdown(double pNow); @Override boolean update(double pNow); MoveToDistance setEpsilonInches(double pEpsilonInches); MoveToDistance setPower(double pPower); }
MoveToDistance implements ICommand { @Override public boolean update(double pNow) { boolean isFinished = false; double deltaDistance = distanceProvider.getAbsoluteDistanceInInches() - goalDistanceInInches; if(Util.epsilonEquals(deltaDistance, 0.0, mEpsilonInches)) { isFinished = true; } else if(deltaDistance > 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(mPower, 0)); isFinished = false; } else if(deltaDistance < 0.0d) { drive.setDriveMessage(DriveMessage.fromThrottleAndTurn(-mPower, 0)); } else { isFinished = true; } return isFinished; } MoveToDistance(Drive drive, IAbsoluteDistanceProvider distanceProvider, double goalDistanceInInches); @Override void init(double pNow); @Override void shutdown(double pNow); @Override boolean update(double pNow); MoveToDistance setEpsilonInches(double pEpsilonInches); MoveToDistance setPower(double pPower);  }