google / brax

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

Applying external forces #61

Closed namheegordonkim closed 3 years ago

namheegordonkim commented 3 years ago

Hi,

I think Brax currently doesn't support applying external force/torque to the bodies. I'm getting around this by setting linear and angular velocities with qp.replace(). It would be nice to have an explicit function like PyBullet's applyExternalForce. Any plan to implement something like this?

cdfreeman-google commented 3 years ago

Yes, we do plan to implement this, but haven't had a good concrete need for it yet, and it somewhat complicates the step semantics if not done carefully. I'll follow up here when we get to this (hopefully soon!)

namheegordonkim commented 3 years ago

Bumping this request. External forces proved very useful for trajectory optimization in my recent project, and I'd love to use Brax for further development of this. See: https://dl.acm.org/doi/abs/10.1145/3480144

erikfrey commented 3 years ago

@namheegordonkim agreed this would be helpful! External forces is under active development fyi.

erikfrey commented 3 years ago

@namheegordonkim and it's live. See brax/physics/forces.py for how it has been implemented. brax/envs/inverted_pendulum.py for an example of usage.

erwincoumans commented 3 years ago

Great, closing the issue. If the external force application doesn't work for you, please file a new issue.