Skip to content

cartpole observation is never contained in observation_space #426

@vfdev-5

Description

@vfdev-5

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:

https://github.com/robotology/gym-ignition/blob/fa14f7f8f667cf84bf226756cea158ec0f5c3d23/python/gym_ignition_environments/tasks/cartpole_discrete_balancing.py#L66-L68

vs

https://github.com/robotology/gym-ignition/blob/fa14f7f8f667cf84bf226756cea158ec0f5c3d23/python/gym_ignition_environments/tasks/cartpole_discrete_balancing.py#L94

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions