feat(envs): add envs pre-post processor#2474
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the LIBERO environment integration to use a more structured observation format. Instead of a flat agent_pos state vector, observations now use a nested robot_state dictionary containing detailed end-effector, gripper, and joint information. A new LiberoProcessorStep is introduced to transform these structured observations into the format expected by LeRobot policies.
Key changes:
- Replaced flat
agent_poswith nestedrobot_statestructure containing eef, gripper, and joints data - Added
LiberoProcessorStepto process LIBERO observations, including quaternion-to-axis-angle conversion and image flipping - Updated environment configuration to define features for all robot state components
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/processor/test_libero_processor.py | Adds test for the new LiberoProcessorStep (note: test should be converted to proper pytest function) |
| src/lerobot/scripts/lerobot_eval.py | Whitespace normalization |
| src/lerobot/processor/observation_processor.py | Implements LiberoProcessorStep for processing LIBERO observations with quaternion conversion and image flipping |
| src/lerobot/envs/utils.py | Adds handling for nested robot_state structure in preprocess_observation (note: needs recursive conversion fix) |
| src/lerobot/envs/libero.py | Updates observation space definition and _format_raw_obs to return structured robot_state instead of flat agent_pos |
| src/lerobot/envs/configs.py | Updates feature definitions and mappings for the new robot_state structure |
| eval.sh | Adds evaluation script (note: contains user-specific path, should not be committed) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
michel-aractingi
left a comment
There was a problem hiding this comment.
Great work @jadechoghari !
minor nits required.
The biggest part is adding constants for the feature names of libero config rather than hardcoding them .
Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co> Signed-off-by: Jade Choghari <chogharijade@gmail.com>
* more changes * working changes * more changes * more fixes * fix style * more * clean * put axis-1 * more fixes * more styling fixes: * iterate on review: * more changes * add env processor * style * more changes * add docs * fix imports * fix test, add to train * Update src/lerobot/envs/factory.py Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co> Signed-off-by: Jade Choghari <chogharijade@gmail.com> * iterate on review --------- Signed-off-by: Jade Choghari <chogharijade@gmail.com> Co-authored-by: jade.choghari@huggingface.co <“chogharijade@gmail.com”> Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co>
* more changes * working changes * more changes * more fixes * fix style * more * clean * put axis-1 * more fixes * more styling fixes: * iterate on review: * more changes * add env processor * style * more changes * add docs * fix imports * fix test, add to train * Update src/lerobot/envs/factory.py Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co> Signed-off-by: Jade Choghari <chogharijade@gmail.com> * iterate on review --------- Signed-off-by: Jade Choghari <chogharijade@gmail.com> Co-authored-by: jade.choghari@huggingface.co <“chogharijade@gmail.com”> Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co>
* more changes * working changes * more changes * more fixes * fix style * more * clean * put axis-1 * more fixes * more styling fixes: * iterate on review: * more changes * add env processor * style * more changes * add docs * fix imports * fix test, add to train * Update src/lerobot/envs/factory.py Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co> Signed-off-by: Jade Choghari <chogharijade@gmail.com> * iterate on review --------- Signed-off-by: Jade Choghari <chogharijade@gmail.com> Co-authored-by: jade.choghari@huggingface.co <“chogharijade@gmail.com”> Co-authored-by: Michel Aractingi <michel.aractingi@huggingface.co>
What this does
With this refactor, Libero environments now expose the full set of state features rather than a fixed subset. The VLA preprocessor is responsible for selecting and formatting the states it needs. This separation of concerns simplifies the pipeline, makes adding new VLA variants much easier, and enables experimentation with richer or alternative state representations without requiring changes to the environment code.
You can now either implement your own custom Libero preprocessor or use the default one,
LiberoProcessorStep, which assumes the policy was trained on the dataset at HuggingFaceVLA/libero.We introduce a new make_env_pre_post_processors function in lerobot/envs/factory.py that creates environment-specific observation processors. This function follows the same factory pattern as make_pre_post_processors for policies, but is specifically designed for environment observation transformations.