Skip to content

Commit

Permalink
Merge branch 'keeperImprovements' into acceleration_control_test
Browse files Browse the repository at this point in the history
  • Loading branch information
roboteampc committed Jun 14, 2024
2 parents c35db7f + fbb0409 commit 33a6a08
Show file tree
Hide file tree
Showing 111 changed files with 640 additions and 774 deletions.
4 changes: 2 additions & 2 deletions roboteam_ai/include/roboteam_ai/control/ControlModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ class ControlModule {
static void limitRobotCommand(rtt::RobotCommand& command, rtt::world::view::RobotView robot);

/**
* @brief Limits the velocity with a control_constants value
* @brief Limits the velocity with a constants value
* @param command Robot command that needs to be checked
*/
static void limitVel(rtt::RobotCommand& command);

/**
* @brief Limits the angular velocity with a control_constants value
* @brief Limits the angular velocity with a constants value
* @param command Robot command that needs to be checked
* @param robot Info about the robot
*/
Expand Down
3 changes: 1 addition & 2 deletions roboteam_ai/include/roboteam_ai/stp/Play.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "PlayEvaluator.h"
#include "Role.hpp"
#include "computations/PositionComputations.h"
#include "constants/GeneralizationConstants.h"
#include "stp/evaluations/BaseEvaluation.h"
#include "utilities/Dealer.h"
#include "utilities/GameState.h"
Expand Down Expand Up @@ -110,7 +109,7 @@ class Play {
uint8_t getLastScore() const;

protected:
std::array<std::unique_ptr<Role>, rtt::ai::Constants::ROBOT_COUNT()> roles; /**< The roles, constructed in ctor of a play */
std::array<std::unique_ptr<Role>, rtt::ai::constants::MAX_ROBOT_COUNT> roles; /**< The roles, constructed in ctor of a play */

std::vector<PlayEvaluator::PlayScoring> scoring; /**< The evaluations with their weight */

Expand Down
2 changes: 1 addition & 1 deletion roboteam_ai/include/roboteam_ai/stp/PlayEvaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class PlayEvaluator {
* @param cutOff Bottom bound value of true
* @return boolean if FUZZY-TRUE is high enough
*/
static bool checkEvaluation(GlobalEvaluation globalEvaluation, const rtt::world::World* world, uint8_t cutOff = control_constants::FUZZY_DEFAULT_CUTOFF) noexcept;
static bool checkEvaluation(GlobalEvaluation globalEvaluation, const rtt::world::World* world, uint8_t cutOff = constants::FUZZY_DEFAULT_CUTOFF) noexcept;

private:
static inline std::unordered_map<GlobalEvaluation, uint8_t> scoresGlobal{}; /**< Map of all loaded Global Evaluations scores */
Expand Down
2 changes: 1 addition & 1 deletion roboteam_ai/include/roboteam_ai/stp/StpInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <optional>
#include <roboteam_utils/Field.hpp>

#include "constants/GeneralizationConstants.h"
#include "computations/PositionScoring.h"
#include "utilities/StpInfoEnums.h"
#include "world/views/BallView.hpp"
#include "world/views/RobotView.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#define RTT_COMPUTATIONMANAGER_H

#include "roboteam_utils/Vector2.h"
#include "stp/constants/GeneralizationConstants.h"

namespace rtt::ai::stp {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

#include "stp/Role.hpp"
#include "stp/StpInfo.h"
#include "stp/constants/GeneralizationConstants.h"
#include "utilities/Constants.h"
#include "world/FieldComputations.h"
#include "world/World.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include <roboteam_utils/LineSegment.h>
#include <stp/computations/InterceptionComputations.h>
#include <stp/constants/GeneralizationConstants.h>

#include <roboteam_utils/Field.hpp>

Expand All @@ -20,8 +19,8 @@ struct PassInfo {
int keeperId = -1;
int passerId = -1;
int receiverId = -1;
Vector2 passLocation; // The location where the ball will be passed from, towards the receiver
Vector2 receiverLocation; // The location of the receiver, who will receive the ball from the passer
Vector2 passLocation; // The location where the ball will be passed from, towards the receiver
Vector2 receiverLocation = Vector2(6, 0); // The location of the receiver, who will receive the ball from the passer
uint8_t passScore = 0;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "stp/Role.hpp"
#include "stp/StpInfo.h"
#include "stp/computations/PassComputations.h"
#include "stp/constants/GeneralizationConstants.h"
#include "utilities/Constants.h"
#include "world/FieldComputations.h"
#include "world/World.hpp"
Expand Down Expand Up @@ -93,7 +92,7 @@ class PositionComputations {
* @param world The current world
* @param interceptionLocation The location where the harasser should go to
*/
static void calculateInfoForHarasser(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, stp::control_constants::MAX_ROBOT_COUNT> *roles,
static void calculateInfoForHarasser(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, constants::MAX_ROBOT_COUNT> *roles,
const Field &field, world::World *world, Vector2 interceptionLocation) noexcept;

/**
Expand All @@ -104,9 +103,8 @@ class PositionComputations {
* @param world The current world
* @param mustStayOnOurSide Whether the defenders should always stay on our side of the field, for example to prevent interference during our own attack
*/
static void calculateInfoForDefendersAndWallers(std::unordered_map<std::string, StpInfo> &stpInfos,
std::array<std::unique_ptr<Role>, stp::control_constants::MAX_ROBOT_COUNT> &roles, const Field &field, world::World *world,
bool mustStayOnOurSide) noexcept;
static void calculateInfoForDefendersAndWallers(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, constants::MAX_ROBOT_COUNT> &roles,
const Field &field, world::World *world, bool mustStayOnOurSide) noexcept;

/**
* @brief Calculates info for the attackers
Expand All @@ -115,7 +113,7 @@ class PositionComputations {
* @param field The current field
* @param world The current world
*/
static void calculateInfoForAttackers(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, stp::control_constants::MAX_ROBOT_COUNT> &roles,
static void calculateInfoForAttackers(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, constants::MAX_ROBOT_COUNT> &roles,
const Field &field, world::World *world) noexcept;

/**
Expand All @@ -125,7 +123,7 @@ class PositionComputations {
* @param field The current field
* @param world The current world
*/
static void calculateInfoForFormation(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, stp::control_constants::MAX_ROBOT_COUNT> &roles,
static void calculateInfoForFormation(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, constants::MAX_ROBOT_COUNT> &roles,
const Field &field, world::World *world) noexcept;

/**
Expand All @@ -135,9 +133,8 @@ class PositionComputations {
* @param field The current field
* @param world The current world
*/
static void calculateInfoForFormationOurSide(std::unordered_map<std::string, StpInfo> &stpInfos,
std::array<std::unique_ptr<Role>, stp::control_constants::MAX_ROBOT_COUNT> &roles, const Field &field,
world::World *world) noexcept;
static void calculateInfoForFormationOurSide(std::unordered_map<std::string, StpInfo> &stpInfos, std::array<std::unique_ptr<Role>, constants::MAX_ROBOT_COUNT> &roles,
const Field &field, world::World *world) noexcept;
/**
* @brief Recalculates info for the position of our robots to not interfere with passing
* @param stpInfos The current stpInfos
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,63 @@

#include <roboteam_utils/Field.hpp>

#include "stp/constants/GeneralizationConstants.h"
#include "world/World.hpp"

namespace rtt::ai::stp {

namespace gen {
/**
* @brief Struct that is used to store computations made with this module.
* Save computations here that are usable for each robot for a position.
* DO NOT save values specific to a robot in here (like TimeToPosition).
* If a position's score for a specific evaluation already had been computed in the tick, it will
* use that value instead of recomputing it. If it was not computed yet, it will compute and save it.
* @memberof scoreOpen : uint8_t score for the Openness of a position -> evaluations/position/OpennessEvaluation
* @memberof scoreLineOfSight : uint8_t score for the LineOfSight to a position from a position -> ../LineOfSightEvaluation
* @memberof scoreGoalShot : uint8_t score for the Goal Shot opportunity for a position -> ../GoalShotEvaluation
*/
struct PositionScores {
std::optional<double> scoreOpen;
std::optional<double> scoreLineOfSight;
std::optional<double> scoreGoalShot;
};

/**
* @brief Combination of weights for each of the scores.
* This will be used to determine the final score for a robot for a position.
* All weights will be multiplied with the corresponding score and then normalized.
* @memberof weightOpen for scoreOpen
* @memberof weightLineOfSight for scoreLineOfSight
* @memberof weightGoalShot for scoreGoalShot
*/
struct ScoreProfile {
double weightOpen;
double weightLineOfSight;
double weightGoalShot;
};

/**
* @brief Structure with a position and its score
* @memberof position Vector2 coordinates of a position
* @memberof score The score for said position
*/
struct ScoredPosition {
Vector2 position;
uint8_t score;
};

/**
* Generalized Position Profiles to be used in plays.
* They consist of a generalized weight combination.
*/

constexpr ScoreProfile AttackingPass = {0.5, 1, 2}; /**< Scoring weights for Attacking Pass */
constexpr ScoreProfile SafePass = {1, 1, 0}; /**< Scoring weights for Safe Pass, used by the keeper */
constexpr ScoreProfile LineOfSight = {0, 1, 0}; /**< Scoring weights for Line of Sight score, only used for testing minimum line of sight */
constexpr ScoreProfile GoalShot = {0, 0, 1}; /**< Scoring weights for Goal Shot Score, a position where we can shoot at goal */
constexpr ScoreProfile ChippingPass = {1, 0, 1}; /**< Scoring weights for ChippingPass score */
} // namespace gen

/**
* @brief Class that manages the scoring for a position
*/
Expand Down
75 changes: 0 additions & 75 deletions roboteam_ai/include/roboteam_ai/stp/constants/ControlConstants.h

This file was deleted.

This file was deleted.

3 changes: 0 additions & 3 deletions roboteam_ai/include/roboteam_ai/stp/skills/Chip.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ class Chip : public Skill {
* @return The name of this skill
*/
const char* getName() override;

private:
int chipAttempts = 0; /**< Keeps track of how many ticks we tried to chip */
};
} // namespace rtt::ai::stp::skill

Expand Down
Loading

0 comments on commit 33a6a08

Please sign in to comment.