Skip to content

Observations

contact_force(*, contact_manager) dataclass

Bases: MdpFn

Returns the vector norm contact force at each contact point.

Parameters:

Name Type Description Default
contact_manager ContactManager

The contact manager to check for contact

required

Returns:

Type Description

torch.Tensor: Shape (num_envs, num_contacts).

contact_manager instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

current_actions(*, action_manager=None) dataclass

Bases: MdpFn

The most current step's raw actions. This is the raw actions from the current step, without the action delay_step, and before they've been processed and converted into their target values.

Parameters:

Name Type Description Default
action_manager BaseActionManager | None

The action manager to source actions from. If not provided, all actions are read from env.actions.

None

action_manager = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

entity_angular_velocity(*, entity_manager=None, entity=None) dataclass

Bases: MdpFn

The angular velocity of the entity's base link, in the entity's local frame.

Parameters:

Name Type Description Default
entity_manager EntityManager | None

The entity manager for the robot/entity the observation is being computed for. This is slightly more performant than using the entity parameter.

None
entity RigidEntity | None

The entity to compute the observation for. Defaults to env.robot. This isn't necessary if entity_manager is provided.

None

Returns:

Type Description

torch.Tensor: The angular velocity of the entity's base link, in the entity's local frame.

entity = None class-attribute instance-attribute

entity_manager = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

entity_dofs_force(*, actuator_manager=None, entity=None, dofs_idx=None, clip_to_max_force=False) dataclass

Bases: MdpFn

The DOF's force being experienced.

Parameters:

Name Type Description Default
actuator_manager ActuatorManager | None

The actuator manager for the robot/entity. This bypasses the need for dofs_idx and entity parameters.

None
entity RigidEntity | None

The entity to read DOFs from. Defaults to env.robot. This isn't necessary if actuator_manager is provided.

None
dofs_idx list[int] | None

The indices of the DOFs to get the force of. This isn't necessary if actuator_manager is provided.

None
clip_to_max_force bool

Clip the force to the maximum force defined in the actuator_manager.

False

Returns:

Type Description

torch.Tensor: The force of the entity's DOFs.

actuator_manager = None class-attribute instance-attribute

clip_to_max_force = False class-attribute instance-attribute

dofs_idx = None class-attribute instance-attribute

entity = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

entity_dofs_position(*, actuator_manager=None, entity=None, dofs_idx=None) dataclass

Bases: MdpFn

The position of the entity's DOFs.

Parameters:

Name Type Description Default
actuator_manager ActuatorManager | None

The actuator manager for the robot/entity. This bypasses the need for dofs_idx and entity parameters.

None
entity RigidEntity | None

The entity to read DOFs from. Defaults to env.robot. This isn't necessary if actuator_manager is provided.

None
dofs_idx list[int] | None

The indices of the DOFs to get the position of. This isn't necessary if actuator_manager is provided.

None

Returns:

Type Description

torch.Tensor: The position of the entity's DOFs.

actuator_manager = None class-attribute instance-attribute

dofs_idx = None class-attribute instance-attribute

entity = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

entity_dofs_velocity(*, actuator_manager=None, entity=None, dofs_idx=None) dataclass

Bases: MdpFn

The velocity of the entity's DOFs.

Parameters:

Name Type Description Default
actuator_manager ActuatorManager | None

The actuator manager for the robot/entity. This bypasses the need for dofs_idx and entity parameters.

None
entity RigidEntity | None

The entity to read DOFs from. Defaults to env.robot. This isn't necessary if actuator_manager is provided.

None
dofs_idx list[int] | None

The indices of the DOFs to get the velocity of. This isn't necessary if actuator_manager is provided.

None

Returns:

Type Description

torch.Tensor: The velocity of the entity's DOFs.

actuator_manager = None class-attribute instance-attribute

dofs_idx = None class-attribute instance-attribute

entity = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

entity_linear_velocity(*, entity_manager=None, entity=None) dataclass

Bases: MdpFn

The linear velocity of the entity's base link, in the entity's local frame.

Parameters:

Name Type Description Default
entity_manager EntityManager | None

The entity manager for the robot/entity the observation is being computed for. This is slightly more performant than using the entity parameter.

None
entity RigidEntity | None

The entity to compute the observation for. Defaults to env.robot. This isn't necessary if entity_manager is provided.

None

Returns:

Type Description

torch.Tensor: The linear velocity of the entity's base link, in the entity's local frame.

entity = None class-attribute instance-attribute

entity_manager = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

entity_projected_gravity(*, entity_manager=None, entity=None) dataclass

Bases: MdpFn

The projected gravity of the entity's base link, in the entity's local frame.

Parameters:

Name Type Description Default
entity_manager EntityManager | None

The entity manager for the robot/entity the observation is being computed for. This is slightly more performant than using the entity parameter.

None
entity RigidEntity | None

The entity to compute the observation for. Defaults to env.robot. This isn't necessary if entity_manager is provided.

None

Returns:

Type Description

torch.Tensor: The projected gravity of the entity's base link, in the entity's local frame.

entity = None class-attribute instance-attribute

entity_manager = None class-attribute instance-attribute

env property

The environment this function is bound to.

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

has_contact(*, contact_manager, threshold=1.0) dataclass

Bases: MdpFn

Return 1 (true) or 0 (false) for each link in the contact manager that meets the contact threshold.

Parameters:

Name Type Description Default
contact_manager ContactManager

The contact manager to check for contact

required
threshold float

The minimum force necessary for contact detection (default: 1.0)

1.0

Returns:

Type Description

1 for each link meeting the contact threshold

contact_manager instance-attribute

env property

The environment this function is bound to.

threshold = 1.0 class-attribute instance-attribute

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

imu_projected_gravity(*, imu_sensor, correction_gain=0.02) dataclass

Bases: MdpFn

Estimates the projected gravity vector from an IMU sensor's accelerometer and gyroscope readings, using a complementary filter.

Each step, the previous estimate is propagated by the gyro reading (a first-order approximation of rotating the body-frame gravity vector opposite to the measured body rotation) and then pulled towards the accelerometer reading, negated and normalized -- under quasi-static conditions (no significant linear acceleration) an accelerometer measures specific force pointing opposite to gravity. The two are blended by correction_gain and re-normalized.

Because the estimate is derived entirely from the IMU's lin_acc/ang_vel readings, any noise, bias, delay or drift configured on the sensor carries through into the resulting value -- unlike entity_projected_gravity, which reads the entity's true orientation directly.

Parameters:

Name Type Description Default
imu_sensor IMUSensor

The IMU sensor to read from.

required
correction_gain float

How strongly the accelerometer corrects the gyro-propagated estimate each step, in (0, 1]. Higher values track the accelerometer more closely (less drift, but more sensitive to non-gravity acceleration); lower values rely more on the gyro propagation (smoother, but drifts without correction).

0.02

Example::

self.imu = self.scene.add_sensor(
    gs.sensors.IMU(
        entity_idx=self.robot.idx,
        pos_offset=(0.24, 0.0, 0.0),
        euler_offset=(0.0, 0.0, 0.0),
        acc_noise=(0.01, 0.01, 0.01),
        gyro_noise=(0.01, 0.01, 0.01),
        acc_random_walk=(0.001, 0.001, 0.001),
        gyro_random_walk=(0.001, 0.001, 0.001),
        delay=self.dt,
        jitter=self.dt,
    )
)

...

ObservationManager(
    self,
    cfg={
        "projected_gravity": {
            "fn": observations.imu_projected_gravity(
                imu_sensor=self.imu,
            ),
        },
    }
)

Returns:

Type Description

torch.Tensor: Shape (num_envs, 3) -- the estimated gravity direction, in the IMU's local frame.

correction_gain = 0.02 class-attribute instance-attribute

env property

The environment this function is bound to.

imu_sensor instance-attribute

build()

Source code in genesis_forge/mdp/observations.py
def build(self):
    self._estimate = torch.zeros(
        (self.env.num_envs, 3), device=gs.device, dtype=gs.tc_float
    )
    self._estimate[:, 2] = -1.0

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Source code in genesis_forge/mdp/observations.py
def reset(self, envs_idx):
    self._estimate[envs_idx] = 0.0
    self._estimate[envs_idx, 2] = -1.0

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

raycaster_distance(*, sensor, reduce='flatten', normalize=False, max_range=None) dataclass

Bases: MdpFn

Distance reading(s) from a raycaster-based sensor (gs.sensors.Raycaster, gs.sensors.Lidar, or gs.sensors.DepthCamera).

With reduce="flatten" (the default), returns every ray distance as a flat vector, keeping which direction each reading came from — what a lidar, depth camera, or any multi-ray pattern is for.

With reduce="min", returns only the smallest distance across all of the sensor's rays, which models a sensor that reports a single nearest echo, like an ultrasonic range finder.

min throws away direction

A single nearest distance says something is this far away without saying where it is. A policy given only that cannot tell an obstacle dead ahead from one just off to the side, so it cannot know which way to steer around it. Use min when the real sensor genuinely reports one number, and expect to give the policy some other way to work out direction -- an aimable sensor, more sensors, or a history of readings to infer it from.

Parameters:

Name Type Description Default
sensor RaycasterSensor

The raycaster sensor to read from, as returned by scene.add_sensor().

required
reduce Literal['min', 'flatten']

How to reduce the ray distances: "flatten" (default) for every reading as a flat vector, "min" for the nearest reading alone.

'flatten'
normalize bool

Divide the distances by the sensor's max range, scaling them to [0, 1].

False
max_range float | None

The range to normalize by. If not set, it is read from the sensor's options.

None

Example::

# In the environment's __init__ (sensors must be added before the scene is built):
self.ultrasonic = self.scene.add_sensor(
    gs.sensors.Raycaster(
        pattern=gs.sensors.SphericalPattern(fov=(15.0, 15.0), n_points=(5, 5)),
        entity_idx=self.robot.idx,
        link_idx_local=self.robot.get_link("head").idx_local,
        max_range=4.0,
        return_points=False,
    )
)

