Hopper
Lerax port of Gymnasium's Hopper environment. A 2D one-legged robot (torso + thigh + leg + foot, 3 actuated joints) must hop along the +x axis without falling over.
Observation space
concat(qpos, clip(qvel, -10, 10)) flattened. When exclude_current_positions_from_observation=True (default) qpos[0] is dropped. Unbounded Box.
Action space
Box(low, high) from the model's actuator_ctrlrange — 3 continuous joint torques.
Reward
forward_reward + healthy_reward - ctrl_cost with
forward_reward = forward_reward_weight * x_velocity,
healthy_reward = is_healthy * healthy_reward (default 1.0), and
ctrl_cost = ctrl_cost_weight * sum(action ** 2) (default 1e-3).
Termination
If terminate_when_unhealthy=True (default), terminates when not healthy. Healthy means every entry of concat(qpos[2:], qvel) lies in healthy_state_range=(-100, 100), torso z in healthy_z_range=(0.7, inf), and torso angle in healthy_angle_range=(-0.2, 0.2). No built-in truncation.
lerax.env.mujoco.Hopper
Bases: AbstractMujocoEnv[Float[Array, '...'], Float[Array, '...']]
MJX-based hopper environment matching Gymnasium's Hopper-v5.
transition
render_states
render_states(
states: Sequence[StateType],
renderer: AbstractRenderer | Literal["auto"] = "auto",
dt: float = 0.0,
)
Render a sequence of frames from multiple states.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
Sequence[StateType]
|
A sequence of environment states to render. |
required |
renderer
|
AbstractRenderer | Literal['auto']
|
The renderer to use for rendering. If "auto", uses the default renderer. |
'auto'
|
dt
|
float
|
The time delay between rendering each frame, in seconds. |
0.0
|
render_stacked
render_stacked(
states: StateType,
renderer: AbstractRenderer | Literal["auto"] = "auto",
dt: float = 0.0,
)
Render multiple frames from stacked states.
Stacked states are typically batched states stored in a pytree structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
states
|
StateType
|
A pytree of stacked environment states to render. |
required |
renderer
|
AbstractRenderer | Literal['auto']
|
The renderer to use for rendering. If "auto", uses the default renderer. |
'auto'
|
dt
|
float
|
The time delay between rendering each frame, in seconds. |
0.0
|
reset
Wrap the functional logic into a Gym API reset method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
Key[Array, '']
|
A JAX PRNG key for any stochasticity in the reset. |
required |
Returns:
| Type | Description |
|---|---|
tuple[StateType, ObsType, dict]
|
A tuple of the initial state, initial observation, and additional info. |
step
step(
state: StateType,
action: ActType,
*,
key: Key[Array, ""],
) -> tuple[
StateType,
ObsType,
Float[Array, ""],
Bool[Array, ""],
Bool[Array, ""],
dict,
]
Wrap the functional logic into a Gym API step method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
state
|
StateType
|
The current environment state. |
required |
action
|
ActType
|
The action to take. |
required |
key
|
Key[Array, '']
|
A JAX PRNG key for any stochasticity in the step. |
required |
Returns:
| Type | Description |
|---|---|
tuple[StateType, ObsType, Float[Array, ''], Bool[Array, ''], Bool[Array, ''], dict]
|
A tuple of the next state, observation, reward, terminal flag, truncate flag, and additional info. |