google / brax

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

Feet contact information #380

Closed maxencefaldor closed 10 months ago

maxencefaldor commented 11 months ago

Hi,

I would like to get the feet contact information for environments like hopper, walker2d, halfcheetah, ant and so on.

For example, for halfcheetah the feet contact information would be a binary two-dimensional vector like [0, 0], [1, 0], [0, 1] or [1, 1], indicating for each foot, if the foot is in contact with the ground.

For ant, a binary four-dimensional vector like [0, 0, 0, 0], [0, 1, 0, 0], ...

What is the best to get that information using a state?

btaba commented 10 months ago

Hi @maxencefaldor ! Apologies for the late reply. I would suggest using the state.pipeline_state.contact.penetration > 0. If you pass debug=True to the base environment (https://github.com/google/brax/blob/main/brax/envs/base.py#L86), the pipeline_state.contact will be populated. Let us know if you have any trouble!