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

feat(dataset): allow overriding tolerance_s #403

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

villekuosmanen
Copy link

What this does

My cameras can do maximum 30 FPS while I would like to record the joint states at higher FPS. In addition, occasional interrupts might cause an individual frame to be dropped or delayed, and having to drop the whole episode because of these may not be worth it.

This simply adds an option to override the tolerance_s constant in LeRobotDataset, and passes the value from data recording command line args.

How it was tested

Tested locally when recording data

How to checkout & try? (for the reviewer)

Record some episodes with a real robot. Test with the command line arg turned on and off.

@@ -126,6 +128,9 @@ def tolerance_s(self) -> float:
are not close enough from the requested frames. It is only used when `delta_timestamps`
is provided or when loading video frames from mp4 files.
"""
if self.tolerance_s is not None:
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the "right" way to handle this would be to have a private attribute self._tolerance which you set to 1 / fps - 1e-4 in the __init__ (btw fps should also be private as in self._fps and then might need its own getter method). Then here you just need to return self._tolerance.

OR, if we don't want to bother with encapsulation, this getter should disappear and we should just have an attribute self.tolerance_s. The only danger here is that it's independent of the fps from an interface perspective.

@Cadene I think you should weigh in here as I know you're not a fan of using private attributes.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@villekuosmanen After discussing internally, we will put your PR on hold for a bit while we think about a design.
cc @alexander-soare

Copy link
Collaborator

Choose a reason for hiding this comment

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

@villekuosmanen yeah so since I am encountering this right now with some RL stuff I am doing, we just want to get wait that working then use whatever it was I did to make it happen. It might be this approach, but there may be other ways of handling it.

Thanks a lot mate!

Copy link
Author

Choose a reason for hiding this comment

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

yep no problem, happy to wait.

@@ -798,7 +799,13 @@ def replay(robot: Robot, episode: int, fps: int | None = None, root="data", repo
nargs="*",
help="Any key=value arguments to override config values (use dots for.nested=overrides)",
)

parser_record.add_argument(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this matter? It gets lost in the hub upload anyway right? Then when someone wants to actually use the dataset they can set the tolerance as they wish.

Copy link
Author

Choose a reason for hiding this comment

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

I was having an issue when calculating stats from the dataset at the end of record which is why I put it here. Happy to delete the arg if there is some other, better way to do it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

It's weird that this is the case as you are not using delta_timestamps which is the only way I could see the tolerance guard is being triggered. Do you have an exception trace (only dig it up if you cbb, as this PR is on hold anyway).

Copy link
Author

Choose a reason for hiding this comment

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

no I don't unfortunately :(

Copy link
Collaborator

@alexander-soare alexander-soare left a comment

Choose a reason for hiding this comment

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

Thanks @villekuosmanen!

I agree that setting tolerance may be helpful. In fact, I came across the same need myself just a couple of days ago.

I'm not entirely sure why it's being added in the record script, so I've got an inline comment on that.

@alexander-soare alexander-soare self-assigned this Sep 2, 2024
@villekuosmanen villekuosmanen marked this pull request as draft September 2, 2024 15:01
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.

3 participants