본문으로 건너뛰기
cccskills
무료GitHub에 공개

add-functor

Use when adding a new observation, event, reward, action, dataset, or randomization functor to an EmbodiChain environment

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain스타 236(GitHub 236 + cccskills 0)

실행 점수 미검증

설치 방법 보기

포함된 파일(2)

  • SKILL.md6.1 KB
  • agents/openai.yaml93 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Add Functor

Scaffold a new functor following EmbodiChain's Functor/FunctorCfg pattern.

When to Use

  • User asks to add an observation term, reward function, event handler, action term, dataset functor, or randomizer
  • User says "add a reward", "new observation", "create a randomizer", "add event functor"
  • Any new function needs to be registered in a manager config

Determine Functor Type

Functor TypeConfig ClassModule FileManagerSignature
ObservationObservationCfg (extends FunctorCfg)managers/observations.pyObservationManager(env, obs, entity_cfg, ...) -> Tensor
RewardRewardCfg (extends FunctorCfg)managers/rewards.pyRewardManager(env, obs, action, info, ...) -> Tensor
EventEventCfg (extends FunctorCfg)managers/events.pyEventManager(env, env_ids, ...) -> None
ActionActionTermCfg (extends FunctorCfg)managers/actions.pyActionManagerVaries
DatasetDatasetFunctorCfg (extends FunctorCfg)managers/datasets.pyDatasetManager(env, ...) -> dict
RandomizationEventCfg (randomizations ARE events)managers/randomization/<type>.pyEventManager(env, env_ids, entity_cfg, ...) -> None

Two Functor Styles

Function-style (Preferred for Simple Functors)

A plain function with the right signature. Registered via FunctorCfg(func=my_function, params={...}).

def my_reward(
    env: EmbodiedEnv,
    obs: dict,
    action: EnvAction,
    info: dict,
    my_param: float = 1.0,       # params become keyword args
) -> torch.Tensor:
    """Short one-line summary.

    Longer description if needed.

    Args:
        env: The environment instance.
        obs: The observation dictionary.
        action: The action taken.
        info: The info dictionary.
        my_param: Description of this parameter.

    Returns:
        Reward tensor of shape (num_envs,).
    """
    # implementation
    return result

Class-style (Required When Functor Has State)

A class inheriting Functor, with __init__(cfg, env) and __call__(env, ...). Registered via FunctorCfg(func=MyClass, params={...}).

class my_randomizer(Functor):
    """One-line summary."""

    def __init__(self, cfg: FunctorCfg, env: EmbodiedEnv):
        super().__init__(cfg, env)
        # Extract params and initialize state
        self.entity_cfg: SceneEntityCfg = cfg.params["entity_cfg"]

    def __call__(self, env: EmbodiedEnv, env_ids: torch.Tensor, **kwargs):
        """Apply the randomization.

        Args:
            env: The environment instance.
            env_ids: Target environment IDs.
        """
        # implementation

Steps

1. Identify Functor Type and Style

Ask the user:

  1. Which manager? (observation / reward / event / action / dataset / randomization)
  2. Function or class style? (function for stateless, class for stateful)
  3. What does it do? (brief description for naming + docstring)

2. Choose the Right Module File

Place the functor in the existing module for its type:

TypeFile
Observationembodichain/lab/gym/envs/managers/observations.py
Rewardembodichain/lab/gym/envs/managers/rewards.py
Eventembodichain/lab/gym/envs/managers/events.py
Actionembodichain/lab/gym/envs/managers/actions.py
Datasetembodichain/lab/gym/envs/managers/datasets.py
Physics randomizationembodichain/lab/gym/envs/managers/randomization/physics.py
Visual randomizationembodichain/lab/gym/envs/managers/randomization/visual.py
Spatial randomizationembodichain/lab/gym/envs/managers/randomization/spatial.py
Geometry randomizationembodichain/lab/gym/envs/managers/randomization/geometry.py

3. Write the Functor

Follow the template for function-style or class-style (see above).

Key rules:

  • First argument is always env: EmbodiedEnv (use TYPE_CHECKING guard for the import)
  • Use from __future__ import annotations at the top
  • Use SceneEntityCfg for entity references, not raw strings
  • For observation functors: add shape key to FunctorCfg.extra dict
  • For randomization functors: second arg is env_ids: torch.Tensor | list[int]
  • For reward functors: return shape must be (num_envs,)

4. Update __all__

Add the new functor to the module's __all__ list. If no __all__ exists, create one.

5. Write a Test

Place at tests/gym/envs/managers/test_<functor_type>.py (append to existing file if present).

For functors that don't need a live simulation, use mock objects (MockEnv, MockSim, etc.) following the pattern in tests/gym/envs/managers/test_reward_functors.py.

6. Run black

black embodichain/lab/gym/envs/managers/<module>.py
black tests/gym/envs/managers/test_<functor_type>.py

Common Mistakes

MistakeFix
Wrong first argument signatureObservation: (env, obs, ...), Reward: (env, obs, action, info, ...), Event/Randomization: (env, env_ids, ...)
Importing EmbodiedEnv at module levelUse TYPE_CHECKING guard to avoid circular imports
Forgetting SceneEntityCfg for entity refsAlways use SceneEntityCfg(uid="...") not bare strings
Returning wrong tensor shapeRewards must return (num_envs,), observations must match declared shape
Missing from __future__ import annotationsRequired in every file
Class-style functor not calling super().__init__Always call super().__init__(cfg, env)
Adding randomizer as standaloneRandomizations ARE events — they go in randomization/ but use EventCfg

Quick Reference

StepAction
1Identify manager type + function vs class style
2Write functor in the correct module file
3Update __all__ in that module
4Write test with mocks (no sim needed for most)
5Run black on changed files

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Add a new simulation atomic action or motion primitive to EmbodiChain's typed planning and execution framework. Use when implementing a new skill, goal contract, action planner, symbolic effect, registration entry, documentation, and tests for AtomicActionEngine.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain2362026년 10월 26일 업데이트

Claude adapter for the canonical EmbodiChain add-atomic-action skill.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain2362026년 10월 26일 업데이트

Claude adapter for the canonical EmbodiChain add-embodiment-component skill.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain2362026년 10월 26일 업데이트

Add or update a reusable EmbodiChain embodiment YAML component that owns one simulation robot, its sensor suite, and an optional Task Program skill_profile. Use for configs/components/embodiments, new Task Program-compatible robots, or multi-embodiment task deployment.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain2362026년 10월 26일 업데이트

Claude adapter for the canonical EmbodiChain add-functor skill.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain2362026년 10월 26일 업데이트

add-robot

무료

Claude adapter for the canonical EmbodiChain add-robot skill.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

DexForce/EmbodiChain2362026년 10월 26일 업데이트

DexForce의 스킬 모두 보기

이 스킬의 문제 신고