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(port-hilserl): Proof of concept to improve episode recording UX using pygame instead of csv.imshow #579

Conversation

jackvial
Copy link
Contributor

@jackvial jackvial commented Dec 16, 2024

What this does

  • Use pygame for rendering camera feed to screen instead of cv2.imshow. This should offer better performance, camera feed and robot movement should be smoother when recording episodes
  • Use pygame event for handling keyboard inputs
  • Encapsulate rendering and keyboard events in a ControlContext class that gets updated in the control_loop. This makes it simple to render helpful information on top of the camera feed e.g. current reward, control phase (warmup|record episode)

Demo

pygame_camera_rendering_demo.mp4

How To Test

pip install pygame

Teleoperate

python lerobot/scripts/control_robot.py teleoperate --robot-path lerobot/configs/robot/koch.yaml --fps 30

Teleoperate should look like this. No episodes or rewards shown at top.

Screenshot from 2024-12-16 21-33-26

Record With Rewards

python lerobot/scripts/control_robot.py record \
    --robot-path lerobot/configs/robot/koch.yaml \
    --fps 30 \
    --root outputs/pygame_rendering_test_0 \
    --repo-id your_hf_username/pygame_rendering_test_0 \
    --warmup-time-s 2 \
    --episode-time-s 10 \
    --reset-time-s 5 \
    --num-episodes 10 \
    --push-to-hub 1 \
    --assign-rewards 1 \
    --single-task test_description

Warmup phase will not show rewards or episodes at the top of the screen.
Record phase will show episodes and count at top of screen.

Screenshot from 2024-12-16 21-34-46

After recording one episode I'm getting this error about the shape of the actions column, not yet sure what is happening here, will have too look into

Exception has occurred: ArrowInvalid
Column 1 named action expected length 0 but got length 589

Screenshot from 2024-12-16 21-36-40

.cache/calibration/koch_tdmpc_jack/main_follower.json Outdated Show resolved Hide resolved
.cache/calibration/koch_tdmpc_jack/main_leader.json Outdated Show resolved Hide resolved
lerobot/configs/robot/koch_jack.yaml Outdated Show resolved Hide resolved
record_with_rewards.sh Outdated Show resolved Hide resolved
teleoperate.sh Outdated Show resolved Hide resolved
@jackvial
Copy link
Contributor Author

jackvial commented Dec 17, 2024

Hey @michel-aractingi , thanks for the feedback. I've removed my scripts and configs.
I've added the commands I used for teleoperate and record along with screen shots.

After recording one episode I get an error of

Exception has occurred: ArrowInvalid
Column 1 named action expected length 0 but got length 589

so I have either broken something or I'm missing some changes, will try figure this out tomorrow.

Also, I think log_control_info could also be moved to ControlContext and be enabled/disabled with a boolean flag in ControlContextConfig. log_control_info produces a lot of output and can quickly bury other information printed to the terminal so would be nice if it were configurable

@michel-aractingi michel-aractingi force-pushed the user/michel-aractingi/2024-11-27-port-hil-serl branch from 3d7e74d to def42ff Compare December 17, 2024 15:22
@jackvial
Copy link
Contributor Author

@michel-aractingi I've created a new branch off main for this as it will probably be easier to coordinate that way and avoid merging conflicts. This is the branch I'm working on https://github.com/jackvial/lerobot/commits/pygame-for-rendering-and-event-handling/ . I have a bit more work to do on it but plan to open a PR in the next few days.

Let me know if it's ok to close this draft PR

@jackvial
Copy link
Contributor Author

closing in favor of #601

@jackvial jackvial closed this Dec 28, 2024
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.

5 participants