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 feedback fields specific to I/O devices,
such as analog and digital pins, or the button and
slider states of the HEBI Mobile I/O app.
'Mobile' returns feedback fields specific to mobile devices,
such as GPS and ARKit/ARCore estimates.
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. This way also lets you request two different
feedback views at the same time.
Advanced Usage
% Reuse struct using standard syntax
reuseFbk = group.getNextFeedbackFull(); % create once
while true % reuse in loop
fbk = group.getNextFeedback(reuseFbk);
display(fbk.position);
end
% Requesting feedback of two different views at once. This
% is useful for getting both the button/slider states and
% mobile feedback from the HEBI Mobile I/O app.
fbkIO = group.getNextFeedbackIO();
fbkMobile = group.getNextFeedbackMobile();
while true
group.getNextFeedback(fbkIO, fbkMobile);
display([ fbkIO.a1 fbkMobile.batteryLevel]);
end
% More optimized syntax
fbk = group.getNextFeedback();
while ~isempty(getNextFeedback(group, fbk))
display(fbk.position);
end