Aborting a capture command waiting for a trigger

I had a colleague have a look at your code and the problem is stemming from there. Or rather from the code snippet I provided above:

retrieve.execute(false);

// If the command had finished, we have overwritten the result
// by re-executing the command at this point. Hence the next if
// statement will never be entered.

if (retrieve.finished() && retrieve.result()[serial][itmRetrieved].asBool()) {
    // A new image has been received and copied into the raw image node
    break;
}

Please move setting the timeout and executing the retrieve command outside the while-true loop:

{
	NxLibCommand(cmdTrigger).execute();

	NxLibCommand retrieve(cmdRetrieve);
	
	// Use a long timeout here so that we can cancel the command
	retrieve.parameters()[itmTimeout] = 5000;

	// Do not wait until the command execution finished, instead we poll
	retrieve.execute(false);

	while (true) {

		if (retrieve.finished() && retrieve.result()[serial][itmRetrieved].asBool()) {
			// A new image has been received and copied into the raw image node
			break;
		}

		// Check for an interrupt
		if (interrupt) {
			// Cancel the current retrieve
			retrieve.cancel();

			// Wait until the command has finished
			while (true) {
				if (retrieve.finished()) {
					break;
				}
			}

			break;
		}
	}
}

Due to the repeated parameter setting and command execution, the buffers of the “Translator” thread did overflow and make it impossible to see in the NxProfiler what the Retrieve command actually returned.

The following, which I assumed in my last post, is not true. You can safely open the cameras separately for them to operate together. It only saves time to open them with one command.

I think in order for them to operate as one combined camera, you would have to open them together in one Open command by providing both serials to the Cameras node of the command parameters […]

I am sorry for the inconvenience.

Kind Regards
Benny

1 Like