maxspahn / gym_envs_planar

Planar gym environments
7 stars 4 forks source link

Dictonaries for state return values #22

Closed maxspahn closed 2 years ago

maxspahn commented 2 years ago

Currently, all robot state information are concatenated in one numpy.array. For the simplest robots (nLinkReacher, pointRobot), this is sufficient but for more complex robots (groundRobot with differential drive), this can quickly become confusing: In which position do you find what state information. It becomes even trickier when information on obstacles should be returned.

To improve the readability of the code, it would be beneficial to use dictonaries instead for the returned values. In doing so, the observation spaces need to be adapted to the type Dict, see https://github.com/openai/gym/blob/master/gym/spaces/dict.py.

Here, it might be important to also integrate verification of the returned values and the defined observation space.

maxspahn commented 2 years ago

@alxschwrz Verification of observation spaces can be done with the function self.observation_space.contains(self.state). https://github.com/maxspahn/gym_envs_planar/blob/29c4cd93bcf81d931479fa54e1841b039791e767/planarCommon/planarEnv.py#L65-L66

maxspahn commented 2 years ago

This will include the introduction of polymorphism to unify the definition of acceleration and velocity environments.

maxspahn commented 2 years ago

@alxschwrz Verification of observation spaces can be done with the function self.observation_space.contains(self.state).

https://github.com/maxspahn/gym_envs_planar/blob/29c4cd93bcf81d931479fa54e1841b039791e767/planarCommon/planarEnv.py#L65-L66

This could also be used for terminating episodes when the limits are reached.

alxschwrz commented 2 years ago

Very nice, would love to assist with this! I think having Dictionaries as observation space will be very beneficial. Seems to me as most StableBaselines3 algorithms also support Dictionaries of the observation space. The action space however should stay as spaces.Box to keep compatibility.

maxspahn commented 2 years ago

Very nice, would love to assist with this!

Go ahead the branch is online ft-dict-observation.

maxspahn commented 2 years ago

The only integration missing is on mobileBase robots. This should be feasible through polymorphism, just like for the nLinkReacher. @alxschwrz Can you do it? Let me know if you need help.

maxspahn commented 2 years ago

Fixed in #28