Terminations#
Termination terms define when an episode ends. Each term is a function that returns a boolean per-environment tensor every step. The termination manager aggregates all terms and reports the result to the training framework as either a terminal failure or a truncation.
Each term is registered by name with a TerminationTermCfg. Setting
time_out=True marks the condition as a truncation rather than a
terminal failure. Truncations map to the truncated signal in the
Gym interface; failures map to terminated. This distinction matters
for value bootstrapping: the agent should estimate future value beyond
a truncation but not beyond a failure.
from mjlab.envs.mdp import terminations
from mjlab.managers.termination_manager import TerminationTermCfg
terminations_cfg = {
"time_out": TerminationTermCfg(
func=terminations.time_out, time_out=True,
),
"fallen": TerminationTermCfg(
func=terminations.bad_orientation,
params={"limit_angle": 1.0},
),
}
Built-in termination functions#
The functions below are available in mjlab.envs.mdp.terminations and
are shared across tasks. Individual tasks may define additional
termination functions specific to their objective. All termination
functions return a boolean tensor of shape [num_envs].
Function |
Description |
|---|---|
|
Returns |
|
Returns |
|
Returns |
|
Returns |
Writing custom termination functions#
Custom termination functions follow the same patterns as reward
functions. A plain function accepts env and returns a boolean
[num_envs] tensor. See Term configuration pattern for the
general pattern.