google / brax

Massively parallel rigidbody physics simulation on accelerator hardware.
Apache License 2.0
2.25k stars 249 forks source link

How to compute sys.link.invweight? #289

Closed gijskoning closed 1 year ago

gijskoning commented 1 year ago

The V2 version Brax is just in time for my thesis and already helping me a lot! Thanks for all the work. However, changing the parameters of an brax environment is not yet trivial. I know v2 is still in beta, and figured out computing most of the parameters. But not for invweight, do you know how to compute the invweight from the original System, or the relation with respect to the mass/size of the robot?

gijskoning commented 1 year ago

Also, let me know if I can do anything for this repo with respect to system identification/ domain randomization!

btaba commented 1 year ago

Hi @gijskoning thanks for using brax! What do you mean by invweight? Inverse inertia can be calculated like so if that's what you're referring to

gijskoning commented 1 year ago

I should have pointed to what I meant. Normally it is obtained by mujoco when loading in the xml file: https://github.com/google/brax/blob/6211f46bf908aa793bc502845afbf469f34e6bb3/brax/v2/io/mjcf.py#L327 And used here: https://github.com/google/brax/blob/6211f46bf908aa793bc502845afbf469f34e6bb3/brax/v2/base.py#L246

Thanks for the link I have looked over this function. Hopefully, that represents the invweight. Will try it out tomorrow.

btaba commented 1 year ago

Ah, sorry for misunderstanding, you can check out how it's computed here before it gets loaded into a brax System: https://github.com/deepmind/mujoco/blob/main/src/engine/engine_setconst.c#L88