Gym#
The embodichain.lab.gym module is the environment layer that turns
simulation scenes into robot-learning tasks. It follows the Gymnasium interface
while adding vectorized simulation, declarative scene configuration, manager
systems for task logic, and tensor-based observations and actions for learning
pipelines.
The design mirrors the separation used in modern robot-learning frameworks such
as Isaac Lab: simulation objects live in the scene, task behavior is composed
through managers, and the environment exposes a stable reset / step API
to reinforcement learning, imitation learning, data collection, and evaluation
code.
Environment Classes#
BaseEnv is the common
Gymnasium-compatible foundation. It owns the
SimulationManager, manages the number of parallel
environments, configures timing through sim_steps_per_control, tracks
episode length, exposes batched observation and action spaces, and defines the
standard environment lifecycle.
EmbodiedEnv builds on
BaseEnv for configuration-driven
embodied tasks. A
single EmbodiedEnvCfg declares
the robot, sensors, lights, background objects, interactive objects,
articulations, and manager configs. The environment constructs the simulation
scene from that config and then delegates task-specific behavior to managers and
functors.
Class |
Role |
Use it when |
|---|---|---|
Provides Gymnasium compatibility, vectorized arena control, simulation timing, spaces, reset, and step bookkeeping. |
You need a custom environment base with direct control over scene setup and task methods. |
|
Configures common environment settings such as |
You are defining shared runtime parameters for any environment. |
|
Adds declarative scene creation and manager-based actions, events, observations, rewards, and dataset recording. |
You are building robot manipulation, RL, IL, or data-generation tasks. |
|
Declares the robot, controlled parts, sensors, objects, articulations, lights, managers, and task extension fields. |
You want the task definition to live primarily in configuration. |
Architecture#
The Gym module sits above the simulation module and below training or data collection code:
RL trainer / IL recorder / evaluation script
|
v
Gymnasium API: reset(), step(action), observation_space, action_space
|
v
BaseEnv
|-- SimulationManager ownership
|-- vectorized arenas and timing
|-- episode state and auto reset
`-- batched observation/action spaces
|
v
EmbodiedEnv
|-- scene config: robot, sensors, objects, lights, articulations
|-- ActionManager: policy action -> robot command
|-- EventManager: startup, reset, and interval behavior
|-- ObservationManager: add or modify observation terms
|-- RewardManager: weighted scalar reward terms
`-- DatasetManager: episode recording and export
This layering keeps task code small. A task can define only the scene configuration, reward or termination logic, and any task-specific parameters while relying on managers for reusable behavior.
Manager and Functor Pattern#
Managers are configured collections of functors. A functor is either a function
or a callable class that receives the environment and optional parameters, then
performs one well-scoped operation. The config objects identify the callable and
its parameters, and
SceneEntityCfg resolves named
robots, objects, joints, links, or bodies from the simulation scene.
Manager |
Responsibility |
Typical use |
|---|---|---|
Action manager |
Converts raw policy actions into robot commands such as joint targets, velocity commands, force commands, or end-effector targets. |
RL policies that output normalized or task-space actions. |
Event manager |
Applies startup, reset, and interval behaviors. |
Domain randomization, object placement, visual changes, and scripted scene updates. |
Observation manager |
Adds task-specific observations or modifies existing nested observation entries. |
Object poses, target states, normalized proprioception, sensor-derived terms, and keypoint projections. |
Reward manager |
Evaluates weighted reward functors and sums them into the environment reward. |
Distance, alignment, success, smoothness, and penalty terms for RL. |
Dataset manager |
Records episode data through dataset functors. |
Imitation-learning demonstrations, LeRobot export, and offline dataset generation. |
Typical Step Flow#
At runtime, an EmbodiedEnv step usually follows this high-level sequence:
Receive a batched action from a policy, script, or teleoperation source.
Use the Action Manager to convert it into robot control targets.
Step the simulation for
sim_steps_per_controlphysics steps.Update sensors and collect base observations from the robot and scene.
Apply Observation Manager terms to add or transform observation entries.
Evaluate rewards, success, failure, timeout, and reset conditions.
Record transition data through the Dataset Manager when configured.
Return Gymnasium-compatible
obs,reward,terminated,truncated, andinfovalues.
Choosing Where to Start#
If you want to… |
Start here |
|---|---|
Understand the full |
|
Connect policy outputs to robot control terms |
|
Randomize scenes, place objects, or capture debug/demo videos |
|
Add task observations or transform existing observation entries |
|
Compose RL reward terms |
|
Save structured demonstrations or offline training datasets |
Start with Embodied Environments for the full
EmbodiedEnvconfiguration and custom task guide.Use Action Functors when connecting policy outputs to robot control.
Use Event Functors for reset randomization, visual randomization, and scene perturbations. This page also covers runtime camera-video capture via
record_camera_data.Use Observation Functors to add task observations without changing base environment code.
Use Reward Functors when composing RL reward terms.
Use Dataset Functors when recording demonstrations or exporting datasets. Use this page for structured episode data, not debug video capture.
Documentation Quality Notes#
Gym documentation should make the runtime contract explicit: tensor shapes,
whether data is batched by num_envs, which manager mode invokes a functor,
and which scene entity each functor expects. Prefer linking to the simulation
overview for asset and sensor details, and keep task pages focused on the
environment lifecycle, manager configuration, and learning interface.