Hi,
I am working on a leader-follower robot system that has a camera setup at an intersection that is scanning for collision prone objects for my senior design.
Basically, I have two seperate, but dependent, functions that need to be ran in parallel. The robots will only be allowed to operate while the OK-2-Go flag is set to 1. If there is an object detected by the camera, the Ok-2-Go flag will be set to 0. The Ok-2-Go flag is defined and updated only in the camera function, but is used as a condition in the turtlebots function.
Here is what my main would look like in terms of this project (excluding the parallel processing stuff):
start();
USB_Camera();
Turtlebots();
My problem is that the camera function needs to be running continuously while the turtlebots function runs at the same time. I have read online and realized that parfor loops do not work as they only work for functions INDEPENDENT of one another. The other thing I've read up on was callbacks but I'm not sure if these will solve this specific issue. The last thing I read up on was parpools, but when I setup a test program, I keep getting errors. I cannot find any examples on how this parpool function should be setup.
Here is what my main function looks like:
delete(gcp('nocreate'));
mpiInit;
p = parpool(myCluster,2);
spmd
labindex
end
COMM2();
COMM1();
Here is what COMM1 looks like:
function [] = COMM1()
x = labReceive(1);
sum = x+10
end
Here is what COMM2 looks like:
function [] = COMM2()
x = 1;
labSend(x, 2);
end
Here is my errors when I run MAINCOMM:
>> MAINCOMM
Starting parallel pool (parpool) using the 'local' profile ...
Connected to the parallel pool (number of workers: 2).
Lab 1:
ans =
1
Lab 2:
ans =
2
Error using labSend
Destination 2 is out of range (valid range: 1 <= destination <= 1).
Error in COMM2 (line 5)
labSend(x, 2);
Error in MAINCOMM (line 14)
COMM2();
>>
Can anyone point me in the right direction or tell me what I'm doing wrong? Is this even the right path to take in terms of what I'm trying to do?
I appreciate all the help!