rosmatlab subscriber synchronization with Main Thread
Hi,
I am using rosmatlab to read Lidar data published bu urg_node in Matlab.
urg_scan = rosmatlab.subscriber('/scan', 'sensor_msgs/LaserScan', 1, node);
urg_scan.setOnNewMessageListeners({@readScanData});
readScanData is a function which reads as follows:
function readScanData(msg)
sensor_data = msg.getRanges();
vectRangeData = sensor_data;
end
vectRangeData is a global variable which I used in Matlab Main Thread to analyses Lidar data. My question is how to synchronizes the access to global variable "vectRangeData"?
As I understand callback function will be run in separate java thread using rosjava jars. After following link:matlab undocumented and inputs from senior developer I think they are using eval or feval functions to execute callback functions under subcriber threads. Still it confused me how to synchronize the access to global vars. I am not using Parallel Computing toolbox. Its just some objects shared between Matlab's Main Thread and Java Threads.