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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

ISAAC_EXEC_SCRIPT=/home/antoiner/Documents/IsaacLab-Internal/isaaclab.sh
RSL_SCRIPT=scripts/benchmarks/benchmark_non_rl.py
TASKS="Isaac-Repose-Cube-Allegro-Direct-v0 Isaac-Ant-Direct-v0 Isaac-Cartpole-Direct-v0 Isaac-Cartpole-RGB-Camera-Direct-v0 Isaac-Cartpole-Depth-Camera-Direct-v0 Isaac-Humanoid-Direct-v0 Isaac-Ant-v0 Isaac-Cartpole-v0 Isaac-Humanoid-v0 Isaac-Velocity-Flat-Unitree-A1-v0 Isaac-Velocity-Flat-Anymal-B-v0 Isaac-Velocity-Flat-Anymal-C-v0 Isaac-Velocity-Flat-Anymal-D-v0 Isaac-Velocity-Flat-Cassie-v0 Isaac-Velocity-Flat-G1-v0 Isaac-Velocity-Flat-G1-v1 Isaac-Velocity-Flat-Unitree-Go1-v0 Isaac-Velocity-Flat-Unitree-Go2-v0 Isaac-Velocity-Flat-H1-v0 Isaac-Velocity-Flat-Spot-v0 Isaac-Reach-Franka-v0 Isaac-Reach-UR10-v0"
TASKS="Isaac-Repose-Cube-Allegro-Direct-v0 Isaac-Ant-Direct-v0 Isaac-Cartpole-Direct-v0 Isaac-Humanoid-Direct-v0 Isaac-Ant-v0 Isaac-Cartpole-v0 Isaac-Humanoid-v0 Isaac-Velocity-Flat-Unitree-A1-v0 Isaac-Velocity-Flat-Anymal-B-v0 Isaac-Velocity-Flat-Anymal-C-v0 Isaac-Velocity-Flat-Anymal-D-v0 Isaac-Velocity-Flat-Cassie-v0 Isaac-Velocity-Flat-G1-v0 Isaac-Velocity-Flat-G1-v1 Isaac-Velocity-Flat-Unitree-Go1-v0 Isaac-Velocity-Flat-Unitree-Go2-v0 Isaac-Velocity-Flat-H1-v0 Isaac-Reach-Franka-v0 Isaac-Reach-UR10-v0"
NUM_FRAMES=100
NUM_ENVS="1024 2048 4096 8192 16384"
TARGET_FOLDER=$1
Expand Down
6 changes: 5 additions & 1 deletion source/isaaclab/isaaclab/cloner/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause

import logging
import numpy as np
from typing import Any

Expand All @@ -12,6 +13,9 @@

from isaaclab.utils.timer import Timer

# Import logging
logger = logging.getLogger(__name__)


