Open formoree opened 4 months ago
@formoree found in fork of this repo: https://github.com/mhming/LearningHumanoidWalking/blob/main/envs/common/robot_interface.py
adding this code or substituting this code in downloaded repo- files- /LearningHumanoidWalking/envs/common/robot_interface.py
I added a snippet so you know where to add. I can create pull request if it didn't work for you
def check_self_collisions(self):
"""
Returns True if there are collisions other than any-geom-floor.
"""
contacts = [self.data.contact[i] for i in range(self.data.ncon)]
floor_contacts = []
floor_id = mujoco.mj_name2id(self.model, mujoco.mjtObj.mjOBJ_BODY, self.floor_body_name)
for i,c in enumerate(contacts):
geom1_is_floor = (self.model.geom_bodyid[c.geom1]==floor_id)
geom2_is_floor = (self.model.geom_bodyid[c.geom2]==floor_id)
if (geom1_is_floor or geom2_is_floor):
floor_contacts.append((i,c))
return len(floor_contacts) != self.data.ncon
def get_pd_target(self): ## this line is added
return [self.current_pos_target, self.current_vel_target] ## this line is added
def set_pd_gains(self, kp, kv):
assert kp.size==self.model.nu
assert kv.size==self.model.nu
self.kp = kp.copy()
self.kv = kv.copy()
return
def step_pd(self, p, v):
self.current_pos_target = p.copy() ## this line is added
self.current_vel_target = v.copy() ## this line is added
target_angles = self.current_pos_target
target_speeds = self.current_vel_target
assert type(target_angles)==np.ndarray
assert type(target_speeds)==np.ndarray
curr_angles = self.get_act_joint_positions()
curr_speeds = self.get_act_joint_velocities()
perror = target_angles - curr_angles
verror = target_speeds - curr_speeds
assert self.kp.size==perror.size
assert self.kv.size==verror.size
assert perror.size==verror.size
return self.kp * perror + self.kv * verror
OK. Let me have a try. I think the Uncomment the code, and the code can be runed. But I don't know whether it will have a impact on the tasks.
Then i check the 'rewards.py' and 'robot_interface.py' files, and i exactly find that there is no function named get_pd_target. So for trainning, I just comment out the code.But I do't know whether it will have a impact on trained models.