Skip to content

Commit

Permalink
Merge pull request #115 from RoboTeamTwente/Fix/warning-during-build2
Browse files Browse the repository at this point in the history
Fix/warning during build2
  • Loading branch information
luukieboy authored Jan 29, 2024
2 parents 3c50c2d + b7b2af7 commit 4dba94d
Show file tree
Hide file tree
Showing 96 changed files with 176 additions and 234 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${RTT_BUILD_FOLDER}/lib)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules)
include(ccache) # For faster compiling
include(GetZmqpp) # For networking between AI, RobotHub and World
include(BuildLibusb) # USB library for RobotHub
include(CheckCXXCompilerFlag) # For testing compiler cxx standard support
include(LocateQt5) # For GUI and some networking
include(GetGoogleTest) # For testing
Expand Down Expand Up @@ -104,4 +103,4 @@ add_subdirectory(roboteam_utils)
add_subdirectory(roboteam_logging)
add_subdirectory(roboteam_ai)
add_subdirectory(roboteam_robothub)
add_subdirectory(roboteam_world)
add_subdirectory(roboteam_world)
6 changes: 2 additions & 4 deletions roboteam_ai/include/roboteam_ai/control/ControlModule.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ class ControlModule {
/**
* @brief Limits the velocity with a control_constants value
* @param command Robot command that needs to be checked
* @param robot Info about the robot
*/
static void limitVel(rtt::RobotCommand& command, std::optional<rtt::world::view::RobotView> robot);
static void limitVel(rtt::RobotCommand& command);

/**
* @brief Limits the angular velocity with a control_constants value
Expand All @@ -57,9 +56,8 @@ class ControlModule {
* @brief Limits the current robot command and adds it to the list of commands to be sent
* @param command Robot command that needs to be added
* @param robot Info about the robot
* @param data Info about world
*/
static void addRobotCommand(std::optional<rtt::world::view::RobotView> robot, const rtt::RobotCommand& command, const rtt::world::World* data) noexcept;
static void addRobotCommand(std::optional<rtt::world::view::RobotView> robot, const rtt::RobotCommand& command) noexcept;
/**
* @brief Sends all commands to robothub
*/
Expand Down
3 changes: 1 addition & 2 deletions roboteam_ai/include/roboteam_ai/control/ControlUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,9 @@ class ControlUtils {
/**
* @brief Determines the chip force based on the distance and the type of chip
* @param distance distance to the target
* @param shotType type of the chip
* @return a chip speed between min and max chip speed
*/
static double determineChipForce(const double distance, stp::ShotType shotType) noexcept;
static double determineChipForce(const double distance) noexcept;

/**
* @brief Determine the max allowed velocity considering the game state and whether the robot has the ball
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,9 @@ class WorldObjects {
* including the part that might already be completed. Only call this function for a new trajectory
* @param field used for checking collisions with the field
* @param BBTrajectory the trajectory to check for collisions
* @param computedPaths the paths of our robots
* @param robotId Id of the robot
* @return optional with rtt::BB::CollisionData
*/
std::optional<CollisionData> getFirstDefenseAreaCollision(const rtt::Field &field, const rtt::Trajectory2D &Trajectory,
const std::unordered_map<int, std::vector<Vector2>> &computedPaths, int robotId);
std::optional<CollisionData> getFirstDefenseAreaCollision(const rtt::Field &field, const rtt::Trajectory2D &Trajectory);

/**
* @brief Takes a calculated path of a robot and checks points along the path if they are outside the
Expand All @@ -100,11 +97,10 @@ class WorldObjects {
* @param field Used for information about the field
* @param collisionDatas std::vector which rtt::BB::CollisionData can be added to
* @param pathPoints std::vector with path points
* @param robotId ID of the robot
* @param timeStep Time between pathpoints
* @param completedTimeSteps Number of completed time steps
*/
void calculateDefenseAreaCollisions(const rtt::Field &field, std::vector<CollisionData> &collisionDatas, const std::vector<Vector2> &pathPoints, int robotId, double timeStep,
void calculateDefenseAreaCollisions(const rtt::Field &field, std::vector<CollisionData> &collisionDatas, const std::vector<Vector2> &pathPoints, double timeStep,
size_t completedTimeSteps);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,14 @@ class PositionControl {
* distance to the first collision on the path
* @param world a pointer to the current world
* @param field the field object, used onwards by the collision detector
* @param robotId the ID of the robot for which the path is calculated
* @param firstCollision location of the first collision on the current path
* @param trajectoryAroundCollision the trajectory to the intermediate point
* @param avoidObjects whether or not to avoid objects
* @param startTime the time at which the trajectory starts
* @return A score for the trajectory
*/
double calculateScore(const rtt::world::World *world, const rtt::Field &field, int robotId, std::optional<BB::CollisionData> &firstCollision,
Trajectory2D &trajectoryAroundCollision, stp::AvoidObjects avoidObjects, double startTime = 0);
double calculateScore(const rtt::world::World *world, const rtt::Field &field, std::optional<BB::CollisionData> &firstCollision, Trajectory2D &trajectoryAroundCollision,
stp::AvoidObjects avoidObjects, double startTime = 0);

/**
* @brief Tries to find a new trajectory when the current path has a collision on it. It tries this by
Expand Down
1 change: 0 additions & 1 deletion roboteam_ai/include/roboteam_ai/interface/api/Output.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ class Output {

static void setRuleSetName(std::string name);
static void setKeeperId(int id);
static void setBallPlacerId(int id);
};

} // namespace rtt::ai::interface
Expand Down
3 changes: 1 addition & 2 deletions roboteam_ai/include/roboteam_ai/stp/Skill.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ class Skill {

/**
* @brief Forwards the current robot command to the ControlModule and refreshes it
* @param data const pointer to world
*/
virtual void forwardRobotCommand(world::World const* data) noexcept;
virtual void forwardRobotCommand() noexcept;

/**
* @brief Resets the internal robot command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,11 @@ class PositionComputations {
/**
* @brief Recalculates info for the position of our robots to not interfere with passing
* @param stpInfos The current stpInfos
* @param roles The current roles
* @param field The current field
* @param world The current world
* @param passInfo The current passInfo
*/
static void recalculateInfoForNonPassers(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, Vector2 passLocation) noexcept;
static void recalculateInfoForNonPassers(std::unordered_map<std::string, StpInfo> &stpInfos, const Field &field, world::World *world, Vector2 passLocation) noexcept;

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class BallOnOurSideGlobalEvaluation : public BaseEvaluation {
/**
* @brief Calculates the score for ball on our side
* @param world The current world
* @param field The current field
* @return The score of ball on our side
*/
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field* field) const noexcept override;
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field*) const noexcept override;

/**
* @brief Retrieves the name of the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class BallOnTheirSideGlobalEvaluation : public BaseEvaluation {
/**
* @brief Calculates the score for ball on their side
* @param world The current world
* @param field The current field
* @return The score of ball on their side
*/
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field* field) const noexcept override;
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field*) const noexcept override;

/**
* @brief Retrieves the name of the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class TheyDoNotHaveBallGlobalEvaluation : public BaseEvaluation {
/**
* @brief Calculates the score for they do not have ball
* @param world The current world
* @param field The current field
* @return The score of they do not have ball
*/
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field* field) const noexcept override;
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field*) const noexcept override;

