fix(augmentation): name-based gait-phase channel mirror for symmetry aug - #184
Open
tkevinbest wants to merge 1 commit into
Open
fix(augmentation): name-based gait-phase channel mirror for symmetry aug#184tkevinbest wants to merge 1 commit into
tkevinbest wants to merge 1 commit into
Conversation
The gait-phase observation mirror hard-coded "negate channel 0", which is only (partially) correct when channel 0 is the LEFT foot (left-first body_names). For right-first orderings or >2 feet it produces an inconsistent mirrored phase, corrupting symmetry-augmented transitions. Derive the phase-channel permutation by NAME instead: map each foot's phase channel to its left/right mirror foot's channel (env.feet_indices order), with a word-boundary-safe _mirror_body_name so mid-word letters (the 'l' in 'roll') are never read as a side token. Identity fallback when a mirror can't be resolved, so behavior degrades to "unchanged" rather than wrong. Correct for any foot ordering and any number of feet.
tkevinbest
marked this pull request as ready for review
August 10, 2026 20:05
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.
What
Symmetry-based data augmentation mirrors observations across the robot's sagittal plane. The gait-phase signals
sin_phaseandcos_phaseare separate observation terms, each carrying one channel per foot, ordered to matchenv.feet_indices. Under a left-right mirror, each foot's phase channel must be swapped with its mirror foot's channel.The old code did neither a full mirror nor a swap:
It only ever touched channel 0 and negated it. So:
The result is an inconsistent mirrored gait phase, which corrupts the symmetry-augmented transitions used in training (observed as a wide-stance gait when augmentation was enabled).
Fix
Mirror the gait phase by swapping each foot's channel with its left-right mirror foot's channel, derived by name:
env.feet_indicesorder). This gives a permutationpwheremirrored_phase[..., i] = phase[..., p[i]]. For g1 this resolves to[1, 0]— a genuine left/right swap._mirror_body_name, which swaps side tokens (left/right, andl_/r_prefixes or_l_/_r_infixes) only at word boundaries — so a mid-word letter like thelinankle_rollis never misread as a side marker.Correct for any foot ordering and any number of feet, bipeds and quadrupeds.
Behavior change
This changes the mirrored phase for every robot, including the existing left-first biped case — it is not a no-op refactor. Old vs new for a left-first biped:
[-sin(φ0), sin(φ1)](negate channel 0, ignore channel 1)[ sin(φ1), sin(φ0)](swap the two feet)The new behavior is the intended consistent leg swap. Any policy trained with symmetry augmentation on the old code was augmenting against a corrupted phase mirror.
Scope
Single file:
agents/modules/augmentation_utils.py(+63 / −23). Isolated to the augmentation path.