xbpeng / DeepMimic

Motion imitation with deep reinforcement learning.
https://xbpeng.github.io/projects/DeepMimic/index.html
MIT License
2.32k stars 489 forks source link

Values for different characters #140

Open tfederico opened 3 years ago

tfederico commented 3 years ago

Hello,

I wanted to train a different character (like you did with the Atlas robot) and I am trying to figure out what changes I need to implement. I am currently using the PyBullet implementation, but in terms of parameters I don't think that makes any difference.

I figured (please correct me if I am wrong) that what I need to change is the values of kd and kp, so I was wondering how you obtained/calculated the values for the controllers in here. For example, how did you obtain the values for the Atlas robot?

In addition, I was wondering if you could help me understand how you calculated the bounds and offset for the actions here.

For example

def build_action_bound_min(self, agent_id):
    #see cCtCtrlUtil::BuildBoundsPDSpherical
    out_scale = [-1] * self.get_action_size(agent_id)
    out_scale = [
        -4.79999999999, -1.00000000000, -1.00000000000, -1.00000000000, -4.00000000000,
        -1.00000000000, -1.00000000000, -1.00000000000, -7.77999999999, -1.00000000000,
        -1.000000000, -1.000000000, -7.850000000, -6.280000000, -1.000000000, -1.000000000,
        -1.000000000, -12.56000000, -1.000000000, -1.000000000, -1.000000000, -4.710000000,
        -7.779999999, -1.000000000, -1.000000000, -1.000000000, -7.850000000, -6.280000000,
        -1.000000000, -1.000000000, -1.000000000, -8.460000000, -1.000000000, -1.000000000,
        -1.000000000, -4.710000000
    ]

    return out_scale

How do you calculate these values? Would they be any different for a different character (e.g., Atlas robot)?

Many thanks in advance!

tfederico commented 3 years ago

So I figured how to calculate the offset and scale for the actions, but I still don't know where the bounds values are coming from. @xbpeng could you please explain how you obtained those values?

xbpeng commented 3 years ago

the kp and kd values are manually tuned. I suspect you can use similar values as the humanoid, but might need to bump them up a bit, since the atlas is a lot heavier. In general, you want kp to be large enough so that the robot can exert enough force to do what you want it to do, but not too high, that the robot ends up being very stiff. kd is usually just set to about 0.1kp.

For the action bounds, they are proportional to the range of motion of each joint. So for a revolute joint like the knees, the range of motion is something like [-pi, 0]. The action bound are then usually set to be a bit larger than that, maybe [-1.5, 0.5]. Either way tho, the exact values of the bounds are not too important. You can take a look at this code to see how the bounds are calculated https://github.com/xbpeng/DeepMimic/blob/50bcc866b924fb425da7b492965c2d871fa82a8c/DeepMimicCore/sim/CtCtrlUtil.cpp#L89

tfederico commented 3 years ago

So given that the humanoid characters and the Atlas robot have similar joints, would the action bounds be the same? Also I would expect the maximum/minimum values for the joints to be around [-2pi, 2pi], but some of the values are larger. Shouldn't 360° be the maximum value for a spherical joint?

Il Mar 26 Gen 2021, 18:25 xbpeng notifications@github.com ha scritto:

the kp and kd values are manually tuned. I suspect you can use similar values as the humanoid, but might need to bump them up a bit, since the atlas is a lot heavier. In general, you want kp to be large enough so that the robot can exert enough force to do what you want it to do, but not too high, that the robot ends up being very stiff. kd is usually just set to about 0.1kp.

For the action bounds, they are proportional to the range of motion of each joint. So for a revolute joint like the knees, the range of motion is something like [-pi, 0]. The action bound are then usually set to be a bit larger than that, maybe [-1.5, 0.5]. Either way tho, the exact values of the bounds are not too important. You can take a look at this code to see how the bounds are calculated

https://github.com/xbpeng/DeepMimic/blob/50bcc866b924fb425da7b492965c2d871fa82a8c/DeepMimicCore/sim/CtCtrlUtil.cpp#L89

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/xbpeng/DeepMimic/issues/140#issuecomment-767698844, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADU47BS3A2SLPCTDKS6OYBDS333G5ANCNFSM4WR7T67A .

xbpeng commented 3 years ago

yes, the actions bounds can probably be similar for the atlas. The limits for the actions are usually slightly larger than the pose limits for each joint. Take a look at the code i pointed to, to see how that is calculated. The intuition for why the range for the actions is larger, is that if the action limits are the same as the joint limits, then when the joint hits its limit, the pd controller will no longer be able to exert a force anymore. By making the action limits a bit larger, this allows the pd controllers to keep exert a force even when the joint limits are hit.

tfederico commented 3 years ago

I took a look at the code that you suggested and I figured out how to calculate those values, but it seems that in order to do so I need to use joint_mat. i suppose the values in joint_mat are the ones in data/characters/humanoid_3d.txt. Thank you very much for your help!

One last question: where did you get the values of TorqueLim and DiffWeight that are in the file data/characters/humanoid_3d.txt?

xbpeng commented 3 years ago

The torque limits are roughly based on those of a human, though the character is on the strong end. Diff weights are also just manually specified.

rohit-kumar-j commented 3 years ago

So I figured how to calculate the offset and scale for the actions, but I still don't know where the bounds values are coming from. @xbpeng could you please explain how you obtained those values?

@tfederico can you elaborate on how to calculate these values?

tfederico commented 3 years ago

@rohit-kumar-j it's slightly different depending of the joint type, but if you take a look here https://github.com/xbpeng/DeepMimic/blob/50bcc866b924fb425da7b492965c2d871fa82a8c/DeepMimicCore/sim/CtCtrlUtil.cpp#L226 you can see how they are calculated for the revolute joint

rohit-kumar-j commented 2 years ago

@tfederico I have replicated an initial simulation for the robot in pybullet. See #2 RJAX: Inital Sims. I will be re-making this with torque limits, joint limits, etc. Back here for a recap😄