lerobot icon indicating copy to clipboard operation
lerobot copied to clipboard

Fix: busy_wait Windows Timer

Open nicholas-maselli opened this issue 6 months ago • 1 comments

What this does

This code fixes the busy_wait function on Windows to use the same strategy as Mac. Windows time.sleep() frequently oversleeps which is causing issues with framerates in recorded data

Examples:

Title Label
Fixes Windows Time Sleep (🐛 Bug)

How it was tested

I ran a remote robot teleop on 10 fps, 20fps, and 30fps.

For Linux all 3 were approximately correct (maybe off by a few hundredths of an fps) For Windows all 3 were wildly off, anywhere from 10%-30%

How to checkout & try? (for the reviewer)

Record a dataset on Mac, Linux, and Windows and you should now see that all 3 have the proper FPS within the INFO logs when recording data

Examples:

python lerobot/scripts/control_robot.py \
  --robot.type=so100 \
  --control.type=teleoperate \
  --control.fps=20 \
  --control.display_data=true

nicholas-maselli avatar Jun 02 '25 23:06 nicholas-maselli

Hi @nicholas-maselli,

Nice catch regarding timers on Windows ! A shame time.sleep() is not precise on Windows and MacOS... Unfortunately, the files architecture changed a bit since your submission. Could you rebase your branch on main so that I can merge this PR ? busy_wait() is now in lerobot/common/utils/robot_utils.py.

Thanks !

Best,

Caroline.

CarolinePascal avatar Jun 10 '25 08:06 CarolinePascal

Hi @nicholas-maselli,

Your PR has been updated to the latest codebase version in #1695, and will be merged anytime soon.

Best,

Caroline.

CarolinePascal avatar Aug 07 '25 17:08 CarolinePascal