Skip to content

Commit

Permalink
Change our formation during kickoffs
Browse files Browse the repository at this point in the history
  • Loading branch information
Luuk committed Jun 24, 2024
1 parent 0415a40 commit c9642b1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 37 deletions.
13 changes: 1 addition & 12 deletions roboteam_ai/src/stp/computations/PositionComputations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,6 @@ std::vector<Vector2> PositionComputations::determineWallPositions(const rtt::Fie
wallLine.end = intersectionOther.value();
}
}
// if (wallLine.length() == 0) {
// RTT_WARNING("Wall line length is 0");
// double lineX = field.leftDefenseArea.right();
// double lineYTop = field.playArea.top();
// double lineYBottom = field.playArea.bottom();
// wallLine = LineSegment({lineX, lineYBottom}, {lineX, lineYTop});
// }

size_t defendersCount = static_cast<size_t>(amountDefenders);
int i = 1;
Expand Down Expand Up @@ -517,11 +510,7 @@ void PositionComputations::calculateInfoForFormationOurSide(std::unordered_map<s
}
for (size_t i = 0; i < formationFrontNames.size(); i++) {
double y = -height / 2 + height / (formationFrontNames.size() + 1) * (i + 1);
// Make sure no robot is between our passer and receiver
if (formationFrontNames.size() % 2 != 0 && i == formationFrontNames.size() / 2) {
y += 0.7;
}
stpInfos[formationFrontNames[i]].setPositionToMoveTo(Vector2{-width / 15, y});
stpInfos[formationFrontNames[i]].setPositionToMoveTo(Vector2{-constants::ROBOT_RADIUS * 1.5, y});
}
}

Expand Down
38 changes: 19 additions & 19 deletions roboteam_ai/src/stp/plays/referee_specific/KickOffThemPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ KickOffThemPrepare::KickOffThemPrepare() : Play() {
roles = std::array<std::unique_ptr<Role>, rtt::ai::constants::MAX_ROBOT_COUNT>{
// Roles is we play 6v6
std::make_unique<role::Keeper>("keeper"),
std::make_unique<role::Formation>("formation_back_0"),
std::make_unique<role::Formation>("formation_mid_0"),
std::make_unique<role::Formation>("waller_0"),
std::make_unique<role::Formation>("waller_1"),
std::make_unique<role::Formation>("waller_2"),
std::make_unique<role::Formation>("formation_front_0"),
std::make_unique<role::Formation>("formation_back_1"),
std::make_unique<role::Formation>("formation_mid_1"),
// Additional roles if we play 11v11
std::make_unique<role::Formation>("formation_front_1"),
std::make_unique<role::Formation>("formation_back_2"),
std::make_unique<role::Formation>("formation_mid_2"),
std::make_unique<role::Formation>("formation_front_2"),
std::make_unique<role::Formation>("formation_mid_3"),
// Additional roles if we play 11v11
std::make_unique<role::Formation>("formation_front_3"),
std::make_unique<role::Formation>("formation_front_4"),
std::make_unique<role::Formation>("formation_front_5"),
std::make_unique<role::Formation>("formation_front_6"),
};
}

Expand All @@ -42,23 +42,23 @@ Dealer::FlagMap KickOffThemPrepare::decideRoleFlags() const noexcept {
Dealer::DealerFlag keeperFlag(DealerFlagTitle::KEEPER);

flagMap.insert({"keeper", {DealerFlagPriority::KEEPER, {keeperFlag}}});
flagMap.insert({"formation_back_0", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_back_1", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_back_2", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_mid_0", {DealerFlagPriority::LOW_PRIORITY, {}}});
flagMap.insert({"formation_mid_1", {DealerFlagPriority::LOW_PRIORITY, {}}});
flagMap.insert({"formation_mid_2", {DealerFlagPriority::LOW_PRIORITY, {}}});
flagMap.insert({"formation_mid_3", {DealerFlagPriority::LOW_PRIORITY, {}}});
flagMap.insert({"formation_front_0", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"formation_front_1", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"formation_front_2", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"waller_0", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"waller_1", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"waller_2", {DealerFlagPriority::LOW_PRIORITY, {}}});
flagMap.insert({"formation_front_0", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_1", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_2", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_3", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_4", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_5", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_6", {DealerFlagPriority::HIGH_PRIORITY, {}}});

return flagMap;
}

void KickOffThemPrepare::calculateInfoForRoles() noexcept {
PositionComputations::calculateInfoForDefendersAndWallers(stpInfos, roles, field, world, true);
PositionComputations::calculateInfoForFormationOurSide(stpInfos, roles, field, world);
stpInfos["formation_front_0"].setPositionToMoveTo(Vector2(-0.73, 0));
}
const char* KickOffThemPrepare::getName() const { return "Kick Off Them Prepare"; }

Expand Down
13 changes: 7 additions & 6 deletions roboteam_ai/src/stp/plays/referee_specific/KickOffUsPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ KickOffUsPrepare::KickOffUsPrepare() : Play() {
// Roles is we play 6v6
std::make_unique<role::Keeper>("keeper"),
std::make_unique<role::Formation>("kicker"),
std::make_unique<role::Formation>("formation_mid_0"),
std::make_unique<role::Formation>("waller_0"),
std::make_unique<role::Formation>("waller_1"),
std::make_unique<role::Formation>("formation_front_0"),
std::make_unique<role::Formation>("formation_front_1"),
std::make_unique<role::Formation>("formation_front_2"),
// Additional roles if we play 11v11
std::make_unique<role::Formation>("formation_back_0"),
std::make_unique<role::Formation>("formation_back_1"),
std::make_unique<role::Formation>("formation_front_3"),
std::make_unique<role::Formation>("formation_front_4"),
std::make_unique<role::Formation>("formation_front_5"),
std::make_unique<role::Formation>("formation_front_6"),
};
}

Expand All @@ -46,20 +46,21 @@ Dealer::FlagMap KickOffUsPrepare::decideRoleFlags() const noexcept {

flagMap.insert({"keeper", {DealerFlagPriority::KEEPER, {keeperFlag}}});
flagMap.insert({"kicker", {DealerFlagPriority::REQUIRED, {kickerFlag, detectionFlag}}});
flagMap.insert({"formation_back_0", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"formation_back_1", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"formation_mid_0", {DealerFlagPriority::LOW_PRIORITY, {}}});
flagMap.insert({"waller_0", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"waller_1", {DealerFlagPriority::MEDIUM_PRIORITY, {}}});
flagMap.insert({"formation_front_0", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_1", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_2", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_3", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_4", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_5", {DealerFlagPriority::HIGH_PRIORITY, {}}});
flagMap.insert({"formation_front_6", {DealerFlagPriority::LOW_PRIORITY, {}}});

return flagMap;
}

void KickOffUsPrepare::calculateInfoForRoles() noexcept {
PositionComputations::calculateInfoForDefendersAndWallers(stpInfos, roles, field, world, true);
PositionComputations::calculateInfoForFormationOurSide(stpInfos, roles, field, world);

// The "kicker" will go to the ball
Expand Down

0 comments on commit c9642b1

Please sign in to comment.