-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
When running a trained robomimic model with one environment, the rollout behaves normally. However, when switching to multiple environments, the policy enters a strange state and effectively stops progressing. The only change is the number of environments (num_envs).
Single env (works as expected)
2025-12-18.19-33-15.mov
Multiple envs (unexpected behavior)
The system enters an abnormal state and appears to stall.
2025-12-18.19-31-13.mov
Steps to reproduce
- Train a BC model using robomimic with camera features encoded via
mdp.image_features. - Run the trained checkpoint using the script below with
--num_envs > 1.
# Copyright (c) 2022-2025, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md).
# All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
"""Script to play and evaluate a trained policy from robomimic.
This script loads a robomimic policy and plays it in an Isaac Lab environment.
Args:
task: Name of the environment.
checkpoint: Path to the robomimic policy checkpoint.
horizon: If provided, override the step horizon of each rollout.
num_rollouts: If provided, override the number of rollouts.
seed: If provided, overeride the default random seed.
norm_factor_min: If provided, minimum value of the action space normalization factor.
norm_factor_max: If provided, maximum value of the action space normalization factor.
"""
"""Launch Isaac Sim Simulator first."""
import argparse
from isaaclab.app import AppLauncher
# add argparse arguments
parser = argparse.ArgumentParser(description="Evaluate robomimic policy for Isaac Lab environment.")
parser.add_argument("--num_envs", type=int, default=1, help="Number of environments to play.")
parser.add_argument(
"--disable_fabric", action="store_true", default=False, help="Disable fabric and use USD I/O operations."
)
parser.add_argument("--task", type=str, default=None, help="Name of the task.")
parser.add_argument("--checkpoint", type=str, default=None, help="Pytorch model checkpoint to load.")
parser.add_argument("--horizon", type=int, default=800, help="Step horizon of each rollout.")
parser.add_argument("--num_rollouts", type=int, default=1, help="Number of rollouts.")
parser.add_argument("--seed", type=int, default=101, help="Random seed.")
parser.add_argument(
"--norm_factor_min", type=float, default=None, help="Optional: minimum value of the normalization factor."
)
parser.add_argument(
"--norm_factor_max", type=float, default=None, help="Optional: maximum value of the normalization factor."
)
parser.add_argument("--enable_pinocchio", default=False, action="store_true", help="Enable Pinocchio.")
parser.add_argument("--seq_len", type=int, default=10, help="Sequence length for rnn and transformer models. Refer to the json key: train.seq_length.")
# append AppLauncher cli args
AppLauncher.add_app_launcher_args(parser)
# parse the arguments
args_cli = parser.parse_args()
if args_cli.enable_pinocchio:
# Import pinocchio before AppLauncher to force the use of the version installed by IsaacLab and not the one installed by Isaac Sim
# pinocchio is required by the Pink IK controllers and the GR1T2 retargeter
import pinocchio # noqa: F401
# launch omniverse app
app_launcher = AppLauncher(args_cli)
simulation_app = app_launcher.app
"""Rest everything follows."""
import copy
from collections import deque
import gymnasium as gym
import numpy as np
import random
import torch
import robomimic.utils.file_utils as FileUtils
import robomimic.utils.torch_utils as TorchUtils
if args_cli.enable_pinocchio:
import isaaclab_tasks.manager_based.manipulation.pick_place # noqa: F401
from isaaclab_tasks.utils import parse_env_cfg
import ramen.tasks
def rollout(rollout_policy, env, success_term, horizon, device):
"""Perform a single rollout of the policy in the environment.
Args:
policy: The robomimicpolicy to play.
env: The environment to play in.
horizon: The step horizon of each rollout.
device: The device to run the policy on.
Returns:
terminated: Whether the rollout terminated.
traj: The trajectory of the rollout.
"""
policy = rollout_policy.policy
policy.set_eval()
obs_dict, _ = env.reset()
for i in range(horizon):
# Prepare observations
obs = copy.deepcopy(obs_dict["policy"])
actions = policy.get_action(obs)
# Unnormalize actions
if args_cli.norm_factor_min is not None and args_cli.norm_factor_max is not None:
actions = (
(actions + 1) * (args_cli.norm_factor_max - args_cli.norm_factor_min)
) / 2 + args_cli.norm_factor_min
# Apply actions
obs_dict, _, terminated, truncated, _ = env.step(actions)
obs = obs_dict["policy"]
return False
def main():
"""Run a trained policy from robomimic with Isaac Lab environment."""
# parse configuration
env_cfg = parse_env_cfg(args_cli.task, device=args_cli.device, num_envs=args_cli.num_envs, use_fabric=not args_cli.disable_fabric)
# Set observations to dictionary mode for Robomimic
env_cfg.observations.policy.concatenate_terms = False
# Set termination conditions
env_cfg.terminations.time_out = None
# Disable recorder
env_cfg.recorders = None
# Extract success checking function
success_term = env_cfg.terminations.success
env_cfg.terminations.success = None
# Create environment
env = gym.make(args_cli.task, cfg=env_cfg).unwrapped
# Set seed
torch.manual_seed(args_cli.seed)
np.random.seed(args_cli.seed)
random.seed(args_cli.seed)
env.seed(args_cli.seed)
# Acquire device
device = TorchUtils.get_torch_device(try_to_use_cuda=True)
# Run policy
results = []
for trial in range(args_cli.num_rollouts):
print(f"[INFO] Starting trial {trial}")
policy, _ = FileUtils.policy_from_checkpoint(ckpt_path=args_cli.checkpoint, device=device)
terminated = rollout(policy, env, success_term, args_cli.horizon, device)
results.append(terminated)
print(f"[INFO] Trial {trial}: {terminated}\n")
print(f"\nSuccessful trials: {results.count(True)}, out of {len(results)} trials")
print(f"Success rate: {results.count(True) / len(results)}")
print(f"Trial Results: {results}\n")
env.close()
if __name__ == "__main__":
# run the main function
main()
# close sim app
simulation_app.close()System Info
- Commit:
bde0bcaa1f6aacaa9b89b226d2ae10754a23d3e1 - Isaac Sim Version: 5.1
- OS: Ubuntu 22.04
- GPU: RTX Ada 6000
- CUDA: 12.4
- GPU Driver: 550.163.01
Additional context
- I logged images at every timestep and confirmed there is no lag, delay, or visual disorientation.
- Switching from
tiled_camerato a regular camera does not resolve the issue. - I inspected the robomimic model implementation but did not find any logic that obviously breaks when
num_envs > 1.
Checklist
- I have checked that there is no similar issue in the repo
- I have checked that the issue is not in running Isaac Sim itself and is related to the repo
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working