rail-berkeley / rlkit

Collection of reinforcement learning algorithms
MIT License
2.45k stars 550 forks source link

Cannot render custom Gym environment "TypeError: 'bool' object is not callable" #90

Closed PierreExeter closed 4 years ago

PierreExeter commented 4 years ago

Hello,

First of all, thanks a lot for this very useful code! I have some issues with rendering a custom-made Gym environment after training it using the DDPG example.

I am able to visualise a trained policy using other Gym environments (for example cartpole-v0 trained using the DQN example script). I am also able to render the custom-made Gym environment with random action inputs (in the Pybullet engine). I am able to train the custom-made Gym environment using the DDPG example script. However, when running the trained policy,

python scripts/run_policy.py ./data/DDPG-replab/DDPG_replab_2019_11_07_12_34_13_0000--s-0/params.pkl

I get the following error:

pybullet build time: Feb  4 2019 11:21:51
b3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:
No inertial data for link, using mass=1, localinertiadiagonal = 1,1,1, identity local inertial frameb3Warning[examples/Importers/ImportURDFDemo/BulletUrdfImporter.cpp,126]:
gripper_aux_linkPolicy loaded
Traceback (most recent call last):
  File "run_policy.py", line 40, in <module>
    simulate_policy(args)
  File "run_policy.py", line 24, in simulate_policy
    render=True,
  File "~/rlkit/rlkit/samplers/rollout_functions.py", line 110, in rollout
    env.render(**render_kwargs)
  File "~/rlkit/rlkit/envs/wrappers.py", line 27, in render
    return self._wrapped_env.render(*args, **kwargs)
TypeError: 'bool' object is not callable

Do you have any idea what is causing this issue?

Many thanks in advance, Pierre

vitchyr commented 4 years ago

It looks like the render variable on the wrapped env is a boolean and not a function. Can you check that the render member of your environment is a function?

vitchyr commented 4 years ago

Feel free to reopen this, but I am going to close it since it seems to be an issue with the env and not rlkit.

PierreExeter commented 4 years ago

Apologies, I realized that I actually never replied. You were right, in my environment I had a boolean variable called render that was overwriting the render() method. I renamed it render_bool to solve the issue.

Thanks