diff --git a/src/main/java/nl/roboteamtwente/autoref/SSLAutoRef.java b/src/main/java/nl/roboteamtwente/autoref/SSLAutoRef.java index f70de3e..ba6ba99 100644 --- a/src/main/java/nl/roboteamtwente/autoref/SSLAutoRef.java +++ b/src/main/java/nl/roboteamtwente/autoref/SSLAutoRef.java @@ -27,6 +27,7 @@ public class SSLAutoRef { private int commands = 0; private int nextTouchId = 0; + private long time_counter = 0; public SSLAutoRef() { this.referee = new Referee(); @@ -67,6 +68,10 @@ public void processWorldState(StateOuterClass.State statePacket) { gameStateChanges(game); referee.setGame(game); + time_counter += 1; + if (time_counter % 80 == 0) { + System.out.println("AUTOREF ALIVE"); + } } /** diff --git a/src/main/java/nl/roboteamtwente/autoref/WorldConnection.java b/src/main/java/nl/roboteamtwente/autoref/WorldConnection.java index 746dcc5..46e039b 100644 --- a/src/main/java/nl/roboteamtwente/autoref/WorldConnection.java +++ b/src/main/java/nl/roboteamtwente/autoref/WorldConnection.java @@ -35,18 +35,19 @@ public void connect() { * Receive and process messages */ public void listener() { - try { - while (!Thread.currentThread().isInterrupted() && worldSocket != null) { + while (!Thread.currentThread().isInterrupted() && worldSocket != null) { + try { byte[] buffer = worldSocket.recv(); StateOuterClass.State packet = StateOuterClass.State.parseFrom(buffer); ref.checkViolations(packet); - } - } catch (InvalidProtocolBufferException e) { - e.printStackTrace(); - } catch (ZMQException e) { - //4 is the error code when we close the connection by hand, which can be ignored - if (e.getErrorCode() != 4) { + + } catch (InvalidProtocolBufferException e) { e.printStackTrace(); + } catch (ZMQException e) { + //4 is the error code when we close the connection by hand, which can be ignored + if (e.getErrorCode() != 4) { + e.printStackTrace(); + } } } } diff --git a/src/main/java/nl/roboteamtwente/autoref/validators/BotCrashingValidator.java b/src/main/java/nl/roboteamtwente/autoref/validators/BotCrashingValidator.java index 3c2abe4..ca245f9 100644 --- a/src/main/java/nl/roboteamtwente/autoref/validators/BotCrashingValidator.java +++ b/src/main/java/nl/roboteamtwente/autoref/validators/BotCrashingValidator.java @@ -13,7 +13,7 @@ public class BotCrashingValidator implements RuleValidator { - private static final float BOT_CRASH_DISTANCE = 0.2f; + private static final float BOT_CRASH_DISTANCE = 0.005f; private static final float SPEED_VECTOR_THRESHOLD = 1.5f; private static final float MIN_SPEED_DIFFERENCE = 0.3f; private static final double GRACE_PERIOD = 2.0; @@ -111,7 +111,7 @@ public RuleViolation validate(Game game) { Vector2 robotBlueVel = robotBlue.getVelocity().xy(); float distanceBetweenRobots = robotYellowPos.distance(robotBluePos); - if (distanceBetweenRobots <= BOT_CRASH_DISTANCE) { + if (distanceBetweenRobots <= robotYellow.getRadius() + robotBlue.getRadius() + BOT_CRASH_DISTANCE) { // projection length of difference between speed vector float crashSpeed = calculateCollisionVelocity(robotBluePos, robotBlueVel, robotYellowPos, robotYellowVel);