| name | add-task-env |
| description | Use when creating a new task environment for EmbodiChain, including expert demonstration tasks, RL tasks or any EmbodiedEnv subclass |
Add Task Environment
Scaffold a new task environment following EmbodiChain's conventions and patterns.
When to Use
- User asks to create a new task or environment
- User says "add a task", "new env", "create environment for X"
Steps
1. Determine Task Category
Ask the user:
- Category:
tableware, rl, or special (maps to embodichain/lab/gym/envs/tasks/<category>/)
- Task name (snake_case, e.g.
pick_place)
- Gym ID (e.g.
PickPlace-v1)
- Task type: RL task (needs reward functors) or expert demonstration task (needs
create_demo_action_list)
2. Create the Task File
Place at embodichain/lab/gym/envs/tasks/<category>/<name>.py.
Template:
from __future__ import annotations
import torch
from typing import Dict, Any, Tuple
from embodichain.lab.gym.utils.registration import register_env
from embodichain.lab.gym.envs import EmbodiedEnv, EmbodiedEnvCfg
from embodichain.lab.sim.types import EnvObs
__all__ = ["<CamelCaseName>Env"]
@register_env("<GymId>")
class <CamelCaseName>Env(EmbodiedEnv):
"""<One-line description of the task>.
<Longer description of what the task involves and its reward structure.>
"""
def __init__(self, cfg: EmbodiedEnvCfg = None, **kwargs):
if cfg is None:
cfg = EmbodiedEnvCfg()
super().__init__(cfg, **kwargs)
3. Update Exports
Add to embodichain/lab/gym/envs/tasks/__init__.py:
from embodichain.lab.gym.envs.tasks.<category>.<name> import <CamelCaseName>Env
Add "<CamelCaseName>Env" to the __all__ list.
4. Create Test Stub
Place at tests/gym/envs/tasks/test_<name>.py.
5. Format
black embodichain/lab/gym/envs/tasks/<category>/<name>.py
black tests/gym/envs/tasks/test_<name>.py
Checklist