RuntimeError: normal expects all elements of std >= 0.0 when running custom articulation task

I am trying to modify the for simulating and training various robots with different length of thigh at same time.
the code I modified are list downside.

for i in range(self.num_envs):
            thigh_length = random.uniform(0.38, 0.45)
            tree = ET.parse(asset_root + '/' + asset_file)
            root = tree.getroot()
            right_shin_element = root.find(".//body[@name='right_shin']")
            left_shin_element = root.find(".//body[@name='left_shin']")
            right_thigh_geom_element = root.find(".//geom[@name='right_thigh']")
            left_thigh_geom_element = root.find(".//geom[@name='left_thigh']")
            new_shin_pos = "0 .01 " + str(-thigh_length)
            new_thigh_fromto = "0 0 0 0 .01 " + str(-thigh_length+0.07)
            # new_shin_pos = "0 .01 -0.403"
            # new_thigh_fromto = "0 0 0 0 .01 -0.34"
            right_shin_element.set('pos', new_shin_pos)
            left_shin_element.set('pos', new_shin_pos)
            right_thigh_geom_element.set('fromto', new_thigh_fromto)
            left_thigh_geom_element.set('fromto', new_thigh_fromto)
            tree.write(asset_root + '/' + asset_file)
            height_humanoid = 1.34 + thigh_length - 0.400

            humanoid_asset = self.gym.load_asset(self.sim, asset_root, asset_file, asset_options)

            # Note - for this asset we are loading the actuator info from the MJCF
            actuator_props = self.gym.get_asset_actuator_properties(humanoid_asset)
            motor_efforts = [prop.motor_effort for prop in actuator_props]

            # create force sensors at the feet
            right_foot_idx = self.gym.find_asset_rigid_body_index(humanoid_asset, "right_foot")
            left_foot_idx = self.gym.find_asset_rigid_body_index(humanoid_asset, "left_foot")
            sensor_pose = gymapi.Transform()
            self.gym.create_asset_force_sensor(humanoid_asset, right_foot_idx, sensor_pose)
            self.gym.create_asset_force_sensor(humanoid_asset, left_foot_idx, sensor_pose)

            self.max_motor_effort = max(motor_efforts)
            self.motor_efforts = to_torch(motor_efforts, device=self.device)

            self.torso_index = 0
            self.num_bodies = self.gym.get_asset_rigid_body_count(humanoid_asset)
            self.num_dof = self.gym.get_asset_dof_count(humanoid_asset)
            self.num_joints = self.gym.get_asset_joint_count(humanoid_asset)

            start_pose = gymapi.Transform()
            start_pose.p = gymapi.Vec3(*get_axis_params(height_humanoid, self.up_axis_idx))
            start_pose.r = gymapi.Quat(0.0, 0.0, 0.0, 1.0)

            self.start_rotation = torch.tensor([start_pose.r.x, start_pose.r.y, start_pose.r.z, start_pose.r.w], device=self.device)

            self.humanoid_handles = []
            self.envs = []
            self.dof_limits_lower = []
            self.dof_limits_upper = []

            # create env instance
            env_ptr = self.gym.create_env(
                self.sim, lower, upper, num_per_row
            handle = self.gym.create_actor(env_ptr, humanoid_asset, start_pose, "humanoid", i, 0, 0)

            self.gym.enable_actor_dof_force_sensors(env_ptr, handle)

            for j in range(self.num_bodies):
                    env_ptr, handle, j, gymapi.MESH_VISUAL, gymapi.Vec3(0.97, 0.38, 0.06))


At first, the isaac gym successfully run and start training, the model of different robots have different length of thigh as expected. However, during training,the errors occur, and will occur at same epochs if run it again.

Error executing job with overrides: ['task=Humanoid']
Traceback (most recent call last):
  File "./isaacgymenvs/", line 214, in launch_rlg_hydra
    'sigma': cfg.sigma if cfg.sigma != '' else None
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/", line 133, in run
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/", line 116, in run_train
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/common/", line 1318, in train
    step_time, play_time, update_time, sum_time, a_losses, c_losses, b_losses, entropies, kls, last_lr, lr_mul = self.train_epoch()
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/common/", line 1182, in train_epoch
    batch_dict = self.play_steps()
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/common/", line 742, in play_steps
    res_dict = self.get_action_values(self.obs)
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/common/", line 408, in get_action_values
    res_dict = self.model(input_dict)
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/torch/nn/modules/", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/algos_torch/", line 278, in forward
    selected_action = distr.sample()
  File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/torch/distributions/", line 70, in sample
    return torch.normal(self.loc.expand(shape), self.scale.expand(shape))
RuntimeError: normal expects all elements of std >= 0.0

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

the problem is that when the length of thigh get some values like 0.3956247516704176, the robot drift away in isaac gym. it may causued by self-collision.

Hello. I’m trying to call up a humanoid robot I made with asset using the file for learning. The same problem occurs after tensor modification according to my model’s dof, did you solve it?

yeah, since my morphology are generated in random, so when it comes the value like 0.395624751670417, the program crashed. When I limit it to two decimal places like 0.39, it works. I guess it might caused by some self-collision problem.

1 Like

Thank you for your answer! Have you ever applied the code that modified the humanoid asset to the example of isaacgym benchmark to train?

yes, it works great but can not modify the morphology after loading once asset, and destory_env() doesnt work. Do you have any test on this? I’m tring to do some work related with human morphology evolution, but seems that isaac gym can not change morpholog and reset asset during simulation

I’m trying to train through the example of isaacgym benchmark by specifying urdf of a humanoid robot I made myself as asset. So I haven’t tried to change asset during simulation as in your case. I’ll share it if I can proceed with the test in the future.