Skip to content

Recommended way to actively set system's state #498

Answered by erikfrey
yardenas asked this question in Q&A
Discussion options

You must be logged in to vote

You're welcome to rely on the Reset function to create a pool of states that are sampled from some distribution, or override the state yourself during Step - either will work and it depends on your use case.

Brax is designed so resetting has virtually no impact on simulation speed. My default suggestion is to just add your "start upright" states into reset and everything should just work:

def reset(rng: jax.Array) -> State:
  # set the pendulum upright 20% of the time
  up = jax.random.uniform(rng) < 0.2
  pendulum_ypos = jp.where(up, 1.0, 0.0)
  ...

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@yardenas
Comment options

Answer selected by yardenas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants