Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions scripts/tools/check_instanceable.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,11 @@


import isaacsim.core.utils.prims as prim_utils
from isaacsim.core.api.simulation_context import SimulationContext
from isaacsim.core.cloner import GridCloner
from isaacsim.core.utils.carb import set_carb_setting
from isaacsim.core.utils.stage import get_current_stage

from isaaclab.sim import SimulationCfg, SimulationContext
from isaaclab.utils import Timer
from isaaclab.utils.assets import check_file_path

Expand All @@ -80,9 +80,7 @@ def main():
if not check_file_path(args_cli.input):
raise ValueError(f"Invalid file path: {args_cli.input}")
# Load kit helper
sim = SimulationContext(
stage_units_in_meters=1.0, physics_dt=0.01, rendering_dt=0.01, backend="torch", device="cuda:0"
)
sim = SimulationContext(SimulationCfg(dt=0.01))

# get stage handle
stage = get_current_stage()
Expand Down
44 changes: 22 additions & 22 deletions source/isaaclab/isaaclab/sim/utils/stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@
import contextlib
import logging
import threading
import typing
from collections.abc import Generator
from collections.abc import Callable, Generator, Iterable
from typing import Literal

import carb
import omni
import omni.kit.app
from isaacsim.core.utils import stage as sim_stage
from isaacsim.core.utils.carb import get_carb_setting
from isaacsim.core.version import get_version
from omni.metrics.assembler.core import get_metrics_assembler_interface
from omni.usd.commands import DeletePrimsCommand
Expand All @@ -27,6 +26,7 @@
# _context is a singleton design in isaacsim and for that reason
# until we fully replace all modules that references the singleton(such as XformPrim, Prim ....), we have to point
# that singleton to this _context
# FIXME: remove once split from isaac-sim is completed
sim_stage._context = _context

