Skip to main content

An OpenAI Gym Environment for BabyRobot

Project description

BabyRobotGym

A Reinforcement Learning Gym Environment for Baby Robot

The code in this repository accompanies the Towards Data Science article Creating a Custom Gym Environment for Jupyter Notebooks - Part 1: Creating the framework and shows the steps required to create a custom gym environment with graphical output in a Jupyter notebook.

To install:

pip install babyrobot

Animation Example

An example notebook showing how animation and movie creation can be done in the Baby Robot Gym environment:

Binder

API Example

The example notebook, showing all of the API calls used to create a Baby Robot Gym environment can be opened here:

Binder

Reinforcement Learning

Part 1: State Values and Policy Evaluation

Binder

Training Example

An example of using the PPO Reinforcement Learning algorithm to train Baby Robot how to escape from a maze:

Open In Colab

Getting the Github Code:

Testing

The test notebook, showing how to run a simple RL environment can be opened here:

Open In Colab

Cloning the Github repository

To get up and running with this simple custom Gym Environment, do the following:

1.  Get the code and move to the newly created directory:

git clone https://github.com/WhatIThinkAbout/BabyRobotGym.git
cd BabyRobotGym

  • this directory contains the files and folder structure.



2.  Create a Conda environment and install the required packages:

To be able to run our environment we need to have a few other packages installed, most notably 'Gym' itself. To make it easy to setup the environment the Github repo contains a couple of '.yml' files that list the required packages. 

To use these to create a Conda environment and install the packages, do the following (choose the one appropriate for your operating system):

On Unix:

conda env create -f environment_unix.yml

On Windows: 

conda env create -f environment_windows.yml



3.  Activate the environment:

We've created the environment with all our required packages, so now it's just a case of activating it, as follows:

conda activate BabyRobotGym

(when you're finished playing with this environment run "conda deactivate" to get back out)

And once the environment has been activated, to create a Jupyter kernel, run the following. This will let the environment be selected from within your Jupyter notebook:

python -m ipykernel install --user --name=BabyRobotGym



4.  Run the notebook

Everything should now be in place to run our custom Gym environment. To test this we can run the sample Jupyter Notebook 'baby_robot_gym_test.ipynb' that's included in the repository. This will load the 'BabyRobotEnv-v1' environment and test it using the Stable Baseline's environment checker. 

To start this in a browser, just type:

jupyter notebook baby_robot_gym_test.ipynb

(When running in jupyter notebook the current Conda environment will automatically be used and the required packages should all be available. It's also possible to run "python -m ipykernel install --user --name=BabyRobotGym" which will create a Jupyter Notebook kernel, that can then be selected from the notebook's menu.)

Or else just open this file in VS Code and make sure 'BabyRobotGym' is selected as the kernel. This should make the 'BabyRobotEnv-v1' environment, test it in Stable Baselines and then run the environment until it completes, which happens to occur in a single step, since we haven't yet written the 'step' function!



Notes:

If, while running in a terminal (as opposed to a Jupyter Notebook) you get the warning "DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs", in a terminal run:

export JUPYTER_PLATFORM_DIRS=1

followed by:

jupyter --paths

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

babyrobot-1.0.40.tar.gz (117.2 kB view details)

Uploaded Source

Built Distribution

babyrobot-1.0.40-py3-none-any.whl (161.2 kB view details)

Uploaded Python 3

File details

Details for the file babyrobot-1.0.40.tar.gz.

File metadata

  • Download URL: babyrobot-1.0.40.tar.gz
  • Upload date:
  • Size: 117.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for babyrobot-1.0.40.tar.gz
Algorithm Hash digest
SHA256 7a32f71441d39f05e9cfaa09c74fc5d99eb9f1757acf01985885844929f9fe10
MD5 ddd425ff85e94cedd1bbfe9e6f4e9866
BLAKE2b-256 b66418ae1f13125eedace3ad8defefc57c5ea6a5a95b7ec3918509d097e7464f

See more details on using hashes here.

File details

Details for the file babyrobot-1.0.40-py3-none-any.whl.

File metadata

  • Download URL: babyrobot-1.0.40-py3-none-any.whl
  • Upload date:
  • Size: 161.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 colorama/0.4.4 importlib-metadata/4.6.4 keyring/23.5.0 pkginfo/1.8.2 readme-renderer/34.0 requests-toolbelt/0.9.1 requests/2.25.1 rfc3986/1.5.0 tqdm/4.57.0 urllib3/1.26.5 CPython/3.10.12

File hashes

Hashes for babyrobot-1.0.40-py3-none-any.whl
Algorithm Hash digest
SHA256 dcaf4667b57537d3e1e9995a48322580f37fdbc201ae11c0e708a0fc3a7e5225
MD5 985512fb4fddddf2b96653e3b5aeea79
BLAKE2b-256 3b0309f415fa279727d4569b7f38a3c865bdc1c6ae1db963a9746b0210999163

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page