-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Add Newton physics preset for Anymal-D rough terrain #5096
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -288,7 +288,21 @@ def start_simulation(cls) -> None: | |
| device = PhysicsManager._device | ||
| logger.info(f"Finalizing model on device: {device}") | ||
| cls._builder.up_axis = Axis.from_string(cls._up_axis) | ||
| # Set smaller contact margin for manipulation examples (default 10cm is too large) | ||
|
|
||
| # WAR: USD import produces shapes with zero contact margin. Zero margin causes | ||
| # CCD to use the is_discrete path (epsilon=0), where GJK fails to converge on | ||
| # mesh terrain, producing NaN in body_q/joint_q. | ||
| # TODO: file upstream Newton issue for USD importer zero-margin default. | ||
| contact_margin = 0.01 | ||
| n_margin_fixed = 0 | ||
| for i in range(len(cls._builder.shape_margin)): | ||
| if cls._builder.shape_margin[i] == 0.0: | ||
| cls._builder.shape_margin[i] = contact_margin | ||
| n_margin_fixed += 1 | ||
| if n_margin_fixed > 0: | ||
| n_total = len(cls._builder.shape_margin) | ||
| logger.info(f"Set contact margin={contact_margin} on {n_margin_fixed}/{n_total} shapes with zero margin") | ||
|
|
||
| with Timer(name="newton_finalize_builder", msg="Finalize builder took:"): | ||
| cls._model = cls._builder.finalize(device=device) | ||
| cls._model.set_gravity(cls._gravity_vector) | ||
|
|
@@ -398,7 +412,12 @@ def _initialize_contacts(cls) -> None: | |
| if cls._needs_collision_pipeline: | ||
| # Newton collision pipeline: create pipeline and generate contacts | ||
| if cls._collision_pipeline is None: | ||
| cls._collision_pipeline = CollisionPipeline(cls._model, broad_phase="explicit") | ||
| # WAR: default max_triangle_pairs (1M) overflows with mesh terrain at | ||
| # 4096+ envs (~2M triangle pairs). Overflow silently drops contacts. | ||
| # No upstream issue tracking auto-sizing yet. | ||
| cls._collision_pipeline = CollisionPipeline( | ||
| cls._model, broad_phase="explicit", max_triangle_pairs=2_000_000 | ||
| ) | ||
|
Comment on lines
+418
to
+420
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider driving this from |
||
| if cls._contacts is None: | ||
| cls._contacts = cls._collision_pipeline.contacts() | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -42,10 +42,10 @@ def run(self): | |||||
| EXTRAS_REQUIRE = { | ||||||
| "all": [ | ||||||
| "prettytable==3.3.0", | ||||||
| "mujoco==3.5.0", | ||||||
| "mujoco-warp==3.5.0.2", | ||||||
| "mujoco==3.6.0", | ||||||
| "mujoco-warp==3.6.0", | ||||||
| "PyOpenGL-accelerate==3.1.10", | ||||||
| "newton==1.0.0", | ||||||
| "newton @ git+https://github.com/newton-physics/newton.git@141baffff9", | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The newton package is pinned to a 9-character abbreviated SHA (
Suggested change
(Replace the long hash above with the actual full SHA; verify with |
||||||
| ], | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop unconditionally patches every shape whose margin is exactly
0.0across the entire model, including non-locomotion tasks (e.g. manipulation). For tasks where zero contact margin is intentional or where a different default is desirable, this silently changes behavior.The comment in the removed line mentioned "manipulation examples" as the motivation for the old margin logic; applying
0.01across the board may be too broad. At minimum, consider making the fallback value (and whether to apply it at all) configurable viaNewtonCfg, similar to howmax_triangle_pairscould be:This keeps the workaround available while letting tasks that don't need it (or prefer a different value) avoid the side-effect.