Fix video saving bug for the first frame in data generation#199
Fix video saving bug for the first frame in data generation#199
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes an episode-boundary condition in the camera recording event functor so the first frame of a new episode is not incorrectly saved into the previous episode’s video during data generation.
Changes:
- Update the save-trigger condition in
record_camera_data.__call__to save recorded frames whenelapsed_stepsindicates a reset boundary.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # TODO: the current implementation will lost the final episode frames recording. | ||
| # Check if the frames should be saved for the current episode | ||
| if env.elapsed_steps.sum().item() == len(env_ids) and len(self._frames) > 0: | ||
| if env.elapsed_steps.sum().item() == 0 and len(self._frames) > 0: | ||
| video_name = f"episode_{self._current_episode}_{self._name}" | ||
| images_to_video(self._frames, save_path, video_name, fps=20) |
There was a problem hiding this comment.
This bug fix changes the episode-boundary detection (saving when elapsed_steps sum is 0). Since this is easy to regress and the repo has event-functor tests, please add a small unit test that mocks/stubs images_to_video and verifies that when elapsed_steps==0, the previous episode frames are saved before appending the first frame of the new episode (i.e., first frame is not included in the previous video).
Description
Small fix.
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
black .command to format the code base.