|
|
import logging |
|
|
from typing import Any |
|
|
from lerobot.envs.isaaclab_arena import IsaacLabArenaEnvWrapper |
|
|
|
|
|
|
|
|
def make_env(n_envs: int = 1, use_async_envs: bool = False, **kwargs: Any): |
|
|
""" |
|
|
Create vectorized environments for leisaac task. |
|
|
Args: |
|
|
n_envs: Number of parallel environments |
|
|
use_async_envs: Whether to use AsyncVectorEnv or SyncVectorEnv |
|
|
(not use now) |
|
|
**kwargs: Additional arguments to pass to the environment |
|
|
- config_path: Path to the environment configuration file |
|
|
Returns: |
|
|
ManagerBasedRLEnv or DirectRLEnv inherit from gym.Env implemented in IsaacLab |
|
|
""" |
|
|
|
|
|
|
|
|
if "config_path" not in kwargs: |
|
|
raise ValueError("Please set config_path in the arguments") |
|
|
config_path = kwargs['config_path'] |
|
|
logging.warning( |
|
|
"Ignore n_envs and use_async_envs in parameter, we use the config path to create the environment") |
|
|
|
|
|
from lw_benchhub.utils.envhub_utils import export_env_for_envhub |
|
|
|
|
|
raw_env, environment, task, render_mode, episode_length, app_launcher = export_env_for_envhub( |
|
|
config_path=config_path |
|
|
) |
|
|
|
|
|
wrapped_env = IsaacLabArenaEnvWrapper( |
|
|
raw_env, |
|
|
episode_length=episode_length, |
|
|
task=task, |
|
|
render_mode=render_mode, |
|
|
simulation_app=app_launcher, |
|
|
) |
|
|
logging.info(f"Created: {environment} with {wrapped_env.num_envs} envs") |
|
|
|
|
|
return {environment: {0: wrapped_env}} |
|
|
|