Skip to content

Commit

Permalink
Different collision and more margin to their defense
Browse files Browse the repository at this point in the history
  • Loading branch information
Becky committed Jul 18, 2024
1 parent 65f9d1c commit 7c22f84
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ double CollisionCalculations::getFirstCollisionTimeMovingObject(const Trajectory
auto pathLine = LineSegment(pathPoints[checkPoint - 1], pathPoints[checkPoint]);
double velocityOurRobot = Trajectory.getVelocity(checkPoint * 0.1).length();
auto positionOurRobot = Trajectory.getPosition(checkPoint * 0.1);
double additionalMargin = std::pow(std::min(maxVel, velocityOurRobot) / maxVel, 2) * 0.2;
if (velocityOurRobot > 0.4 && avoidObjects.shouldAvoidOurRobots) {
double additionalMargin = std::pow(std::min(3.5, velocityOurRobot) / 3.5, 2) * 0.2;
if (velocityOurRobot > 0.7 && avoidObjects.shouldAvoidOurRobots) {
for (const auto &ourOtherRobot : ourRobots) {
const int &ourOtherRobotId = ourOtherRobot->getId();
if (ourOtherRobotId == robotId) {
Expand Down Expand Up @@ -111,7 +111,7 @@ double CollisionCalculations::getFirstCollisionTimeMovingObject(const Trajectory
}
}
}
if (velocityOurRobot > 0.4 && avoidObjects.shouldAvoidTheirRobots) {
if (velocityOurRobot > 0.7 && avoidObjects.shouldAvoidTheirRobots) {
if (std::any_of(theirRobots.begin(), theirRobots.end(), [&](const auto &theirRobot) {
return LineSegment(theirRobot->getPos() + theirRobot->getVel() * 0.1 * (checkPoint - 1), theirRobot->getPos() + theirRobot->getVel() * 0.1 * checkPoint)
.closestDistanceToLineSegment(pathLine) < 2 * constants::ROBOT_RADIUS + additionalMargin;
Expand Down
4 changes: 2 additions & 2 deletions roboteam_ai/src/world/FieldComputations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
namespace rtt::ai {

std::tuple<double, double> FieldComputations::getDefenseAreaMargin() {
double theirDefenseAreaMargin = constants::ROBOT_RADIUS * 1.1 + constants::GO_TO_POS_ERROR_MARGIN;
double theirDefenseAreaMargin = constants::ROBOT_RADIUS * 1.4 + constants::GO_TO_POS_ERROR_MARGIN;
double ourDefenseAreaMargin = -constants::ROBOT_RADIUS * 0.9 + constants::GO_TO_POS_ERROR_MARGIN;

RuleSetName ruleSetTitle = GameStateManager::getCurrentGameState().getRuleSet().getTitle();
RefCommand currentGameState = GameStateManager::getCurrentGameState().getCommandId();

if (ruleSetTitle == RuleSetName::STOP || currentGameState == RefCommand::DIRECT_FREE_THEM || currentGameState == RefCommand::KICKOFF_THEM ||
currentGameState == RefCommand::DIRECT_FREE_US) {
theirDefenseAreaMargin += 0.2;
theirDefenseAreaMargin += 0.3;
}

return std::make_tuple(theirDefenseAreaMargin, ourDefenseAreaMargin);
Expand Down

0 comments on commit 7c22f84

Please sign in to comment.