diff --git a/aerpaw/controller.coderprj b/aerpaw/controller.coderprj
index a9f8900..d93335a 100644
--- a/aerpaw/controller.coderprj
+++ b/aerpaw/controller.coderprj
@@ -145,7 +145,7 @@
true
- 2026-01-30T17:33:44
+ 2026-01-30T18:21:40
diff --git a/aerpaw/controller.m b/aerpaw/controller.m
index eea06da..955e1e2 100644
--- a/aerpaw/controller.m
+++ b/aerpaw/controller.m
@@ -56,37 +56,20 @@ for i = 1:numClients
end
end
-% Receive TARGET acknowledgments
-targetAcks = zeros(1, numClients, 'int32');
-for i = 1:numClients
- if coder.target('MATLAB')
- disp(['Waiting for ACK:TARGET from client ', num2str(i)]);
- targetAcks(i) = 1; % Simulate successful ACK
- else
- targetAcks(i) = coder.ceval('receiveTargetAck', int32(i));
- end
-end
-
-% Check all ACKs received
+% Wait for TARGET acknowledgments from all clients (simultaneously using select())
if coder.target('MATLAB')
- disp(['Target ACKs received: ', num2str(targetAcks)]);
+ disp('Waiting for ACK:TARGET from all clients...');
+ disp('All TARGET acknowledgments received.');
+else
+ coder.ceval('waitForAllTargetAck', int32(numClients));
end
-% Wait for READY signals (UAVs have reached their targets)
-readySignals = zeros(1, numClients, 'int32');
-for i = 1:numClients
- if coder.target('MATLAB')
- disp(['Waiting for READY from client ', num2str(i)]);
- readySignals(i) = 1; % Simulate READY
- else
- readySignals(i) = coder.ceval('waitForReady', int32(i));
- end
-end
-
-% Check all READY signals received
+% Wait for READY signals from all clients (simultaneously using select())
if coder.target('MATLAB')
- disp(['Ready signals received: ', num2str(readySignals)]);
+ disp('Waiting for READY from all clients...');
disp('All UAVs at target positions.');
+else
+ coder.ceval('waitForAllReady', int32(numClients));
end
% Wait for user input before closing experiment
diff --git a/aerpaw/impl/controller_impl.cpp b/aerpaw/impl/controller_impl.cpp
index 414f5bb..3736371 100644
--- a/aerpaw/impl/controller_impl.cpp
+++ b/aerpaw/impl/controller_impl.cpp
@@ -229,6 +229,18 @@ static int waitForAllMessage(int numClients, const char* expectedMessage) {
return 1;
}
+// Wait for ACK:TARGET from ALL clients simultaneously
+// Returns 1 if all clients acknowledged, 0 otherwise
+int waitForAllTargetAck(int numClients) {
+ return waitForAllMessage(numClients, "ACK:TARGET");
+}
+
+// Wait for READY from ALL clients simultaneously
+// Returns 1 if all clients are ready, 0 otherwise
+int waitForAllReady(int numClients) {
+ return waitForAllMessage(numClients, "READY");
+}
+
// Wait for RTL_COMPLETE from ALL clients simultaneously
// Returns 1 if all clients completed RTL, 0 otherwise
int waitForAllRTLComplete(int numClients) {
diff --git a/aerpaw/impl/controller_impl.h b/aerpaw/impl/controller_impl.h
index ab9aefd..c0939ca 100644
--- a/aerpaw/impl/controller_impl.h
+++ b/aerpaw/impl/controller_impl.h
@@ -18,11 +18,15 @@ int receiveTargetAck(int clientId);
int waitForReady(int clientId);
void sendFinished(int clientId);
+// Parallel wait functions (using select() for simultaneous processing)
+int waitForAllTargetAck(int numClients);
+int waitForAllReady(int numClients);
+int waitForAllRTLComplete(int numClients);
+int waitForAllLANDComplete(int numClients);
+
// RTL and LAND protocol functions
void sendRTL(int clientId);
void sendLAND(int clientId);
-int waitForAllRTLComplete(int numClients);
-int waitForAllLANDComplete(int numClients);
void waitForUserInput();
#ifdef __cplusplus