fix(terrain): eval-mode env origins for OBJ terrains - #185
Open
tkevinbest wants to merge 1 commit into
Open
Conversation
TerrainLocomotion._get_env_origins()'s eval branch (randomize_tiles=False) read self.terrain._env_origins directly, but OBJ (load_obj) terrains never populate that attribute — their per-tile origins come from _get_load_obj_env_origin_grid(). The training branch already handled this via sample_env_origins(), but the eval branch predates OBJ support and was never updated, so evaluating any OBJ-terrain policy (e.g. a stairs-climbing WBT policy) crashed with AttributeError at env init. Add a Terrain.env_origin_grid property that returns the right grid for both terrain types, route sample_env_origins() and the eval branch through it. Verified end-to-end: a g1 stairs WBT eval now boots, loads the fitted-box mesh, and records a rollout.
tkevinbest
force-pushed
the
dev/tkbest/eval-obj-terrain-origins
branch
from
August 10, 2026 20:54
28ef8f0 to
0d05fa1
Compare
tkevinbest
marked this pull request as ready for review
August 10, 2026 21:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes an
AttributeErrorcrash at env init when evaluating a policy on an OBJ (load_obj) terrain — e.g. a stairs-climbing policy on a fitted-box mesh.Terrain spawn origins are computed one of two ways depending on terrain type: procedural terrains store them in
Terrain._env_origins, while OBJ terrains never populate that attribute and instead derive per-tile origins from the loaded mesh via_get_load_obj_env_origin_grid(). Separately,TerrainLocomotion._get_env_origins()has two modes: the training branch (randomize_tiles=True) scatters robots across tiles, and the eval branch (randomize_tiles=False) places every robot at tile(0, 0)for deterministic evaluation.The training branch already fetched origins the right way through
sample_env_origins(), which special-cases OBJ terrains. The eval branch predates OBJ-terrain support and reached forself.terrain._env_origins[0, 0]directly — an attribute that doesn't exist for OBJ terrains — so any OBJ-terrain eval crashed on the first_get_env_origins()call.The fix introduces one accessor and routes both modes through it:
Terrain.env_origin_gridproperty (simulator/shared/terrain.py) that returns the[num_rows, num_cols, 3]per-tile origin grid for either terrain type —_get_load_obj_env_origin_grid()for OBJ,_env_originsfor procedural.sample_env_origins()and the eval branch inlocomotion.pyat the property, so eval handles OBJ terrains exactly the way training already does.Notes for reviewers:
_env_originsarray the old code used, so existing (non-OBJ) training and eval runs are unaffected.[num_rows, num_cols, 3]grid, so the eval branch's[0, 0](→ one 3-vector) andsample_env_origins()'s fancy index (→[num_robots, 3]) both work. The procedural grid is float64 and the OBJ grid float32, but both call sites wrap the result intorch.from_numpy(...).to(torch.float), so the dtype difference is normalized away.sample_env_origins()(now routed); other_env_originsreferences are unrelated per-env tensors on different objects.Verified end-to-end: an OBJ-terrain eval now boots, loads the fitted-box mesh, and records a rollout instead of crashing at init.