Guard set_merge_fixed_ignore_inertia for Isaac Sim version compatibility#6005
Guard set_merge_fixed_ignore_inertia for Isaac Sim version compatibility#6005Isk5434 wants to merge 1 commit into
Conversation
import_config.set_merge_fixed_ignore_inertia is not available on all Isaac Sim URDF importer versions. Calling it unconditionally raises AttributeError during URDF import on those builds. Guard the call with hasattr; when the setter is absent the behavior matches the importer default, so this is safe and restores URDF import across versions. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Signed-off-by: Isk5434 <249087850+Isk5434@users.noreply.github.com>
Greptile SummaryThis PR guards the
Confidence Score: 4/5Safe to merge; the change only adds a compatibility guard around a single setter call and does not alter behavior on Isaac Sim builds where the method exists. On older Isaac Sim builds that lack set_merge_fixed_ignore_inertia, the importer's compiled-in default will be used instead of the user's configured value. The PR assumes that default matches the intended behavior, but this is not verified — users with merge_fixed_joints=True on older builds may silently get different fixed-joint inertia handling than on newer builds, with no log message to indicate why. source/isaaclab/isaaclab/sim/converters/urdf_converter.py — consider adding a log warning in the fallback branch so users on older Isaac Sim builds are informed that fixed-joint inertia behavior may differ. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[_create_urdf_import_config] --> B[set_merge_fixed_joints]
B --> C{hasattr set_merge_fixed_ignore_inertia?}
C -- Yes: newer Isaac Sim --> D[set_merge_fixed_ignore_inertia]
C -- No: older Isaac Sim --> E[Skip — use importer default]
D --> F[set_fix_base / other physics settings]
E --> F
Reviews (1): Last reviewed commit: "Guard set_merge_fixed_ignore_inertia for..." | Re-trigger Greptile |
| if hasattr(import_config, "set_merge_fixed_ignore_inertia"): | ||
| import_config.set_merge_fixed_ignore_inertia(self.cfg.merge_fixed_joints) |
There was a problem hiding this comment.
Silent version fallback could mask behavior differences
When set_merge_fixed_ignore_inertia is absent, the importer silently uses whatever its compiled-in default is for that setting. If a user sets merge_fixed_joints=True and is on an older Isaac Sim build, the behavior will differ from a newer build without any indication — potentially causing hard-to-diagnose articulation issues. A one-line carb.log_warn (or omni.log.warn) here would make the version difference visible in the output log, helping users on older builds understand why their fixed-joint inertia handling differs.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Review Summary
This PR adds a hasattr guard around import_config.set_merge_fixed_ignore_inertia(...) to prevent AttributeError on Isaac Sim versions where this method doesn't exist. The fix is minimal, targeted, and the fallback behavior (method absent → importer uses its default) is safe.
Overall: Looks good with minor suggestions.
Findings
1. 🟡 Consider logging when the method is unavailable
When set_merge_fixed_ignore_inertia is absent, the code silently skips it. This is fine for correctness, but a debug/warning log would help developers understand why behavior differs across Isaac Sim versions.
Suggestion:
if hasattr(import_config, "set_merge_fixed_ignore_inertia"):
import_config.set_merge_fixed_ignore_inertia(self.cfg.merge_fixed_joints)
else:
import omni.log
omni.log.warn(
"ImportConfig does not have 'set_merge_fixed_ignore_inertia'. "
"Skipping — the importer will use its default behavior."
)2. 🟡 The guarded value reuses merge_fixed_joints — intentional but worth a comment
The call passes self.cfg.merge_fixed_joints (not a dedicated merge_fixed_ignore_inertia config field). Based on the class docstring explaining Isaac Sim 5.1's changed merge behavior, this coupling appears intentional — when merging fixed joints, you also want to ignore inertia to preserve legacy behavior.
However, a brief inline comment explaining why the same config flag drives both settings would help future maintainers:
# When merge_fixed_joints is enabled, also ignore inertia during merge
# to preserve pre-5.1 behavior (links with inertia still get merged).
if hasattr(import_config, "set_merge_fixed_ignore_inertia"):
import_config.set_merge_fixed_ignore_inertia(self.cfg.merge_fixed_joints)3. 🟢 Version-pinning context validates the approach
The converter already pins to isaacsim.asset.importer.urdf-2.4.31 on Isaac Sim ≥5.1 (lines 67–70). The hasattr guard adds defense-in-depth for environments where the pinned version still lacks the method (e.g., older Isaac Sim builds < 5.1 that don't have this API at all). This is sound.
4. 🔵 Minor: no test coverage for the guarded path
There's no unit test verifying that _get_urdf_import_config() succeeds when the ImportConfig object lacks set_merge_fixed_ignore_inertia. A simple mock-based test could guard against regressions:
def test_urdf_import_config_without_merge_fixed_ignore_inertia(monkeypatch):
"""Verify graceful handling when set_merge_fixed_ignore_inertia is unavailable."""
# mock ImportConfig without the method
...This is a nice-to-have given the simplicity of the fix, not a blocker.
Verdict
The fix is correct, minimal, and safe. The hasattr pattern is idiomatic Python for optional API support. The two minor suggestions (logging + comment) would improve observability and maintainability but are not blockers for merge.
Description
UrdfConverter._convert_assetunconditionally callsimport_config.set_merge_fixed_ignore_inertia(...). This method is not present onevery Isaac Sim URDF importer version, so importing a URDF raises
on those builds, breaking asset conversion.
Fix
Call the setter only when it exists:
When the setter is absent, the importer behavior matches its default, so guarding the
call is safe and restores URDF import across Isaac Sim versions.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --format