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: genesis.engine.entities.RigidEntity, position: tuple[float, float, float], quat: tuple[float, float, float, float] | None = None, zero_velocity: bool = True)[source]#
Bases:
ResetMdpFnClassReset 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.
- class genesis_forge.mdp.reset.randomize_link_mass_shift(_env: GenesisEnv, entity: genesis.engine.entities.RigidEntity, link_name: str, add_mass_range: tuple[float, float] = (-0.2, 0.2))[source]#
Bases:
ResetMdpFnClassRandomly add/subtract mass to one or more links of the entity. This picks a random value from add_mass_range and passes it to set_mass_shift for each environment. This means that on subsequent calls, the mass can continue to either decrease or increase.
- 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 inertial mass for.
add_mass_range – The range of the mass that can be added or subtracted each reset.
- class genesis_forge.mdp.reset.randomize_terrain_position(env: GenesisEnv, entity: genesis.engine.entities.RigidEntity, terrain_manager: TerrainManager, height_offset: float = 0.0001, subterrain: str | Callable[[], str] | None = None, rotation: dict[Literal['x', 'y', 'z'], float | tuple[float, float]] | None = {'z': (0, 6.283185307179586)}, zero_velocity: bool = True)[source]#
Bases:
ResetMdpFnClassPlace 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.
- genesis_forge.mdp.reset.set_rotation(env: GenesisEnv, entity: genesis.engine.entities.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: genesis.engine.entities.RigidEntity, envs_idx: list[int])[source]#
Zero the velocity of all dofs of the entity.