Skip to content

[BUG FIX] Warn about CoacdOptions.pca=True misalignment (closes #2747)#2757

Open
voidborne-d wants to merge 1 commit intoGenesis-Embodied-AI:mainfrom
voidborne-d:fix/coacd-pca-misalignment-warning
Open

[BUG FIX] Warn about CoacdOptions.pca=True misalignment (closes #2747)#2757
voidborne-d wants to merge 1 commit intoGenesis-Embodied-AI:mainfrom
voidborne-d:fix/coacd-pca-misalignment-warning

Conversation

@voidborne-d
Copy link
Copy Markdown

Summary

Fixes #2747. When gs.options.CoacdOptions(pca=True) is used, upstream CoACD applies a PCA transformation to the input mesh but never transforms the decomposed convex hulls back. The result: collision bodies are misaligned with the original mesh, and stable scenes collapse on contact (see the screenshots in #2747).

This is a known upstream issue: SarahWeiii/CoACD#100. Genesis cannot fix it without a CoACD release, but we can save users from silently hitting it.

Change

CoacdOptions now has a Pydantic model_validator that emits a clear warning when pca=True is set, pointing at the upstream issue and suggesting pca=False as the workaround. Default-constructed options (pca=False) stay silent.

I went with a warning rather than the hard assert pca=False the issue suggests because it preserves backward-compatible construction (users may want to opt into the buggy behaviour to keep an old hull cache stable, or run experiments with the upcoming CoACD fix), and matches the soft-warning convention used elsewhere in genesis/options/ (e.g. the deprecation warnings in morphs.py).

Diff

  • genesis/options/misc.py — add model_validator(mode="after") that calls gs.logger.warning(...) when self.pca is True. Imports model_validator, Self, and genesis as gs (the validator pattern already used by morphs.py:106).
  • tests/test_misc.py — two @pytest.mark.required unit tests:
    • test_coacd_options_warn_when_pca_true asserts gs.logger.warning is called once with "pca=True" and the upstream issue URL.
    • test_coacd_options_no_warning_for_pca_false_default asserts CoacdOptions() and CoacdOptions(pca=False) are both silent.

The mocking pattern matches tests/test_utils.py::test_warn_once_logs_once.

Test

Pre-fix repro: stash the CoacdOptions validator, run the new tests → both fail (no warning fires for pca=True). Restore the validator → 2/2 pass.

ruff format --check and ruff check clean on both touched files.

I couldn't run the full pytest -m required suite locally because Genesis depends on a custom quadrants package and CUDA-enabled torch that I don't have on this machine; the CI runner will catch any regression. The new tests are entirely about the option-level validator and don't touch the simulator stack.

Notes

  • Behaviour change is strictly additive — no existing call site changes, no API breakage. Default pca=False users see no log noise.
  • I considered using the codebase's warn_once helper from genesis.utils.warnings to dedupe across many CoacdOptions(pca=True) constructions, but that helper is not currently used in genesis/options/ and would silently suppress the warning across separate experiments. A per-construction warning matches Pydantic's per-instance validator semantics.

Generated with Claude Code.

…died-AI#2747)

Upstream CoACD applies a PCA transformation to the input mesh during
convex decomposition but does not transform the resulting hulls back,
so collision bodies end up misaligned with the original mesh and
otherwise stable scenes collapse on contact.

Add a model_validator on CoacdOptions that emits a clear warning
referencing the upstream issue (SarahWeiii/CoACD#100) so users running
into the misalignment know to set pca=False until a fix lands upstream.
The flag still works the same way — this is a soft warning, not a hard
assertion, since users may legitimately want to opt into the buggy
behaviour for compatibility with old caches.
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1f06b7b5b7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread genesis/options/misc.py
# decomposed convex hulls back, so the resulting collision body is misaligned with the
# original mesh. See https://github.com/SarahWeiii/CoACD/issues/100.
if self.pca:
gs.logger.warning(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Guard logger access in CoacdOptions validator

CoacdOptions(pca=True) now calls gs.logger.warning(...) unconditionally, but gs.logger is initialized as None until gs.init() runs (see genesis/__init__.py), so constructing this options object before initialization will raise an AttributeError instead of emitting the intended warning. This is a regression for workflows that build options upfront and initialize Genesis later; the warning path should tolerate an uninitialized logger.

Useful? React with 👍 / 👎.

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.

[Bug]: [CoacdOptions] Setting CoACDOptions with PCA=True causes collision detection collapse

1 participant