ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Error while using OpenAI Gym in ROS Noetic

asked 2022-10-24 15:42:22 -0600

jandisoon gravatar image

updated 2022-10-26 04:45:38 -0600

ravijoshi gravatar image

I have installed OpenAI Gym and ROS Noetic. Now, I'm following this tutorial in YouTube in my local installation. However, after executing the following command rosrun cartpole_v0_training start_training.py, I am getting below error:

/usr/lib/python3/dist-packages/requests/__init__.py:89: RequestsDependencyWarning: urllib3 (1.26.12) or chardet (3.0.4) doesn't match a supported version!
  warnings.warn("urllib3 ({}) or chardet ({}) doesn't match a supported "
Traceback (most recent call last):
  File "/home/zahra/openai_ws/src/cartpole_v0_training/scripts/start_training.py", line 29, in <module>
    env = gym.make('MyCartPole-v0')
  File "/usr/local/lib/python3.8/dist-packages/gym/envs/registration.py", line 669, in make
    env = PassiveEnvChecker(env)
  File "/usr/local/lib/python3.8/dist-packages/gym/wrappers/env_checker.py", line 24, in __init__
    assert hasattr(
AssertionError: The environment must specify an observation space. https://www.gymlibrary.dev/content/environment_creation/
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-10-26 04:44:55 -0600

ravijoshi gravatar image

Below, I am quoting the error from logs posted in the question:

AssertionError: The environment must specify an observation space. https://www.gymlibrary.dev/content/en...

The above error is unrelated to ROS. It is coming from OpenAI Gym.

There are certain rules that must be followed when designing a new environment in OpenAI Gym. For example, every environment must have observation space. The observation space is defined by the observation_space attribute. However, it is not specified in your case, i.e., env.observation_space in None. Thus you are getting the error.

Please change line number 29 of the start_training.py file, where you are creating an environment, with the following:

env = gym.make('CartPole-v0')

Notice that I am using an existing environment in OpenAI Gym.

edit flag offensive delete link more

Comments

did it work in ros Noetic

kedarnath gravatar image kedarnath  ( 2023-05-30 07:20:19 -0600 )edit

Question Tools

Stats

Asked: 2022-10-24 15:42:22 -0600

Seen: 537 times

Last updated: Oct 26 '22