I am trying to modify the humanoid.py
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):
self.gym.set_rigid_body_color(
env_ptr, handle, j, gymapi.MESH_VISUAL, gymapi.Vec3(0.97, 0.38, 0.06))
self.envs.append(env_ptr)
self.humanoid_handles.append(handle)
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/train.py", 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/torch_runner.py", line 133, in run
self.run_train(args)
File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/torch_runner.py", line 116, in run_train
agent.train()
File "/home/lau/anaconda3/envs/isaac_env_py_3_7/lib/python3.7/site-packages/rl_games/common/a2c_common.py", 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/a2c_common.py", 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/a2c_common.py", 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/a2c_common.py", 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/module.py", 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/models.py", 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/normal.py", 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.