Skip to content

Instantly share code, notes, and snippets.

@cmoxiv
Created August 29, 2019 13:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cmoxiv/a4d1671e28efcf783326755508cbc9ee to your computer and use it in GitHub Desktop.
Save cmoxiv/a4d1671e28efcf783326755508cbc9ee to your computer and use it in GitHub Desktop.
## Values in the observation vector
# 'vtgt_field': vtgt vectors in body frame (2*11*11 = 242 values)
# 'pelvis': height, pitch, roll, 6 vel (9 values)
# for each 'r_leg' and 'l_leg' (*2)
# 'ground_reaction_forces' (3 values)
# 'joint' (4 values)
# 'd_joint' (4 values)
# for each of the eleven muscles (*11)
# normalized 'f', 'l', 'v' (3 values)
# 242 + 9 + 2*(3 + 4 + 4 + 11*3) = 339
def obsdict2list(obs_dict):
# Augmented environment from the L2R challenge
res = []
# target velocity field (in body frame)
v_tgt = np.ndarray.flatten(obs_dict['v_tgt_field'])
res += v_tgt.tolist()
res.append(obs_dict['pelvis']['height'])
res.append(obs_dict['pelvis']['pitch'])
res.append(obs_dict['pelvis']['roll'])
res.append(obs_dict['pelvis']['vel'][0]/self.LENGTH0)
res.append(obs_dict['pelvis']['vel'][1]/self.LENGTH0)
res.append(obs_dict['pelvis']['vel'][2]/self.LENGTH0)
res.append(obs_dict['pelvis']['vel'][3])
res.append(obs_dict['pelvis']['vel'][4])
res.append(obs_dict['pelvis']['vel'][5])
for leg in ['r_leg', 'l_leg']:
res += obs_dict[leg]['ground_reaction_forces']
res.append(obs_dict[leg]['joint']['hip_abd'])
res.append(obs_dict[leg]['joint']['hip'])
res.append(obs_dict[leg]['joint']['knee'])
res.append(obs_dict[leg]['joint']['ankle'])
res.append(obs_dict[leg]['d_joint']['hip_abd'])
res.append(obs_dict[leg]['d_joint']['hip'])
res.append(obs_dict[leg]['d_joint']['knee'])
res.append(obs_dict[leg]['d_joint']['ankle'])
for MUS in ['HAB', 'HAD', 'HFL', 'GLU', 'HAM',
'RF', 'VAS', 'BFSH', 'GAS', 'SOL', 'TA']:
res.append(obs_dict[leg][MUS]['f'])
res.append(obs_dict[leg][MUS]['l'])
res.append(obs_dict[leg][MUS]['v'])
return res
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment