IsaacLab icon indicating copy to clipboard operation
IsaacLab copied to clipboard

I cannot reset my episode with my own motion

Open waivivian opened this issue 2 months ago • 3 comments

I tried to reset the robot using my motion, which may potentially have joint pos not within joint limit but I can do this in IsaacGym, I don't know why in Isaaclab I will get errors, below is the function I use for reset

def _reset_strategy_random(
    self, env_ids: torch.Tensor, start: bool = False
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
    # sample random motion times (or zeros if start is True)
    num_samples = env_ids.shape[0]
    self.motion_ids = self._motion_loader.sample_motions(self.num_envs)
    self.motion_times = np.zeros(num_samples) if start else self._motion_loader.sample_time(self.motion_ids)
    self.motion_times = torch.ones_like(self._motion_loader.sample_time(self.motion_ids), device = self.device)* 67
    # sample random motions
    (
         self.hoi_data_batch[env_ids],
        body_positions,
        body_rotations,
        body_linear_velocities,
        body_angular_velocities,
        dof_positions,
        dof_velocities,
        object_position,
        object_pos_vel,
        object_rotation,
        object_rot_vel,
        object2_position,
        object2_pos_vel,
        object2_rotation,
        object2_rot_vel

    ) = self._motion_loader.get_initial_state(env_ids, self.motion_ids, self.motion_times)
    skill_label = self._motion_loader.motion_class[self.motion_ids.cpu().numpy()]
    self.skill_labels[env_ids] = torch.from_numpy(skill_label).to(self.device)

    # get root transforms (the humanoid torso)
    root_state = self.robot.data.default_root_state[env_ids].clone()
    root_state[:, 0:3] = body_positions[:, :] + self.scene.env_origins[env_ids]
    root_state[:, 3:7] = body_rotations[:, :]
    root_state[:, 7:10] = body_linear_velocities[:, :]
    root_state[:, 10:13] = body_angular_velocities[:, :]

    # get DOFs state
    dof_pos = dof_positions[:, :]
    dof_vel = dof_velocities[:, :]

    obj_state = self.object.data.default_root_state[env_ids].clone()
    obj_state[:, 0:3] = object_position[:, :] + self.scene.env_origins[env_ids]
    obj_state[:, 3:7] = object_rotation[:, :]
    obj_state[:, 7:10] = object_pos_vel[:, :]
    obj_state[:, 10:13] = object_rot_vel[:, :]
    
    obj2_state = self.object2.data.default_root_state[env_ids].clone()
    obj2_state[:, 0:3] = object2_position[:, :] + self.scene.env_origins[env_ids]
    obj2_state[:, 3:7] = object2_rotation[:, :]
    obj2_state[:, 7:10] = object2_pos_vel[:, :]
    obj2_state[:, 10:13] = object2_rot_vel[:, :]
     
    # update AMP observation
    # amp_observations = self.collect_reference_motions(num_samples, times)
    # self.amp_observation_buffer[env_ids] = amp_observations.view(num_samples, self.cfg.num_amp_observations, -1)

    return root_state, dof_pos, dof_vel, obj_state, obj2_state

Error with torch.cuda.amp.autocast(enabled=self.mixed_precision): fps step: 3 fps step and policy inference: 3 fps total: 3 epoch: 1/30000 frames: 0 [2025-11-07 19:28:32,306][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,307][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,307][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,308][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,309][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,309][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,309][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,309][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,310][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,310][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. [2025-11-07 19:28:32,310][tensorboardX.x2num][WARNING] - NaN or Inf found in input tensor. Error executing job with overrides: []

Any help would be greatly appreciated!

waivivian avatar Nov 07 '25 11:11 waivivian

Thank you for posting this. The NaN or Inf errors you encounter when resetting a robot in Isaac Lab using joint positions sampled from your motion (which can be out of joint limits) arise because Isaac Lab enforces joint limits during reset. Always clip or validate joint positions before calling the reset function to ensure none are outside the specified joint limits.

RandomOakForest avatar Nov 07 '25 13:11 RandomOakForest

Thanks a lot for your kind reply! I now have tried to set my joint limit to very large value like lower="-10000" upper="10000" in my robot hand urdf and coverted to usd. And I also find that self._data.joint_pos_limits in articulation.py has been changed to the large values. Might I know is this the joint limits during reset you refer to?

If yes, it is the joint limits you referring to, I still get the same "NaN or Inf found in input tensor." error. However, now I should have my motion joint within the limit, so might I know why do I still get this error?

If no, might I know where it the right place I should modify the joint limit to avoid this error during reset?

Thanks again.

Image

waivivian avatar Nov 08 '25 11:11 waivivian

Can anyone pls kindly help? Thanks a lot!

waivivian avatar Nov 13 '25 06:11 waivivian