Farama-Foundation / HighwayEnv

A minimalist environment for decision-making in autonomous driving
https://highway-env.farama.org/
MIT License
2.63k stars 753 forks source link

observation_space return None #592

Open izvvv opened 6 months ago

izvvv commented 6 months ago

state_dim = env.observation_space.shape[0] action_dim = env.action_space.shape[0] max_action = float(env.action_space.high[0])

parking-v0 env.observation_space.shape return none lead to error how to deal with it?

eleurent commented 6 months ago

This is because for ParkingEnv is compatible with training with HER (Hindsight Experience Replay), which requires it to be (see first warning) a gym.GoalEnv, and GoalEnv environments use Dict as observation spaces, not Boxes/arrays, so env.observation.space.shape wont work, you first need to get its fields, and then get their shape.

For example,


print(env.observation_space['observation'].shape)
print(env.observation_space['achieved_goal'].shape)
print(env.observation_space['desired_goal'].shape)