sending starting positions to agents (not verified on AERPAW yet)

This commit is contained in:
2026-01-29 16:42:19 -08:00
parent fa5d63361c
commit 1ae617d5f7
20 changed files with 1398 additions and 155 deletions

View File

@@ -15,21 +15,48 @@
// Function Definitions
void controller(int numClients)
{
static const char b_filename[12]{"targets.txt"};
double targets[12];
char filename[12];
// Maximum clients supported
// Allocate targets array (MAX_CLIENTS x 3)
// Load targets from file
// Define filename as null-terminated character array for C compatibility
for (int i{0}; i < 12; i++) {
targets[i] = 0.0;
filename[i] = b_filename[i];
}
// loadTargets fills targets array (row-major: x1,y1,z1,x2,y2,z2,...)
loadTargets(&filename[0], &targets[0], 4);
// Initialize server
initServer();
// Accept clients
for (int i{0}; i < numClients; i++) {
acceptClient(i + 1);
}
// Send messages to clients
// Send target coordinates to each client
for (int i{0}; i < numClients; i++) {
sendMessage(i + 1);
double target[3];
// Get target for this client (1x3 array)
target[0] = targets[i];
target[1] = targets[i + 4];
target[2] = targets[i + 8];
sendTarget(i + 1, &target[0]);
}
// Receive acknowledgements
// Receive TARGET acknowledgments
for (int i{0}; i < numClients; i++) {
receiveAck(i + 1);
receiveTargetAck(i + 1);
}
// Check all ACKs received
// Wait for READY signals (UAVs have reached their targets)
for (int i{0}; i < numClients; i++) {
waitForReady(i + 1);
}
// Check all READY signals received
// Send COMPLETE to all clients before closing
for (int i{0}; i < numClients; i++) {
sendFinished(i + 1);
}
// Digest ACKs
// Close server
closeServer();
}