Skip to content

Commit

Permalink
Merge pull request #129 from RoboTeamTwente/wallerImprov
Browse files Browse the repository at this point in the history
Waller improv
  • Loading branch information
JornJorn authored Jul 9, 2024
2 parents a45512b + 2d4e03f commit cade609
Show file tree
Hide file tree
Showing 70 changed files with 614 additions and 954 deletions.
4 changes: 2 additions & 2 deletions roboteam_ai/include/roboteam_ai/control/ControlUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class ControlUtils {
/**
* @brief Determines the kick force based on the distance and the type of kick
* @param distance distance to the target
* @param shotType type of the kick
* @param shotPower type of the kick
* @return a kick speed between min and max kick speed
*/
static double determineKickForce(const double distance, stp::ShotType shotType) noexcept;
static double determineKickForce(const double distance, stp::ShotPower shotPower) noexcept;
/**
* @brief Determines the chip force based on the distance and the type of chip
* @param distance distance to the target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ class PositionControl {
* @param world a pointer to the current world
* @param field the field object, used onwards by the collision detector
* @param currentPosition the current position of the robot
* @param targetPosition the desired position that the robot has to reach
* @param avoidObjects whether or not to avoid objects
* @return A new target position
*/
Vector2 handleBallPlacementCollision(const rtt::world::World *world, const rtt::Field &field, Vector2 currentPosition, stp::AvoidObjects avoidObjects);
Vector2 handleBallPlacementCollision(const rtt::world::World *world, const rtt::Field &field, Vector2 currentPosition, Vector2 targetPosition, stp::AvoidObjects avoidObjects);

/**
* @brief Handles the collision with the defense area at the current position, will move away from the defense area as quickly as possible.
Expand Down
2 changes: 2 additions & 0 deletions roboteam_ai/include/roboteam_ai/stp/Play.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class Play {

std::vector<GlobalEvaluation> startPlayEvaluation; /**< Invariant vector that contains invariants that need to be true to start this play */

static int waller_count;

/**
* @brief Initializes stpInfos struct, distributes roles, sets the previousRobotNum variable and calls onInitialize()
*/
Expand Down
12 changes: 7 additions & 5 deletions roboteam_ai/include/roboteam_ai/stp/StpInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <optional>
#include <roboteam_utils/Field.hpp>
#include <roboteam_utils/RobotCommands.hpp>

#include "computations/PositionScoring.h"
#include "utilities/StpInfoEnums.h"
Expand Down Expand Up @@ -46,10 +47,11 @@ struct StpInfo {
bool getDribblerOn() const { return dribblerOn; }
void setDribblerOn(bool dribblerOn) { this->dribblerOn = dribblerOn; }

ShotType getShotType() const { return shotType; }
void setShotType(ShotType shotType) { this->shotType = shotType; }
ShotPower getShotPower() const { return shotPower; }
void setShotPower(ShotPower shotPower) { this->shotPower = shotPower; }

void setKickOrChip(const std::optional<KickOrChip>& kickOrChip) { StpInfo::kickOrChip = kickOrChip; }
rtt::KickType getKickOrChip() const { return kickOrChip; }
void setKickOrChip(rtt::KickType kickOrChip) { this->kickOrChip = kickOrChip; }

world::World* getCurrentWorld() const { return currentWorld; }
/// This function is used in a lambda, [[maybe_unused]] is to suppress 'unused' warnings
Expand Down Expand Up @@ -149,7 +151,7 @@ struct StpInfo {
/**
* Type of the kick/chip
*/
ShotType shotType{};
ShotPower shotPower{};

/**
* Reference yaw of the robot
Expand All @@ -164,7 +166,7 @@ struct StpInfo {
/**
* Set the shot to be a kick or chip
*/
std::optional<KickOrChip> kickOrChip;
rtt::KickType kickOrChip = rtt::KickType::NO_KICK;

/**
* The maximum velocity the robot is allowed to have
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ class InterceptionComputations {
* @return HarasserInfo with the id and the time to the ball
*/
static InterceptionInfo calculateInterceptionInfoExcludingKeeperAndCarded(const rtt::world::World *world) noexcept;

/**
* @brief Calculates the point where they will have the ball
* @param info the StpInfo struct
* @param ballTrajectory the trajectory of the ball
* @return the point where they will have the ball
*/
static std::optional<Vector2> calculateTheirBallInterception(const rtt::world::World *world, rtt::LineSegment ballTrajectory) noexcept;
};
} // namespace rtt::ai::stp
#endif // RTT_INTERCEPTIONCOMPUTATIONS_H
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,14 @@ class PositionComputations {
static gen::ScoredPosition getPosition(std::optional<rtt::Vector2> currentPosition, const Grid &searchGrid, gen::ScoreProfile profile, const Field &field,
const world::World *world);

/**
* @brief Calculates amount of wallers needed based on the position of the ball
* @param field
* @param world
* @return The amount of wallers needed
*/
static void setAmountOfWallers(const rtt::Field &field, rtt::world::World *world) noexcept;

/**
* @brief Makes a wall if not ready done, saves it in calculatedWallPositions and deals the index
* @param index Index of the wall position (do unique positions)
Expand Down Expand Up @@ -150,6 +158,8 @@ class PositionComputations {
*/
static void calculateInfoForAvoidBallHarasser(std::unordered_map<std::string, StpInfo> &stpInfos, world::World *world) noexcept;

static int amountOfWallers;

private:
/**
* @brief Calculates a position outside of a given shape
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef RTT_DEFENDSHOT_H
#define RTT_DEFENDSHOT_H
#ifndef RTT_DEFEND_H
#define RTT_DEFEND_H

#include <stp/computations/InterceptionComputations.h>

Expand All @@ -8,16 +8,16 @@
namespace rtt::ai::stp::play {

/**
* @brief DefendShot Play is executed when the opponent has or is close to the ball and on our side of the field.
* @brief Defend Play is executed when the opponent has or is close to the ball.
* In this case they most likely will try to score. Some defenders defend the goal by blocking the path between enemy
* robots and the goal. Other defenders block other enemy robots to avoid passes to them.
*/
class DefendShot : public Play {
class Defend : public Play {
public:
/**
* @brief Constructor that initializes roles with roles that are necessary for this play
*/
DefendShot();
Defend();

/**
* @brief Calculates the score of this play to determine which play is best in this situation
Expand Down Expand Up @@ -46,4 +46,4 @@ class DefendShot : public Play {
};
} // namespace rtt::ai::stp::play

#endif // RTT_DEFENDSHOT_H
#endif // RTT_DEFEND_H
50 changes: 0 additions & 50 deletions roboteam_ai/include/roboteam_ai/stp/plays/defensive/DefendPass.h

This file was deleted.

61 changes: 0 additions & 61 deletions roboteam_ai/include/roboteam_ai/stp/plays/offensive/ChippingPass.h

This file was deleted.

20 changes: 0 additions & 20 deletions roboteam_ai/include/roboteam_ai/stp/roles/active/Chipper.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class KeeperPasser : public Role {
* @param name The name of the role
*/
KeeperPasser(std::string name);

/**
* @brief Besides the default update from base class Role, it also switches between tactics depending on the ball position
* @param info TacticInfo to be passed to update()
* @return The status that the current tactic returns
*/
[[nodiscard]] Status update(StpInfo const& info) noexcept override;
};
} // namespace rtt::ai::stp::role

Expand Down
26 changes: 0 additions & 26 deletions roboteam_ai/include/roboteam_ai/stp/skills/Chip.h

This file was deleted.

8 changes: 0 additions & 8 deletions roboteam_ai/include/roboteam_ai/stp/tactics/KeeperBlockBall.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ class KeeperBlockBall : public Tactic {
*/
static Vector2 calculateTargetPositionBallShot(const StpInfo info, rtt::LineSegment keepersLineSegment, rtt::LineSegment ballTrajectory) noexcept;

/**
* @brief Calculates the point where they will have the ball
* @param info the StpInfo struct
* @param ballTrajectory the trajectory of the ball
* @return the point where they will have the ball
*/
static std::optional<Vector2> calculateTheirBallInterception(const StpInfo &info, rtt::LineSegment ballTrajectory) noexcept;

/**
* @brief Calculates the target position for the keeper when the ball is not shot
* @param info the StpInfo struct
Expand Down
55 changes: 0 additions & 55 deletions roboteam_ai/include/roboteam_ai/stp/tactics/active/ChipAtPos.h

This file was deleted.

Loading

0 comments on commit cade609

Please sign in to comment.