Commit 8a3b09f9 authored by NicolaiO's avatar NicolaiO 🐼 Committed by TIGERs GitLab
Browse files

Resolve "ReduceToggling in CenterBack CoverModes"

Closes #1733

See merge request main/Sumatra!1503

sumatra-commit: 2227c2e32f666e68929202faae9c6c6c97c84a77
parent 9ff1a382
Pipeline #17599 passed with stage
in 4 minutes and 12 seconds
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.math;
......@@ -98,6 +98,18 @@ public final class AngleMath
}
public static int compareAngle(final double angle1, final double angle2)
{
final var rotDirection = AngleMath.rotationDirection(angle1, angle2);
return switch (rotDirection)
{
case NONE -> 0;
case CLOCKWISE -> 1;
case COUNTER_CLOCKWISE -> -1;
};
}
/**
* Get the absolute smallest difference between angle1 and angle2.<br>
* <code>abs(norm(angle1-angle2))</code>
......
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.math;
......@@ -92,6 +92,18 @@ public class AngleMathTest
}
@Test
public void testCompareAngle()
{
assertThat(AngleMath.compareAngle(AngleMath.deg2rad(-45), AngleMath.deg2rad(45))).isEqualTo(-1);
assertThat(AngleMath.compareAngle(AngleMath.deg2rad(45), AngleMath.deg2rad(-45))).isEqualTo(1);
assertThat(AngleMath.compareAngle(AngleMath.deg2rad(-135), AngleMath.deg2rad(135))).isEqualTo(1);
assertThat(AngleMath.compareAngle(AngleMath.deg2rad(135), AngleMath.deg2rad(-135))).isEqualTo(-1);
assertThat(AngleMath.compareAngle(0, 1e-7)).isZero();
assertThat(AngleMath.compareAngle(0, -1e-7)).isZero();
}
@Test
public void testDeg2Rad()
{
......
......@@ -90,6 +90,10 @@ public class AutoRefRunner implements Runnable, IWorldFrameObserver
{
// switch off engine first
changeMode(EAutoRefMode.OFF);
// deregister from WP frames
SumatraModel.getInstance().getModule(AWorldPredictor.class).removeObserver(this);
// clear auto ref shape map
SumatraModel.getInstance().getModule(AWorldPredictor.class).notifyRemoveSourceFromShapeMap(AUTO_REF);
try
{
executorService.shutdown();
......@@ -99,10 +103,8 @@ public class AutoRefRunner implements Runnable, IWorldFrameObserver
log.error("Interrupted while awaiting termination", e);
Thread.currentThread().interrupt();
}
// deregister from WP frames
SumatraModel.getInstance().getModule(AWorldPredictor.class).removeObserver(this);
// clear auto ref shape map
SumatraModel.getInstance().getModule(AWorldPredictor.class).notifyRemoveSourceFromShapeMap(AUTO_REF);
// Remove any remaining frames
consumableFrames.pollLast();
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment