Skip to content

Restore zero-norm rejection in trnorm - #316

Open
kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-trnorm-degenerate-nov20
Open

kaushikgunasekaren wants to merge 2 commits into
rai-opensource:masterfrom
kaushikgunasekaren:fix-trnorm-degenerate-nov20

Conversation

@kaushikgunasekaren

Copy link
Copy Markdown

Bug

The scalar optimization in #214 removed the zero-norm checks previously performed by unitvec. trnorm() now divides by zero for zero or collinear axes, returning a matrix of NaNs with runtime warnings instead of raising ValueError. Near-zero axes also silently bypass the prior rejection threshold. This propagates through SO3.norm() and SE3.norm().

Change

Check all three computed axis norms against the same 20 * eps threshold used by the previous unitvec implementation, before any division. Keep the scalar arithmetic and valid-input normalization unchanged.

Validation

  • 22 focused regression/control cases: 14 fail before the fix; all 22 pass after it.
  • Zero matrices, collinear axes, zero orientation/approach axes, near-zero norms, both 3x3 and 4x4 inputs, and pose-level callers. Runtime warnings are treated as errors for direct invalid-input calls.
  • Valid drifted rotations match the prior cross-product/unitvec algorithm; orthogonality, determinant, translation and input preservation are checked.
  • Full local suite: 588 passed, 3 skipped, 99 subtests passed (21 warnings), versus 566 passed on unchanged master.
  • Fatal changed-file flake8 and regression-test Black checks pass. Source formatting is kept local to the fix rather than reformatting an unrelated existing expression. Whole-repository fatal lint has two pre-existing undefined-name findings in tests/test_dualquaternion.py.

AI assistance was used for investigation, implementation and tests. Validation is local Python testing only; no hardware validation is claimed.

a_norm = (a0 * a0 + a1 * a1 + a2 * a2) ** 0.5

# Retain the zero-norm checks previously performed by unitvec on each axis.
if not (n_norm > 20 * _eps and o_norm > 20 * _eps and a_norm > 20 * _eps):

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would prefer you add a tol:float =20 parameter rather than hardwiring. We are trying to get rid of hardwired tolerances. Anything calling a function with a tol should also have a tol parameter.

This branch has not been deployed

No deployments
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.

2 participants