Skip to content

Commit

Permalink
initial pipline implementation (not working)
Browse files Browse the repository at this point in the history
  • Loading branch information
aelhabashy committed Nov 22, 2024
1 parent b9b7d7c commit e840b34
Show file tree
Hide file tree
Showing 6 changed files with 189 additions and 115 deletions.
81 changes: 81 additions & 0 deletions .gitconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
[safe]
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
directory = /home/roboteamtwente
directory = /home/roboteamtwente/build/_deps/tracy-src
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,9 @@ ENV/
env.bak/
venv.bak/
__pycache__/
tigers_sumatra
docker/runner/ssl-game-controller-config/20*
roboteam_ai/src/RL/src/ppo_*
roboteam_ai/src/RL/src/best_model_PPO.zip
roboteam_ai/src/RL/src/tmp/eval_monitor.monitor.csv
roboteam_ai/src/RL/src/tmp/monitor.monitor.csv
8 changes: 8 additions & 0 deletions roboteam_ai/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,11 @@ gtest_discover_tests(roboteam_ai_tests)
# PRIVATE roboteam_utils
# PRIVATE testHelpers
# )
# Add the protobuf generated source files
set(PROTO_SRCS
${CMAKE_SOURCE_DIR}/roboteam_networking/proto/ActionCommand.pb.cc
)
target_sources(roboteam_ai PRIVATE ${PROTO_SRCS})
find_package(Protobuf REQUIRED)

target_link_libraries(roboteam_ai PRIVATE protobuf::libprotobuf)
16 changes: 14 additions & 2 deletions roboteam_ai/include/roboteam_ai/stp/plays/offensive/Attack.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
#define RTT_ATTACK_H

#include "stp/Play.hpp"
#include <vector> // For std::vector

namespace rtt::ai::stp::play {

/**
* @brief The attack play is executed when there is a chance to shoot at the enemey goal
* @brief The attack play is executed when there is a chance to shoot at the enemy goal
*/
class Attack : public Play {
public:
Expand All @@ -15,6 +16,14 @@ class Attack : public Play {
*/
Attack();

~Attack() override;


/**
* @brief Receives action commands dynamically to modify roles
*/
void receiveActionCommand();

/**
* @brief Calculates the score of this play to determine which play is best in this situation
* @param field The current Field
Expand All @@ -34,7 +43,7 @@ class Attack : public Play {
void calculateInfoForRoles() noexcept override;

/**
* @brief Check if play should end. True when stri role is finished.
* @brief Check if play should end. True when striker role is finished.
*/
bool shouldEndPlay() noexcept override;

Expand All @@ -43,6 +52,9 @@ class Attack : public Play {
* @return The name of the play as string
*/
const char* getName() const override;

private:
std::vector<std::unique_ptr<Role>> roles; // Updated to std::vector
};

} // namespace rtt::ai::stp::play
Expand Down
11 changes: 8 additions & 3 deletions roboteam_ai/src/RL/sentActionCommand.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
roboteam_path = os.path.abspath(os.path.join(current_dir, "..", "..", ".."))

# Add to sys.path
sys.path.append(roboteam_path)
sys.path.append(roboteam_path)
pipe_path = os.path.join(os.path.dirname(__file__), "action_pipe")

# Import the generated protobuf classes
from roboteam_networking.proto import ActionCommand_pb2
Expand All @@ -18,16 +19,20 @@ def send_action_command(num_attacker, num_defender, num_waller):
socket = context.socket(zmq.PUSH) # Use PUSH socket type
socket.bind("tcp://*:5555") # Send data over this port.


action_command = ActionCommand_pb2.ActionCommand()
action_command.numDefender = num_defender
action_command.numAttacker = num_attacker
action_command.numWaller = num_waller

message = action_command.SerializeToString()
socket.send(message)
# socket.send(message)
print(f"Sent: numDefender={num_defender}, numAttacker={num_attacker}, numWaller={num_waller}")

with open(pipe_path, "wb") as fifo:
fifo.write(message)
print(f"Sent: numDefender={num_defender}, numAttacker={num_attacker}, numWaller={num_waller}")


if __name__ == "__main__":
# Example usage
Expand Down
Loading

0 comments on commit e840b34

Please sign in to comment.