Commit 175c60bc authored by AndreR's avatar AndreR Committed by TIGERs GitLab
Browse files

Resolve "Tune pass detection and TC play"

Closes #1638

See merge request main/Sumatra!1381

sumatra-commit: f58388ba0227b6e80e42dd16fec837ab25999dd4
parent 5040dda3
Pipeline #16679 passed with stage
in 4 minutes and 22 seconds
......@@ -56,6 +56,7 @@ public class PassDetectionAutoRefCalc implements IAutoRefereeCalc
private int passId;
private Pass lastPass;
private IKickEvent lastConsumedKickEvent;
private int numValidPasses;
@Override
......@@ -63,12 +64,18 @@ public class PassDetectionAutoRefCalc implements IAutoRefereeCalc
{
if (!enabled || !frame.getGameState().isRunning())
{
if (numValidPasses > 0)
{
log.info("Detected {} valid passes.", numValidPasses);
}
passId = 0;
lastKickEvent = null;
lastKickFitState = null;
ballVel.clear();
lastPass = null;
lastPasses.clear();
numValidPasses = 0;
return;
}
......@@ -83,6 +90,10 @@ public class PassDetectionAutoRefCalc implements IAutoRefereeCalc
}
lastPasses.add(pass);
log.info("Detected pass: {}", lastPass);
if (pass.isValid())
{
numValidPasses++;
}
});
}
......@@ -145,11 +156,9 @@ public class PassDetectionAutoRefCalc implements IAutoRefereeCalc
var direction = target.subtractNew(source).getAngle();
var directionChange = getDirectionChange(direction);
var initialBallSpeed = lastKickFitState.getAbsoluteKickSpeed();
var valid = (directionChange == null || directionChange > minDirectionChange)
&& distance > minDistance
&& initialBallSpeed <= RuleConstraints.getMaxBallSpeed();
var valid = isValid(distance, receiver, directionChange, initialBallSpeed);
return Optional.of(Pass.builder()
.id(passId++)
.id(++passId)
.timestamp(lastKickEvent.getTimestamp())
.distance(distance)
.direction(direction)
......@@ -165,6 +174,18 @@ public class PassDetectionAutoRefCalc implements IAutoRefereeCalc
}
private boolean isValid(double distance, BotID receiver, Double directionChange, double initialBallSpeed)
{
if (directionChange != null && directionChange < minDirectionChange)
{
return false;
}
return distance >= minDistance
&& initialBallSpeed <= RuleConstraints.getMaxBallSpeed()
&& getLastShooter() != receiver;
}
private Double getDirectionChange(double direction)
{
if (lastPass != null)
......@@ -175,6 +196,16 @@ public class PassDetectionAutoRefCalc implements IAutoRefereeCalc
}
private BotID getLastShooter()
{
if (lastPass != null)
{
return lastPass.getShooter();
}
return BotID.noBot();
}
private boolean passFinished(AutoRefFrame frame)
{
if (lastKickEvent == null ||
......
......@@ -178,7 +178,8 @@ public class BallFilter
KickFitResult kickFitResult = optBestKickFitResult.get();
filteredKick = FilteredVisionKick.builder()
.withKickTimestamp(kickFitResult.getKickTimestamp())
.withKickTimestamp(lastKickEvent.getTimestamp())
.withTrajectoryStartTime(kickFitResult.getKickTimestamp())
.withKickingBot(lastKickEvent.getKickingBot())
.withKickingBotPosition(lastKickEvent.getKickingBotPosition())
.withKickingBotOrientation(lastKickEvent.getBotDirection())
......
......@@ -16,6 +16,7 @@ import lombok.Value;
public class FilteredVisionKick
{
long kickTimestamp;
long trajectoryStartTime;
BotID kickingBot;
IVector2 kickingBotPosition;
......
/*
* Copyright (c) 2009 - 2020, DHBW Mannheim - TIGERs Mannheim
* Copyright (c) 2009 - 2021, DHBW Mannheim - TIGERs Mannheim
*/
package edu.tigers.sumatra.vision.kick.validators;
......@@ -29,8 +29,8 @@ public class DistanceValidator implements IKickValidator
@Configurable(defValue = "130.0", comment = "First sample must be closer, all others further away than this")
private static double thresholdDist1 = 130.0;
@Configurable(defValue = "150.0", comment = "First sample must be closer, all others further away than this (alternative)")
private static double thresholdDist2 = 150.0;
@Configurable(defValue = "170.0", comment = "First sample must be closer, all others further away than this (alternative)")
private static double thresholdDist2 = 170.0;
static
{
......
......@@ -287,7 +287,7 @@ public class WorldInfoCollector extends AWorldPredictor
var kick = filteredVisionFrame.getKick().get();
return new BallKickFitState(kick.getBallTrajectory().getInitialPos().getXYVector(),
kick.getBallTrajectory().getInitialVel(), kick.getKickTimestamp());
kick.getBallTrajectory().getInitialVel(), kick.getTrajectoryStartTime());
}
......
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