/**
* @brief Retrieves the name of the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class TheyHaveBallGlobalEvaluation : public BaseEvaluation {
/**
* @brief Calculates the score for they have ball
* @param world The current world
* @param field The current field
* @return The score of they have ball
*/
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field* field) const noexcept override;
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field*) const noexcept override;

/**
* @brief Retrieves the name of the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class WeDoNotHaveBallGlobalEvaluation : public BaseEvaluation {
/**
* @brief Calculates the score for we don't have ball
* @param world The current world
* @param field The current field
* @return The score of we don't have ball
*/
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field* field) const noexcept override;
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field*) const noexcept override;

/**
* @brief Retrieves the name of the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@ class WeHaveBallGlobalEvaluation : public BaseEvaluation {
/**
* @brief Calculates the score for we have ball
* @param world The current world
* @param field The current field
* @return The score of we have ball
*/
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field* field) const noexcept override;
[[nodiscard]] uint8_t metricCheck(const world::World* world, const Field*) const noexcept override;

/**
* @brief Retrieves the name of the evaluation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ class KeeperBlockBall : public Tactic {
/**
* @brief Is this tactic failing during execution (go back to the previous tactic)
* This tactic can never fail, so always returns false
* @param info StpInfo can be used to check some data
* @return true, tactic will fail (go back to prev tactic), false execution will continue as usual
*/
bool isTacticFailing(const StpInfo &info) noexcept override;
bool isTacticFailing(const StpInfo &) noexcept override;

/**
* @brief Should this tactic be reset (go back to the first skill of this tactic)
Expand Down
3 changes: 1 addition & 2 deletions roboteam_ai/include/roboteam_ai/utilities/Dealer.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,10 @@ class Dealer {
/**
* @brief Calculates the cost of travelling a certain distance
* @param distance The distance to travel
* @param fieldWidth The width of the field
* @param fieldHeight The height of the field
* @return Cost of travelling that distance
*/
static double costForDistance(double distance, double fieldWidth, double fieldHeight);
static double costForDistance(double distance, double fieldHeight);