AXES_TOKEN = {
Expand Down Expand Up @@ -58,7 +58,7 @@ def attach_stage_to_usd_context(attaching_early: bool = False):
If the stage is not in memory or rendering is not enabled, this function will return without attaching.

Args:
attaching_early: Whether to attach the stage to the usd context before stage is created. Defaults to False.
Whether to attach the stage to the usd context before stage is created. Defaults to False.
Copy link
Contributor

Choose a reason for hiding this comment

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

style: parameter name missing in docstring - should be attaching_early: to match codebase standard (see nucleus.py or actuator_base.py for examples)

Suggested change
Whether to attach the stage to the usd context before stage is created. Defaults to False.
attaching_early: Whether to attach the stage to the usd context before stage is created. Defaults to False.

"""

from isaacsim.core.simulation_manager import SimulationManager
Expand All @@ -81,7 +81,7 @@ def attach_stage_to_usd_context(attaching_early: bool = False):

# this carb flag is equivalent to if rendering is enabled
carb_setting = carb.settings.get_settings()
is_rendering_enabled = get_carb_setting(carb_setting, "/physics/fabricUpdateTransformations")
is_rendering_enabled = carb_setting.get("/physics/fabricUpdateTransformations")

# if rendering is not enabled, we don't need to attach it
if not is_rendering_enabled:
Expand Down Expand Up @@ -142,7 +142,7 @@ def use_stage(stage: Usd.Stage) -> Generator[None, None, None]:
In Isaac Sim < 5.0, this is a no-op to maintain compatibility.

Args:
stage: The stage to set temporarily.
The stage to set temporarily.
Copy link
Contributor

Choose a reason for hiding this comment

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

style: parameter name missing - should be stage: to match codebase standard

Suggested change
The stage to set temporarily.
stage: The stage to set temporarily.


Raises:
AssertionError: If the stage is not a USD stage instance.
Expand Down Expand Up @@ -243,7 +243,7 @@ def update_stage() -> None:


# TODO: make a generic util for setting all layer properties
def set_stage_up_axis(axis: str = "z") -> None:
def set_stage_up_axis(axis: Literal["x", "y", "z"] = "z") -> None:
"""Change the up axis of the current stage

Args:
Expand Down Expand Up @@ -271,7 +271,7 @@ def get_stage_up_axis() -> str:
"""Get the current up-axis of USD stage.

Returns:
str: The up-axis of the stage.
The up-axis of the stage.

Example:

Expand All @@ -286,11 +286,11 @@ def get_stage_up_axis() -> str:
return UsdGeom.GetStageUpAxis(stage)


def clear_stage(predicate: typing.Callable[[str], bool] | None = None) -> None:
def clear_stage(predicate: Callable[[str], bool] | None = None) -> None:
"""Deletes all prims in the stage without populating the undo command buffer

Args:
predicate: user defined function that takes a prim_path (str) as input and returns True/False if the prim
predicate: user defined function that takes a prim_path as input and returns True/False if the prim
Copy link
Contributor

Choose a reason for hiding this comment

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

style: parameter name missing - should be predicate: to match codebase standard

Suggested change
predicate: user defined function that takes a prim_path as input and returns True/False if the prim
predicate: user defined function that takes a prim_path as input and returns True/False if the prim

should/shouldn't be deleted. If predicate is None, a default is used that deletes all prims

Example:
Expand Down Expand Up @@ -445,7 +445,7 @@ def create_new_stage() -> Usd.Stage:
"""Create a new stage attached to the USD context.

Returns:
Usd.Stage: The created USD stage.
The created USD stage.

Example:

Expand Down Expand Up @@ -493,13 +493,13 @@ def open_stage(usd_path: str) -> bool:
"""Open the given usd file and replace currently opened stage.

Args:
usd_path (str): Path to the USD file to open.
usd_path: Path to the USD file to open.
Copy link
Contributor

Choose a reason for hiding this comment

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

style: parameter name missing - should be usd_path: to match codebase standard

Suggested change
usd_path: Path to the USD file to open.
usd_path: Path to the USD file to open.


Raises:
ValueError: When input path is not a supported file type by USD.

Returns:
bool: True if operation is successful, otherwise false.
True if operation is successful, otherwise false.

Example:

Expand All @@ -523,14 +523,14 @@ def save_stage(usd_path: str, save_and_reload_in_place=True) -> bool:
"""Save usd file to path, it will be overwritten with the current stage

Args:
usd_path (str): File path to save the current stage to
usd_path: File path to save the current stage to
Copy link
Contributor

Choose a reason for hiding this comment

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

style: parameter name missing - should be usd_path: to match codebase standard

Suggested change
usd_path: File path to save the current stage to
usd_path: File path to save the current stage to

save_and_reload_in_place (bool, optional): use ``save_as_stage`` to save and reload the root layer in place. Defaults to True.

Raises:
ValueError: When input path is not a supported file type by USD.

Returns:
bool: True if operation is successful, otherwise false.
True if operation is successful, otherwise false.

Example:

Expand All @@ -555,7 +555,7 @@ def save_stage(usd_path: str, save_and_reload_in_place=True) -> bool:
return result


def close_stage(callback_fn: typing.Callable | None = None) -> bool:
def close_stage(callback_fn: Callable | None = None) -> bool:
"""Closes the current opened USD stage.

.. note::
Expand All @@ -566,7 +566,7 @@ def close_stage(callback_fn: typing.Callable | None = None) -> bool:
callback_fn: Callback function to call while closing. Defaults to None.

Returns:
bool: True if operation is successful, otherwise false.
True if operation is successful, otherwise false.

Example:

Expand Down Expand Up @@ -597,7 +597,7 @@ def close_stage(callback_fn: typing.Callable | None = None) -> bool:
return result


def traverse_stage(fabric=False) -> typing.Iterable:
def traverse_stage(fabric=False) -> Iterable:
"""Traverse through prims (hidden or not) in the opened Usd stage.

Returns:
Expand Down Expand Up @@ -630,7 +630,7 @@ def is_stage_loading() -> bool:
"""Convenience function to see if any files are being loaded.

Returns:
bool: True if loading, False otherwise
True if loading, False otherwise

Example:

Expand Down Expand Up @@ -723,11 +723,11 @@ def get_next_free_path(path: str, parent: str = None) -> str:
"""Returns the next free usd path for the current stage

Args:
path (str): path we want to check
parent (str, optional): Parent prim for the given path. Defaults to None.
path: path we want to check
parent: Parent prim for the given path. Defaults to None.
Comment on lines +726 to +727
Copy link
Contributor

Choose a reason for hiding this comment

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

style: parameter names missing - should be path: and parent: to match codebase standard

Suggested change
path: path we want to check
parent: Parent prim for the given path. Defaults to None.
path: path we want to check
parent: Parent prim for the given path. Defaults to None.


Returns:
str: a new path that is guaranteed to not exist on the current stage
A new path that is guaranteed to not exist on the current stage

Example:

Expand Down
3 changes: 2 additions & 1 deletion source/isaaclab/isaaclab/ui/widgets/line_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from typing import TYPE_CHECKING

import omni
from isaacsim.core.api.simulation_context import SimulationContext

from isaaclab.sim import SimulationContext

with suppress(ImportError):
# isaacsim.gui is not available when running in headless mode.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from typing import TYPE_CHECKING

import omni.kit.app
from isaacsim.core.api.simulation_context import SimulationContext

from isaaclab.managers import ManagerBase
from isaaclab.sim import SimulationContext
from isaaclab.utils import configclass

from .image_plot import ImagePlot
Expand Down
14 changes: 3 additions & 11 deletions source/isaaclab/test/deps/isaacsim/check_rep_texture_randomizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,27 +47,19 @@

import isaacsim.core.utils.prims as prim_utils
import omni.replicator.core as rep
from isaacsim.core.api.simulation_context import SimulationContext
from isaacsim.core.cloner import GridCloner
from isaacsim.core.objects import DynamicSphere
from isaacsim.core.prims import RigidPrim
from isaacsim.core.utils.viewports import set_camera_view

from isaaclab.sim import SimulationCfg, SimulationContext


def main():
"""Spawn a bunch of balls and randomly change their textures."""

# Load kit helper
sim_params = {
"use_gpu": True,
"use_gpu_pipeline": True,
"use_flatcache": True, # deprecated from Isaac Sim 2023.1 onwards
"use_fabric": True, # used from Isaac Sim 2023.1 onwards
"enable_scene_query_support": True,
}
sim = SimulationContext(
physics_dt=1.0 / 60.0, rendering_dt=1.0 / 60.0, sim_params=sim_params, backend="torch", device="cuda:0"
)
sim = SimulationContext(SimulationCfg())
# Set main camera
set_camera_view([0.0, 30.0, 25.0], [0.0, 0.0, -2.5])

Expand Down
5 changes: 2 additions & 3 deletions source/isaaclab/test/devices/check_keyboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@

import ctypes

from isaacsim.core.api.simulation_context import SimulationContext

from isaaclab.devices import Se3Keyboard, Se3KeyboardCfg
from isaaclab.sim import SimulationCfg, SimulationContext


def print_cb():
Expand All @@ -41,7 +40,7 @@ def quit_cb():

def main():
# Load kit helper
sim = SimulationContext(physics_dt=0.01, rendering_dt=0.01)
sim = SimulationContext(SimulationCfg(dt=0.01))

# Create teleoperation interface
teleop_interface = Se3Keyboard(Se3KeyboardCfg(pos_sensitivity=0.1, rot_sensitivity=0.1))
Expand Down
4 changes: 2 additions & 2 deletions source/isaaclab/test/markers/test_visualization_markers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
import torch

import pytest
from isaacsim.core.api.simulation_context import SimulationContext

import isaaclab.sim as sim_utils
from isaaclab.markers import VisualizationMarkers, VisualizationMarkersCfg
from isaaclab.markers.config import FRAME_MARKER_CFG, POSITION_GOAL_MARKER_CFG
from isaaclab.sim import SimulationCfg, SimulationContext
from isaaclab.sim.utils import stage as stage_utils
from isaaclab.utils.math import random_orientation
from isaaclab.utils.timer import Timer
Expand All @@ -33,7 +33,7 @@ def sim():
# Open a new stage
stage_utils.create_new_stage()
# Load kit helper
sim_context = SimulationContext(physics_dt=dt, rendering_dt=dt, backend="torch", device="cuda:0")
sim_context = SimulationContext(SimulationCfg(dt=dt))
yield sim_context
# Cleanup
sim_context.stop()
Expand Down
4 changes: 2 additions & 2 deletions source/isaaclab/test/sensors/check_contact_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
import torch

import isaacsim.core.utils.prims as prim_utils
from isaacsim.core.api.simulation_context import SimulationContext
from isaacsim.core.cloner import GridCloner
from isaacsim.core.utils.viewports import set_camera_view

import isaaclab.sim as sim_utils
from isaaclab.assets import Articulation
from isaaclab.sensors.contact_sensor import ContactSensor, ContactSensorCfg
from isaaclab.sim import SimulationCfg, SimulationContext
from isaaclab.utils.timer import Timer

##
Expand Down Expand Up @@ -76,7 +76,7 @@ def main():
"""Spawns the ANYmal robot and clones it using Isaac Sim Cloner API."""

# Load kit helper
sim = SimulationContext(physics_dt=0.005, rendering_dt=0.005, backend="torch", device="cuda:0")
sim = SimulationContext(SimulationCfg(dt=0.005))
# Set main camera
set_camera_view([2.5, 2.5, 2.5], [0.0, 0.0, 0.0])

Expand Down
13 changes: 2 additions & 11 deletions source/isaaclab/test/sensors/check_imu_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

import carb
import omni
from isaacsim.core.api.simulation_context import SimulationContext
from isaacsim.core.cloner import GridCloner
from isaacsim.core.utils.viewports import set_camera_view
from pxr import PhysxSchema
Expand All @@ -49,6 +48,7 @@
import isaaclab.terrains as terrain_gen
from isaaclab.assets import RigidObject, RigidObjectCfg
from isaaclab.sensors.imu import Imu, ImuCfg
from isaaclab.sim import SimulationCfg, SimulationContext
from isaaclab.terrains.config.rough import ROUGH_TERRAINS_CFG
from isaaclab.terrains.terrain_importer import TerrainImporter
from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR
Expand Down Expand Up @@ -115,16 +115,7 @@ def main():
"""Main function."""

# Load kit helper
sim_params = {
"use_gpu": True,
"use_gpu_pipeline": True,
"use_flatcache": True, # deprecated from Isaac Sim 2023.1 onwards
"use_fabric": True, # used from Isaac Sim 2023.1 onwards
"enable_scene_query_support": True,
}
sim = SimulationContext(
physics_dt=1.0 / 60.0, rendering_dt=1.0 / 60.0, sim_params=sim_params, backend="torch", device="cuda:0"
)
sim = SimulationContext(SimulationCfg())
# Set main camera
set_camera_view([0.0, 30.0, 25.0], [0.0, 0.0, -2.5])

Expand Down
14 changes: 2 additions & 12 deletions source/isaaclab/test/sensors/check_ray_caster.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
import torch

import isaacsim.core.utils.prims as prim_utils
from isaacsim.core.api.simulation_context import SimulationContext
from isaacsim.core.cloner import GridCloner
from isaacsim.core.prims import RigidPrim
from isaacsim.core.utils.viewports import set_camera_view

import isaaclab.sim as sim_utils
import isaaclab.terrains as terrain_gen
from isaaclab.sensors.ray_caster import RayCaster, RayCasterCfg, patterns
from isaaclab.sim import SimulationCfg, SimulationContext
from isaaclab.terrains.config.rough import ROUGH_TERRAINS_CFG
from isaaclab.terrains.terrain_importer import TerrainImporter
from isaaclab.utils.assets import ISAAC_NUCLEUS_DIR
Expand Down Expand Up @@ -89,17 +89,7 @@ def design_scene(sim: SimulationContext, num_envs: int = 2048):
def main():
"""Main function."""

# Load kit helper
sim_params = {
"use_gpu": True,
"use_gpu_pipeline": True,
"use_flatcache": True, # deprecated from Isaac Sim 2023.1 onwards
"use_fabric": True, # used from Isaac Sim 2023.1 onwards
"enable_scene_query_support": True,
}
sim = SimulationContext(
physics_dt=1.0 / 60.0, rendering_dt=1.0 / 60.0, sim_params=sim_params, backend="torch", device="cuda:0"
)
sim = SimulationContext(SimulationCfg())
# Set main camera
set_camera_view([0.0, 30.0, 25.0], [0.0, 0.0, -2.5])

Expand Down
Loading
Loading