google / brax

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

'torque' control mode actually controls angular velocity #322

Closed Theo-Cheynel closed 1 year ago

Theo-Cheynel commented 1 year ago

Hi,

I created a simple motorized pendulum environment to confirm doubt I had regarding BRAX's nomenclature. It has a fixed body, and a link + actuator linking it to a swinging body with a certain mass.

When the actuator is controlled in 'position', and you give say 90 as the action, then the pendulum progressively goes to a 90 degrees angle (it goes faster when you increase the strength of the actuator obviously).

However, when the actuator is controlled in 'torque', and you give 1 as the action for the first 10 steps, and start giving 0 afterwards, you'd expect it to start swinging (because no torque is applied, making it a regular pendulum). This is not what we observe, instead, the pendulum stays at the same orientation, making its velocity 0. I expected the 'torque' method to cause the actions given to be passed as angular efforts, instead, they appear to be passed as the target angular velocities. This is quite confusing... Can anyone confirm that 'torque' actuators are not actually controlled in torque, and if so, is there any way for me to control the torque applied via an actuator ?

btaba commented 1 year ago

Hi @Theo-Cheynel thanks for opening an issue! motor actuators should simply add a torque, resulting in accelerating angular velocity (they aren't dependent on position, but a few things that can affect position dependence are the ctrl_range and joint limits). If you provide a concrete example I'm happy to take a look to see if there is a bug

Theo-Cheynel commented 1 year ago

Hi ! Thanks for answering ! Yes, in v2, motor actuators seem to add a torque (except when it exceeds the joint limit etc), which is totally what I expected. The issue is in BRAX v1, where adding a torque actuator does not seem to add a torque, but a velocity control. If you're still working on v1 I can give you an example, but if you're planning on migrating everything to v2 in the coming days, not sure there's really a need for it, you tell me :smile:

btaba commented 1 year ago

Ha ok! Indeed we are not planning to support v1 going forward (we just pushed v2 to the main folder and will tag a release soon), but the observation that torque actuators in v1 are velocity controllers seems like a bug