Observation Pipeline
1. Entry Point & Environment Setup
File: env_factory.py
make_env() loads pal_kangaroo_flat_env_cfg() and builds the ManagerBasedRlEnv.
2. Configuration of Observation Terms
File: kangaroo_env_cfg.py
pal_kangaroo_flat_env_cfg()is based onpal_kangaroo_rough_env_cfg()pal_kangaroo_rough_env_cfg()overrides observation terms:- Removed:
base_lin_vel,projected_gravity - Added:
imu_projected_gravity(IMU quaternion),base_lin_acc(IMU linear acceleration)
File: velocity_env_cfg.py
Defines policy_terms and critic_terms as ObservationTermCfg.
3. Observation Functions (Data Sources)
File: observations.py
| Term | Source |
|---|---|
base_lin_vel |
Root-link linear velocity (simulator state) |
base_ang_vel |
Root-link angular velocity (simulator state) |
projected_gravity |
Gravity in the body frame |
joint_pos_rel |
Joint positions relative to the default position |
joint_vel_rel |
Joint velocities |
last_action |
from ActionManager |
generated_commands |
from CommandManager |
builtin_sensor |
MuJoCo sensor data |
imu_projected_gravity |
IMU quaternion → projected gravity |
4. Sensor Source (MuJoCo)
File: builtin_sensor.py
BuiltinSensor reads sensordata directly from MuJoCo.
File: scene.py
Binds sensors from the scene/entity XML via BuiltinSensor.from_existing().
5. Robot State (from the simulator)
File: data.py
All raw values come from mjwarp.Data (simulator state):
projected_gravity_broot_link_lin_vel_broot_link_ang_vel_bjoint_posjoint_vel
6. Observation Pipeline (Processing Steps)
File: observation_manager.py
_prepare_terms() computes shapes and initializes delay/history buffers.
compute_group() processes each term in this order:
term_cfg.func(...) → raw observation
│
▼ Noise (NoiseCfg / NoiseModelCfg)
▼ Clip (term_cfg.clip)
▼ Scale (term_cfg.scale)
▼ NaN check
▼ Delay (DelayBuffer)
▼ History (CircularBuffer, optional flatten)
▼ Concatenate (if the group is configured that way)
7. Observation Groups
Policy Group (Shape: (86,))
| Index | Term | Shape |
|---|---|---|
| 0 | base_ang_vel |
(3,) |
| 1 | joint_pos |
(26,) |
| 2 | joint_vel |
(26,) |
| 3 | actions |
(22,) |
| 4 | command |
(3,) |
| 5 | imu_projected_gravity |
(3,) |
| 6 | base_lin_acc |
(3,) |
base_lin_velandprojected_gravityare disabled in this config (None).
Critic Group (Shape: (104,))
| Index | Term | Shape |
|---|---|---|
| 0 | base_lin_vel |
(3,) |
| 1 | base_ang_vel |
(3,) |
| 2 | projected_gravity |
(3,) |
| 3 | joint_pos |
(26,) |
| 4 | joint_vel |
(26,) |
| 5 | actions |
(22,) |
| 6 | command |
(3,) |
| 7 | foot_height |
(2,) |
| 8 | foot_air_time |
(2,) |
| 9 | foot_contact |
(2,) |
| 10 | foot_contact_forces |
(6,) |
| 11 | imu_projected_gravity |
(3,) |
| 12 | base_lin_acc |
(3,) |
foot_height,foot_air_time,foot_contact, andfoot_contact_forcesdepend on theContactSensor.
The critic has access to privileged information that is not available to the policy.