microsoft / AirSim

Open source simulator for autonomous vehicles built on Unreal Engine / Unity, from Microsoft AI & Research
https://microsoft.github.io/AirSim/
Other
16.31k stars 4.54k forks source link

ERROR in DQN drone example: Environment space is not image or dictionary observation space #4862

Closed kanishkanarch closed 1 year ago

kanishkanarch commented 1 year ago

Bug report

What's the issue you encountered?

The DQN example in the repository is giving environment gym error saying that the environment space is not an image or a dictionary. Following is the error I am getting: image

Settings

I am using default settings

How can the issue be reproduced?

  1. Run the LandscapeMountains simulator using ~/LandscapeMountains/LinuxNoEditor/LandscapeMountains.sh -windowed
  2. Run the given DQN example using python3 ~/AirSim/PythonClient/reinforcement_learning/dqn_drone.py

Include full error message in text form

/home/ubuntu20sdd/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/base_vec_env.py:74: UserWarning: The render_mode attribute is not defined in your environment. It will be set to None. warnings.warn("The render_mode attribute is not defined in your environment. It will be set to None.") Traceback (most recent call last): File "dqn_drone.py", line 27, in env = VecTransposeImage(env) File "/home/ubuntu20sdd/.local/lib/python3.8/site-packages/stable_baselines3/common/vec_env/vectranspose.py", line 22, in __init_\ assert is_image_space(venv.observation_space) or isinstance( AssertionError: The observation space must be an image or dictionary observation space

What's better than filing an issue? Filing a pull request :).

GioFic95 commented 1 year ago

Hi @kanishkanarch, I had your same problem some minutes ago. I downgraded some libraries and now the example seems to be working.

I am using Python 3.8.17. This is the output of pip freeze:

absl-py==1.4.0
cachetools==5.3.1
certifi==2023.5.7
charset-normalizer==3.2.0
cloudpickle==2.2.1
contourpy==1.1.0
cycler==0.11.0
filelock==3.12.2
fonttools==4.41.0
google-auth==2.22.0
google-auth-oauthlib==1.0.0
grpcio==1.56.0
gym==0.21.0
idna==3.4
importlib-metadata==4.13.0
importlib-resources==6.0.0
Jinja2==3.1.2
kiwisolver==1.4.4
Markdown==3.4.3
MarkupSafe==2.1.3
matplotlib==3.6.0
mpmath==1.3.0
msgpack-python==0.5.6
msgpack-rpc-python==0.4.1
networkx==3.1
numpy==1.19.5
oauthlib==3.2.2
opencv-contrib-python==4.8.0.74
packaging==23.1
pandas==1.4.4
Pillow==10.0.0
protobuf==4.23.4
pyasn1==0.5.0
pyasn1-modules==0.3.0
PyAudio==0.2.13
pyparsing==3.0.9
python-dateutil==2.8.2
pytz==2023.3
requests==2.31.0
requests-oauthlib==1.3.1
rsa==4.9
six==1.16.0
stable-baselines3==1.7.0
sympy==1.12
tensorboard==2.13.0
tensorboard-data-server==0.7.1
torch==2.0.1
tornado==4.5.3
typing_extensions==4.7.1
urllib3==1.26.16
Werkzeug==2.3.6
zipp==3.16.1

While this is the output of conda list:

# packages in environment at C:\Users\super\miniconda3\envs\airsim:
#
# Name                    Version                   Build  Channel
absl-py                   1.4.0                    pypi_0    pypi
ca-certificates           2023.05.30           haa95532_0  
cachetools                5.3.1                    pypi_0    pypi
certifi                   2023.5.7                 pypi_0    pypi
charset-normalizer        3.2.0                    pypi_0    pypi
cloudpickle               2.2.1                    pypi_0    pypi
contourpy                 1.1.0                    pypi_0    pypi
cycler                    0.11.0                   pypi_0    pypi
filelock                  3.12.2                   pypi_0    pypi
fonttools                 4.41.0                   pypi_0    pypi
google-auth               2.22.0                   pypi_0    pypi
google-auth-oauthlib      1.0.0                    pypi_0    pypi
grpcio                    1.56.0                   pypi_0    pypi
gym                       0.21.0                   pypi_0    pypi
idna                      3.4                      pypi_0    pypi
importlib-metadata        4.13.0                   pypi_0    pypi
importlib-resources       6.0.0                    pypi_0    pypi
jinja2                    3.1.2                    pypi_0    pypi
kiwisolver                1.4.4                    pypi_0    pypi
libffi                    3.4.4                hd77b12b_0  
markdown                  3.4.3                    pypi_0    pypi
markupsafe                2.1.3                    pypi_0    pypi
matplotlib                3.6.0                    pypi_0    pypi
mpmath                    1.3.0                    pypi_0    pypi
msgpack-python            0.5.6                    pypi_0    pypi
msgpack-rpc-python        0.4.1                    pypi_0    pypi
networkx                  3.1                      pypi_0    pypi
numpy                     1.19.5                   pypi_0    pypi
oauthlib                  3.2.2                    pypi_0    pypi
opencv-contrib-python     4.8.0.74                 pypi_0    pypi
openssl                   3.0.9                h2bbff1b_0  
packaging                 23.1                     pypi_0    pypi
pandas                    1.4.4                    pypi_0    pypi
pillow                    10.0.0                   pypi_0    pypi
pip                       23.1.2           py38haa95532_0  
protobuf                  4.23.4                   pypi_0    pypi
pyasn1                    0.5.0                    pypi_0    pypi
pyasn1-modules            0.3.0                    pypi_0    pypi
pyaudio                   0.2.13                   pypi_0    pypi
pyparsing                 3.0.9                    pypi_0    pypi
python                    3.8.17               h1aa4202_0  
python-dateutil           2.8.2                    pypi_0    pypi
pytz                      2023.3                   pypi_0    pypi
requests                  2.31.0                   pypi_0    pypi
requests-oauthlib         1.3.1                    pypi_0    pypi
rsa                       4.9                      pypi_0    pypi
setuptools                65.5.0                   pypi_0    pypi
six                       1.16.0                   pypi_0    pypi
sqlite                    3.41.2               h2bbff1b_0  
stable-baselines3         1.7.0                    pypi_0    pypi
sympy                     1.12                     pypi_0    pypi
tensorboard               2.13.0                   pypi_0    pypi
tensorboard-data-server   0.7.1                    pypi_0    pypi
torch                     2.0.1                    pypi_0    pypi
tornado                   4.5.3                    pypi_0    pypi
typing-extensions         4.7.1                    pypi_0    pypi
urllib3                   1.26.16                  pypi_0    pypi
vc                        14.2                 h21ff451_1  
vs2015_runtime            14.27.29016          h5e58377_2  
werkzeug                  2.3.6                    pypi_0    pypi
wheel                     0.38.4           py38haa95532_0  
zipp                      3.16.1                   pypi_0    pypi
kanishkanarch commented 1 year ago

Thanks, @GioFic95 , I am using Python 3.8.10. Following is the difference in your packages and my packages, can you please specify which libraries you downgraded?: image

(List of my packages in text) ``` absl-py==1.4.0 cachetools==5.3.0 certifi==2019.11.28 charset-normalizer==3.1.0 cloudpickle==2.2.1 contourpy==1.0.7 cycler==0.11.0 filelock==3.12.0 fonttools==4.39.4 google-auth==2.18.0 google-auth-oauthlib==1.0.0 grpcio==1.54.0 gym==0.21.0 idna==2.8 importlib-metadata==6.6.0 importlib-resources==5.12.0 Jinja2==2.10.1 kiwisolver==1.4.4 Markdown==3.4.3 MarkupSafe==2.1.2 matplotlib==3.7.1 mpmath==1.3.0 msgpack-python==0.5.6 msgpack-rpc-python==0.4.1 networkx==3.1 numpy==1.24.3 oauthlib==3.1.0 opencv-contrib-python==4.8.0.74 packaging==23.1 pandas==2.0.2 Pillow==9.5.0 protobuf==4.23.0 pyasn1==0.4.2 pyasn1-modules==0.2.1 PyAudio==0.2.11 pyparsing==2.4.6 python-dateutil==2.8.2 pytz==2023.3 requests==2.31.0 requests-oauthlib==1.3.1 rsa==4.9 six==1.14.0 stable-baselines3==2.0.0 sympy==1.12 tensorboard==2.13.0 tensorboard-data-server==0.7.0 torch==1.13.1+cu117 tornado==4.5.3 typing-extensions==4.7.1 urllib3==1.25.8 Werkzeug==2.3.4 zipp==3.15.0 ```

I can't use conda for this particular project (there's a technical reason), so I have installed packages with native pip. Anyhow, I checked and there's no difference in your pip packages and your conda packages, so I don't know what to do with your conda package list: image

kanishkanarch commented 1 year ago

I downgraded only stable-baselines3 library (to 1.7.0) and now the RL code is working perfectly fine without any errors. Thank you so much for your help, @GioFic95 !!

wzwb commented 1 year ago

Thanks!!!!