stanfordnmbl / osim-rl

Reinforcement learning environments with musculoskeletal models
http://osim-rl.stanford.edu/
MIT License
877 stars 248 forks source link

Question about the localized velocity #185

Closed joneswong closed 5 years ago

joneswong commented 5 years ago

I am confused by this:

yaw = state_desc['joint_pos']['ground_pelvis'][2]
dx_local, dy_local = rotate_frame(  state_desc['body_vel']['pelvis'][0],
                                                        state_desc['body_vel']['pelvis'][2],
                                                        yaw)
dz_local = state_desc['body_vel']['pelvis'][1]

If we use yaw to rotate velocities in axis-0 and axis-2, the yaw is certainly acquired from axis-1 which is orthogonal to the plane of axis-0 and axis-2. Could someone give me a help? Thanks!

joneswong commented 5 years ago

Hi Lukasz @kidzik I think ["body_vel"]["pelvis"][0] and ["body_vel"]["pelvis"][2] are the velocity in the horizon plane. The author want to rotate them according to the orientation of pelvis (i.e., the rotated angle in vertical axis). According to http://osim-rl.stanford.edu/docs/nips2018/observation/ ["joint_pos"]["ground_pelvis"][0:3] are translation along the axes. So why does ["ground_pelvis][2] correspond to the rotation in vertical axis? Could you give me some ideas as, in this year, there has not been any guidance on the observation space? Thanks!

smsong commented 5 years ago

Hi, @joneswong.

The observation space this year is different from last year as it is defined in the body frame (relative to the human model) instead of in the global frame. http://osim-rl.stanford.edu/docs/nips2018/observation/ may not apply for this year.

We thought that the key-values of the obs_dict would be straightforward. Refer to the comments (e.g. (+) forward, (+) leftward, ...) for array values. For example, obs_dict['pelvis']['vel'] is an array with 6 values, where the first three represent the forward, leftward and upward velocities, and the latter three represent pitch, roll and yaw angular velocities (as described in the comment). Please let us know if any values do not match its description. I have just checked those and they seem to match.

joneswong commented 5 years ago

Hi @smsong
Thanks for your explanation. I knew the 6 values but I thought yaw is incorrect. After I studied the opensim model file, I got the reason.

<TransformAxis name="rotation3">
    <!--Names of the coordinates that serve as the independent variables         of the transform function.-->
    <coordinates>pelvis_rotation</coordinates>
    <!--Rotation or translation axis for the transform.-->
    <axis>0 1 0</axis>
    <!--Transform function of the generalized coordinates used to        represent the amount of transformation      along a specified axis.-->
     <function>
     <LinearFunction>
     <coefficients> 1 0</coefficients>
     </LinearFunction>
     </function>
</TransformAxis>

The entries of state_desc['joint']['ground_pelvis'] are not the same as last year's document defined. According to the code snippet I pasted, yaw = state_desc['joint_pos']['ground_pelvis'][2] now refers to the rotation in vertical (i.e., the second axis). Thus, your implementation is correct. Thanks for your help!