Resets#

These are simple helper functions that can be used in the EntityManager on_reset configuration.

class genesis_forge.mdp.reset.position(env: GenesisEnv, entity: RigidEntity, position: tuple[float, float, float], quat: tuple[float, float, float, float] | None = None, zero_velocity: bool = True)[source]#

Bases: ResetMdpFnClass

Reset the entity to a fixed position and (optional) rotation

Parameters:
  • env – The environment

  • entity – The entity to set the position of.

  • position – The position to set the entity to.

  • quat – The quaternion to set the entity to.

  • zero_velocity – Whether to zero the velocity of all the entity’s dofs. Defaults to True. This is a safety measure after a sudden change in entity pose.

build()#

Called during the environment build phase and when MDP params are changed.

Bases: ResetMdpFnClass

Randomly add/subtract mass to one or more links of the entity. This picks a random value from mass_range and passes it to set_mass_shift for each environment.

See: https://genesis-world.readthedocs.io/en/latest/api_reference/entity/rigid_entity/rigid_entity.html#genesis.engine.entities.rigid_entity.rigid_entity.RigidEntity.set_mass_shift

Parameters:
  • env – The environment

  • entity – The entity to set the rotation of.

  • link_name – The name, or regex pattern, of the link(s) to set the mass for.

  • mass_range – The range of the mass that will be added or subtracted from the link(s) on each reset.

Called during the environment build phase and when MDP params are changed.

class genesis_forge.mdp.reset.randomize_terrain_position(env: GenesisEnv, entity: RigidEntity, terrain_manager: TerrainManager, height_offset: float = 0.0001, subterrain: str | Callable[[], str] | None = None, rotation: XYZRotation | None = {'z': (0, 6.283185307179586)}, zero_velocity: bool = True)[source]#

Bases: ResetMdpFnClass

Place the entity in a random position on the terrain for each environment.

Parameters:
  • env – The environment

  • entity – The entity to set the position of.

  • envs_idx – The environment ids to set the position for.

  • terrain_manager – The terrain manager to use to generate the random position.

  • height_offset – The height offset to add to the random position.

  • subterrain – The subterrain to generate the random position on. Either a string or a callable that returns a string.

  • rotation – The X/Y/Z rotation to set the entity to. Defaults to a random rotation around the z-axis. Set to None to not set a rotation.

  • zero_velocity – Whether to zero the velocity of all the entity’s dofs. Defaults to True. This is a safety measure after a sudden change in entity pose.

build()[source]#

Initialize the buffers

define_quat(envs_idx: list[int], rotation: dict[Literal['x', 'y', 'z'], float | tuple[float, float]])[source]#

Set the rotation quaternion for the given environment ids.

genesis_forge.mdp.reset.set_rotation(env: GenesisEnv, entity: RigidEntity, envs_idx: list[int], x: float | tuple[float, float] = 0, y: float | tuple[float, float] = 0, z: float | tuple[float, float] = 0)[source]#

Set the entity’s rotation in either absolute or randomized euler angles. If the x/y/z value is a tuple (for example: (0, 2 * math.pi)), the rotation will be randomized within that radian range.

Parameters:
  • env – The environment

  • entity – The entity to set the rotation of.

  • envs_idx – The environment ids to set the rotation for.

  • x – The x angle or range to set the rotation to.

  • y – The y angle or range to set the rotation to.

  • z – The z angle or range to set the rotation to.

genesis_forge.mdp.reset.zero_all_dofs_velocity(env: GenesisEnv, entity: RigidEntity, envs_idx: list[int])[source]#

Zero the velocity of all dofs of the entity.

genesis_forge.mdp.reset.XYZRotation#

Define the rotation around the X/Y/Z axes. The value can either be a distinct value, or a tuple of (min, max) values to randomize within.

alias of dict[Literal[‘x’, ‘y’, ‘z’], float | tuple[float, float]]