Skip to content

Commit e39376f

Browse files
Fix backend factory fallback before simulator initialization
Signed-off-by: Sylvester Kaczmarek <16242628+sylvesterkaczmarek@users.noreply.github.com>
1 parent 3c0694c commit e39376f

3 files changed

Lines changed: 27 additions & 1 deletion

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Fixed
2+
^^^^^
3+
4+
* Fixed backend factory resolution raising before simulator initialization instead of using the documented
5+
``physx`` compatibility fallback when no ``SimulationContext`` exists.

source/isaaclab/isaaclab/utils/backend_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,11 @@ def _get_backend(cls, *args, **kwargs) -> str:
7979
# Import lazily to avoid import cycles at module load time.
8080
from isaaclab.sim.simulation_context import SimulationContext
8181

82-
manager_name = SimulationContext.instance().physics_manager.__name__.lower()
82+
sim_context = SimulationContext.instance()
83+
if sim_context is None:
84+
return "physx"
85+
86+
manager_name = sim_context.physics_manager.__name__.lower()
8387
if manager_name.startswith("newton"):
8488
return "newton"
8589
if manager_name.startswith("ovphysx"):
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
2+
# All rights reserved.
3+
#
4+
# SPDX-License-Identifier: BSD-3-Clause
5+
6+
import pytest
7+
8+
from isaaclab.sim.simulation_context import SimulationContext
9+
from isaaclab.utils.backend_utils import FactoryBase
10+
11+
pytestmark = pytest.mark.unit
12+
13+
14+
def test_factory_backend_falls_back_to_physx_without_simulation_context(monkeypatch):
15+
monkeypatch.setattr(SimulationContext, "_instance", None)
16+
17+
assert FactoryBase._get_backend() == "physx"

0 commit comments

Comments
 (0)