Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Fixed
^^^^^

* Fixed backend factory resolution raising before simulator initialization by using the team-confirmed ``newton``
fallback when no ``SimulationContext`` exists.
9 changes: 6 additions & 3 deletions source/isaaclab/isaaclab/utils/backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ def register(cls, name: str, sub_class) -> None:
def _get_backend(cls, *args, **kwargs) -> str:
"""Return active backend name for this factory.

Falls back to ``"physx"`` for backward compatibility when no simulation
context is initialized yet.
Falls back to ``"newton"`` when no simulation context is initialized yet.
"""
# Import lazily to avoid import cycles at module load time.
from isaaclab.sim.simulation_context import SimulationContext

manager_name = SimulationContext.instance().physics_manager.__name__.lower()
sim_context = SimulationContext.instance()
if sim_context is None:
return "newton"

manager_name = sim_context.physics_manager.__name__.lower()
if manager_name.startswith("newton"):
return "newton"
if manager_name.startswith("ovphysx"):
Expand Down
17 changes: 17 additions & 0 deletions source/isaaclab/test/utils/test_backend_fallback.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause

import pytest

from isaaclab.sim.simulation_context import SimulationContext
from isaaclab.utils.backend_utils import FactoryBase

pytestmark = pytest.mark.unit


def test_factory_backend_falls_back_to_newton_without_simulation_context(monkeypatch):
monkeypatch.setattr(SimulationContext, "_instance", None)

assert FactoryBase._get_backend() == "newton"
Loading