Possible to access environment variables from a Policy's compute_actions() function?

How severe does this issue affect your experience of using Ray?

  • Medium: It contributes to significant difficulty to complete my task, but I can work around it.

Hello! I am using RLlib to train some pybullet-simulated robots to perform some actions, and I want to create a comparison policy that uses simple inverse kinematics as as performed by pybullet. However, I have a problem: pybullet wants the body ID of the robot to calculate IK for, and this ID can be different for each environment. I am hoping there is some way to access environment variables from compute_actions(); it seems like config[“env”] is just a string so that won’t work. Is there any way to do what I’m trying to do, or will I need to come up with a work-around? Thanks!

Hi @automata,

Yes, config[“env”] is a string. RLlib will search the tune registry for such an env - you can put it there yourself with ray.tune.registry.register_env.

Now to your problem: Have you tried putting the ‘body ID’ of your robot into the info field?
On every step, gym-style environments return not only an observation, but also info.


1 Like

I didn’t think of using the info field, but that’s exactly what I need I think. Thank you very much for your assistance!

1 Like