Vicon DataStream MATLAB SDK

15 views (last 30 days)
Kurt Buchholz
Kurt Buchholz on 19 Feb 2018
Answered: Walter Roberson on 19 Feb 2018
I am working with Vicon Nexus DataStream SDK in MATLAB and I am looking to sample two streams simultaneously. The two streams are from two separate force plates (ForcePlateCount, below). I realize that the index for each forceplate (1 & 2 respectively) will execute the loop as 1 or 2 in each iteration. The code listed below is all nested in a large while loop. Does anyone have experience running this with the parallel computing toolbox (i.e. using a 'parfor' loop on the line 8)? Would this be an appropriate application of the parallel computing toolbox?
Thank you!
while ishandle( MessageBox )
...
% Count the number of force plates
ForcePlateCount = MyClient.GetForcePlateCount().ForcePlateCount;
% This will equal 2 in the current setup
for ForcePlateIndex = 1:ForcePlateCount
...
% Get the number of subsamples associated with this device.
Output_GetForcePlateSubsamples = MyClient.GetForcePlateSubsamples( ForcePlateIndex );
...
for ForcePlateSubsample = 1:Output_GetForcePlateSubsamples.ForcePlateSubsamples
% Output all the subsamples.
fprintf( ' Sample #%d:\n', ForcePlateSubsample - 1 );
Output_GetGlobalForceVector = MyClient.GetGlobalForceVector( ForcePlateIndex, ForcePlateSubsample );
fprintf( ' Force (%g, %g, %g)\n', ...
Output_GetGlobalForceVector.ForceVector( 1 ), ...
Output_GetGlobalForceVector.ForceVector( 2 ), ...
Output_GetGlobalForceVector.ForceVector( 3 ) );
Output_GetGlobalMomentVector = MyClient.GetGlobalMomentVector( ForcePlateIndex, ForcePlateSubsample );
fprintf( ' Moment (%g, %g, %g)\n', ...
Output_GetGlobalMomentVector.MomentVector( 1 ), ...
Output_GetGlobalMomentVector.MomentVector( 2 ), ...
Output_GetGlobalMomentVector.MomentVector( 3 ) );
Output_GetGlobalCentreOfPressure = MyClient.GetGlobalCentreOfPressure( ForcePlateIndex, ForcePlateSubsample );
fprintf( ' CoP (%g, %g, %g)\n', ...
Output_GetGlobalCentreOfPressure.CentreOfPressure( 1 ), ...
Output_GetGlobalCentreOfPressure.CentreOfPressure( 2 ), ...
Output_GetGlobalCentreOfPressure.CentreOfPressure( 3 ) );
end% ForcePlateSubsample
end% ForcePlateIndex
...
end

Answers (1)

Walter Roberson
Walter Roberson on 19 Feb 2018
It is common that access from different workers is not possible in the case where the data is coming from a single hardware device, even if that hardware device is handling multiple channels. Device drivers often lock access down to one process at a time as doing so means that they do not have to keep state for each distinct connection. parfor workers are different processes.
But sometimes it is possible, especially if the connection is made by way of ActiveX. In such a case the trick is that the MyClient needs to be recreated on each worker. Typically the easiest way to do that is to run the initialization code on each worker by using parfevalOnAll()

Categories

Find more on Troubleshooting in MATLAB Compiler SDK in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!