Repository navigation
Fix XYZW quaternion zeroing slice in ForgeEnv (noisy_fingertip_quat[:, 2:4].zero_()) - #9349
angusforbes wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Isaac Lab Review Bot
Needs attention: Implementation (1), Style consistency (1). Other reviewed categories look good.
- PR description: Condense repeated derivations, qualify norm and velocity claims as noiseless, reconcile the Torch snippet with NumPy output, and label training causality unproven until paired results are available.
- Design and architecture: Architecture looks good.
- Scope and over-engineering: No over-engineering issues.
- API: API changes look good.
- Compatibility and deprecation: No breaking changes identified.
- Implementation: The behavior correction is absent from the package changelog; add a bug-fix fragment under source/isaaclab_tasks/changelog.d/.
- Style consistency: The added comment incorrectly equates noisy quaternion components with noiseless yaw identities; remove those identities and redundant index narration, retaining only the projection’s intent.
- Test quality: Test quality looks good.
Minor fixes needed. Posted 2 inline findings.
Automated review; human maintainers own approval decisions.
| self.fingertip_midpoint_quat, quat_from_angle_axis(rot_noise_angle, rot_noise_axis) | ||
| ) | ||
| self.noisy_fingertip_quat[:, ::3].zero_() | ||
| # Zero z (idx 2) and w (idx 3) in XYZW format, preserving x=cos(yaw/2) and y=-sin(yaw/2). |
There was a problem hiding this comment.
🟡 Warning · Style Consistency — Remove inaccurate quaternion identities
The preceding arbitrary-axis rotation noise changes x and y, so they do not generally equal the stated yaw terms. Remove the redundant index narration and false identities, or state only the projection's intent.
| ) | ||
| self.noisy_fingertip_quat[:, ::3].zero_() | ||
| # Zero z (idx 2) and w (idx 3) in XYZW format, preserving x=cos(yaw/2) and y=-sin(yaw/2). | ||
| self.noisy_fingertip_quat[:, 2:4].zero_() |
There was a problem hiding this comment.
🟡 Warning · Implementation — Add the package changelog fragment
This isaaclab_tasks behavior fix has no required changelog fragment, leaving the correction out of the package changelog. Add a bug-fix fragment under source/isaaclab_tasks/changelog.d/.
Signed-off-by: Angus Forbes <aforbes@nvidia.com>
Confidence Score: 4/5
[Medium impact] The change reaches Forge task observations and angular-velocity estimates. The quaternion slice is correct, but the claimed yaw velocity fix needs to be completed before merging. Findings
SummaryUpdates
Reviews (1) · Last reviewed commit: "Fix XYZW quaternion zeroing slice in For..." · Reviewed by Greptile |
cccd871 to
7925a92
Compare
| ) | ||
| self.noisy_fingertip_quat[:, ::3].zero_() | ||
| # Zero z (idx 2) and w (idx 3) in XYZW format, preserving x=cos(yaw/2) and y=-sin(yaw/2). | ||
| self.noisy_fingertip_quat[:, 2:4].zero_() |
There was a problem hiding this comment.
The slice fixes the quaternion observation, but it does not restore yaw velocity. super()._compute_intermediate_values(dt) replaces prev_fingertip_quat with the current clean quaternion before this line runs. The later calculation compares the current noisy orientation against the current clean orientation, not the previous step.
With noise disabled and a downward-facing gripper, ee_angvel_fd therefore remains zero during yaw motion. Keep a separate previous noisy quaternion, or save it before calling the superclass.
Signed-off-by: Angus Forbes <aforbes@nvidia.com>
Summary
In
source/isaaclab_tasks/isaaclab_tasks/contrib/forge/forge_env.py(line 82 onmain),ForgeEnv._compute_intermediate_values()zeroes indices[0, 3]viaself.noisy_fingertip_quat[:, ::3].zero_(). That slice is a leftover from the pre-3.0 WXYZ convention and zeroesxandwinstead ofzandwunder Isaac Lab 3.0's XYZW layout. Replacing[:, ::3].zero_()with[:, 2:4].zero_()restores the intended XYZW yaw projection ofnoisy_fingertip_quat(unit norm in the noiseless limit and yaw-sign observability underflip_quats).Scope note: this PR fixes only the
noisy_fingertip_quatXYZW slice. The separate pre-existing history-overwrite bug wheresuper()._compute_intermediate_values(dt)overwritesprev_fingertip_posandprev_fingertip_quatbeforeForgeEnvcomputesee_linvel_fdandee_angvel_fdis tracked in #8874 and intentionally left out of scope here.Type of change
Root Cause and Upstream Comparison
When
ForgeEnvwas migrated from WXYZ[w, x, y, z]to XYZW[x, y, z, w](PR #4558), neighboring quaternion operations were updated (rot_diff_quat[:, 3]on line 91,identity_quat = [0.0, 0.0, 0.0, 1.0]on line 106), but the projection slice kept[0, 3]rewritten as::3.Isaac Lab v2.3.0:direct/forge/forge_env.py:77usedself.noisy_fingertip_quat[:, [0, 3]] = 0.0(WXYZ, zeroingwandz).Isaac Lab main:contrib/forge/forge_env.py:82usesself.noisy_fingertip_quat[:, ::3].zero_()(XYZW, zeroingxandw).Noiseless Analytical Impact
For a noiseless downward-facing Franka end-effector (
q_180x = [1, 0, 0, 0]in XYZW) followed by bolt-frame yawpsi(q_z(psi) = [0, 0, sin(psi/2), cos(psi/2)]), the XYZW product isq = [cos(psi/2), -sin(psi/2), 0, 0].q[:, ::3].zero_()dropsx = cos(psi/2), leaving[0, -sin(psi/2), 0, 0]with norm|sin(psi/2)|(collapsing to[0, 0, 0, 0]atyaw = 0).flip_quats(noiseless limit): before the fix,q(-psi) = -q(+psi), so random sign flips (flip_quats in {-1, +1}) make+psiand-psiindistinguishable; afterq[:, 2:4].zero_(),x * y = -0.5 * sin(psi)is sign-flip invariant.Verification
A standalone reproducer checks noiseless norm preservation across
[0, 30, 60, 90, 120, 180]deg,+yawvs-yawseparability underflip_quats, and scans all 7 Python files incontrib/forge/for stale WXYZ slices. On a local CPU host without PyTorch installed, the reproducer executes the same XYZW Hamilton-product math on NumPy (python3 -W error):Equivalent PyTorch unit-test check for Isaac Lab environments:
We also verified inside a live Isaac Lab 3.0.0 container on
IsaacContrib-Forge-PegInsert-Directat reset (yaw ~ 0 deg) that the patched slice preservesq_norm = 1.0000with|q| = [1.0000, 0.0003, 0.0000, 0.0000].Audit of
contrib/forge/andcontrib/factory/contrib/forge/(7 Python files):forge_env.py:82(self.noisy_fingertip_quat[:, ::3].zero_()) is the sole remaining stale WXYZ quaternion index slice.contrib/factory/(7 Python files): all quaternion literals and indices are consistent with XYZW (rot_diff_quat[:, 3],fingertip_midpoint_quat_norm[:, 3], identity[0.0, 0.0, 0.0, 1.0], andflip_z_quat = [0.0, 1.0, 0.0, 0.0]).Observational Context
In an unmodified Isaac Lab 3.0.0 NutThread diagnostic across 1,024 evaluation episodes (3.71% success rate, 75.7% engagement), all 38 successes clustered around
yaw = -55 degwhile all 737 engaged-but-unthreaded failures clustered aroundyaw = +120 deg. This is observational diagnostic data only and does not establish training causality on its own; paired from-scratch A/B training runs are in progress and results will be posted in a follow-up comment once complete.Checklist
pre-commitchecks withuv run isaaclab --formatsource/<pkg>/changelog.d/for every touched package (do not editCHANGELOG.rstor bump package versions; CI handles that)CONTRIBUTORS.mdor my name already exists there