@Timer(name="replicate_environment", msg="Replicate environment took:", enable=True, format="ms")
def replicate_environment(
Expand Down Expand Up @@ -56,7 +60,7 @@ def replicate_environment(
# up_axis sanity check
stage_up_axis = stage_info.get("up_axis")
if isinstance(stage_up_axis, str) and stage_up_axis.upper() != up_axis.upper():
print(f"WARNING: up_axis '{up_axis}' does not match USD stage up_axis '{stage_up_axis}'")
logger.warning(f"WARNING: up_axis '{up_axis}' does not match USD stage up_axis '{stage_up_axis}'")

with Timer(name="newton_prototype_builder", msg="Prototype Builder took:", enable=True, format="ms"):
# Get child xforms from the prototype path
Expand Down
20 changes: 10 additions & 10 deletions source/isaaclab/isaaclab/envs/direct_rl_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ def __init__(self, cfg: DirectRLEnvCfg, render_mode: str | None = None, **kwargs
torch.cuda.set_device(self.device)

# print useful information
print("[INFO]: Base environment:")
print(f"\tEnvironment device : {self.device}")
print(f"\tEnvironment seed : {self.cfg.seed}")
print(f"\tPhysics step-size : {self.physics_dt}")
print(f"\tRendering step-size : {self.physics_dt * self.cfg.sim.render_interval}")
print(f"\tEnvironment step-size : {self.step_dt}")
logger.info("Base environment:")
logger.info(f"\tEnvironment device : {self.device}")
logger.info(f"\tEnvironment seed : {self.cfg.seed}")
logger.info(f"\tPhysics step-size : {self.physics_dt}")
logger.info(f"\tRendering step-size : {self.physics_dt * self.cfg.sim.render_interval}")
logger.info(f"\tEnvironment step-size : {self.step_dt}")

if self.cfg.sim.render_interval < self.cfg.decimation:
msg = (
Expand All @@ -133,7 +133,7 @@ def __init__(self, cfg: DirectRLEnvCfg, render_mode: str | None = None, **kwargs
self.scene = InteractiveScene(self.cfg.scene)
self._setup_scene()
# attach_stage_to_usd_context()
print("[INFO]: Scene manager: ", self.scene)
logger.info(f"Scene manager: {self.scene}")

# set up camera viewport controller
# viewport is not available in other rendering modes so the function will throw a warning
Expand All @@ -158,7 +158,7 @@ def __init__(self, cfg: DirectRLEnvCfg, render_mode: str | None = None, **kwargs
# note: this activates the physics simulation view that exposes TensorAPIs
# note: when started in extension mode, first call sim.reset_async() and then initialize the managers
# if builtins.ISAAC_LAUNCHED_FROM_TERMINAL is False:
print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...")
logger.info("Starting the simulation. This may take a few seconds. Please wait...")
with Timer("[INFO]: Time taken for simulation start", "simulation_start"):
# since the reset can trigger callbacks which use the stage,
# we need to set the stage context here
Expand Down Expand Up @@ -213,7 +213,7 @@ def __init__(self, cfg: DirectRLEnvCfg, render_mode: str | None = None, **kwargs
# perform events at the start of the simulation
if self.cfg.events:
# we print it here to make the logging consistent
print("[INFO] Event Manager: ", self.event_manager)
logger.info(f"Event Manager: {self.event_manager}")

if "startup" in self.event_manager.available_modes:
self.event_manager.apply(mode="startup")
Expand All @@ -223,7 +223,7 @@ def __init__(self, cfg: DirectRLEnvCfg, render_mode: str | None = None, **kwargs
self.metadata["render_fps"] = 1 / self.step_dt

# print the environment information
print("[INFO]: Completed setting up the environment...")
logger.info("Completed setting up the environment...")

def __del__(self):
"""Cleanup for the environment."""
Expand Down
26 changes: 13 additions & 13 deletions source/isaaclab/isaaclab/envs/manager_based_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ def __init__(self, cfg: ManagerBasedEnvCfg):
torch.cuda.set_device(self.device)

# print useful information
print("[INFO]: Base environment:")
print(f"\tEnvironment device : {self.device}")
print(f"\tEnvironment seed : {self.cfg.seed}")
print(f"\tPhysics step-size : {self.physics_dt}")
print(f"\tRendering step-size : {self.physics_dt * self.cfg.sim.render_interval}")
print(f"\tEnvironment step-size : {self.step_dt}")
logger.info("Base environment:")
logger.info(f"\tEnvironment device : {self.device}")
logger.info(f"\tEnvironment seed : {self.cfg.seed}")
logger.info(f"\tPhysics step-size : {self.physics_dt}")
logger.info(f"\tRendering step-size : {self.physics_dt * self.cfg.sim.render_interval}")
logger.info(f"\tEnvironment step-size : {self.step_dt}")

if self.cfg.sim.render_interval < self.cfg.decimation:
msg = (
Expand All @@ -149,7 +149,7 @@ def __init__(self, cfg: ManagerBasedEnvCfg):
with use_stage(self.sim.get_initial_stage()):
self.scene = InteractiveScene(self.cfg.scene)
# attach_stage_to_usd_context()
print("[INFO]: Scene manager: ", self.scene)
logger.info(f"Scene manager: {self.scene}")

# set up camera viewport controller
# viewport is not available in other rendering modes so the function will throw a warning
Expand All @@ -173,7 +173,7 @@ def __init__(self, cfg: ManagerBasedEnvCfg):
# note: this activates the physics simulation view that exposes TensorAPIs
# note: when started in extension mode, first call sim.reset_async() and then initialize the managers
# if builtins.ISAAC_LAUNCHED_FROM_TERMINAL is False:
print("[INFO]: Starting the simulation. This may take a few seconds. Please wait...")
logger.info("Starting the simulation. This may take a few seconds. Please wait...")
with Timer("[INFO]: Time taken for simulation start", "simulation_start"):
# since the reset can trigger callbacks which use the stage,
# we need to set the stage context here
Expand Down Expand Up @@ -292,7 +292,7 @@ def export_IO_descriptors(self, output_dir: str | None = None):
os.makedirs(output_dir, exist_ok=True)

with open(os.path.join(output_dir, "IO_descriptors.yaml"), "w") as f:
print(f"[INFO]: Exporting IO descriptors to {os.path.join(output_dir, 'IO_descriptors.yaml')}")
logger.info(f"Exporting IO descriptors to {os.path.join(output_dir, 'IO_descriptors.yaml')}")
yaml.safe_dump(IO_descriptors, f)

"""
Expand All @@ -317,16 +317,16 @@ def load_managers(self):
"""
# prepare the managers
# -- event manager (we print it here to make the logging consistent)
print("[INFO] Event Manager: ", self.event_manager)
logger.info(f"Event Manager: {self.event_manager}")
# -- recorder manager
self.recorder_manager = RecorderManager(self.cfg.recorders, self)
print("[INFO] Recorder Manager: ", self.recorder_manager)
logger.info(f"Recorder Manager: {self.recorder_manager}")
# -- action manager
self.action_manager = ActionManager(self.cfg.actions, self)
print("[INFO] Action Manager: ", self.action_manager)
logger.info(f"Action Manager: {self.action_manager}")
# -- observation manager
self.observation_manager = ObservationManager(self.cfg.observations, self)
print("[INFO] Observation Manager:", self.observation_manager)
logger.info(f"Observation Manager: {self.observation_manager}")

# perform events at the start of the simulation
# in-case a child implementation creates other managers, the randomization should happen
Expand Down
14 changes: 9 additions & 5 deletions source/isaaclab/isaaclab/envs/manager_based_rl_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from __future__ import annotations

import gymnasium as gym
import logging
import math
import numpy as np
import torch
Expand All @@ -20,6 +21,9 @@
from .manager_based_env import ManagerBasedEnv
from .manager_based_rl_env_cfg import ManagerBasedRLEnvCfg

# import logger
logger = logging.getLogger(__name__)


class ManagerBasedRLEnv(ManagerBasedEnv, gym.Env):
"""The superclass for the manager-based workflow reinforcement learning-based environments.
Expand Down Expand Up @@ -85,7 +89,7 @@ def __init__(self, cfg: ManagerBasedRLEnvCfg, render_mode: str | None = None, **
# -- set the framerate of the gym video recorder wrapper so that the playback speed of the produced video matches the simulation
self.metadata["render_fps"] = 1 / self.step_dt

print("[INFO]: Completed setting up the environment...")
logger.info("Completed setting up the environment...")

"""
Properties.
Expand All @@ -110,21 +114,21 @@ def load_managers(self):
# and the reward manager needs to know the termination manager
# -- command manager
self.command_manager: CommandManager = CommandManager(self.cfg.commands, self)
print("[INFO] Command Manager: ", self.command_manager)
logger.info(f"Command Manager: {self.command_manager}")

# call the parent class to load the managers for observations and actions.
super().load_managers()

# prepare the managers
# -- termination manager
self.termination_manager = TerminationManager(self.cfg.terminations, self)
print("[INFO] Termination Manager: ", self.termination_manager)
logger.info(f"Termination Manager: {self.termination_manager}")
# -- reward manager
self.reward_manager = RewardManager(self.cfg.rewards, self)
print("[INFO] Reward Manager: ", self.reward_manager)
logger.info(f"Reward Manager: {self.reward_manager}")
# -- curriculum manager
self.curriculum_manager = CurriculumManager(self.cfg.curriculum, self)
print("[INFO] Curriculum Manager: ", self.curriculum_manager)
logger.info(f"Curriculum Manager: {self.curriculum_manager}")

# setup the action and observation spaces for Gym
self._configure_gym_env_spaces()
Expand Down
8 changes: 6 additions & 2 deletions source/isaaclab/isaaclab/managers/action_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from __future__ import annotations

import inspect
import logging
import re
import torch
import weakref
Expand All @@ -25,6 +26,9 @@
if TYPE_CHECKING:
from isaaclab.envs import ManagerBasedEnv

# import logger
logger = logging.getLogger(__name__)


class ActionTerm(ManagerTermBase):
"""Base class for action terms.
Expand Down Expand Up @@ -291,13 +295,13 @@ def get_IO_descriptors(self) -> list[dict[str, Any]]:
try:
data.append(term.IO_descriptor.__dict__.copy())
except Exception as e:
print(f"Error getting IO descriptor for term '{term_name}': {e}")
logger.warning(f"Failed to get IO descriptor for term '{term_name}': {e}")

formatted_data = []
for item in data:
name = item.pop("name")
formatted_item = {"name": name, "extras": item.pop("extras")}
print(item["export"])
logger.info(item["export"])
if not item.pop("export"):
continue
for k, v in item.items():
Expand Down
6 changes: 5 additions & 1 deletion source/isaaclab/isaaclab/managers/observation_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from __future__ import annotations

import inspect
import logging
import numpy as np
import torch
from collections.abc import Sequence
Expand All @@ -23,6 +24,9 @@
if TYPE_CHECKING:
from isaaclab.envs import ManagerBasedEnv

# import logger
logger = logging.getLogger(__name__)


class ObservationManager(ManagerBase):
"""Manager for computing observation signals for a given world.
Expand Down Expand Up @@ -264,7 +268,7 @@ def get_IO_descriptors(self, group_names_to_export: list[str] = ["policy"]):
desc.update(overloads)
group_data[group_name].append(desc)
except Exception as e:
print(f"Error getting IO descriptor for term '{term_name}' in group '{group_name}': {e}")
logger.warning(f"Error getting IO descriptor for term '{term_name}' in group '{group_name}': {e}")
# Format the data for YAML export
formatted_data = {}
for group_name, data in group_data.items():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from __future__ import annotations

import logging
import torch
from collections.abc import Sequence
from typing import TYPE_CHECKING
Expand All @@ -26,6 +27,9 @@
if TYPE_CHECKING:
from .contact_sensor_cfg import ContactSensorCfg

# import logger
logger = logging.getLogger(__name__)


class ContactSensor(SensorBase):
"""A contact reporting sensor.
Expand Down Expand Up @@ -274,7 +278,7 @@ def _create_buffers(self):
"Number of bodies is not an integer multiple of the number of environments. Received:"
f" {self._num_bodies} bodies and {self._num_envs} environments."
)
print(f"[INFO] Contact sensor initialized with {self._num_bodies} bodies.")
logger.info(f"Contact sensor initialized with {self._num_bodies} bodies.")

# Assume homogeneous envs, i.e. all envs have the same number of bodies / shapes
# Only get the names for the first env. Expected structure: /World/envs/env_.*/...
Expand Down
31 changes: 16 additions & 15 deletions source/isaaclab/isaaclab/sim/_impl/newton_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#
# SPDX-License-Identifier: BSD-3-Clause

import logging
import numpy as np
import re

Expand All @@ -17,6 +18,9 @@
from isaaclab.sim.utils.stage import get_current_stage
from isaaclab.utils.timer import Timer

# import logger
logger = logging.getLogger(__name__)


def flipped_match(x: str, y: str) -> re.Match | None:
"""Flipped match function.
Expand Down Expand Up @@ -117,13 +121,13 @@ def start_simulation(cls) -> None:
This function finalizes the model and initializes the simulation state.
"""

print(f"[INFO] Builder: {NewtonManager._builder}")
logger.info(f"Builder: {NewtonManager._builder}")
if NewtonManager._builder is None:
NewtonManager.instantiate_builder_from_stage()
print("[INFO] Running on init callbacks")
logger.info("Running on init callbacks")
for callback in NewtonManager._on_init_callbacks:
callback()
print(f"[INFO] Finalizing model on device: {NewtonManager._device}")
logger.info(f"Finalizing model on device: {NewtonManager._device}")
NewtonManager._builder.gravity = np.array(NewtonManager._gravity_vector)[-1]
NewtonManager._builder.up_axis = Axis.from_string(NewtonManager._up_axis)
with Timer(name="newton_finalize_builder", msg="Finalize builder took:", enable=True, format="ms"):
Expand All @@ -141,7 +145,7 @@ def start_simulation(cls) -> None:
)
else:
NewtonManager._contacts = Contacts(0, 0)
print("[INFO] Running on start callbacks")
logger.info("Running on start callbacks")
for callback in NewtonManager._on_start_callbacks:
callback()
if not NewtonManager._clone_physics_only:
Expand Down Expand Up @@ -186,7 +190,6 @@ def initialize_solver(cls):
with Timer(name="newton_initialize_solver", msg="Initialize solver took:", enable=True, format="ms"):
NewtonManager._num_substeps = NewtonManager._cfg.num_substeps
NewtonManager._solver_dt = NewtonManager._dt / NewtonManager._num_substeps
print(NewtonManager._model.gravity)
NewtonManager._solver = NewtonManager._get_solver(NewtonManager._model, NewtonManager._cfg.solver_cfg)
if isinstance(NewtonManager._solver, SolverMuJoCo):
NewtonManager._needs_collision_pipeline = not NewtonManager._cfg.solver_cfg.get(
Expand Down Expand Up @@ -291,9 +294,9 @@ def step(cls) -> None:

if NewtonManager._cfg.debug_mode:
convergence_data = NewtonManager.get_solver_convergence_steps()
# print(f"solver niter: {convergence_data}")
logger.info(f"solver niter: {convergence_data}")
if convergence_data["max"] == NewtonManager._solver.mjw_model.opt.iterations:
print("solver didn't converge!", convergence_data["max"])
logger.warning("solver didn't converge!", convergence_data["max"])

NewtonManager._sim_time += NewtonManager._solver_dt * NewtonManager._num_substeps

Expand Down Expand Up @@ -402,21 +405,19 @@ def add_contact_sensor(
if contact_partners_body_expr is not None and contact_partners_shape_expr is not None:
raise ValueError("Only one of contact_partners_body_expr or contact_partners_shape_expr must be provided")
if contact_partners_body_expr is None and contact_partners_shape_expr is None:
print(f"[INFO] Adding contact view for {body_names_expr}. It will report contacts with all bodies/shapes.")
logger.info(f"Adding contact view for {body_names_expr}. It will report contacts with all bodies/shapes.")
else:
if body_names_expr is not None:
if contact_partners_body_expr is not None:
print(f"[INFO] Adding contact view for {body_names_expr} with filter {contact_partners_body_expr}.")
logger.info(f"Adding contact view for {body_names_expr} with filter {contact_partners_body_expr}.")
else:
print(f"[INFO] Adding contact view for {body_names_expr} with filter {shape_names_expr}.")
logger.info(f"Adding contact view for {body_names_expr} with filter {shape_names_expr}.")
else:
if contact_partners_body_expr is not None:
print(
f"[INFO] Adding contact view for {shape_names_expr} with filter {contact_partners_body_expr}."
)
logger.info(f"Adding contact view for {shape_names_expr} with filter {contact_partners_body_expr}.")
else:
print(
f"[INFO] Adding contact view for {shape_names_expr} with filter {contact_partners_shape_expr}."
logger.info(
f"Adding contact view for {shape_names_expr} with filter {contact_partners_shape_expr}."
)

NewtonManager._newton_contact_sensor = NewtonContactSensor(
Expand Down
Loading
Loading