File size: 1,486 Bytes
0157b12
 
 
b643de7
 
0157b12
b643de7
 
 
 
 
 
0157b12
 
b643de7
 
 
 
 
0157b12
 
 
 
 
b643de7
0157b12
b643de7
0157b12
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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
    """

    # use environment variable to set config path
    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}}