question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blur view of reacher pybullet env

See original GitHub issue

I trained the ReacherBulletEnv-v0 using this repository, but when I run the enjoy.py file, I get a very blur environment. How to correct this?

Screenshot from 2020-12-07 16-56-01

The config and version of packages in my environment are given below:

Package                        Version           
------------------------------ -------------------
absl-py                        0.11.0
alembic                        1.4.3
astroid                        2.4.2
astunparse                     1.6.3
atari-py                       0.2.6
attrs                          20.3.0
azure                          1.0.3
azure-common                   1.1.26
azure-mgmt                     0.20.2
azure-mgmt-common              0.20.0
azure-mgmt-compute             0.20.1
azure-mgmt-network             0.20.1
azure-mgmt-nspkg               3.0.2
azure-mgmt-resource            0.20.1
azure-mgmt-storage             0.20.0
azure-nspkg                    3.0.2
azure-servicebus               0.20.1
azure-servicemanagement-legacy 0.20.2
azure-storage                  0.20.3
backcall                       0.2.0
baselines                      0.1.4            
cachetools                     4.1.1
certifi                        2020.6.20
cffi                           1.14.3
chardet                        3.0.4
click                          7.1.2
cliff                          3.5.0
cloudpickle                    1.6.0
cmaes                          0.7.0
cmd2                           1.4.0
colorama                       0.4.4
colorlog                       4.6.2
cycler                         0.10.0
Cython                         0.29.21
dataclasses                    0.6
decorator                      4.4.2
dill                           0.3.3
future                         0.18.2
gast                           0.3.3
glfw                           2.0.0
google-auth                    1.23.0
google-auth-oauthlib           0.4.2
google-pasta                   0.2.0
grpcio                         1.33.2
gym                            0.17.3
h5py                           2.10.0
idna                           2.10
imageio                        2.9.0
iniconfig                      1.1.1
ipdb                           0.13.4
ipython                        7.18.1
ipython-genutils               0.2.0
isort                          5.5.4
jedi                           0.17.2
joblib                         0.17.0
Keras-Preprocessing            1.1.2
kiwisolver                     1.2.0
lazy-object-proxy              1.4.3
llvmlite                       0.34.0
lockfile                       0.12.2
Mako                           1.1.3
Markdown                       3.3.3
MarkupSafe                     1.1.1
matplotlib                     3.3.2
mccabe                         0.6.1
more-itertools                 8.5.0
mpi4py                         3.0.3
numba                          0.51.2
numpy                          1.19.2
oauthlib                       3.1.0
opencv-python                  4.4.0.44
opt-einsum                     3.3.0
optuna                         2.3.0
packaging                      20.7
pandas                         1.1.2
parso                          0.7.1
pbr                            5.5.1
pexpect                        4.8.0
pickleshare                    0.7.5
Pillow                         7.2.0
pip                            20.2.2
pluggy                         0.13.1
prettytable                    0.7.2
progressbar2                   3.53.1
prompt-toolkit                 3.0.8
protobuf                       3.13.0
psutil                         5.7.3
ptyprocess                     0.6.0
py                             1.9.0
py-dateutil                    2.2
pyarrow                        2.0.0
pyasn1                         0.4.8
pyasn1-modules                 0.2.8
pybullet                       3.0.4
pybullet-robot-envs            0.0.1              
pycparser                      2.20
pyglet                         1.5.0
Pygments                       2.7.2
pylint                         2.6.0
pyparsing                      2.4.7
pyperclip                      1.8.1
pytest                         6.1.2
python-dateutil                2.8.1
python-editor                  1.0.4
python-utils                   2.4.0
pytz                           2020.1
PyYAML                         5.3.1
pyzmq                          20.0.0
requests                       2.25.0
requests-oauthlib              1.3.0
rsa                            4.6
scipy                          1.5.2
seaborn                        0.11.0
setuptools                     49.6.0.post20200925
six                            1.15.0
SQLAlchemy                     1.3.20
stable-baselines               2.10.1
stable-baselines3              0.10.0
stevedore                      3.3.0
tensorboard                    2.4.0
tensorboard-plugin-wit         1.7.0
tensorboardX                   2.1
tensorflow                     2.3.1
tensorflow-estimator           2.3.0
termcolor                      1.1.0
toml                           0.10.1
torch                          1.7.0
tqdm                           4.51.0
traitlets                      5.0.5
typing-extensions              3.7.4.3
urllib3                        1.26.2
wcwidth                        0.2.5
Werkzeug                       1.0.1
wheel                          0.35.1
wrapt                          1.12.1
zmq                            0.0.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
erwincoumanscommented, Apr 13, 2021

The blurry image is likely due to the simple cpu TinyRenderer instead of using hardware OpenGL 3. Yes, it is a good idea to call env.render() before the first env.reset(). This is a special feature that enables hardware rendering, since the Gym API has no proper way to add options before starting the env. Can this be made default, if ‘enjoying’ the pybullet environments?

Another option is to run a pybullet server, which will be used for hardware OpenGL rendering in a different terminal, leave it running, and then enjoy the environment/create a video. A PyBullet env will first try to detect such server and connect over shared memory. Don’t resize/close while creating the video.

python -m pybullet_utils.runServer

This is how it should look like (AntBullet-v0), note the reflection and shadows etc:

image

1reaction
chisariecommented, Jan 20, 2021

Also other pybullet envs have some distortion. But I just found out that doing env.render() before env.reset() solves both the weird color and the distortion. The image is still blurry / low quality, but I guess this is only a setting thing. In case the OP is still interested, this is my script:

import time
import gym
import pybullet_envs  # noqa: F401
from stable_baselines3.common.vec_env import VecVideoRecorder, DummyVecEnv

env_id = "ReacherBulletEnv-v0"
video_folder = "logs/videos/"
video_length = 100

env = DummyVecEnv([lambda: gym.make(env_id)])
env.render()

# Record the video starting at the first step
env = VecVideoRecorder(
    env,
    video_folder,
    record_video_trigger=lambda x: x == 0,
    video_length=video_length,
    name_prefix="random-agent-{}".format(env_id),
)

obs = env.reset()
for _ in range(video_length + 1):
    action = [env.action_space.sample()]
    obs, _, _, _ = env.step(action)
# Save the video
env.close()

Read more comments on GitHub >

github_iconTop Results From Across the Web

Simulate Images for ML in PyBullet — The Quick & Easy Way
This function returns three image buffers: rgbImg, depthImg, and segImg. rgbImg is a uint8 image with red, green, blue, and alpha channels of ......
Read more >
Fix Constraint is Not Fixed - Real-Time Physics Simulation ...
I am using pyBullet, so I guess the "JOINT_FIXED" constraint is the same as btFixedConstraints in Bullet. I do not update anything once...
Read more >
A visualization of our PyBullet gym environment. The blue ...
Download scientific diagram | A visualization of our PyBullet gym environment. The blue vectors represent the target velocities of each agent, ...
Read more >
Learning to Fly -- a Gym Environment with PyBullet Physics for ...
In this paper, we propose an open-source OpenAI Gym-like environment for multiple quadcopters based on the Bullet physics engine. Its multi-agent and vision- ......
Read more >
Learning to Fly—a Gym Environment with PyBullet Physics for ...
In this paper, we propose an open-source OpenAI Gym-like environment for multiple quadcopters based on the Bullet physics engine. Its multi- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found