feedback frequency and getNextFeedback

Questions, comments, and issues that aren't related to a specific product
Post Reply
husch
Posts: 16
Joined: Fri Oct 30, 2020 6:18 am

feedback frequency and getNextFeedback

Post by husch » Fri May 27, 2022 4:53 am

According to the document (https://docs.hebi.us/tools.html#cpp-feedback, https://docs.hebi.us/tools.html#get-next-feedback-2) and example,
group->setFeedbackFrequencyHz(F1);

// loop frequency F2
while (!stop_loop)
{
if (!group->getNextFeedback(&feedback))
continue;
// ... read/use feedback object contents here.
}
we set feedback frequency for a background thread on host computer to collect feedbacks from actuators. We call getNextFeedback to get the next new (not previously accessed) synchronized feedback.

If F2 is faster than F1, the getNextFeedback call blocks, according to the document.
What happens if F1 is faster than F2? Will the feedbacks be pushed in a buffer? If so, what is its size? Does getNextFeedback return the latest state (feedback) or the old state?

Thank you very much.
User avatar
florian_enner
HEBI Official
Posts: 30
Joined: Wed Mar 25, 2020 11:31 am
Location: Austria

Re: feedback frequency and getNextFeedback

Post by florian_enner » Fri May 27, 2022 7:38 am

getNextFeedback always returns the latest state or blocks until a new state is available. If F2 is slower than F1, it will end up skipping some measurements rather than adding lag by buffering.

The only exception to this are offline log-groups where getNextFeedback always advances by one.
husch
Posts: 16
Joined: Fri Oct 30, 2020 6:18 am

Re: feedback frequency and getNextFeedback

Post by husch » Fri May 27, 2022 9:09 am

Cool, that is perfect! Thanks a lot :)
husch
Posts: 16
Joined: Fri Oct 30, 2020 6:18 am

Re: feedback frequency and getNextFeedback

Post by husch » Wed Jun 15, 2022 4:04 am

A few more questions :mrgreen:

So we have two loops in two threads,
- background thread on host computer to collect feedbacks from actuators, runs @ F1
- main thread where getNextFeedback is called, runs @ F2.
When F2 is faster than F1, main thread blocks until there is a new status collected by background thread.

(1)
Do these two threads (processes) run in parallel? Or do they run in a time sharing manner on a single process, concurrently?
More information will be useful :) to predict the behaviour.

(2)
How does background thread work with UDP packages and network layers?
Could you please describe what happens when feedback UDP packages arrive at the host computer?

(3)
If there are n actuators and we only receive (n-1) states, is the main thread going to block?

(4)
What is your advice on setting the optimal F1 and F2. Do you run some benchmarks to determine the optimal F1 and F2?

Thanks a lot.
husch
Posts: 16
Joined: Fri Oct 30, 2020 6:18 am

Re: feedback frequency and getNextFeedback

Post by husch » Tue Jun 21, 2022 4:13 am

Any update for the questions in the previous post, please?
Thank you very much :D
Post Reply