Create a new enviroment in gym_gazebo2

It is likely that you want to extend gym-gazebo2 with your own environment. We encourage you to experiment with MARA robotic arm, which will give you the best user experience, as it is the robot we are training and improving daily.

In this tutorial you will learn the steps you must follow in order to register a new environment.

Let's say you created a new MARA environment, which is the same as the most basic MARA-v0, but with some interesting changes in the reward system. Since it is a good idea to keep both environments, as they supposedly produce valid but different policies, we are not going to overwrite the existing env. We are going to create a new MARA-v1 version instead. You can replace MARA-v1 for any name you want to give to the new environment, note that you must follow the {name}-v{number} convention to register it.

The following are the steps that should be followed from the creation of the new environment, to the final registration of it.

1. Create the new environment and place it under /gym_gazebo2/envs/MARA.

# go to the envs/MARA folder
cd gym_gazebo2/envs/MARA

# copy the base mara env and rename it

2. Give a new name to the class inside

# remove
class MARAEnv(gym.Env):
# add
class MARANewRewardEnv(gym.Env):

3. Import the new environment to MARA/

# add
from gym_gazebo2.envs.MARA.mara_new_reward import MARANewRewardEnv

4. Register the environment in gym_gazebo2/

# add

5. Finally, we can call the environment from the learning script and initialize it.

env = gym.make('MARA-v1')