Install RL Baseline3 Zoo

https://stable-baselines3.readthedocs.io/en/master/guide/install.html

Write Your Environment

Check the environments in learning_envs as examples. Basically, you need to create a class from RCareWorldGymWrapper and write your own functions for __init__ and step() , reset().

In step(), it needs to return obs, rewards, dones, info . Check StableBaseline’s tutorial for more details.

Build Your Scene into an Executable

Check Build a Scene into Executable

Register Your Environment

In pyrcareworld/envs/learning_envs/__init__.py , add your environment.

from pyrcareworld.envs.learning_envs.limb_repositioning_env import LimbRepositionEnv
# Add your environment
from pyrcareworld.envs.learning_envs.your_learning_env import YourLearningEnv

#Add your learning environment to __all__
__all__  = ['LimbRepositionEnv', 'YourLearningEnv']

try:
    from gym.envs.registration import register
		# Original environments 
    register(
        id='LimbRepositioning-v1',
        entry_point = 'pyrcareworld.envs.learning_envs:LimbRepositionEnv',
        kwargs ={
            'executable_file': '<your_path>/Build/limb_reposition/limb_repo.x86_64'
        }
    )

		# Add your new environment
    # id should be the name of the environment-vx 
    # entry_point is the class of your learning environment 
    # specify other keyword arguments in kwargs, here we need to specify the path of the executable file
		register(
        id='YourLearningEnv-v1',
				entry_point = 'pyrcareworld.envs.learning_envs:YourLearningEnv',
        kwargs ={
            'executable_file': '<your_path>/Build/your_learning.x86_64'
        }

except ImportError:
    print('No gym installed. Please install gym!')
    pass

Train your environment

Go to stable baseline’s folder. Use this command to train

python train.py --env YourLearningEnv-v1 --algo tqc

Enjoy your trained environment

Go to stable baseline’s folder. Use this command to enjoy

python enjoy.py --env YourLearningEnv-v1 --algo tqc -f logs/ --deterministic --seed 123