Commit e25b9c69 authored by MarkG's avatar MarkG Committed by TIGERs GitLab
Browse files

Resolve "Fix AI recalculation"

Closes #1749

See merge request main/Sumatra!1524

sumatra-commit: 7156ebe05eaab51cb1e7232f5619fd6ddb52dc9e
parent 2e1cfe71
Pipeline #17745 passed with stage
in 7 minutes and 49 seconds
/*
* Copyright (c) 2009 - 2018, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.ids;
import com.github.g3force.s2vconverter.IString2ValueConverter;
import java.util.ArrayList;
import java.util.List;
import com.github.g3force.s2vconverter.IString2ValueConverter;
/**
* Converter for {@link AObjectID}s
......@@ -23,8 +23,8 @@ public class ObjectIdConverter implements IString2ValueConverter
|| impl.equals(BallID.class)
|| impl.equals(UninitializedID.class);
}
@Override
public Object parseString(final Class<?> impl, final String value)
{
......@@ -38,7 +38,7 @@ public class ObjectIdConverter implements IString2ValueConverter
throw new NumberFormatException("Format does not conform to: id[[, ]color]. Values: " + finalValues);
}
int id = Integer.parseInt(finalValues.get(0));
if (id == UninitializedID.UNINITIALIZED_ID)
if (id == AObjectID.UNINITIALIZED_ID)
{
return new UninitializedID();
}
......@@ -49,8 +49,8 @@ public class ObjectIdConverter implements IString2ValueConverter
ETeamColor color = getTeamColor(finalValues.get(1));
return BotID.createBotId(id, color);
}
private static List<String> parseValues(final String value)
{
String[] values = value.replaceAll("[,;]", " ").split("[ ]");
......@@ -64,8 +64,8 @@ public class ObjectIdConverter implements IString2ValueConverter
}
return finalValues;
}
private static ETeamColor getTeamColor(final String str)
{
if (str.startsWith("Y"))
......@@ -77,13 +77,13 @@ public class ObjectIdConverter implements IString2ValueConverter
}
throw new NumberFormatException("invalid team color: " + str);
}
@Override
public String toString(final Class<?> impl, final Object value)
{
AObjectID vec = (AObjectID) value;
return vec.getSaveableString();
}
}
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.autoreferee.engine.detector;
......@@ -23,6 +23,7 @@ import edu.tigers.sumatra.wp.data.ITrackedBot;
import java.awt.Color;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
......@@ -77,7 +78,7 @@ public class BallPlacementInterferenceDetector extends AGameEventDetector
private boolean isNewViolator(BotID id)
{
return violators.stream().noneMatch(e -> e.getBotId() == id);
return violators.stream().noneMatch(e -> Objects.equals(e.getBotId(), id));
}
......
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.autoreferee.engine.detector;
......@@ -14,7 +14,7 @@ import edu.tigers.sumatra.wp.data.ITrackedBot;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
......@@ -32,11 +32,11 @@ public class BotStopSpeedDetector extends AGameEventDetector
@Configurable(comment = "[s] The number of milliseconds that a bot needs violate the stop speed limit to be reported (to compensate known bad vision filter detections)", defValue = "0.3")
private static double minViolationDuration = 0.3;
private final Map<BotID, Violator> violatorMap = new IdentityHashMap<>();
private final Map<BotID, Violator> violatorMap = new HashMap<>();
/**
* Rules state: A violation of this rule is only counted once per robot and stoppage.
*/
private final Map<BotID, Boolean> infringementRecordedThisStopPhase = new IdentityHashMap<>();
private final Map<BotID, Boolean> infringementRecordedThisStopPhase = new HashMap<>();
private long entryTime;
private long lastGameEventRaised;
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.persistence;
......@@ -182,9 +182,8 @@ public class BerkeleyEnv
zipParams.setCompressionLevel(CompressionLevel.FAST);
log.info("Compressing database...");
long tStart = System.nanoTime();
try
try (ZipFile zipFile = new ZipFile(zipFileHandle))
{
ZipFile zipFile = new ZipFile(zipFileHandle);
zipFile.addFolder(envHome, zipParams);
} catch (ZipException e)
{
......
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.vision;
......@@ -379,7 +379,7 @@ public class CamFilter
if (numCloseTrackers > 0)
{
log.debug("[" + r.getCameraId() + "] Ignoring new robot " + r.getBotId());
log.debug("[{}] Ignoring new robot {}", r.getCameraId(), r.getBotId());
} else
{
if (robots.containsKey(r.getBotId()))
......@@ -400,7 +400,7 @@ public class CamFilter
{
RobotTracker tracker;
Optional<FilteredVisionBot> filteredBot = mergedRobots.stream()
.filter(m -> m.getBotID() == robot.getBotId())
.filter(m -> m.getBotID().equals(robot.getBotId()))
.findFirst();
if (filteredBot.isPresent() && fieldRectWithBoundary.isPresent()
......
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.vision;
......@@ -10,7 +10,7 @@ import edu.tigers.sumatra.cam.data.CamRobot;
import edu.tigers.sumatra.ids.BotID;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -31,7 +31,7 @@ public class RobotQualityInspector
ConfigRegistration.registerClass("vision", RobotQualityInspector.class);
}
private final Map<BotID, List<Long>> measurements = new IdentityHashMap<>();
private final Map<BotID, List<Long>> measurements = new HashMap<>();
private long initialTimestamp;
private double maxPossibleDetectionsPerCam;
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.wp;
......@@ -17,7 +17,7 @@ import edu.tigers.sumatra.wp.data.TrackedBall;
import edu.tigers.sumatra.wp.data.TrackedBot;
import edu.tigers.sumatra.wp.data.WorldFrame;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
......@@ -70,7 +70,7 @@ public class WorldFrameFactory
*/
public static SimpleWorldFrame createSimpleWorldFrame(final long frameNumber, final long timestamp)
{
final Map<BotID, ITrackedBot> bots = new IdentityHashMap<>();
final Map<BotID, ITrackedBot> bots = new HashMap<>();
for (int i = 0; i < 6; i++)
{
......
/*
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.wp;
......@@ -64,8 +64,8 @@ import lombok.extern.log4j.Log4j2;
import java.io.IOException;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -231,7 +231,7 @@ public class WorldInfoCollector extends AWorldPredictor
filteredVisionBotMap.get(r.getBotId())))
.filter(Objects::nonNull)
.collect(Collectors.toMap(ITrackedBot::getBotId, Function.identity()));
return new IdentityHashMap<>(trackedBots);
return new HashMap<>(trackedBots);
}
......@@ -255,7 +255,7 @@ public class WorldInfoCollector extends AWorldPredictor
return null;
}
var kick = filteredVisionFrame.getKick().get();
var kick = filteredVisionFrame.getKick().orElseThrow();
return KickEvent.builder()
.kickingBot(kick.getKickingBot())
......@@ -285,7 +285,7 @@ public class WorldInfoCollector extends AWorldPredictor
return null;
}
var kick = filteredVisionFrame.getKick().get();
var kick = filteredVisionFrame.getKick().orElseThrow();
return new BallKickFitState(kick.getBallTrajectory().getInitialPos().getXYVector(),
kick.getBallTrajectory().getInitialVel(), kick.getTrajectoryStartTime());
}
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2022, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.wp.data;
......@@ -13,7 +13,7 @@ import lombok.RequiredArgsConstructor;
import java.util.Arrays;
import java.util.Collections;
import java.util.IdentityHashMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
......@@ -71,7 +71,7 @@ public class SimpleWorldFrame implements IMirrorable<SimpleWorldFrame>
@Override
public SimpleWorldFrame mirrored()
{
Map<BotID, ITrackedBot> newBots = new IdentityHashMap<>();
Map<BotID, ITrackedBot> newBots = new HashMap<>();
for (ITrackedBot bot : bots.values())
{
ITrackedBot mBot = bot.mirrored();
......@@ -128,8 +128,8 @@ public class SimpleWorldFrame implements IMirrorable<SimpleWorldFrame>
*/
public Map<BotID, ITrackedBot> getAllBotsBut(BotID... botID)
{
var allBots = new IdentityHashMap<>(bots);
allBots.keySet().removeAll(Arrays.asList(botID));
var allBots = new HashMap<>(bots);
Arrays.asList(botID).forEach(allBots.keySet()::remove);
return allBots;
}
}
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