Repository navigation
Update MJCF converter to support scene import, update urdf cfg - #4826
Conversation
Greptile SummaryThis PR updates the URDF and MJCF converters to work with Isaac Sim 3 by replacing the old multi-step pipeline ( Key changes:
Issues found:
Confidence Score: 2/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[UrdfConverter.__init__] --> B[Set usd_file_name from robot stem]
B --> C[AssetConverterBase.__init__]
C --> D{USD cached?}
D -- Yes --> E[Return cached USD]
D -- No --> F[_convert_asset]
F --> G[_warn_unsupported_features]
G --> H{merge_fixed_joints?}
H -- Yes --> I[XML pre-process: merge fixed joints]
H -- No --> J[Clean output_subdir if exists]
I --> J
J --> K["Build URDFImporterConfig\nurdf_path, usd_path, merge_mesh,\ncollision_from_visuals, collision_type,\nallow_self_collision"]
K --> L["URDFImporter.import_urdf()"]
L --> M{fix_base?}
M -- Yes --> N["_fix_articulation_root_for_fixed_base\nmove ArticulationRootAPI to parent prim"]
M -- No --> O[Cleanup temp merged URDF]
N --> O
P["fix_base world joint\nlink_density\njoint_drive"] -. "NOT forwarded" .-> K
style P fill:#fcc,stroke:#c33
Last reviewed commit: cc0b14a
|
| importer_config = URDFImporterConfig( | ||
| urdf_path=urdf_path, | ||
| usd_path=usd_path, | ||
| merge_mesh=cfg.merge_mesh, | ||
| collision_from_visuals=cfg.collision_from_visuals, | ||
| collision_type=cfg.collision_type, | ||
| allow_self_collision=cfg.self_collision, | ||
| ) | ||
|
|
||
| importer_utils.run_asset_transformer_profile( | ||
| input_stage_path=intermediate_path, | ||
| output_package_root=os.path.normpath(os.path.join(usd_path, robot_name)), | ||
| profile_json_path=asset_structure_profile_json_path, | ||
| ) | ||
| importer = URDFImporter(importer_config) | ||
| usd_path = importer.import_urdf() | ||
|
|
||
| # step 6b: fix ArticulationRootAPI placement for fixed-base articulations. | ||
| # fix ArticulationRootAPI placement for fixed-base articulations. | ||
| # After the asset transformer, ArticulationRootAPI ends up on the root rigid body. | ||
| # Having a FixedJoint on the same rigid body that has ArticulationRootAPI causes | ||
| # PhysX to treat the articulation as a floating-base + constraint (maximal coordinate | ||
| # tree) rather than a fixed-base reduced-coordinate articulation. | ||
| # Moving ArticulationRootAPI to the parent of the root rigid body resolves this. | ||
| if cfg.fix_base: | ||
| final_usd_path = os.path.join(usd_path, robot_name, f"{robot_name}.usda") | ||
| self._fix_articulation_root_for_fixed_base(final_usd_path) | ||
|
|
||
| # step 7: clean up intermediate files | ||
| if os.path.exists(usdex_path): | ||
| shutil.rmtree(usdex_path) | ||
| temp_dir = os.path.dirname(intermediate_path) | ||
| if os.path.exists(temp_dir): | ||
| shutil.rmtree(temp_dir) | ||
| self._fix_articulation_root_for_fixed_base(usd_path) |
There was a problem hiding this comment.
fix_base, link_density, and joint_drive config fields silently ignored
The new URDFImporterConfig construction does not forward three important config parameters:
cfg.fix_base— the_apply_fix_basestatic method (which creates the fixed world joint) is no longer called. Only_fix_articulation_root_for_fixed_baseruns, which movesArticulationRootAPI— but if no fixed joint to the world exists, this post-processing step has no meaningful effect.cfg.link_density—_apply_link_densityis never called, so density values will be silently ignored.cfg.joint_drive—_apply_joint_drivesis never called, so all joint drive configuration (type, target, gains) will be silently ignored.
These methods still exist in the class as dead code. If the new URDFImporter handles these features natively, the corresponding config fields and static methods should be deprecated and removed. If not, they should still be applied after importer.import_urdf(), the same way _fix_articulation_root_for_fixed_base is. Either way this should be explicitly addressed to avoid silent behavior regressions for users who rely on link_density > 0 or joint_drive settings.
| @@ -134,13 +134,13 @@ class NaturalFrequencyGainsCfg: | |||
| collision_from_visuals = False | |||
| """Whether to create collision geometry from visual geometry. Defaults to False.""" | |||
|
|
|||
| collider_type: Literal["convex_hull", "convex_decomposition"] = "convex_hull" | |||
| collision_type: Literal["Convex Hull", "Convex Decomposition"] = "Convex Hull" | |||
There was a problem hiding this comment.
Breaking rename without deprecation path
collider_type was renamed to collision_type (and the value literals changed from "convex_hull" / "convex_decomposition" to "Convex Hull" / "Convex Decomposition"). Any existing user config that sets collider_type="convex_hull" or collider_type="convex_decomposition" will silently stop working. The PR description marks this as a breaking change, but there is no deprecation warning or migration notice in the docstring or changelog entry visible in this diff. Consider adding a deprecation shim (e.g., __post_init__ or a @property) or at minimum updating the changelog and class docstring to make the migration path explicit.
There was a problem hiding this comment.
collider_type is a new term introduced in the develop branch recently, so renaming it is fine. Also this will align with the arg used in mjcf converter cfg and isaac sim urdf / mjcf importers
43e12bd to
623c76f
Compare
|
I asked for default on False for import-physics-scene parameter |
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context.
List any dependencies that are required for this change.
Fixes # (issue)
Type of change
Screenshots
Please attach before and after screenshots of the change if applicable.
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there