Risk-Aware Walking for a Humanoid on a Pretrained Policy: 3D Risk Maps, Spatio-Temporal MPPI and Narrow-Gap Side-Stepping

Technical report · ohora23 · 30 November 2026 · Code: github.com/ohora23/risk-aware-g1-walking (Apache-2.0) · Project page · Simulation: MuJoCo, Unitree G1

Abstract

We replace only the planning layer above a pretrained, velocity-commanded humanoid walking policy and leave the policy untouched. The layer builds a dense 3D risk grid in which each obstacle contributes a severity-weighted Gaussian of its distance at every body height, plus a severity-independent collision core, and plans with sampling-based MPPI. Three additions matter in the experiments: (i) height-aware risk avoids a chest-height overhang that 2D methods hit (0/20 vs 1/20 collisions); (ii) evaluating moving people at their predicted position at each rollout time instead of smearing their future path into the map cuts person contacts from 18/30 to 3/30 and falls from 3 to 0, and to 0/30 when the person yields; (iii) a rule-based narrow-gap mode side-steps a 0.33–0.36 m opening 20/20 where plain MPPI never finds the centimetre-level alignment. The risk grid can also be built from a noisy virtual depth camera with a voxel map and unknown-space risk, matching the ground-truth map on the overhang task. All results come from frozen-parameter batch evaluations (1,000+ episodes); negative results and superseded versions are reported.

map source ground-truth obstaclesor, from the camera: head depthD435i model odometry(+ drift) voxel maplog-odds, labels persontracker 3D risk gridstatic obstacles moving agentsx, y, vx, vy, S, r MPPI 256 × 3 srisk at time t_k gap passerif gap fits sideways G1 policypretrained, fixed MuJoCophysics pose and depth back to the sensors lethal scan vx, vy, ω
Figure 1. System. The pretrained walking policy is fixed; blue boxes are the planning layer contributed here. The risk grid carries static obstacles only; people are passed to MPPI as agents and evaluated at each rollout time. Dashed: the narrow-gap detector scans the grid's lethal cells.

1. Introduction

Learned locomotion policies for humanoids now walk robustly when commanded a body velocity, so the open problem for deployment is the layer that decides where and how fast to walk. Common navigation stacks inherit a 2D occupancy costmap from wheeled robots: every obstacle is equally dangerous, overhangs are invisible to a LiDAR slice, and moving people are either ignored or inflated. This work asks how much a humanoid gains from three changes to that layer, measured in closed loop on a real pretrained policy in physics simulation.

Contributions.

2. Method

2.1 Static 3D risk

Body points x are sampled on a footprint at heights 0.1, 0.5, 0.9 and 1.2 m. For obstacles k with severity Sk (wall 1, cabinet 3, vase 5, shelf 8, person 10) and signed distance dk:

Rs(x) = Σk Sk · exp( − max(dk(x), 0)2 / 2σ2 ),   Rs ← 100 if mink dk(x) < rlethal(1)

with σ = 0.25 m. The collision core exists because a pure severity Gaussian made touching a severity-1 wall cost only 1: the planner either brushed walls or froze. The grid is a dense window (8 × 6 × 2 m at 0.1 m, built in 6 ms) around the robot; a smooth field compresses poorly in an octree and MPPI needs ≈30k vectorised lookups per plan.

2.2 Camera-built grid

A head camera (87° × 58°, 212 × 120) renders depth through mujoco-realsensor's sensor model (z² noise, edge holes, 0.2–10 m); MuJoCo segmentation supplies class labels as a stand-in for a detector. Points update a world-fixed voxel map with log-odds L ← clip(L + 0.85 per hit, − 0.4 per ray pass); a voxel is occupied when L > 1.0, i.e. after two hits. Per class, an exact 3D Euclidean distance transform (2D per layer, exact 1D lower envelope along z) gives dk. Unseen voxels add Ru = su exp(−du2/2σ2), su = 1, combined by max, which slows the robot into unexplored space. The robot's own footprint column is cleared each tick. People are not mapped; a tracker takes the centroid of their points and an EMA velocity. A drift variant integrates odometry with 1 % scale error and 0.5°/m yaw drift and builds the map in that frame; the goal stays fixed in the map frame.

2.3 Moving people: spatio-temporal cost

Agent j observed now at (pj, vj) is evaluated at the time tk = (k+1)Δt of rollout step k, with uncertainty growing in time (σv = 0.15 m/s):

Rd(x, tk) = Σj Sj · exp( − max(‖x − (pj + vj tk)‖ − rj, 0)2 / 2(σ + σv tk)2 )(2)

The earlier version put the person in the static grid at its current and four predicted positions with weights 1 − 0.5i/n (max over them). Figure 2 shows why that fails.

