Skip to content

Commit

Permalink
little update
Browse files Browse the repository at this point in the history
  • Loading branch information
flimdejong committed Dec 21, 2024
1 parent 54ec97b commit 8668a26
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@
[submodule "roboteam_robothub/roboteam_embedded_messages"]
path = roboteam_robothub/roboteam_embedded_messages
url = https://github.com/RoboTeamTwente/roboteam_embedded_messages.git
[submodule "modules/tigers_sumatra"]
path = modules/tigers_sumatra
url = https://github.com/TIGERs-Mannheim/Sumatra.git
branch = master
18 changes: 9 additions & 9 deletions docker/runner/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ services:
- LD_LIBRARY_PATH=/home/roboteamtwente/lib/
volumes:
- ../../build/release/:/home/roboteamtwente/
profiles: ["simulator","diff","game", "robocup"]
profiles: ["simulator","diff","game", "robocup", "RL"]

roboteam_secondary_ai:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -72,7 +72,7 @@ services:
- LD_LIBRARY_PATH=/home/roboteamtwente/lib/
volumes:
- ../../build/release/:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

roboteam_observer_game:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -111,7 +111,7 @@ services:
- LD_LIBRARY_PATH=/home/roboteamtwente/lib/
volumes:
- ../../build/release/:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

roboteam_robothub_game:
image: roboteamtwente/roboteam:development
Expand Down Expand Up @@ -147,7 +147,7 @@ services:
- 8080:8080
volumes:
- ../../roboteam_interface/:/home/roboteamtwente/
profiles: ["simulator","diff","game", "robocup"]
profiles: ["simulator","diff","game", "robocup", "RL"]

roboteam_autoref:
image: gradle:8.4.0-jdk17
Expand All @@ -164,7 +164,7 @@ services:
- GRADLE_USER_HOME=/home/roboteamtwente/.cache # Cache gradle dependencies
volumes:
- ../../roboteam_autoref/:/home/roboteamtwente/
profiles: ["simulator","diff","game","autoref"]
profiles: ["simulator","diff","game","autoref", "RL"]

erforce_autoref_sim:
image: roboteamtwente/roboteam:development
Expand All @@ -179,7 +179,7 @@ services:
- 10010:10010 # Tracker port
volumes:
- ../../:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

erforce_autoref_game:
image: roboteamtwente/roboteam:development
Expand All @@ -201,7 +201,7 @@ services:
container_name: RTT_erforce_simulator
restart: always
working_dir: "/home/roboteamtwente/external/framework/build/bin/"
command: sh -c "./simulator-cli"
command: sh -c "./simulator-cli --realism RC2021"
network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix
expose:
- 10301:10301 #Blue Control Port
Expand All @@ -212,7 +212,7 @@ services:
- 30013:30013 #Simulation Feedback Port
volumes:
- ../../:/home/roboteamtwente/
profiles: ["simulator","diff"]
profiles: ["simulator","diff", "RL"]

ssl-game-controller:
image: robocupssl/ssl-game-controller:latest
Expand All @@ -221,4 +221,4 @@ services:
network_mode: "host" # Workaround to connect from interface on host to AI websocket, please fix
ports:
- "8081:8081/tcp" # UI port
profiles: ["simulator","diff","game"]
profiles: ["simulator","diff","game", "RL"]
1 change: 1 addition & 0 deletions modules/tigers_sumatra
Submodule tigers_sumatra added at c2f886
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ class PositionComputations {
* @param robotId ID of the passer robot
* @return Best position for the passer
*/
static Vector2 calculatePasserPosition(Vector2 currentPos, world::World* world, int robotId) noexcept;
static Vector2 calculatePasserPosition(Vector2 currentPos, world::World* world, int robotId, Vector2 initialBallPos) noexcept;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
namespace rtt::ai::stp::tactic {

class SmoothPass : public Tactic {

private:
Vector2 initialBallPos; // Store initial ball position
bool initialized{false};

public:
/**
* @brief Constructor for the tactic, initializes skills state machine
Expand Down
2 changes: 1 addition & 1 deletion roboteam_ai/include/roboteam_ai/utilities/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ constexpr double MAX_ANGULAR_VELOCITY = 6.0; /**< Maximum allowed angular veloc
constexpr double MIN_YAW = -M_PI; /**< Minimum yaw the robot can have */
constexpr double MAX_YAW = M_PI; /**< Maximum yaw the robot can have */
constexpr double MAX_ACC = 2.0; /**< Maximum acceleration of the robot */
constexpr double MAX_VEL = 2.0; /**< Maximum allowed velocity of the robot */
constexpr double MAX_VEL = 5.0; /**< Maximum allowed velocity of the robot */
constexpr double MAX_JERK_DEFAULT = 6; /**< Default jerk limit */

/// GoToPos Constants
Expand Down
38 changes: 27 additions & 11 deletions roboteam_ai/src/stp/tactics/active/SmoothPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,32 +23,48 @@ std::optional<StpInfo> SmoothPass::calculateInfoForSkill(const StpInfo &info) no
return skillStpInfo;
}

// Store initial ball position when tactic first starts
if (!initialized) {
initialBallPos = info.getBall().value()->position;
initialized = true;
}

auto currentPos = info.getRobot().value()->getPos();
auto world = info.getCurrentWorld();

if (world) {
// Use our new computation functions
Vector2 newPos = PositionComputations::calculatePasserPosition(currentPos, world, info.getRobot().value()->getId());
Angle newAngle = PositionComputations::calculatePasserAngle(currentPos, world);
Vector2 newPos = PositionComputations::calculatePasserPosition(currentPos, world, info.getRobot().value()->getId(), initialBallPos);
double angleToTarget = (info.getPositionToShootAt().value() - info.getRobot().value()->getPos()).angle();

skillStpInfo.setPositionToMoveTo(newPos);
skillStpInfo.setYaw(newAngle);
skillStpInfo.setYaw(angleToTarget);
}

return skillStpInfo;
}

bool SmoothPass::isTacticFailing(const StpInfo &info) noexcept {
return !info.getPositionToShootAt() || !info.getBall();
return !info.getPositionToShootAt() ||
!info.getBall() ||
!info.getRobot().value()->hasBall(); // Add this check
}

bool SmoothPass::shouldTacticReset(const StpInfo &info) noexcept {
// Reset if we've deviated too much from desired angle during orbit
if (skills.current_num() == 0) { // During OrbitAndDrive
const auto errorMargin = constants::GO_TO_POS_ANGLE_ERROR_MARGIN * M_PI;
return info.getRobot().value()->getYaw().shortestAngleDiff(info.getYaw()) > errorMargin;
}
return false;
if (skills.current_num() != 0) return false; // Only check during OrbitAndDrive

// Get current robot position and target position
auto robot = info.getRobot().value();
auto currentPos = robot->getPos();
auto targetPos = info.getPositionToMoveTo().value();

// Check angle deviation
const auto angleErrorMargin = constants::GO_TO_POS_ANGLE_ERROR_MARGIN * M_PI;
bool angleDeviated = robot->getYaw().shortestAngleDiff(info.getYaw()) > angleErrorMargin;

// Check position deviation
bool positionDeviated = (currentPos - targetPos).length() > constants::GO_TO_POS_ERROR_MARGIN;

return angleDeviated || positionDeviated;
}

bool SmoothPass::isEndTactic() noexcept {
Expand Down

0 comments on commit 8668a26

Please sign in to comment.