# In config():
ObservationManager(
    self,
    cfg={
        "ultrasonic": {
            "fn": observations.raycaster_distance(
                sensor=self.ultrasonic, reduce="min", normalize=True
            ),
        },
    },
)

Returns:

Type Description

torch.Tensor: Shape (num_envs, 1) for "min", or (num_envs, num_rays) for "flatten".

env property

The environment this function is bound to.

max_range = None class-attribute instance-attribute

normalize = False class-attribute instance-attribute

reduce = 'flatten' class-attribute instance-attribute

sensor instance-attribute

build()

Source code in genesis_forge/mdp/observations.py
def build(self):
    self._max_range = self.max_range
    if self._max_range is None:
        options = getattr(self.sensor, "_options", None)
        self._max_range = getattr(options, "max_range", None)
    if self.normalize and self._max_range is None:
        raise ValueError(
            "Could not determine the sensor's max range for normalization. "
            "Set the max_range parameter explicitly."
        )

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()

read_imu(*, imu) dataclass

Bases: MdpFn

Makes an IMU reading and returns the concatenated linear acceleration and angular velocity readings.

Parameters:

Name Type Description Default
imu IMUSensor

The IMU sensor to read from.

required

Example::

self.imu = gs.sensors.IMU(
    entity_idx=self.robot.idx,
    pos_offset=(0.24, 0.0, 0.0),
    euler_offset=(0.0, 0.0, 0.0),
)

...

ObservationManager(
    self,
    cfg={
        "imu_sensor": {
            "fn": observations.read_imu(imu=self.imu),
        },
    }
)

Returns:

Type Description

torch.Tensor: Shape (n_envs, 6) — [lin_acc_xyz, ang_vel_xyz] per env.

env property

The environment this function is bound to.

imu instance-attribute

build()

Build/rebuild any state or buffers necessary for the function call.

Called once by the manager during the environment build phase, and again after any param is changed. Must be idempotent -- it is safe to call any number of times, and re-deriving from scratch is the expected implementation.

Source code in genesis_forge/managers/config/mdp_fn.py
def build(self) -> None:
    """
    Build/rebuild any state or buffers necessary for the function call.

    Called once by the manager during the environment build phase, and again after
    any param is changed. Must be idempotent -- it is safe to call any number of
    times, and re-deriving from scratch is the expected implementation.
    """

context(env)

Store the environment this function is bound to.

Called by the manager during the environment build phase.

Override to store additional values -- see :meth:ResetMdpFn.context, which also stores entity.

Source code in genesis_forge/managers/config/mdp_fn.py
def context(self, env: GenesisEnv) -> None:
    """
    Store the environment this function is bound to.

    Called by the manager during the environment build phase.

    Override to store additional values -- see :meth:`ResetMdpFn.context`, which
    also stores ``entity``.
    """
    object.__setattr__(self, "_env", env)

reset(envs_idx)

Called every time one or more environments reset.

Parameters:

Name Type Description Default
envs_idx Tensor

The environment ids being reset.

required
Source code in genesis_forge/managers/config/mdp_fn.py
def reset(self, envs_idx: torch.Tensor) -> None:
    """
    Called every time one or more environments reset.

    Args:
        envs_idx: The environment ids being reset.
    """

safe_build()

Run :meth:build with re-entrancy guarded, so a build that assigns one of its own declared fields does not create an infinite build loop.

Source code in genesis_forge/managers/config/mdp_fn.py
def safe_build(self) -> None:
    """
    Run :meth:`build` with re-entrancy guarded, so a build that assigns one of its
    own declared fields does not create an infinite build loop.
    """
    object.__setattr__(self, "_building", True)
    try:
        self.build()
    finally:
        object.__setattr__(self, "_building", False)
    object.__setattr__(self, "_can_build", True)

update(**params)

Change several params at once, rebuilding only once.

Assigning params one at a time rebuilds once per assignment and exposes :meth:build to a partially updated param set. Use this when a curriculum changes more than one param together.

Parameters:

Name Type Description Default
**params Any

Declared param names and their new values.

{}

Raises:

Type Description
AttributeError

If a name is not a declared param.

Source code in genesis_forge/managers/config/mdp_fn.py
def update(self, **params: Any) -> None:
    """
    Change several params at once, rebuilding only once.

    Assigning params one at a time rebuilds once per assignment and exposes
    :meth:`build` to a partially updated param set. Use this when a curriculum
    changes more than one param together.

    Args:
        **params: Declared param names and their new values.

    Raises:
        AttributeError: If a name is not a declared param.
    """
    if not params:
        return

    # Check if we're trying to set unknown params
    unknown = sorted(set(params) - self._param_names())
    if unknown:
        raise AttributeError(f"{type(self).__name__} has no param(s) {unknown!r}. ")

    # Set the param values, bypassing the rebuild hook for each value, and then rebuild once at the end
    for name, value in params.items():
        object.__setattr__(self, name, value)

    if self._can_build:
        self.safe_build()