Cartpole example::: Unable to train multi environment robot!

Isaac version 4.1.0 with windows11

I’m studying with Isaac Sim, but why isn’t this working? Can someone help me?

예외가 발생했습니다. ValueError
only one element tensors can be converted to Python scalars
File “C:\Users\KIRO\AppData\Local\ov\pkg\isaac-sim-4.1.0\kiro_ws\kiro_cartpole_train.py”, line 89, in _observation_to_tensor
return torch.tensor(observation, device=self.device, dtype=torch.float32).view(self.num_envs, -1)
File “C:\Users\KIRO\AppData\Local\ov\pkg\isaac-sim-4.1.0\kiro_ws\kiro_cartpole_train.py”, line 129, in reset
return self._observation_to_tensor(self._env.reset()), {}
File “C:\Users\KIRO\AppData\Local\ov\pkg\isaac-sim-4.1.0\kiro_ws\kiro_cartpole_train.py”, line 194, in
trainer.train()
ValueError: only one element tensors can be converted to Python scalars

Cartpole_multyenv.zip (5.1 KB)

Hi @aiden_kim

The VecEnvBase.reset (from omni.isaac.gym.vec_env import VecEnvBase) method returns a tuple with a torch.Tensor (observation) and a Python dict (environment info).
You need to modify the training script (line 129) to take that into account:

obs_tensor, self._info_dict = self._env.reset()
self._obs_tensor = self._observation_to_tensor(obs_tensor)
return self._obs_tensor, self._info_dict

Btw, note that omni.isaac.gym was marked as deprecated in Isaac Sim 4.0.0 and will be removed in next versions:

image

Please, use Isaac Lab for reinforcement learning