Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cartpole observation is never contained in observation_space #426

Open
2 of 4 tasks
vfdev-5 opened this issue Dec 11, 2021 · 0 comments
Open
2 of 4 tasks

cartpole observation is never contained in observation_space #426

vfdev-5 opened this issue Dec 11, 2021 · 0 comments

Comments

@vfdev-5
Copy link

vfdev-5 commented Dec 11, 2021

Description:

OpenAI Gym changed the way to check if observation_space contains the observation, openai/gym#2374
and thus tasks like cartpole_discrete_balancing.py are not working anymore due to float64 vs float32 inconsistent usage:

observation_space = gym.spaces.Box(
low=-obs_high, high=obs_high, dtype=np.float32
)

vs

observation = Observation(np.array([x, dx, q, dq]))

Steps to reproduce

import gym
import numpy as np

high = np.array(
    [
        2.4,  # x
        20.0,  # dx
        np.deg2rad(12),  # q
        np.deg2rad(3 * 360),  # dq
    ]
)

# Configure the observation space
obs_high = high.copy() * 1.2
observation_space = gym.spaces.Box(
    low=-obs_high, high=obs_high, dtype=np.float32
)

x, dx, q, dq = [0.0, 0.0, 0.0, 0.0]
observation = np.array([x, dx, q, dq])

assert observation_space.contains(observation)
> AssertionError

Environment

  • OS:
  • GPU:
  • Python:
  • Version:
  • Channel:
    • Stable
    • Nightly
  • Installation type:
    • User
    • Developer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant