in gym-compete/gym_compete/new_envs/agents/humanoid.py [0:0]
def _get_obs_relative(self):
'''
Return agent's observations, positions are relative
'''
qpos = self.get_qpos()
my_pos = qpos[2:]
other_agents_qpos = self.get_other_agent_qpos()
all_other_qpos = []
for i in range(self.n_agents):
if i == self.id: continue
other_qpos = other_agents_qpos[i]
other_relative_xy = other_qpos[:2] - qpos[:2]
other_qpos = np.concatenate([other_relative_xy.flat, other_qpos[2:].flat], axis=0)
all_other_qpos.append(other_qpos)
all_other_qpos = np.concatenate(all_other_qpos)
vel = self.get_qvel()
cfrc_ext = np.clip(self.get_cfrc_ext(), -1, 1)
cvel = self.get_cvel()
cinert = self.get_cinert()
qfrc_actuator = self.get_qfrc_actuator()
obs = np.concatenate(
[my_pos.flat, vel.flat,
cinert.flat, cvel.flat,
qfrc_actuator.flat, cfrc_ext.flat,
all_other_qpos.flat]
)
assert np.isfinite(obs).all(), "Humanoid observation is not finite!!"
return obs