smeared prediction (v2) spatio-temporal cost (v3) person now whole sweepis risky now robot slows on the line, dodges into the path t = 0t = 1 st = 2 s t = 1 st = 3 s robot at the line at t = 2 s,the person is already past risk(x) = max over predicted positions, whenever the robot gets there rollout step k is checked against the person at time k·Δt; speed cap uses t = 0 only
Figure 2. Why smearing hurts. In v2 the crossing band is risky at every time, so the speed cap slows the robot exactly on the line, and because far predictions are down-weighted, moving away from the person's current position moves the robot into its future path. Measured at first contact (seeds 2/7/13): robot on the line (x − xcross = −0.02…+0.13 m) at 0.24–0.27 m/s, displaced toward the person's heading.

2.4 MPPI

Rollouts use a body-frame unicycle with measured tracking gains (vx, vy, ω scaled by 1.006, 0.823, 0.786 for the 29-dof G1). For each of 256 samples over H = 30 steps of 0.1 s, with goal g, rollout poses (pt, ψt), bearing βt to the goal and body points xt,b:

J = wgHΣt‖pt − g‖ + wT‖pH − g‖ + wr maxt,b(Rs + Rd)(xt,b, t) + wcΣ‖ut‖2(3a)
   + whHΣt(1 − cos(ψt − βt)) min(‖pt − g‖, 1) + wbΣmax(0, −vx,t)2 + wlΣvy,t2(3b)
ωi ∝ exp( − (Ji − Jmin) / λ(Jmed − Jmin) ),   u = Σ ωiui,   (vx, vy) ← (vx, vy) / (1 + βR0)(4)

Weights wg = 10, wT = 10, wr = 1, wc = 0.005, wh = 3, wb = 10, wl = 0.5, λ = 0.1, β = 0.5; 20 % of samples are drawn around zero with doubled noise. Each term was added for a measured failure: a too-large control cost made standing optimal; a fixed temperature gave near-uniform weights; without the terminal term "stand still" beat any risky-but-feasible pass (deadlock); without the heading terms the goal was position-only, so walking backward was as cheap as walking forward and the robot back-stepped after the gap (57 commands with vx < −0.1 on one seed, down to −0.78 m/s). R0 is the risk at the current pose with people at t = 0 only.

2.5 Narrow-gap mode and body models

Scan lines across the goal heading find the widest free interval w of the lethal grid on each line. An opening with depth ≤ w < 2 × half-width triggers a feedback controller (Figure 3). MPPI alone never threaded such a gap: the feasible pelvis window is 8–11 cm wide, and even a hand-made ideal turn-and-slide hit the core from 2° of yaw error. The 12-dof G1 model has forearms fixed forward (0.44 m deep at 0.8–0.95 m height vs 0.36 m wide), so side-stepping gains nothing; the gap study uses the 29-dof model with arms PD-held (0.23 m × 0.37 m), after copying the policy's joint armature/damping/friction into it (without them it falls immediately). For the person study, the 12-dof outline including the forearms (x −0.07…+0.38 m, y ±0.18 m) is the "body12" footprint; the earlier pelvis column + 0.25 m missed the forearms, which caused every remaining contact with a yielding person.

MPPIapproachrotateslideturn gap aheads₀ < 1.2 m at stand-off< 5 cm sidewaysyaw err < 3° past barrier facing travel direction (< 10°): hand back, gap passed once 0.12 m/s, centreline P k = 3
Figure 3. Narrow-gap passer. The turn state was added after the robot, handed back sideways, mixed backward steps into MPPI's turn; commands are divided by the measured tracking gains.

3. Experimental setup

MuJoCo 3.14, Unitree G1 with the unitree_rl_gym pretrained 12-joint leg policy (50 Hz, velocity command), planning at 10 Hz with a 0.4 low-pass on commands. CPU only.

Table 1. Scenarios (seed-jittered layouts).
scenariowhat it testslayout
shelfoverhang invisible to a 2D sliceshelf at 0.95–1.05 m protruding 0.55–0.75 m, low cabinet opposite so the floor-level free space lies under the shelf
gapopening narrower than the body widthfull-height partition, opening 0.33–0.36 m (29-dof G1: 0.23 m deep, 0.37 m wide)
crossinga person crossing the pathdoorways in both walls; person 0.6–1.0 m/s, started to reach the centreline when a 0.6 m/s robot would (± 1.5 s); planners see only its current velocity
crossing_yielda person who yieldsas above, but the person stops while the robot is ahead within 0.5 m

Metrics. Success (goal within 0.3 m, 0.5 m for drift), falls, contacts (MuJoCo contacts between robot and obstacle geoms), minimum distance from the body column to the highest-severity obstacle, and risk exposure ∫ maxb R dt scored with the same ground-truth grid for every method.

Protocol. Acceptance tests were written before each implementation. Parameters were tuned on seed 0 only, frozen and hashed (sha256) before batch runs of 20–30 seeds. Any later change produced a new version (v2, v3) and the old hashes are recorded as superseded; earlier negative results are kept.

4. Results

4.1 Overhang

