Skip to content

Feat/g1 flip - #117

Merged
TATP-233 merged 12 commits into
mainfrom
feat/g1_flip
Apr 9, 2026
Merged

TATP-233 merged 12 commits into
mainfrom
feat/g1_flip

Conversation

@caozx1110

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a dedicated G1 flip motion-tracking task/profile and expands the motion-tracking pipeline to better support multi-clip datasets (clip-aware sampling + truncation at clip boundaries), alongside quaternion utilities to make orientation/velocity computations robust to quaternion sign flips.

Changes:

  • Add g1_flip_tracking task (Hydra + registry) with flip-specific defaults and training budgets.
  • Update motion loading/sampling to support multiple NPZ clips and add clip-boundary truncation behavior in the env.
  • Add quaternion helpers (canonicalize, ensure_continuity, angular_velocity) and update CSV→NPZ scripts/tests accordingly; pin Torch version in project deps/lock.

Reviewed changes

Copilot reviewed 23 out of 27 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
uv.lock Updates locked dependencies (Torch/Triton/TorchVision and CUDA/NVIDIA wheels layout).
pyproject.toml Pins torch==2.7.0.
src/unilab/base/np_env.py Adds _compute_truncated hook + scratch buffer; integrates truncation into step() flow.
src/unilab/utils/math_utils.py Adds quaternion canonicalization/continuity + angular velocity helper; reuses canonicalize in error magnitude.
src/unilab/envs/motion_tracking/g1/motion_loader.py Supports multi-clip NPZ loading; adds clip-aware sampling mode and clip-end detection.
src/unilab/envs/motion_tracking/g1/tracking.py Supports list-valued motion_file; adds clip_start sampling mode; truncates episodes at clip end.
src/unilab/envs/motion_tracking/g1/flip_tracking.py New flip-specific config/profile + env registration (G1FlipTracking).
src/unilab/envs/motion_tracking/g1/__init__.py Exports flip-tracking symbols.
src/unilab/envs/motion_tracking/__init__.py Re-exports flip-tracking symbols at package level.
conf/ppo/task/g1_flip_tracking.yaml Adds PPO Hydra task config for flip tracking.
conf/appo/task/g1_flip_tracking.yaml Adds APPO Hydra task config for flip tracking.
docs/05-g1-motion-tracking.md Documents new flip task and multi-clip semantics.
tests/utils/test_math_utils.py Adds coverage for sign-flip invariance and angular-velocity robustness.
tests/envs/test_motion_loader.py New tests for multi-clip loader + sampler modes and clip-end behavior.
tests/envs/test_env_configs.py Adds tests for legacy defaults, flip profile defaults, and clip-end truncation behavior.
tests/base/test_np_env.py Adds tests for truncation hook behavior + scratch-buffer reuse.
tests/config/test_locomotion_params.py Adds PPO config assertions for motion/flip tracking tasks.
tests/config/test_config_system.py Includes g1_flip_tracking in task composition matrix.
tests/scripts/test_train_script_configs.py Ensures train script configs load for the new task.
scripts/motion/csv_to_npz.py Uses shared quaternion continuity + angular velocity utilities.
scripts/motion/replay_bones_seed_csv.py New tool to replay BONES-SEED CSV motions in MuJoCo viewer.
scripts/motion/bones_seed_csv_to_npz.py New converter from BONES-SEED CSV to NPZ with FK + velocities.
scripts/motion/README.md Documents the new replay/conversion scripts and formats.
src/unilab/assets/robots/g1/scene_flat_with_wall.xml Adds a MuJoCo scene variant including a wall.
.gitignore Ignores flip CSV/NPZ asset directories.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +85 to +93
def np_quat_canonicalize(q: np.ndarray) -> np.ndarray:
"""Flip quaternion signs so the real part is non-negative."""
q_was_1d = q.ndim == 1
if q_was_1d:
q = q[None, :]

sign = np.where(q[:, 0:1] < 0.0, -1.0, 1.0)
result = q * sign
return np.asarray(result[0] if q_was_1d else result)

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np_quat_canonicalize assumes an input shaped like (N, 4) (or (4,)) but doesn’t validate this; for other shapes it will raise a confusing IndexError when slicing q[:, 0:1]. Consider adding explicit shape/ndim checks consistent with np_quat_ensure_continuity (e.g., require q.ndim in {1,2} and last dim == 4) and raise a clear ValueError when violated.

Copilot uses AI. Check for mistakes.
Comment on lines 370 to 376
def step(self):
"""Advance all frames by one step."""
self.current_frames += 1

# Find environments that reached end of motion
done_mask = self.current_frames >= self.motion_loader.num_frames
# Find environments that reached the end of their current clip.
done_mask = self.current_frames > self.current_clip_end_frames
return np.where(done_mask)[0]

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MotionSampler.step() advances current_frames past current_clip_end_frames for done envs (and for the last clip this can become num_frames, i.e. out of bounds). Since get_current_motion() indexes directly with current_frames, calling it after step() can return frames from the next clip or raise an IndexError. Consider clamping indices for done envs, or having get_current_motion() use np.minimum(current_frames, current_clip_end_frames) so the sampler remains safe to use even if callers don’t immediately resample/reset.

Copilot uses AI. Check for mistakes.
@caozx1110

Copy link
Copy Markdown
Collaborator Author

@TATP-233

@TATP-233
TATP-233 merged commit a527141 into main Apr 9, 2026
3 checks passed
@TATP-233
TATP-233 deleted the feat/g1_flip branch April 9, 2026 06:25
TATP-233 added a commit that referenced this pull request May 4, 2026
TATP-233 added a commit that referenced this pull request May 30, 2026
TATP-233 added a commit that referenced this pull request Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants