Terminations#
- genesis_forge.mdp.terminations.bad_orientation(env: GenesisEnv, limit_angle: float = 40.0, entity_attr: str = 'robot', entity_manager: EntityManager = None, grace_steps: int = 0) torch.Tensor[source]#
Terminate the environment if the robot is tipping over too much.
This function uses projected gravity to detect when the robot has tilted beyond a safe threshold. When the robot is perfectly upright, projected gravity should be [0, 0, -1] in the body frame. As the robot tilts, the x,y components increase, indicating roll and pitch angles.
- Parameters:
env – The Genesis environment containing the robot
limit_angle – Maximum allowed tilt angle in degrees (default: 40 degrees)
entity_manager – The entity manager for the entity.
entity_attr – The attribute name of the entity in the environment. This isn’t necessary if entity_manager is provided.
grace_steps – Number of steps at episode start to ignore tilt detection (default: 0) This gives the robot a chance to stabilize before tilt detection is active.
- Returns:
Boolean tensor indicating which environments should terminate
- Return type:
- genesis_forge.mdp.terminations.base_height_below_minimum(env: GenesisEnv, minimum_height: float = 0.05, entity_attr: str = 'robot', entity_manager: EntityManager = None) torch.Tensor[source]#
Terminate the environment if the robot’s base height falls below a minimum threshold.
- Parameters:
env – The Genesis environment containing the robot
minimum_height – Minimum allowed base height in meters
entity_manager – The entity manager for the entity.
entity_attr – The attribute name of the entity in the environment. This isn’t necessary if entity_manager is provided.
- Returns:
Boolean tensor indicating which environments should terminate
- Return type:
- genesis_forge.mdp.terminations.contact_force(_env: GenesisEnv, contact_manager: ContactManager, threshold: float = 1.0) torch.Tensor[source]#
Terminate if any link in the contact manager is in contact with something with a force greater than the threshold.
- Parameters:
env – The Genesis environment containing the robot
contact_manager – The contact manager to check for contact
threshold – The force threshold for contact detection (default: 1.0 N)
- Returns:
The total force for the contact manager for each environment
- genesis_forge.mdp.terminations.contact_force_with_grace_period(env: GenesisEnv, contact_manager: ContactManager, threshold: float = 100.0, grace_steps: int = 10) torch.Tensor[source]#
Terminate if contact force exceeds threshold, with a grace period at episode start.
This is useful for quadrupeds that may start in slightly unstable positions and need a few steps to stabilize before fall detection becomes active.
- Parameters:
env – The Genesis environment containing the robot
contact_manager – The contact manager to check for contact
threshold – The force threshold for contact detection (default: 100.0 N)
grace_steps – Number of steps at episode start to ignore contacts (default: 10)
- Returns:
Boolean tensor indicating which environments should terminate
- genesis_forge.mdp.terminations.dof_control_force_limit(_env: GenesisEnv, actuator_manager: ActuatorManager, threshold: float | None = None) torch.Tensor[source]#
Terminate if any joint’s commanded actuator force exceeds a limit (+/-).
Uses control/output force (what the actuator commands), not measured joint load. Suitable for teaching policies to stay within rated motor torque.
- Parameters:
env – The Genesis environment
actuator_manager – Actuator manager for the controlled joints
threshold – Force/torque limit (in simulator units). If None, uses max_force value from actuator_manager.
- Returns:
Boolean tensor indicating which environments should terminate
- genesis_forge.mdp.terminations.dof_velocity_limit(_env: GenesisEnv, actuator_manager: ActuatorManager, threshold: float, unit: Literal['rpm', 'rad'] = 'rad') torch.Tensor[source]#
Terminate if any of the actuator_manager’s joints moves faster than a speed limit.
- Parameters:
env – The Genesis environment
actuator_manager – Actuator manager for the controlled joints
threshold – Speed limit in the units given by unit
unit – The speed units - “rad” for radians per second (default) - “rpm” for revolutions per minute
- Returns:
Boolean tensor indicating which environments should terminate
- genesis_forge.mdp.terminations.has_contact(_env: GenesisEnv, contact_manager: ContactManager, threshold=1.0, min_contacts=1) torch.Tensor[source]#
One or more links in the contact manager are in contact with something.
- Parameters:
env – The Genesis environment containing the robot
contact_manager – The contact manager to check for contact
threshold – The force threshold, per contact, for contact detection (default: 1.0)
min_contacts – The minimum number of contacts required to terminate (default: 1)
- Returns:
True for each environment that has contact
- genesis_forge.mdp.terminations.is_upsidedown(env: GenesisEnv, threshold: float = 0.5, entity_attr: str = 'robot', entity_manager: EntityManager = None, grace_steps: int = 0) torch.Tensor[source]#
Terminate when the robot is belly-up (inverted).
Uses projected gravity in the body frame: upright is approximately [0, 0, -1], belly-up is approximately [0, 0, +1]. Side-lying poses keep z below threshold.
- Parameters:
env – The Genesis environment
threshold – Terminate when projected_gravity[:, 2] exceeds this value
entity_manager – The entity manager for the robot
entity_attr – Entity attribute if entity_manager is not provided
grace_steps – Steps at episode start to ignore this check
- genesis_forge.mdp.terminations.out_of_bounds(env: GenesisEnv, terrain_manager: TerrainManager, subterrain: str | None = None, border_margin: float = 0.5, entity_attr: str = 'robot') torch.Tensor[source]#
Terminate if the entity’s base position is outside of the terrain.
- Parameters:
env – The Genesis environment containing the robot
terrain_manager – The terrain manager to check for out of bounds
subterrain – The subterrain to keep the robot inside of
border_margin – The margin (in meters) to add to the terrain bounds This terminates the episode before the robot falls off the terrain.
entity_attr – The attribute name of the entity in the environment. This isn’t necessary if entity_manager is provided.
- genesis_forge.mdp.terminations.timeout(env: GenesisEnv) torch.Tensor[source]#
Terminate the environment if the episode length exceeds the maximum episode length.