/**
* @brief Calculates the cost of a property of a robot
Expand Down
7 changes: 2 additions & 5 deletions roboteam_ai/include/roboteam_ai/world/FieldComputations.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,9 @@ class FieldComputations {
* @param field The field class which is used to determine the boundaries of the field.
* @param point The point to be projected to a valid position
* @param avoidObjects Struct indicating which areas of the field should be avoided. Defaults to avoid entering the defense area and leaving the field
* @param fieldMargin The outwards margin in which the field area will get expanded/shrunk in all directions. A positive value means that the field area will be
* expanded, a negative value means that the field area will be shrunk.
* @return The position closest to the given point that fulfills the criteria set in avoidObjects (except ball avoidance)
*/
static Vector2 projectPointToValidPosition(const rtt::Field &field, Vector2 point, stp::AvoidObjects avoidObjects = {}, double fieldMargin = 0.0);
static Vector2 projectPointToValidPosition(const rtt::Field &field, Vector2 point, stp::AvoidObjects avoidObjects = {});

/**
* @brief Projects the given point into the field on a line between two given points.
Expand All @@ -103,13 +101,12 @@ class FieldComputations {
* @param point The point to be projected to a valid position
* @param p1 First point on the line
* @param p2 Second point on the line
* @param avoidObjects Struct indicating which areas of the field should be avoided. Defaults to avoid entering the defense area and leaving the field
* @param fieldMargin The outwards margin in which the field area will get expanded/shrunk in all directions. A positive value means that the field area will be
* expanded, a negative value means that the field area will be shrunk.
* @return The closest valid position to the given point on the line between p1 and p2.
* If no such position can be found, return the closest valid position to the given point (but not on the given line).
*/
static Vector2 projectPointToValidPositionOnLine(const Field &field, Vector2 point, Vector2 p1, Vector2 p2, stp::AvoidObjects avoidObjects = {}, double fieldMargin = 0);
static Vector2 projectPointToValidPositionOnLine(const Field &field, Vector2 point, Vector2 p1, Vector2 p2, double fieldMargin = 0);

/**
* @brief Get the percentage of goal visible from a given point, i.e. how much of the goal can be reached by directly shooting a ball over the ground from a given point without
Expand Down
12 changes: 4 additions & 8 deletions roboteam_ai/src/control/ControlModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ void ControlModule::rotateRobotCommand(rtt::RobotCommand& command) {
}

void ControlModule::limitRobotCommand(rtt::RobotCommand& command, std::optional<rtt::world::view::RobotView> robot) {
limitVel(command, robot);
limitVel(command);
limitAngularVel(command, robot);
}

void ControlModule::limitVel(rtt::RobotCommand& command, std::optional<rtt::world::view::RobotView> robot) {
void ControlModule::limitVel(rtt::RobotCommand& command) {
// The robot can currently not reach very low speeds- if we want it to move a non-trivial amount, we need to send a higher velocity than the path-planning outputs
// TODO: Look at the correct value for this with control
if (command.velocity.length() > 0.03 && command.velocity.length() < 0.25) command.velocity = command.velocity.stretchToLength(0.25);
command.velocity = command.velocity.stretchToLength(std::clamp(command.velocity.length(), 0.0, Constants::MAX_VEL_CMD()));
}
Expand Down Expand Up @@ -53,13 +54,8 @@ void ControlModule::limitAngularVel(rtt::RobotCommand& command, std::optional<rt
// TODO: Well, then also limit the target angular velocity just like target angle!
}

void ControlModule::addRobotCommand(std::optional<::rtt::world::view::RobotView> robot, const rtt::RobotCommand& command, const rtt::world::World* data) noexcept {
void ControlModule::addRobotCommand(std::optional<::rtt::world::view::RobotView> robot, const rtt::RobotCommand& command) noexcept {
rtt::RobotCommand robot_command = command; // TODO: Why make a copy of the command? It will be copied anyway when we put it in the vector

if (robot && robot->get()) {
// TODO: Fix this visualisation
Angle target = command.targetAngle;
}
// If we are not left, commands should be rotated (because we play as right)
if (!GameSettings::isLeft()) {
rotateRobotCommand(robot_command);
Expand Down
2 changes: 1 addition & 1 deletion roboteam_ai/src/control/ControlUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ double ControlUtils::determineKickForce(const double distance, stp::ShotType sho
return std::clamp(velocity, stp::control_constants::MIN_KICK_POWER, stp::control_constants::MAX_KICK_POWER);
}
/// Calculates the chip force
double ControlUtils::determineChipForce(const double distance, stp::ShotType shotType) noexcept {
double ControlUtils::determineChipForce(const double distance) noexcept {
// Factor that determines the chipping force
double chipFactor = 3.0;
// Calculate the velocity based on this function with the previously set limitingFactor
Expand Down
Loading

0 comments on commit 4dba94d

Please sign in to comment.