Skip to content

[Newton] Fixes rotation computation for locomotion environment - #4499

Merged
kellyguo11 merged 2 commits into
isaac-sim:dev/newtonfrom
AntoineRichard:fix/compute_rot
Jan 30, 2026
Merged

kellyguo11 merged 2 commits into
isaac-sim:dev/newtonfrom
AntoineRichard:fix/compute_rot

Conversation

@AntoineRichard

Copy link
Copy Markdown
Collaborator

Description

Fixes an issue where the walking direction was incorrectly calculated. Bug came from IsaacSim internal code. Need to look where else it's used.

Fixes #4465

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks with ./isaaclab.sh --format
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the changelog and the corresponding version in the extension's config/extension.toml file
  • I have added my name to the CONTRIBUTORS.md or my name already exists there

@github-actions github-actions Bot added bug Something isn't working isaac-lab Related to Isaac Lab team labels Jan 30, 2026
@greptile-apps

greptile-apps Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Greptile Overview

Greptile Summary

This PR fixes a critical bug in the locomotion environment where the walking direction angle was incorrectly calculated using the Z-axis coordinate instead of the Y-axis coordinate in the atan2 function.

Key Changes:

  • Fixed compute_rot() in locomotion_env.py to use targets[:, 1] (Y-axis) instead of targets[:, 1] (Z-axis)
  • Applied the same fix to the Warp kernel version in locomotion_env_warp.py
  • Updated version from 0.10.41 to 0.10.42
  • Added appropriate changelog entry

Technical Context:
The bug originated from IsaacSim internal code. For calculating the horizontal plane angle between the robot's position and target, atan2(Δy, Δx) is the correct formula. Using the Z-coordinate (vertical axis) instead of Y-coordinate resulted in incorrect walking direction calculations. The codebase confirms Z is the up-axis (see line 304: to_target[:, 2] = 0.0 and up_idx=2 on line 307).

Confidence Score: 5/5

  • This PR is safe to merge with high confidence - it fixes a clear mathematical bug with a straightforward correction
  • The fix is mathematically correct (using Y instead of Z for horizontal angle calculation), consistently applied across both PyTorch and Warp implementations, properly versioned, and documented in the changelog
  • No files require special attention

Important Files Changed

Filename Overview
source/isaaclab_tasks/isaaclab_tasks/direct/locomotion/locomotion_env.py Fixed coordinate index in atan2 calculation from Z (index 2) to Y (index 1) for correct horizontal plane angle computation
source/isaaclab_tasks_experimental/isaaclab_tasks_experimental/direct/locomotion/locomotion_env_warp.py Applied same coordinate fix in Warp kernel version, changing from index 2 to index 1 in atan2 calculation

Sequence Diagram

sequenceDiagram
    participant Env as LocomotionEnv
    participant ObsFunc as get_observations()
    participant CompRot as compute_rot()
    participant atan2 as torch.atan2()
    
    Env->>ObsFunc: Request observations
    ObsFunc->>ObsFunc: Get torso_position and targets
    ObsFunc->>CompRot: compute_rot(torso_quat, velocity, ang_velocity, targets, torso_position)
    CompRot->>CompRot: Transform velocities to local frame
    CompRot->>CompRot: Extract roll, pitch, yaw from quaternion
    CompRot->>atan2: Calculate walk_target_angle
    Note over atan2: FIXED: Now uses Y-axis (index 1)<br/>Previously used Z-axis (index 2)
    atan2-->>CompRot: walk_target_angle = atan2(Δy, Δx)
    CompRot->>CompRot: angle_to_target = walk_target_angle - yaw
    CompRot-->>ObsFunc: Return (vel_loc, angvel_loc, roll, pitch, yaw, angle_to_target)
    ObsFunc-->>Env: Return observation tensor
Loading

@greptile-apps greptile-apps Bot 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.

2 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@kellyguo11 kellyguo11 changed the title [Newton] Fix compute rot [Newton] Fixes rotation computation for locomotion environment Jan 30, 2026
@kellyguo11
kellyguo11 merged commit 1f73b93 into isaac-sim:dev/newton Jan 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants