Skip to content

Commit

Permalink
Pipeline second version
Browse files Browse the repository at this point in the history
  • Loading branch information
HamzaKady committed Nov 28, 2024
1 parent 1de6ca4 commit 79f1f05
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions roboteam_ai/src/RL/receiveActionCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string>

int main() {

std::string input;

// Read each line from stdin
Expand Down
31 changes: 31 additions & 0 deletions roboteam_ai/src/RL/sentActionCommand2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import os
import sys
import subprocess

def send_action_command(num_attacker, num_defender, num_waller):
# Path to the C++ executable
current_dir = os.path.dirname(os.path.abspath(__file__))
cpp_executable_path = os.path.join(current_dir, "receiveActionCommand") # Adjust if necessary

# Start the subprocess
process = subprocess.Popen(
[cpp_executable_path],
stdin=subprocess.PIPE, # Open a pipe to the C++ program
text=True # Use text mode for easier communication
)

# Format the data as a comma-separated string
message = f"{num_defender},{num_attacker},{num_waller}\n"

# Write the message to the subprocess stdin
process.stdin.write(message)
process.stdin.flush()

print(f"Sent: {message.strip()}")

# Close the stdin to signal EOF to the subprocess
process.stdin.close()
process.wait()

if __name__ == "__main__":
send_action_command(2, 3, 1)

0 comments on commit 79f1f05

Please sign in to comment.