unilab.tasks.locomotion.common.gait_terms¶
mjlab-aligned gait-quality terms shared by locomotion families.
These are the window-form feet_air_time and the clearance / swing-height /
slip / angular-momentum reward terms that mjlab ships in its velocity task,
plus the privileged per-foot observation terms (foot_height /
foot_air_time / foot_contact / foot_contact_forces) its velocity
critic consumes. mjlab reads feet through a ContactSensor (primaries with
per-slot any-reduce) and a TerrainHeightSensor; the UniLab port binds one
named contact sensor group per foot through the SensorTermBase cold-path
contract (any sensor in the group above the threshold means foot contact,
mirroring the slot reduce) and reads foot heights/velocities from
body_link_pos_w / body_link_lin_vel_w through asset_cfg.body_ids,
which is exact on flat terrain without raycast.
Functions
|
Penalize clearance-height deviation weighted by planar foot velocity. |
|
Per-foot vertical clearance above the terrain, shape |
Classes
Penalize whole-body angular momentum read from a named vec3 sensor. |
|
Count feet whose current air time sits inside the rewarded window. |
|
Penalize foot sliding: squared xy velocity while the foot is in contact. |
|
Penalize peak-swing-height deviation from the target, evaluated at landing. |
|
Current per-foot air time in seconds, shape |
|
Per-foot contact flag as float, shape |
|
Log-compressed per-foot contact forces, shape |
|
Count monitored self-collision geom pairs reporting contact. |
- class unilab.tasks.locomotion.common.gait_terms.angular_momentum_penalty[source]¶
Bases:
SensorTermBasePenalize whole-body angular momentum read from a named vec3 sensor.
- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- class unilab.tasks.locomotion.common.gait_terms.feet_air_time[source]¶
Bases:
_FootContactTermCount feet whose current air time sits inside the rewarded window.
Mirrors mjlab
feet_air_time: air time accumulatesenv.step_dtwhile the foot has no contact and resets to zero on contact; a foot scores whilethreshold_min < air_time < threshold_max. Whencommand_nameis set the count is gated by the command gate.- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- unilab.tasks.locomotion.common.gait_terms.feet_clearance(env, target_height, command_name=None, command_threshold=0.01, asset_cfg=SceneEntityCfg(name='robot', joint_names=None, joint_ids=slice(None, None, None), body_names=None, body_ids=slice(None, None, None), geom_names=None, geom_ids=slice(None, None, None), site_names=None, site_ids=slice(None, None, None), actuator_names=None, actuator_ids=slice(None, None, None), tendon_names=None, tendon_ids=slice(None, None, None), camera_names=None, camera_ids=slice(None, None, None), light_names=None, light_ids=slice(None, None, None), material_names=None, material_ids=slice(None, None, None), texture_names=None, texture_ids=slice(None, None, None), pair_names=None, pair_ids=slice(None, None, None), preserve_order=False))[source]¶
Penalize clearance-height deviation weighted by planar foot velocity.
Mirrors mjlab
feet_clearancewith foot heights taken from world-frame foot body z (exact on flat terrain) instead of a terrain height sensor.
- class unilab.tasks.locomotion.common.gait_terms.feet_slip[source]¶
Bases:
_FootContactTermPenalize foot sliding: squared xy velocity while the foot is in contact.
- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- class unilab.tasks.locomotion.common.gait_terms.feet_swing_height[source]¶
Bases:
_FootContactTermPenalize peak-swing-height deviation from the target, evaluated at landing.
Mirrors mjlab
feet_swing_height: the peak foot height accumulates while the foot is in the air; on first contact the squared relative error(peak / target_height - 1)^2is charged and the peak resets.- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- class unilab.tasks.locomotion.common.gait_terms.foot_air_time[source]¶
Bases:
_FootContactTermCurrent per-foot air time in seconds, shape
(num_envs, num_feet).Mirrors mjlab
foot_air_time(ContactSensor.data.current_air_time): the timer accumulatesenv.step_dtwhile the foot has no contact and resets to zero on contact.- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- class unilab.tasks.locomotion.common.gait_terms.foot_contact[source]¶
Bases:
_FootContactTermPer-foot contact flag as float, shape
(num_envs, num_feet).Mirrors mjlab
foot_contact(ContactSensor.data.found > 0).- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- class unilab.tasks.locomotion.common.gait_terms.foot_contact_forces[source]¶
Bases:
_FootContactTermLog-compressed per-foot contact forces, shape
(num_envs, 3 * num_feet).Mirrors mjlab
foot_contact_forces: the per-foot 3-D contact forces are flattened in sensor-group order and compressed assign(f) * log1p(|f|).- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)
- unilab.tasks.locomotion.common.gait_terms.foot_height(env, asset_cfg=SceneEntityCfg(name='robot', joint_names=None, joint_ids=slice(None, None, None), body_names=None, body_ids=slice(None, None, None), geom_names=None, geom_ids=slice(None, None, None), site_names=None, site_ids=slice(None, None, None), actuator_names=None, actuator_ids=slice(None, None, None), tendon_names=None, tendon_ids=slice(None, None, None), camera_names=None, camera_ids=slice(None, None, None), light_names=None, light_ids=slice(None, None, None), material_names=None, material_ids=slice(None, None, None), texture_names=None, texture_ids=slice(None, None, None), pair_names=None, pair_ids=slice(None, None, None), preserve_order=False))[source]¶
Per-foot vertical clearance above the terrain, shape
(num_envs, num_feet).mjlab reads this from a
TerrainHeightSensorring around each foot; the UniLab port returns the world-frame foot body z, which is identical on flat terrain.- Parameters:
env (
ManagerBasedRlEnv)asset_cfg (
SceneEntityCfg)
- Return type:
- class unilab.tasks.locomotion.common.gait_terms.self_collision_cost[source]¶
Bases:
_FootContactTermCount monitored self-collision geom pairs reporting contact.
Mirrors mjlab
self_collision_costin its found-count form: each sensor group binds one contact sensor watching a geom pair, and the cost is the number of pairs with an active contact. mjlab’sforce_thresholdonly applies when the sensor records force history, which the upstream config does not enable, so it is not ported.- Parameters:
cfg (
ManagerTermBaseCfg)env (
ManagerBasedRlEnv)