unilab.tasks.locomotion.g1.manager_terms

Task-owned Manager-Based terms for G1 biped locomotion.

The reward/observation equations and tuned constants are ported from UniLab’s pre-Manager-Based G1Walk joystick task family (ported in 64c7f8b8, roadmap #1042). The adaptation uses community func + params terms, Torch state carriers, and cached cold-path sensor bindings; hot paths never parse assets or probe backend privates.

Functions

compute_feet_phase_contact_targets(...)

Expected per-foot contact flags derived from the Bézier height targets.

compute_feet_phase_height_targets(...)

Cubic-Bézier per-foot height targets, from the G1Walk task family (64c7f8b8).

make_g1_walk_env(cfg[, num_envs, backend_type])

Construct the Registry-owned G1 Manager-Based production runtime.

Classes

G1GaitPhase

Two-foot gait phase observation in radians, with per-reset phase sampling.

G1PenaltyCurriculum

Scale negative-weight reward terms by average episode length.

G1VelocityCommand

G1VelocityCommandCfg

G1 velocity command with the G1Walk-family planar-norm dead zone.

G1WalkManagerBasedEnv

Manager-Based G1 walk runtime.

G1WalkResetOwner

Own the tensor G1 command reset and skip redundant host validations.

G1WalkResetOwnerCfg

Fuse the selected-reset lifecycle for the canonical G1 walk command.

G1WalkRewardPack

Evaluate the canonical walk reward family in one tensor carrier read.

G1WalkRewardPackCfg

Fused canonical G1 walk reward family for tensor-resident owners.

G1WalkTerminationPack

Evaluate the canonical G1 walk failure terms in one carrier read.

G1WalkTerminationPackCfg

Fused canonical G1 walk timeout, tilt, and height termination.

feet_air_time

Count feet whose current air time sits inside the rewarded window.

feet_double_stance

Penalize double-stance contact while a forward command is active.

feet_phase

Reward gait phase tracking by encouraging the expected swing-foot height.

feet_phase_contact

Reward foot contact matching the expected stance phase of the gait.

feet_phase_contrast

Reward left/right foot-height contrast against the gait-phase targets.

forward_progress

Reward forward progress relative to commanded speed.

g1_base_height_below_minimum

Terminate when root height drops below the task threshold.

g1_tilt_exceeded

Terminate when the base tilt from upright exceeds max_tilt_deg.

penalty_close_feet_xy

Penalty for feet closer than threshold in the horizontal plane.

penalty_feet_ori

Penalty for non-flat foot orientations (roll/pitch quaternion rows).

under_speed

Penalty for being below commanded forward speed.

upper_body_pose

Weighted L2 pose penalty with the twelve leg joints zeroed out.

weighted_pose

Weighted L2 penalty for joint position deviation from the default pose.

class unilab.tasks.locomotion.g1.manager_terms.G1GaitPhase[source]

Bases: ManagerTermBase

Two-foot gait phase observation in radians, with per-reset phase sampling.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

__init__(cfg, env)[source]
Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

reset(env_ids)[source]
Parameters:

env_ids (Tensor)

Return type:

None

class unilab.tasks.locomotion.g1.manager_terms.G1PenaltyCurriculum[source]

Bases: ManagerTermBase

Scale negative-weight reward terms by average episode length.

Ports the G1Walk task-family penalty curriculum (64c7f8b8, roadmap #1042): penalty weights start at initial_scale of their configured value and relax toward max_scale as the tracked average episode length crosses the configured thresholds.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

__init__(cfg, env)[source]
Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

reset(env_ids)[source]

Row boundary for the global curriculum state.

Parameters:

env_ids (Tensor)

Return type:

None

reset_scoped(env, env_ids, **params)[source]

Selected-row curriculum update at reset.

Parameters:
Return type:

dict[str, float]

class unilab.tasks.locomotion.g1.manager_terms.G1VelocityCommand[source]

Bases: UniformVelocityCommand

Parameters:
cfg: G1VelocityCommandCfg
__init__(cfg, env)[source]
Parameters:
class unilab.tasks.locomotion.g1.manager_terms.G1VelocityCommandCfg[source]

Bases: UniformVelocityCommandCfg

G1 velocity command with the G1Walk-family planar-norm dead zone.

Parameters:
  • resampling_time_range (tuple[float, float])

  • debug_vis (bool)

  • entity_name (str)

  • heading_command (bool)

  • heading_control_stiffness (float)

  • rel_standing_envs (float)

  • rel_heading_envs (float)

  • rel_world_envs (float)

  • rel_forward_envs (float)

  • init_velocity_prob (float)

  • ranges (Ranges)

  • viz (VizCfg)

  • planar_dead_zone (float)

planar_dead_zone: float = 0.2
build(env)[source]

Build the command term from this config.

Parameters:

env (ManagerBasedRlEnv)

Return type:

G1VelocityCommand

__init__(*, resampling_time_range, debug_vis=False, entity_name, heading_command=False, heading_control_stiffness=1.0, rel_standing_envs=0.0, rel_heading_envs=1.0, rel_world_envs=0.0, rel_forward_envs=0.0, init_velocity_prob=0.0, ranges, viz=<factory>, planar_dead_zone=0.2)
Parameters:
  • resampling_time_range (tuple[float, float])

  • debug_vis (bool)

  • entity_name (str)

  • heading_command (bool)

  • heading_control_stiffness (float)

  • rel_standing_envs (float)

  • rel_heading_envs (float)

  • rel_world_envs (float)

  • rel_forward_envs (float)

  • init_velocity_prob (float)

  • ranges (Ranges)

  • viz (VizCfg)

  • planar_dead_zone (float)

class unilab.tasks.locomotion.g1.manager_terms.G1WalkResetOwner[source]

Bases: ResetOwner

Own the tensor G1 command reset and skip redundant host validations.

The walk command is sampled from bounded Torch uniforms and the G1 dead-zone write is bounded by construction. Re-running the generic full-command finite synchronization after that device-resident transaction only adds a device synchronization on the reset hot path.

Parameters:
__init__(cfg, env)[source]
Parameters:
reset_transaction(env_ids)[source]

Execute reset ownership for the selected envs before commit.

Parameters:

env_ids (Tensor)

Return type:

dict[str, float]

reset_committed(env_ids)[source]

Execute reset ownership for the selected envs after commit.

Parameters:

env_ids (Tensor)

Return type:

dict[str, float]

class unilab.tasks.locomotion.g1.manager_terms.G1WalkResetOwnerCfg[source]

Bases: ResetOwnerCfg

Fuse the selected-reset lifecycle for the canonical G1 walk command.

Parameters:
  • func (Any)

  • params (dict[str, Any])

  • command_name (str)

  • owns_command_reset (bool)

  • owns_action_reset (bool)

  • owns_observation_reset (bool)

  • owns_metric_reset (bool)

command_name: str = 'twist'
owns_observation_reset: bool = False

If True, the owner replaces ObservationManager.reset for the selected rows. The bypass does not cover manager-owned temporal state: delay/history buffers are not cleared, so reset rows keep their previous episode’s delay lag, step counter, and phase schedule (nothing is resampled), and the observation cache is not invalidated — a compute(update_history=False) caller between the reset and the next step reads pre-reset values. Owners enabling this bypass must reset that temporal state themselves (see the publicly exported CircularBuffer/DelayBuffer).

__init__(func, params=<factory>, *, command_name='twist', owns_command_reset=True, owns_action_reset=True, owns_observation_reset=False, owns_metric_reset=True)
Parameters:
  • func (Any)

  • params (dict[str, Any])

  • command_name (str)

  • owns_command_reset (bool)

  • owns_action_reset (bool)

  • owns_observation_reset (bool)

  • owns_metric_reset (bool)

class unilab.tasks.locomotion.g1.manager_terms.G1WalkManagerBasedEnv[source]

Bases: ManagerBasedRlEnv

Manager-Based G1 walk runtime.

Parameters:
class unilab.tasks.locomotion.g1.manager_terms.G1WalkRewardPack[source]

Bases: ManagerTermBase

Evaluate the canonical walk reward family in one tensor carrier read.

This pack fuses the G1 owner’s state-only per-step rewards: linear/angular tracking, angular-xy and orientation penalties, action rate, weighted pose, foot-orientation penalty, and phase tracking. Equations, weights, and declaration order remain owned by RewardManager; this owner only removes duplicate carrier reads and intermediate per-term kernel launches.

Parameters:
returns_transient_tensor = True
last_step_timing_ms: dict[str, float] = {}
__init__(cfg, env)[source]
Parameters:
property tensor_sensor_names: tuple[str, ...]
class unilab.tasks.locomotion.g1.manager_terms.G1WalkTerminationPack[source]

Bases: ManagerTermBase

Evaluate the canonical G1 walk failure terms in one carrier read.

Parameters:
returns_transient_tensor = True
__init__(cfg, env)[source]
Parameters:
property tensor_sensor_names: tuple[str, ...]
property tensor_body_names: tuple[str, ...]
property entity_name: str
reset(env_ids)[source]

Row boundary for the stateless termination pack.

Parameters:

env_ids (Tensor)

Return type:

None

class unilab.tasks.locomotion.g1.manager_terms.G1WalkTerminationPackCfg[source]

Bases: TerminationTermCfg

Fused canonical G1 walk timeout, tilt, and height termination.

Parameters:
entity_name: str = 'robot'
root_body_name: str = 'pelvis'
max_tilt_deg: float = 65.0
minimum_height: float = 0.3
__init__(func, params=<factory>, time_out=False, *, entity_name='robot', root_body_name='pelvis', max_tilt_deg=65.0, minimum_height=0.3)
Parameters:
class unilab.tasks.locomotion.g1.manager_terms.G1WalkRewardPackCfg[source]

Bases: RewardTermCfg

Fused canonical G1 walk reward family for tensor-resident owners.

Parameters:
command_name: str = 'twist'
entity_name: str = 'robot'
tracking_lin_sigma: float = 0.25
tracking_ang_sigma: float = 0.25
gait_frequency: float = 1.5
gait_init_mode: str = 'offset_phase'
swing_height: float = 0.09
feet_phase_sigma: float = 0.04
min_forward_speed: float = 0.0
pose_weights: tuple[float, ...] = (1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0)
__init__(params=<factory>, *, func, weight, reward_pack_names=(), command_name='twist', entity_name='robot', tracking_lin_sigma=0.25, tracking_ang_sigma=0.25, gait_frequency=1.5, gait_init_mode='offset_phase', swing_height=0.09, feet_phase_sigma=0.04, min_forward_speed=0.0, pose_weights=(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0))
Parameters:
unilab.tasks.locomotion.g1.manager_terms.compute_feet_phase_contact_targets(gait_phase, swing_height)[source]

Expected per-foot contact flags derived from the Bézier height targets.

Parameters:
Return type:

tuple[Tensor, Tensor]

unilab.tasks.locomotion.g1.manager_terms.compute_feet_phase_height_targets(gait_phase, swing_height)[source]

Cubic-Bézier per-foot height targets, from the G1Walk task family (64c7f8b8).

Parameters:
Return type:

tuple[Tensor, Tensor]

class unilab.tasks.locomotion.g1.manager_terms.feet_air_time[source]

Bases: _FootContactTerm

Count feet whose current air time sits inside the rewarded window.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

__init__(cfg, env)[source]
Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

reset(env_ids)[source]

Row boundary for stateless sensor terms.

Parameters:

env_ids (Tensor)

Return type:

None

class unilab.tasks.locomotion.g1.manager_terms.feet_double_stance[source]

Bases: _FootContactTerm

Penalize double-stance contact while a forward command is active.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

class unilab.tasks.locomotion.g1.manager_terms.feet_phase[source]

Bases: _GaitRewardTerm

Reward gait phase tracking by encouraging the expected swing-foot height.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

class unilab.tasks.locomotion.g1.manager_terms.feet_phase_contact[source]

Bases: _FootContactTerm

Reward foot contact matching the expected stance phase of the gait.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

class unilab.tasks.locomotion.g1.manager_terms.feet_phase_contrast[source]

Bases: _GaitRewardTerm

Reward left/right foot-height contrast against the gait-phase targets.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (_G1Env)

class unilab.tasks.locomotion.g1.manager_terms.forward_progress[source]

Bases: _LinVelTerm

Reward forward progress relative to commanded speed.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

class unilab.tasks.locomotion.g1.manager_terms.g1_tilt_exceeded[source]

Bases: _UpvectorTerm

Terminate when the base tilt from upright exceeds max_tilt_deg.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

__init__(cfg, env)[source]
Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

unilab.tasks.locomotion.g1.manager_terms.make_g1_walk_env(cfg, num_envs=1, backend_type='mujoco')[source]

Construct the Registry-owned G1 Manager-Based production runtime.

Parameters:
Return type:

G1WalkManagerBasedEnv

class unilab.tasks.locomotion.g1.manager_terms.penalty_close_feet_xy[source]

Bases: _SensorTerm

Penalty for feet closer than threshold in the horizontal plane.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

__init__(cfg, env)[source]
Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

property tensor_sensor_names: tuple[str, ...]
class unilab.tasks.locomotion.g1.manager_terms.penalty_feet_ori[source]

Bases: _SensorTerm

Penalty for non-flat foot orientations (roll/pitch quaternion rows).

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

__init__(cfg, env)[source]
Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

property tensor_sensor_names: tuple[str, ...]
class unilab.tasks.locomotion.g1.manager_terms.under_speed[source]

Bases: _LinVelTerm

Penalty for being below commanded forward speed.

Parameters:
  • cfg (ManagerTermBaseCfg)

  • env (ManagerBasedRlEnv)

class unilab.tasks.locomotion.g1.manager_terms.upper_body_pose[source]

Bases: weighted_pose

Weighted L2 pose penalty with the twelve leg joints zeroed out.

Parameters:
  • cfg (RewardTermCfg)

  • env (ManagerBasedRlEnv)

__init__(cfg, env)[source]
Parameters:
  • cfg (RewardTermCfg)

  • env (ManagerBasedRlEnv)

class unilab.tasks.locomotion.g1.manager_terms.weighted_pose[source]

Bases: ManagerTermBase

Weighted L2 penalty for joint position deviation from the default pose.

Parameters:
  • cfg (RewardTermCfg)

  • env (ManagerBasedRlEnv)

__init__(cfg, env)[source]
Parameters:
  • cfg (RewardTermCfg)

  • env (ManagerBasedRlEnv)

property tensor_state_entity: str
reset(env_ids)[source]
Parameters:

env_ids (Tensor)

Return type:

None