Reputation: 363
Using Python3.6, Ubuntu 18.04, Gym 0.15.4, RoS melodic, Tensorflow 1.14 and rl_coach 1.01:
I have built a custom Gym environment that is using a 360 element array as the observation_space.
high = np.array([4.5] * 360) #360 degree scan to a max of 4.5 meters
low = np.array([0.0] * 360)
self.observation_space = spaces.Box(low, high, dtype=np.float32)
However, this is not enough state to properly train via the ClippedPPO algo and I want to add additional features to my state that include:
Position in the world (x,y coords)
Orientation in the world (Quaternion: x,y,z,w)
Linear Trajectory (x,y,z coords)
angular trajectory (x,y,z coords).
I put the four features above into their own np.arrays and tried to pass them all back as the state object, but obviously it does not match the observation space. the space.Box confuses me. I am assuming I cannot dump all these features into a single np array since uppper and lower bounds will differ, however, I can't determine how to create a spaces.Box object with multiple "features".
TIA
Upvotes: 10
Views: 24167
Reputation: 6076
gym.spaces.Dict
is what you need:
import gym
spaces = {
'position': gym.spaces.Box(low=0, high=100, shape=(2,),
'orientation': ...
}
dict_space = gym.spaces.Dict(spaces)
Upvotes: 10