[Newton] Refactors Simulation Manager and Context#4646
[Newton] Refactors Simulation Manager and Context#4646ooctipus merged 4 commits intoisaac-sim:dev/newtonfrom
Conversation
e05e458 to
920e51d
Compare
| @@ -0,0 +1,170 @@ | |||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | |||
There was a problem hiding this comment.
was this from Piotr's changes?
| def get_metadata(self) -> dict[str, Any]: | ||
| return dict(self._metadata) | ||
|
|
||
| def get_transforms(self) -> dict[str, Any] | None: |
There was a problem hiding this comment.
would it help with the merge if we also implement this first?
There was a problem hiding this comment.
I got the newton scene data provider kind of working in dev/newton, but I thought I'd like to reserve the implementation detail to @matthewtrepte and i might be beneficial for him to directly work on develop and not worry about dev/newton. Maybe
There was a problem hiding this comment.
Look great! Thanks @ooctipus! I would start moving some files about in the correct modules / package just to make sure we can make things work. We'd need to separate the PhysX / Newton Managers and move them to their respective modules. Same with the visualizers, scene data providers etc...
Greptile SummaryRefactored simulation architecture to extract physics backend logic from Key architectural changes:
Impact:
Confidence Score: 4/5
Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class SimulationContext {
+SimulationCfg cfg
+PhysicsManager physics_manager
+SceneDataProvider scene_data_provider
+initialize_visualizers()
+reset()
+step()
+forward()
}
class PhysicsManager {
<<abstract>>
+initialize(sim_context)
+reset(soft)
+step()
+forward()
+register_callback(callback, event, order)
+deregister_callback(id)
}
class PhysxManager {
+AnimationRecorder _anim_recorder
+_warmup_and_create_views()
+_configure_physics()
+step()
}
class NewtonManager {
+ModelBuilder _builder
+Model _model
+State _state_0
+initialize_solver()
+step()
}
class SceneDataProvider {
<<interface>>
+get_transforms()
+get_velocities()
+get_newton_model()
+get_usd_stage()
+get_metadata()
}
class PhysxSceneDataProvider {
+_stage
+_physics_sim_view
+_newton_model
+get_transforms()
+get_velocities()
}
class NewtonSceneDataProvider {
+_model
+_state
+get_transforms()
+get_newton_model()
}
class Visualizer {
<<abstract>>
+SceneDataProvider scene_data_provider
+initialize(provider)
+step(dt, state)
+close()
}
class KitVisualizer {
+_viewport_window
+step(dt, state)
}
class NewtonVisualizer {
+_window
+step(dt, state)
}
class RerunVisualizer {
+_rec
+step(dt, state)
}
SimulationContext --> PhysicsManager : uses
SimulationContext --> SceneDataProvider : creates
SimulationContext --> Visualizer : manages
PhysicsManager <|-- PhysxManager : extends
PhysicsManager <|-- NewtonManager : extends
SceneDataProvider <|.. PhysxSceneDataProvider : implements
SceneDataProvider <|.. NewtonSceneDataProvider : implements
Visualizer <|-- KitVisualizer : extends
Visualizer <|-- NewtonVisualizer : extends
Visualizer <|-- RerunVisualizer : extends
Visualizer --> SceneDataProvider : uses
Last reviewed commit: d291a11 |
d291a11 to
a7281e7
Compare
a7281e7 to
3214457
Compare
## Summary Fix incorrect attribute name `contact_margin` → `gap` on Newton `ShapeConfig` in `NewtonManager.create_builder()`. Newton PR #1732 renamed `contact_margin` to `gap` (broad-phase AABB expansion). The IsaacLab code was never updated, creating a dead attribute that Python silently accepted. The intended 1 cm default shape gap was never applied. ## Newton PR #1732 rename mapping | Old field | New field | Semantics | |-----------|-----------|-----------| | `thickness` | `margin` | Shape surface extension (affects contact forces) | | `contact_margin` | **`gap`** | Broad-phase AABB expansion (detection range only) | | `rigid_contact_margin` | `rigid_gap` | Builder-level default gap (already 0.1) | ## Timeline | Date | Newton | IsaacLab | `contact_margin` valid? | |------|--------|----------|------------------------| | Feb 19 | pin: `51ce35e` (has `contact_margin`) | #4646 adds `contact_margin = 0.01` | Yes | | Feb 24 | **PR #1732 renames `contact_margin` → `gap`** | — | — | | Mar 2 | pin updated to `v0.2.3` (after rename) | #4761 keeps `contact_margin` | **No — broken** | | Mar 9 | — | #4883 removes the line | Removed | | Apr 13 | — | #4822 re-adds `contact_margin` | **No — still broken** | ## Ablation: gap vs margin We conducted an ablation study to understand the impact. Note: `margin` (shape surface extension) is a different field from `gap` (broad-phase range). The original code intended to set `gap`, but setting `margin` also has a significant positive effect on training for rough terrain locomotion. | Setting | `gap` | `margin` | Go1 Reward (300 iter) | Effect | |---------|-------|----------|----------------------|--------| | Dead field (baseline) | 0.1 (default) | 0.0 | ~1.0 | — | | `gap=0.01` only | 0.01 | 0.0 | 0.66 | No training improvement | | `margin=0.01` only | 0.1 (default) | 0.01 | 18.77 | Major improvement | | `gap=0.01` + `margin=0.01` | 0.01 | 0.01 | 16.54 | Similar to margin-only | **This PR fixes the correct field migration** (`contact_margin` → `gap`). The `margin` setting for rough terrain contact quality will be addressed separately in the rough terrain env PR (#5248) via a new `default_shape_margin` config field on `NewtonCfg`. ## Test plan - [x] Verified `contact_margin` is not a field on `ShapeConfig` (Newton 1.1.0.dev0) - [x] Verified `gap` is the correct replacement field per Newton PR #1732 - [x] Confirmed by camevor (Newton developer) - [x] Ablation study: gap alone doesn't change training, so existing tests should pass Co-authored-by: Antoine RICHARD <antoiner@nvidia.com>
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