Skip to content

Tune Newton MJWarp locomotion environments - #6861

Open
ooctipus wants to merge 8 commits into
isaac-sim:developfrom
ooctipus:feat/locomotion_sim_to_sim_tunning
Open

Tune Newton MJWarp locomotion environments#6861
ooctipus wants to merge 8 commits into
isaac-sim:developfrom
ooctipus:feat/locomotion_sim_to_sim_tunning

Conversation

@ooctipus

@ooctipus ooctipus commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

Description

This PR tunes the Newton MJWarp preset used by locomotion velocity environments to improve rough-terrain contact stability as part of sim-to-sim policy transfer work.

The changes:

  • Increase MJWarp solver capacities from njmax=200 and nconmax=100 to njmax=1000 and nconmax=300.
  • Use two simulation substeps and explicit contact parameters (margin=0.0, ke=160000.0, and kd=1100.0).
  • Scale rigid_contact_max with nconmax * num_envs so contact allocation follows the environment count.
  • Raise the ANYmal-D initial root height to 0.65 m and remove its model-specific shape-margin override.
  • Add body_lin_vel_out_of_manual_limit and terminate locomotion episodes when any robot body exceeds 20 m/s.

No new dependencies are required.

Performance impact

Increasing num_substeps from 1 to 2 costs approximately 8% performance. This tradeoff is intentional to improve simulation stability.

Type of change

  • Bug fix (non-breaking change)
  • New feature (non-breaking reusable termination term)
  • Breaking change
  • Documentation update

Validation

  • uv run python tools/changelog/cli.py check develop
  • uv run isaaclab -f
  • Measured the substep change at approximately 8% performance cost
  • Added dedicated regression tests

Screenshots

Not applicable.

Checklist

  • I have read and understood the contribution guidelines
  • I have run the pre-commit checks
  • No separate documentation changes are required
  • My changes generate no new pre-commit warnings
  • I have added a changelog fragment for every touched package
  • My name already exists in CONTRIBUTORS.md

@ooctipus
ooctipus requested a review from a team August 3, 2026 10:55
@github-actions github-actions Bot added the isaac-lab Related to Isaac Lab team label Aug 3, 2026
@greptile-apps

greptile-apps Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR retunes Newton MJWarp contact and solver settings for velocity locomotion, adjusts AnymalD initialization, and adds a maximum body-speed termination.

  • Expands Newton solver/contact capacities and doubles physics substeps.
  • Replaces the shared rough-terrain shape margin with zero and adds contact stiffness/damping.
  • Adds a termination when any robot body exceeds 20 m/s.
  • Raises AnymalD's initial base position from 0.60 m to 0.65 m.

Confidence Score: 4/5

The PR should not merge until the nonzero Newton rough-terrain contact margin is restored or replaced with robot-specific margins that preserve stable triangle-mesh contact.

The shared configuration now applies a zero collision margin to Newton rough-terrain robots despite the prior documented requirement for nonzero margins, and its newly explicit contact capacity becomes stale when supported configuration paths change the environment count.

Files Needing Attention: source/isaaclab_tasks/isaaclab_tasks/core/velocity/velocity_env_cfg.py and source/isaaclab_tasks/isaaclab_tasks/core/velocity/config/anymal_d/rough_env_cfg.py

Important Files Changed

Filename Overview
source/isaaclab/isaaclab/envs/mdp/init.pyi Exposes the new body-speed termination through the MDP stub without introducing an import mismatch.
source/isaaclab/isaaclab/envs/mdp/terminations.py Adds a correctly shaped per-environment termination that checks all selected bodies against a speed threshold.
source/isaaclab_tasks/isaaclab_tasks/core/velocity/config/anymal_d/rough_env_cfg.py Raises AnymalD's spawn height and removes its dedicated Newton margin override, contributing to the zero-margin contact regression.
source/isaaclab_tasks/isaaclab_tasks/core/velocity/velocity_env_cfg.py Retunes shared Newton physics but removes the required rough-terrain contact margin and caches contact capacity before supported environment-count overrides.

Reviews (1): Last reviewed commit: "fix locomotion" | Re-trigger Greptile

# terrain — without it, non-AnymalD robots fail to learn stable contact
# on triangle-mesh terrain. See isaaclab_newton 0.5.22 changelog.
default_shape_cfg=NewtonShapeCfg(margin=0.01),
default_shape_cfg=NewtonShapeCfg(margin=0.0, ke=160000.0, kd=1100.0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Zero margin breaks terrain contact

When inherited rough-terrain tasks run with the newton_mjwarp preset, this shared zero margin removes the nonzero margin required for stable triangle-mesh contact, causing affected robots to lose contact stability and fail to learn rough-terrain locomotion. It also combines with the removed AnymalD override to discard that robot's separately tuned margin.

Knowledge Base Used: isaaclab_tasks: Task Registration and Organization

self.sim.render_interval = self.decimation
self.sim.physics_material = self.scene.terrain.physics_material
newton = self.sim.physics.newton_mjwarp
newton.collision_cfg.rigid_contact_max = newton.solver_cfg.nconmax * self.scene.num_envs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Contact capacity becomes stale

rigid_contact_max is calculated from the construction-time environment count, but play mode and CLI/Hydra overrides change scene.num_envs afterward without recalculating it. This leaves play mode with a substantially oversized contact allocation and larger runs with a contact budget that no longer matches the requested number of environments.

Knowledge Base Used: isaaclab_tasks: Task Registration and Organization

@isaaclab-review-bot isaaclab-review-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Isaac Lab Review Bot

The PR adds a public body-speed termination and retunes the shared Newton/MJWarp rough-locomotion configuration. Before merge, the shared zero-margin tuning should be scoped or justified against the documented dependency of other robots, contact-buffer sizing must account for the final environment count, public API documentation needs parameter units, and both touched packages need changelog fragments.

  • Design and architecture: The termination is appropriately placed with the existing manual-limit terms. However, the zero-margin contact retune is applied through the shared RoughPhysicsCfg even though the removed comment documents that non-AnymalD rough-terrain tasks rely on the previous margin; the robot-specific adjustment is limited to AnymalD.
  • API: The new symbol is exported through the MDP API and follows the existing naming convention. Its public docstring does not document max_speed in m/s or describe its parameters in the required Google-style Args section. The new API and task behavior also lack the required per-package changelog fragments.
  • Implementation: The termination correctly computes per-body linear speed and reduces violations across selected bodies. However, rigid_contact_max is calculated during post-initialization from the default scene.num_envs, so later CLI/Hydra environment-count overrides leave the buffer over- or under-sized.

Significant concerns. Posted 4 actionable findings inline.

Automated review; human maintainers own approval decisions.

)


def body_lin_vel_out_of_manual_limit(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning · Implementation — Missing changelog fragments for touched packages

Repository rules require one fragment per touched package under source/<pkg>/changelog.d/. This PR touches isaaclab (new exported body_lin_vel_out_of_manual_limit) and isaaclab_tasks (physics preset retune, new body_speed termination, AnymalD init pose) but adds none, so these user-visible changes will be omitted from the compiled changelog. Add an Added fragment for the termination and a Changed fragment for the locomotion config updates.

# terrain — without it, non-AnymalD robots fail to learn stable contact
# on triangle-mesh terrain. See isaaclab_newton 0.5.22 changelog.
default_shape_cfg=NewtonShapeCfg(margin=0.01),
default_shape_cfg=NewtonShapeCfg(margin=0.0, ke=160000.0, kd=1100.0),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning · Design Architecture — Shared preset drops margin other robots rely on

RoughPhysicsCfg is inherited by every rough-terrain velocity task, not only AnymalD. The comment deleted from these exact lines stated the 1 cm margin was required for non-AnymalD robots to learn stable contact on triangle-mesh terrain, and the AnymalD-specific override was removed in the same change. Setting margin=0.0 (plus new ke/kd) in the shared preset therefore regresses the other inheriting configs. Keep the shared default and scope the retune to the AnymalD config.

self.sim.render_interval = self.decimation
self.sim.physics_material = self.scene.terrain.physics_material
newton = self.sim.physics.newton_mjwarp
newton.collision_cfg.rigid_contact_max = newton.solver_cfg.nconmax * self.scene.num_envs

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Warning · Implementation — Contact buffer sized from default num_envs

rigid_contact_max is computed in __post_init__, which runs at config construction while scene.num_envs is still the class default (4096). CLI/Hydra --num_envs overrides are applied to the instantiated config afterwards and do not re-run __post_init__, so the buffer stays at 300*4096 regardless: heavily over-allocated for small runs and undersized above 4096 envs. Derive this where num_envs is final.

def body_lin_vel_out_of_manual_limit(
env: ManagerBasedRLEnv, max_speed: float, asset_cfg: SceneEntityCfg = SceneEntityCfg("robot")
) -> torch.Tensor:
"""Terminate when any of the asset's bodies moves faster than the provided limit."""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Suggestion · Api — Docstring lacks Args and SI unit

Public API docstrings must be Google-style with an Args: section and inline SI units for physical quantities. This newly exported termination documents neither max_speed ([m/s]) nor asset_cfg, so callers cannot tell how the threshold is interpreted. Add an Args: block using name: description form and annotate the speed unit.

@ooctipus ooctipus changed the title Tunning newton mjwarp locomotion Tune Newton MJWarp locomotion environments Aug 3, 2026
Record the new MDP termination and Newton locomotion tuning. Apply Ruff formatting to the ANYmal-D configuration so the required PR checks pass.
@ooctipus
ooctipus force-pushed the feat/locomotion_sim_to_sim_tunning branch from 285ec69 to 0c20987 Compare August 4, 2026 09:29

@AntoineRichard AntoineRichard left a comment

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.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

isaac-lab Related to Isaac Lab team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants