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

Reward assignment during recording #518

Open
wants to merge 22 commits into
base: user/michel-aractingi/2024-11-27-port-hil-serl
Choose a base branch
from

Conversation

ChorntonYoel
Copy link

@ChorntonYoel ChorntonYoel commented Nov 22, 2024

What this does

Examples:

Title Label
Item1 of Reward Classifier in issue #504 (Feature)

Those PR is meant to add the possibility for the teleoperator to add rewards when performing the tasks.
The current approach simply consists in having frames labeled 0 until the experimenter presses the space bar. Then the reward for each frame becomes 1. The experimenter can press the bar again (eg. in case of subsequent failure) and the frame labeling will return to 0. Each time the space bar is pressed, the labeling switches

This is one way to go about it, but lmk if you have a better idea!

How it was tested

I made datasets with Moss with and without rewards. Checking that I got the expected behavior.

How to checkout & try? (for the reviewer)

python lerobot/scripts/control_robot.py record \
    --robot-path lerobot/configs/robot/moss.yaml \
    --fps 30 \
    --root data \
    --repo-id ${HF_USER}/moss_test \
    --tags moss tutorial \
    --warmup-time-s 5 \
    --episode-time-s 40 \
    --reset-time-s 10 \
    --num-episodes 2 \
    --push-to-hub 1 \
    --assign_rewards

Copy link
Collaborator

@Cadene Cadene left a comment

Choose a reason for hiding this comment

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

Really cool! I like this design ;)

We are in the process of switching to dataset v2. We removed populate_dataset.py and updated scripts/control_robot.py.
By any chance could you rebase on top of user/aliberts/2024_09_25_reshape_dataset? Sorry for that!!!

You might need to solve some conflicts. Happy to jump on a call if needed or message me on Discord ;)

git fetch origin user/aliberts/2024_09_25_reshape_dataset
git rebase origin/user/aliberts/2024_09_25_reshape_dataset

lerobot/scripts/control_robot.py Outdated Show resolved Hide resolved
@Cadene
Copy link
Collaborator

Cadene commented Nov 22, 2024

Also style check failing was failing. Could you please run our pre-commit? :D

pre-commit install
pre-commit run --all-files

https://github.com/huggingface/lerobot/blob/main/CONTRIBUTING.md#submitting-a-pull-request-pr

@ChorntonYoel ChorntonYoel changed the base branch from main to user/aliberts/2024_09_25_reshape_dataset November 22, 2024 22:51
nargs="*",
help="Add tags to your dataset on the hub.",
)
# parser_record.add_argument(
Copy link
Author

Choose a reason for hiding this comment

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

I commented those because they were raising "unexpected keyword argument" errors. Probably shouldn't be done in this PR. Lmk if you want me to bring them back

Copy link
Collaborator

Choose a reason for hiding this comment

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

We will bring them back after merging Simon's PR ;) thanks for flagging ; same for force-override
cc @aliberts

@ChorntonYoel ChorntonYoel marked this pull request as ready for review November 23, 2024 15:33
Copy link
Collaborator

@Cadene Cadene left a comment

Choose a reason for hiding this comment

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

Thanks ;) Let's wait for Simon's to merge the PR, then we can merge

nargs="*",
help="Add tags to your dataset on the hub.",
)
# 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.

We will bring them back after merging Simon's PR ;) thanks for flagging ; same for force-override
cc @aliberts

lerobot/scripts/control_robot.py Show resolved Hide resolved
lerobot/common/robot_devices/control_utils.py Outdated Show resolved Hide resolved
lerobot/common/robot_devices/control_utils.py Outdated Show resolved Hide resolved
lerobot/scripts/control_robot.py Show resolved Hide resolved
dataset.push_to_hub(private=True)
dataset.push_to_hub()
Copy link
Collaborator

Choose a reason for hiding this comment

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

@ChorntonYoel ChorntonYoel changed the base branch from user/aliberts/2024_09_25_reshape_dataset to user/michel-aractingi/2024-11-27-port-hil-serl November 27, 2024 17:34
Copy link
Collaborator

@michel-aractingi michel-aractingi left a comment

Choose a reason for hiding this comment

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

Nice work! Left few comments but in general it's ready to merge.

Comment on lines +294 to +295
features = {} if features is None else features
features.update(get_features_from_robot(robot, use_videos))
Copy link
Collaborator

Choose a reason for hiding this comment

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

What do you think of writing it like this?

Suggested change
features = {} if features is None else features
features.update(get_features_from_robot(robot, use_videos))
features = {**(features or {}), **get_features_from_robot(robot)}

Comment on lines 124 to 126
# Allow to exit early while recording an episode or resetting the environment,
# by tapping the right arrow key '->'. This might require a sudo permission
# to allow your terminal to monitor keyboard events.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we add some comments here to explain assign_rewards?

Suggested change
# Allow to exit early while recording an episode or resetting the environment,
# by tapping the right arrow key '->'. This might require a sudo permission
# to allow your terminal to monitor keyboard events.
"""
Initializes a keyboard listener to enable early termination of an episode
or environment reset by pressing the right arrow key ('->'). This may require
sudo permissions to allow the terminal to monitor keyboard events.
Args:
assign_rewards (bool): If True, allows annotating the collected trajectory
with a binary reward at the end of the episode to indicate success.
"""

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also the same in the comments header of lerobot/scripts/control_robot.py

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.

6 participants