Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added an image buffer to fix the artificial latency in sim #919

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

Maximellerbach
Copy link
Contributor

@Maximellerbach Maximellerbach commented Aug 15, 2021

We previously used time.sleep to simulate the latency, but this method slows down the whole loop.
I added an image/info buffer to fix this issue.

what it does:

  • when an image is received, store it into the buffer
  • if an image has been long enough in the buffer use it as self.frame and remove it from the buffer.

If you have SIM_ARTIFICIAL_LATENCY=100, you should expect to have from 4 to 5 images in the buffer

tested on my machine with donkeycar in the sim

donkeycar/parts/dgym.py Outdated Show resolved Hide resolved

# go through the buffer
num_to_remove = 0
for it in range(len(self.buffer)):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can now make this more pythonic by not using the random access iterator at all but just:

for buf in in self.buffer:
    if now - buf[0] >= self.delay
    ...

@DocGarbanzo
Copy link
Contributor

Great, this looks good to me, I only have one minor comment. Can you please rebase and squash all the commits into one and force-push your branch so we keep git history linear? I will merge this then.

author Maxime Ellerbach <maxime@ellerbach.net> 1629036953 +0200
committer Maxime Ellerbach <maxime@ellerbach.net> 1630618548 +0200

added an image buffer to fix the artificial latency
Copy link
Contributor

@DocGarbanzo DocGarbanzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@DocGarbanzo DocGarbanzo merged commit bd83e0c into autorope:dev Sep 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants