getNextFeedback returns the next new synchronized feedback.
This method returns the next available feedback. This function
ensures that feedback will not get returned multiple times. If there
already is new feedback available, then this function returns
immediately. If no feedback is available, this function waits until
new feedback arrives or a timeout is reached.
If this function reaches the timeout, it will either throw an error
(live groups) or return an empty matrix (log replay groups). If this
happens, make sure that the hardware is turned on and that the feedback
request rate is set appropriately.
'Timeout' Parameter sets the timeout in seconds.
'View' Parameter
'Simple' returns basic feedback. This is appropriate for most
users. (default)
'Full' returns all available feedback. This is appropriate
for advanced users that care about additional
timestamps and less common sensors.
'IO' returns the state of pins on an IO board.
Example
% retrieve feedback from group
group = HebiLookup.newGroupFromFamily('*');
group.setFeedbackFrequency(100);
simpleFbk = group.getNextFeedback();
fullFbk = group.getNextFeedback('View', 'full');
Note that creating a feedback struct can be expensive in some time
critical applications. For such cases, there is a way to reuse
existing structs.
Example
% Reuse struct using standard syntax
reuseStruct = group.getFeedbackFull(); % create once
while true % reuse in loop
fbk = group.getNextFeedback(reuseStruct);
display(fbk.position);
end
% More optimized syntax
fbk = group.getNextFeedback();
while ~isempty(getNextFeedback(group, fbk))
display(fbk.position);
end