Table 2. Shelf, 20 seeds (v2).
mapmethodcollisionsshelf distance mean (worst)exposuretime
ground truth3D risk0/200.49 m (0.44)8.0815.3 s
ground truth2D slice risk1/200.27 m (0.18)10.3013.1 s
ground truth2D binary inflation (Nav2-like)1/200.32 m (0.20)8.6912.9 s
camera3D risk0/200.49 m (0.42)8.9118.1 s
camera2D slice0/200.33 m (0.22)9.7814.9 s
camera + drift3D risk0/200.49 m (0.43)9.9518.8 s

3D risk keeps about twice the clearance of 2D methods. On the camera map the 2D slice did not collide in this run, so the advantage there is in clearance, not in collisions; 0/20 vs 1/20 is not a statistically strong difference.

3D risk: G1 keeps away from the shelf2D slice: G1 walks under the shelf and touches it
Figure 4. Shelf, seed 4, ground truth: 3D risk (left, 0.45 m) and 2D slice (right, touches the shelf at 0.20 m).

4.2 Narrow gap

Table 3. Gap 0.33–0.36 m, 20 seeds (v2).
mapmethodclean passescontactsyaw in gaptime
ground truthside-step gap mode20/200/2087°24.9 s
ground truthcircular-footprint MPPI0/200/20–timeout
cameraside-step gap mode20/200/20–33.9 s
camera + driftside-step gap mode17/201/20–33.7 s

The circular baseline cannot fit by construction (its 0.215 m core leaves no free centres), so this compares the gap mode with plain MPPI; oriented-footprint MPPI without the mode also failed.

4.3 A person crossing the path

Table 4. Crossing, 30 seeds per condition (v3, body12 footprint).
methodno yield: contactsfallssuccessyields: contactsworst distancesuccess
3D, prediction smeared18/30327/302/300.30 m28/30
3D, no prediction16/30327/304/300.19 m27/30
2D binary inflation14/30327/304/300.16 m26/30
4D spatio-temporal3/30029/300/300.54 m30/30

The 4D cost is also the fastest (14.6 s vs 16.1–16.3 s for a non-yielding person). With the earlier pelvis-column footprint the ranking was the same (4D 11/30 vs smeared 23/30 contacts, 0 vs 5 falls). The remaining contacts come from a person who walks into the robot without yielding. Camera-map variants scored 0/30 in both conditions but arrived about 5 s later than the person's timing assumes and never met it (minimum distance ≥ 0.84 m), so they are not evidence of avoidance.

smeared prediction, seed 13: robot slows near the crossing4D cost, seed 13: robot passes without contact
Figure 5. Crossing, seed 13: smeared prediction (left) touches the person and falls; the 4D cost (right) passes at 0.44 m.

5. Failures found and what changed

6. Limitations

Simulation only; labels from segmentation; drift is a model, not SLAM; hand-set severities; a kinematic person that never avoids; 20–30 seeds; a rule-based gap mode that assumes a barrier perpendicular to the goal heading; camera-based person avoidance not yet tested fairly.

7. Future work

  1. Trigger the crossing person on the robot's position so every method meets it, and evaluate the camera 4D planner over 100 seeds.
  2. A real detector or injected label noise; real odometry/SLAM (e.g. KISS-ICP) and an octree or nvblox map.
  3. CVaR instead of the maximum over the rollout, interactive pedestrian models, data-driven severities.
  4. Whole-body responses (ducking under the shelf) with a motion tracker such as SuperMimic, then transfer to a real G1 with a D435i calibrated through mujoco-realsensor.

8. Reproducibility

Frozen parameter hashes (sha256 prefixes): v2 params.json 3ba09cb8, params_gap.json 6f387727, params_perc.json eccb6344, params_gap_perc.json 39d63592; v3 params_v3.json 76dab463, params_perc_v3.json 3292be3b. Superseded v1 hashes and every design change with its evidence are in progress.txt.

export MUJOCO_GL=egl UNITREE_RL_GYM=/path/to/unitree_rl_gym REALSENSOR_ROOT=/path/to/mujoco-realsensor
python eval.py                    # shelf + corridor (v2)
python eval.py --gap              # narrow gap
python eval.py --perc             # camera map, drift
python eval.py --body12           # crossing, both person models (v3)
for t in tests/test_*.py; do python $t; done

References

  1. G. Williams et al., "Aggressive driving with model predictive path integral control," ICRA 2016.
  2. A. Hornung et al., "OctoMap: an efficient probabilistic 3D mapping framework based on octrees," Autonomous Robots, 2013.
  3. S. Macenski et al., "The Marathon 2: a navigation system," IROS 2020 (Nav2 costmaps).
  4. P. F. Felzenszwalb, D. P. Huttenlocher, "Distance transforms of sampled functions," Theory of Computing, 2012.
  5. Unitree Robotics, unitree_rl_gym (pretrained G1 policy). MuJoCo, Google DeepMind. mujoco-realsensor (virtual camera model).