unilab.envs.locomotion.common

class unilab.envs.locomotion.common.BaseNoiseConfig[source]

Bases: object

BaseNoiseConfig(level: ‘float’ = 0.0, scale_joint_angle: ‘float’ = 0.03, scale_joint_vel: ‘float’ = 0.5, scale_gyro: ‘float’ = 0.2, scale_gravity: ‘float’ = 0.05, scale_linvel: ‘float’ = 0.1)

Parameters:
level: float = 0.0
scale_joint_angle: float = 0.03
scale_joint_vel: float = 0.5
scale_gyro: float = 0.2
scale_gravity: float = 0.05
scale_linvel: float = 0.1
__init__(level=0.0, scale_joint_angle=0.03, scale_joint_vel=0.5, scale_gyro=0.2, scale_gravity=0.05, scale_linvel=0.1)
Parameters:
class unilab.envs.locomotion.common.Commands[source]

Bases: object

Commands(vel_limit: ‘list[list[float]]’ = <factory>, resampling_time: ‘float’ = 0.0, heading_command: ‘bool’ = False, heading_range: ‘list[float]’ = <factory>, heading_control_stiffness: ‘float’ = 0.5, rel_standing_envs: ‘float’ = 0.0)

Parameters:
vel_limit: list[list[float]]
resampling_time: float = 0.0
heading_command: bool = False
heading_range: list[float]
heading_control_stiffness: float = 0.5
rel_standing_envs: float = 0.0
__init__(vel_limit=<factory>, resampling_time=0.0, heading_command=False, heading_range=<factory>, heading_control_stiffness=0.5, rel_standing_envs=0.0)
Parameters:
class unilab.envs.locomotion.common.ControlConfigBase[source]

Bases: object

ControlConfigBase(action_scale: ‘float’ = 0.25, simulate_action_latency: ‘bool’ = False)

Parameters:
  • action_scale (float)

  • simulate_action_latency (bool)

action_scale: float = 0.25
simulate_action_latency: bool = False
__init__(action_scale=0.25, simulate_action_latency=False)
Parameters:
  • action_scale (float)

  • simulate_action_latency (bool)

class unilab.envs.locomotion.common.DomainRandConfig[source]

Bases: object

DomainRandConfig(randomize_base_mass: ‘bool’ = False, added_mass_range: ‘list[float]’ = <factory>, randomize_body_mass: ‘bool’ = False, body_mass_multiplier_range: ‘list[float]’ = <factory>, random_com: ‘bool’ = False, com_offset_x: ‘list[float]’ = <factory>, randomize_gravity: ‘bool’ = False, gravity_range: ‘list[list[float]]’ = <factory>, randomize_ground_friction: ‘bool’ = False, ground_friction_multiplier_range: ‘list[float]’ = <factory>, randomize_dof_armature: ‘bool’ = False, dof_armature_multiplier_range: ‘list[float]’ = <factory>, push_robots: ‘bool’ = False, push_interval: ‘int’ = 750, max_force: ‘list[float]’ = <factory>, push_body_name: ‘str | None’ = None)

Parameters:
randomize_base_mass: bool = False
added_mass_range: list[float]
randomize_body_mass: bool = False
body_mass_multiplier_range: list[float]
random_com: bool = False
com_offset_x: list[float]
randomize_gravity: bool = False
gravity_range: list[list[float]]
randomize_ground_friction: bool = False
ground_friction_multiplier_range: list[float]
randomize_dof_armature: bool = False
dof_armature_multiplier_range: list[float]
push_robots: bool = False
push_interval: int = 750
max_force: list[float]
push_body_name: str | None = None
__init__(randomize_base_mass=False, added_mass_range=<factory>, randomize_body_mass=False, body_mass_multiplier_range=<factory>, random_com=False, com_offset_x=<factory>, randomize_gravity=False, gravity_range=<factory>, randomize_ground_friction=False, ground_friction_multiplier_range=<factory>, randomize_dof_armature=False, dof_armature_multiplier_range=<factory>, push_robots=False, push_interval=750, max_force=<factory>, push_body_name=None)
Parameters:
class unilab.envs.locomotion.common.HeightScanConfig[source]

Bases: object

HeightScanConfig(enabled: ‘bool’ = True, hfield_name: ‘str’ = ‘terrain_hfield’, geom_name: ‘str’ = ‘floor’, measured_points_x: ‘list[float]’ = <factory>, measured_points_y: ‘list[float]’ = <factory>, vertical_offset: ‘float’ = 0.5, scale: ‘float’ = 5.0)

Parameters:
enabled: bool = True
hfield_name: str = 'terrain_hfield'
geom_name: str = 'floor'
measured_points_x: list[float]
measured_points_y: list[float]
vertical_offset: float = 0.5
scale: float = 5.0
__init__(enabled=True, hfield_name='terrain_hfield', geom_name='floor', measured_points_x=<factory>, measured_points_y=<factory>, vertical_offset=0.5, scale=5.0)
Parameters:
class unilab.envs.locomotion.common.LocomotionBaseCfg[source]

Bases: EnvCfg

LocomotionBaseCfg(scene: unilab.base.scene.SceneCfg | None = None, sim_dt: ‘float’ = 0.01, max_episode_seconds: Optional[float] = None, ctrl_dt: ‘float’ = 0.02, render_spacing: float = 1.0, render_offset_mode: str = ‘grid’, motrix_max_iterations: Optional[int] = None, post_step_forward_sensor: bool = False, control_config: ‘ControlConfigBase’ = <factory>, noise_config: ‘BaseNoiseConfig’ = <factory>, sensor: ‘Sensor’ = <factory>)

Parameters:
control_config: ControlConfigBase
noise_config: BaseNoiseConfig
sensor: Sensor
sim_dt: float = 0.01
ctrl_dt: float = 0.02
__init__(scene=None, sim_dt=0.01, max_episode_seconds=None, ctrl_dt=0.02, render_spacing=1.0, render_offset_mode='grid', motrix_max_iterations=None, post_step_forward_sensor=False, control_config=<factory>, noise_config=<factory>, sensor=<factory>)
Parameters:
class unilab.envs.locomotion.common.LocomotionBaseEnv[source]

Bases: NpEnv

Common base environment for locomotion tasks (G1, Go1, Go2, etc.).

Parameters:
__init__(cfg, backend, num_envs=1)[source]
Parameters:
property action_space: Box

Action space

apply_action(actions, state)[source]

子类实现:action → ctrl

Parameters:
Return type:

ndarray

get_local_linvel()[source]
Return type:

ndarray

get_gyro()[source]
Return type:

ndarray

get_dof_pos()[source]
Return type:

ndarray

get_dof_vel()[source]
Return type:

ndarray

class unilab.envs.locomotion.common.LocomotionDRProvider[source]

Bases: DomainRandomizationProvider

Base DR provider for locomotion joystick environments.

Shared logic: - validate, build_interval_randomization_plan, _sample_commands - build_reset_plan (template with hooks) - build_reset_observation (template with hook)

Override these hooks in subclasses: - _get_qvel_limit — default 0.5 - _build_extra_info_updates — default empty dict - _compute_reset_obs — must be implemented per robot

validate(env, capabilities)[source]
Parameters:
Return type:

None

build_interval_randomization_plan(env, step_counter)[source]
Parameters:
  • env (Any)

  • step_counter (int)

Return type:

IntervalRandomizationPlan | None

build_reset_plan(env, env_ids)[source]
Parameters:
Return type:

ResetPlan

build_reset_observation(env, env_ids, info_updates)[source]
Parameters:
Return type:

dict[str, ndarray]

class unilab.envs.locomotion.common.PdControlConfig[source]

Bases: ControlConfigBase

ControlConfigBase plus shared PD-actuator gains (Go1/Go2/Go2W defaults).

Parameters:
Kp: float = 35.0
Kd: float = 0.5
__init__(action_scale=0.25, simulate_action_latency=False, Kp=35.0, Kd=0.5)
Parameters:
class unilab.envs.locomotion.common.RewardContext[source]

Bases: object

Immutable snapshot of everything reward functions may read.

Built once per _compute_reward call. Shared functions access only the fields they need; robot-specific methods that still live on the environment class receive the same context via self.

Parameters:
info: dict
linvel: ndarray
gyro: ndarray
dof_pos: ndarray
num_envs: int = 0
default_angles: ndarray
tracking_sigma: float = 0.25
base_height_target: float = 0.0
base_height: ndarray
gravity: ndarray | None = None
dof_vel: ndarray | None = None
pose_weights: ndarray | None = None
joint_range: ndarray | None = None
linvel_yaw: ndarray | None = None
__init__(info, linvel, gyro, dof_pos, num_envs=0, default_angles=<factory>, tracking_sigma=0.25, base_height_target=0.0, base_height=<factory>, gravity=None, dof_vel=None, pose_weights=None, joint_range=None, linvel_yaw=None)
Parameters:
class unilab.envs.locomotion.common.Sensor[source]

Bases: object

Sensor()

local_linvel = 'local_linvel'
gyro = 'gyro'
__init__()
unilab.envs.locomotion.common.apply_heading_yaw_feedback(commands, base_quat, heading_commands, *, stiffness, clip=2.0)[source]

In-place P-control on heading error → commands[:, 2] (yaw rate).

Parameters:
Return type:

None

unilab.envs.locomotion.common.sample_heading_commands(env, num_samples)[source]

Uniformly sample heading targets from env.cfg.commands.heading_range.

Parameters:
Return type:

ndarray

unilab.envs.locomotion.common.sample_velocity_commands(rng, num_samples, low, high)[source]
Parameters:
Return type:

ndarray

unilab.envs.locomotion.common.zero_small_xy_commands(commands, *, threshold=0.2)[source]

Zero commands[:, :2] in-place wherever its norm is below threshold.

Parameters:
Return type:

None

Modules

base

commands

domain_rand

dr_provider

Shared DomainRandomizationProvider for locomotion environments.

height_scan

Shared height-scan and terrain-bound helpers for rough locomotion envs.

rewards

Shared reward functions for locomotion environments.

terrain_spawn

Spawn-origin managers for locomotion envs.