Skip to content

Commit c42fc73

Browse files
Changes from omni.log to python logging (#3912)
# Description Changes from `omni.log` to an own python logger for IsaacLab. The logging information are formatted as follows: ``` 14:09:39 [manager_based_env.py] WARNING: The render interval (1) is smaller than the decimation (2). Multiple render calls will happen for each environment step. If this is not intended, set the render interval to be equal to the decimation. ``` All logs are saved to a temp file. Carb initialized a logging handler: ``` <_CarbLogHandler <stderr> (NOTSET)> ``` which is removed when configuring our handler. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [ ] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: ooctipus <[email protected]> Co-authored-by: ooctipus <[email protected]>
1 parent 9223836 commit c42fc73

File tree

59 files changed

+511
-266
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+511
-266
lines changed

scripts/environments/teleoperation/teleop_se3_agent.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,9 @@
5656

5757

5858
import gymnasium as gym
59+
import logging
5960
import torch
6061

61-
import omni.log
62-
6362
from isaaclab.devices import Se3Gamepad, Se3GamepadCfg, Se3Keyboard, Se3KeyboardCfg, Se3SpaceMouse, Se3SpaceMouseCfg
6463
from isaaclab.devices.openxr import remove_camera_configs
6564
from isaaclab.devices.teleop_device_factory import create_teleop_device
@@ -73,6 +72,9 @@
7372
import isaaclab_tasks.manager_based.locomanipulation.pick_place # noqa: F401
7473
import isaaclab_tasks.manager_based.manipulation.pick_place # noqa: F401
7574

75+
# import logger
76+
logger = logging.getLogger(__name__)
77+
7678

7779
def main() -> None:
7880
"""
@@ -106,12 +108,12 @@ def main() -> None:
106108
env = gym.make(args_cli.task, cfg=env_cfg).unwrapped
107109
# check environment name (for reach , we don't allow the gripper)
108110
if "Reach" in args_cli.task:
109-
omni.log.warn(
111+
logger.warning(
110112
f"The environment '{args_cli.task}' does not support gripper control. The device command will be"
111113
" ignored."
112114
)
113115
except Exception as e:
114-
omni.log.error(f"Failed to create environment: {e}")
116+
logger.error(f"Failed to create environment: {e}")
115117
simulation_app.close()
116118
return
117119

@@ -183,7 +185,9 @@ def stop_teleoperation() -> None:
183185
args_cli.teleop_device, env_cfg.teleop_devices.devices, teleoperation_callbacks
184186
)
185187
else:
186-
omni.log.warn(f"No teleop device '{args_cli.teleop_device}' found in environment config. Creating default.")
188+
logger.warning(
189+
f"No teleop device '{args_cli.teleop_device}' found in environment config. Creating default."
190+
)
187191
# Create fallback teleop device
188192
sensitivity = args_cli.sensitivity
189193
if args_cli.teleop_device.lower() == "keyboard":
@@ -199,8 +203,8 @@ def stop_teleoperation() -> None:
199203
Se3GamepadCfg(pos_sensitivity=0.1 * sensitivity, rot_sensitivity=0.1 * sensitivity)
200204
)
201205
else:
202-
omni.log.error(f"Unsupported teleop device: {args_cli.teleop_device}")
203-
omni.log.error("Supported devices: keyboard, spacemouse, gamepad, handtracking")
206+
logger.error(f"Unsupported teleop device: {args_cli.teleop_device}")
207+
logger.error("Supported devices: keyboard, spacemouse, gamepad, handtracking")
204208
env.close()
205209
simulation_app.close()
206210
return
@@ -210,15 +214,15 @@ def stop_teleoperation() -> None:
210214
try:
211215
teleop_interface.add_callback(key, callback)
212216
except (ValueError, TypeError) as e:
213-
omni.log.warn(f"Failed to add callback for key {key}: {e}")
217+
logger.warning(f"Failed to add callback for key {key}: {e}")
214218
except Exception as e:
215-
omni.log.error(f"Failed to create teleop device: {e}")
219+
logger.error(f"Failed to create teleop device: {e}")
216220
env.close()
217221
simulation_app.close()
218222
return
219223

220224
if teleop_interface is None:
221-
omni.log.error("Failed to create teleop interface")
225+
logger.error("Failed to create teleop interface")
222226
env.close()
223227
simulation_app.close()
224228
return
@@ -253,7 +257,7 @@ def stop_teleoperation() -> None:
253257
should_reset_recording_instance = False
254258
print("Environment reset complete")
255259
except Exception as e:
256-
omni.log.error(f"Error during simulation step: {e}")
260+
logger.error(f"Error during simulation step: {e}")
257261
break
258262

259263
# close the simulator

scripts/imitation_learning/isaaclab_mimic/generate_dataset.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,23 +64,26 @@
6464
import asyncio
6565
import gymnasium as gym
6666
import inspect
67+
import logging
6768
import numpy as np
6869
import random
6970
import torch
7071

71-
import omni
72-
7372
from isaaclab.envs import ManagerBasedRLMimicEnv
7473

7574
import isaaclab_mimic.envs # noqa: F401
7675

7776
if args_cli.enable_pinocchio:
7877
import isaaclab_mimic.envs.pinocchio_envs # noqa: F401
78+
7979
from isaaclab_mimic.datagen.generation import env_loop, setup_async_generation, setup_env_config
8080
from isaaclab_mimic.datagen.utils import get_env_name_from_dataset, setup_output_paths
8181

8282
import isaaclab_tasks # noqa: F401
8383

84+
# import logger
85+
logger = logging.getLogger(__name__)
86+
8487

8588
def main():
8689
num_envs = args_cli.num_envs
@@ -110,7 +113,7 @@ def main():
110113

111114
# Check if the mimic API from this environment contains decprecated signatures
112115
if "action_noise_dict" not in inspect.signature(env.target_eef_pose_to_action).parameters:
113-
omni.log.warn(
116+
logger.warning(
114117
f'The "noise" parameter in the "{env_name}" environment\'s mimic API "target_eef_pose_to_action", '
115118
"is deprecated. Please update the API to take action_noise_dict instead."
116119
)

scripts/reinforcement_learning/ray/mlflow_to_local_tensorboard.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def process_run(args):
6666

6767
def download_experiment_tensorboard_logs(uri: str, experiment_name: str, download_dir: str) -> None:
6868
"""Download MLflow experiment logs and convert to TensorBoard format."""
69+
# import logger
6970
logger = logging.getLogger(__name__)
7071

7172
try:

scripts/reinforcement_learning/rl_games/train.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,12 @@
6060
"""Rest everything follows."""
6161

6262
import gymnasium as gym
63+
import logging
6364
import math
6465
import os
6566
import random
6667
from datetime import datetime
6768

68-
import omni
6969
from rl_games.common import env_configurations, vecenv
7070
from rl_games.common.algo_observer import IsaacAlgoObserver
7171
from rl_games.torch_runner import Runner
@@ -86,6 +86,9 @@
8686
import isaaclab_tasks # noqa: F401
8787
from isaaclab_tasks.utils.hydra import hydra_task_config
8888

89+
# import logger
90+
logger = logging.getLogger(__name__)
91+
8992
# PLACEHOLDER: Extension template (do not remove this comment)
9093

9194

@@ -169,7 +172,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
169172
if isinstance(env_cfg, ManagerBasedRLEnvCfg):
170173
env_cfg.export_io_descriptors = args_cli.export_io_descriptors
171174
else:
172-
omni.log.warn(
175+
logger.warning(
173176
"IO descriptors are only supported for manager based RL environments. No IO descriptors will be exported."
174177
)
175178

scripts/reinforcement_learning/rsl_rl/train.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@
7373
"""Rest everything follows."""
7474

7575
import gymnasium as gym
76+
import logging
7677
import os
7778
import torch
7879
from datetime import datetime
7980

80-
import omni
8181
from rsl_rl.runners import DistillationRunner, OnPolicyRunner
8282

8383
from isaaclab.envs import (
@@ -96,6 +96,9 @@
9696
from isaaclab_tasks.utils import get_checkpoint_path
9797
from isaaclab_tasks.utils.hydra import hydra_task_config
9898

99+
# import logger
100+
logger = logging.getLogger(__name__)
101+
99102
# PLACEHOLDER: Extension template (do not remove this comment)
100103

101104
torch.backends.cuda.matmul.allow_tf32 = True
@@ -151,7 +154,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
151154
if isinstance(env_cfg, ManagerBasedRLEnvCfg):
152155
env_cfg.export_io_descriptors = args_cli.export_io_descriptors
153156
else:
154-
omni.log.warn(
157+
logger.warning(
155158
"IO descriptors are only supported for manager based RL environments. No IO descriptors will be exported."
156159
)
157160

scripts/reinforcement_learning/sb3/train.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ def cleanup_pbar(*args):
7373
"""Rest everything follows."""
7474

7575
import gymnasium as gym
76+
import logging
7677
import numpy as np
7778
import os
7879
import random
7980
from datetime import datetime
8081

81-
import omni
8282
from stable_baselines3 import PPO
8383
from stable_baselines3.common.callbacks import CheckpointCallback, LogEveryNTimesteps
8484
from stable_baselines3.common.vec_env import VecNormalize
@@ -98,6 +98,8 @@ def cleanup_pbar(*args):
9898
import isaaclab_tasks # noqa: F401
9999
from isaaclab_tasks.utils.hydra import hydra_task_config
100100

101+
# import logger
102+
logger = logging.getLogger(__name__)
101103
# PLACEHOLDER: Extension template (do not remove this comment)
102104

103105

@@ -145,7 +147,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
145147
if isinstance(env_cfg, ManagerBasedRLEnvCfg):
146148
env_cfg.export_io_descriptors = args_cli.export_io_descriptors
147149
else:
148-
omni.log.warn(
150+
logger.warning(
149151
"IO descriptors are only supported for manager based RL environments. No IO descriptors will be exported."
150152
)
151153

scripts/reinforcement_learning/skrl/train.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@
7373
"""Rest everything follows."""
7474

7575
import gymnasium as gym
76+
import logging
7677
import os
7778
import random
7879
from datetime import datetime
7980

80-
import omni
8181
import skrl
8282
from packaging import version
8383

@@ -111,6 +111,9 @@
111111
import isaaclab_tasks # noqa: F401
112112
from isaaclab_tasks.utils.hydra import hydra_task_config
113113

114+
# import logger
115+
logger = logging.getLogger(__name__)
116+
114117
# PLACEHOLDER: Extension template (do not remove this comment)
115118

116119
# config shortcuts
@@ -183,7 +186,7 @@ def main(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg | DirectMARLEnvCfg, agen
183186
if isinstance(env_cfg, ManagerBasedRLEnvCfg):
184187
env_cfg.export_io_descriptors = args_cli.export_io_descriptors
185188
else:
186-
omni.log.warn(
189+
logger.warning(
187190
"IO descriptors are only supported for manager based RL environments. No IO descriptors will be exported."
188191
)
189192

scripts/tools/record_demos.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,12 +90,11 @@
9090

9191
# Third-party imports
9292
import gymnasium as gym
93+
import logging
9394
import os
9495
import time
9596
import torch
9697

97-
# Omniverse logger
98-
import omni.log
9998
import omni.ui as ui
10099

101100
from isaaclab.devices import Se3Keyboard, Se3KeyboardCfg, Se3SpaceMouse, Se3SpaceMouseCfg
@@ -119,6 +118,9 @@
119118
import isaaclab_tasks # noqa: F401
120119
from isaaclab_tasks.utils.parse_cfg import parse_env_cfg
121120

121+
# import logger
122+
logger = logging.getLogger(__name__)
123+
122124

123125
class RateLimiter:
124126
"""Convenience class for enforcing rates in loops."""
@@ -201,7 +203,7 @@ def create_environment_config(
201203
env_cfg = parse_env_cfg(args_cli.task, device=args_cli.device, num_envs=1)
202204
env_cfg.env_name = args_cli.task.split(":")[-1]
203205
except Exception as e:
204-
omni.log.error(f"Failed to parse environment configuration: {e}")
206+
logger.error(f"Failed to parse environment configuration: {e}")
205207
exit(1)
206208

207209
# extract success checking function to invoke in the main loop
@@ -210,7 +212,7 @@ def create_environment_config(
210212
success_term = env_cfg.terminations.success
211213
env_cfg.terminations.success = None
212214
else:
213-
omni.log.warn(
215+
logger.warning(
214216
"No success termination term was found in the environment."
215217
" Will not be able to mark recorded demos as successful."
216218
)
@@ -251,7 +253,7 @@ def create_environment(env_cfg: ManagerBasedRLEnvCfg | DirectRLEnvCfg) -> gym.En
251253
env = gym.make(args_cli.task, cfg=env_cfg).unwrapped
252254
return env
253255
except Exception as e:
254-
omni.log.error(f"Failed to create environment: {e}")
256+
logger.error(f"Failed to create environment: {e}")
255257
exit(1)
256258

257259

@@ -276,26 +278,28 @@ def setup_teleop_device(callbacks: dict[str, Callable]) -> object:
276278
if hasattr(env_cfg, "teleop_devices") and args_cli.teleop_device in env_cfg.teleop_devices.devices:
277279
teleop_interface = create_teleop_device(args_cli.teleop_device, env_cfg.teleop_devices.devices, callbacks)
278280
else:
279-
omni.log.warn(f"No teleop device '{args_cli.teleop_device}' found in environment config. Creating default.")
281+
logger.warning(
282+
f"No teleop device '{args_cli.teleop_device}' found in environment config. Creating default."
283+
)
280284
# Create fallback teleop device
281285
if args_cli.teleop_device.lower() == "keyboard":
282286
teleop_interface = Se3Keyboard(Se3KeyboardCfg(pos_sensitivity=0.2, rot_sensitivity=0.5))
283287
elif args_cli.teleop_device.lower() == "spacemouse":
284288
teleop_interface = Se3SpaceMouse(Se3SpaceMouseCfg(pos_sensitivity=0.2, rot_sensitivity=0.5))
285289
else:
286-
omni.log.error(f"Unsupported teleop device: {args_cli.teleop_device}")
287-
omni.log.error("Supported devices: keyboard, spacemouse, handtracking")
290+
logger.error(f"Unsupported teleop device: {args_cli.teleop_device}")
291+
logger.error("Supported devices: keyboard, spacemouse, handtracking")
288292
exit(1)
289293

290294
# Add callbacks to fallback device
291295
for key, callback in callbacks.items():
292296
teleop_interface.add_callback(key, callback)
293297
except Exception as e:
294-
omni.log.error(f"Failed to create teleop device: {e}")
298+
logger.error(f"Failed to create teleop device: {e}")
295299
exit(1)
296300

297301
if teleop_interface is None:
298-
omni.log.error("Failed to create teleop interface")
302+
logger.error("Failed to create teleop interface")
299303
exit(1)
300304

301305
return teleop_interface

source/isaaclab/isaaclab/actuators/actuator_pd.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55

66
from __future__ import annotations
77

8+
import logging
89
import torch
910
from collections.abc import Sequence
1011
from typing import TYPE_CHECKING
1112

12-
import omni.log
13-
1413
from isaaclab.utils import DelayBuffer, LinearInterpolation
1514
from isaaclab.utils.types import ArticulationActions
1615

@@ -25,6 +24,8 @@
2524
RemotizedPDActuatorCfg,
2625
)
2726

27+
# import logger
28+
logger = logging.getLogger(__name__)
2829

2930
"""
3031
Implicit Actuator Models.
@@ -57,7 +58,7 @@ def __init__(self, cfg: ImplicitActuatorCfg, *args, **kwargs):
5758
# effort limits
5859
if cfg.effort_limit_sim is None and cfg.effort_limit is not None:
5960
# throw a warning that we have a replacement for the deprecated parameter
60-
omni.log.warn(
61+
logger.warning(
6162
"The <ImplicitActuatorCfg> object has a value for 'effort_limit'."
6263
" This parameter will be removed in the future."
6364
" To set the effort limit, please use 'effort_limit_sim' instead."
@@ -79,7 +80,7 @@ def __init__(self, cfg: ImplicitActuatorCfg, *args, **kwargs):
7980
if cfg.velocity_limit_sim is None and cfg.velocity_limit is not None:
8081
# throw a warning that previously this was not set
8182
# it leads to different simulation behavior so we want to remain backwards compatible
82-
omni.log.warn(
83+
logger.warning(
8384
"The <ImplicitActuatorCfg> object has a value for 'velocity_limit'."
8485
" Previously, although this value was specified, it was not getting used by implicit"
8586
" actuators. Since this parameter affects the simulation behavior, we continue to not"

0 commit comments

Comments
 (0)