diff --git a/.gitignore b/.gitignore index 63c4b3f..cb9095b 100644 --- a/.gitignore +++ b/.gitignore @@ -65,6 +65,8 @@ instance/ # Sphinx documentation docs/_build/ +docs/build/ +docs/source/docstring/ # PyBuilder target/ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..69fe55e --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,19 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) \ No newline at end of file diff --git a/docs/UML/pyrobolearn-uml.dia b/docs/UML/pyrobolearn-uml.dia index b516d1b..52ded9a 100644 Binary files a/docs/UML/pyrobolearn-uml.dia and b/docs/UML/pyrobolearn-uml.dia differ diff --git a/docs/UML/pyrobolearn_uml.png b/docs/UML/pyrobolearn_uml.png new file mode 100644 index 0000000..272c3d2 Binary files /dev/null and b/docs/UML/pyrobolearn_uml.png differ diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..543c6b1 --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/docs/make_docs.sh b/docs/make_docs.sh new file mode 100755 index 0000000..2b63980 --- /dev/null +++ b/docs/make_docs.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +# . venv/bin/activate + +rm -Rf build +rm -Rf source/docstring + +sphinx-apidoc -f -o source/docstring/ ../pyrobolearn +make html + diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..56d12d6 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,187 @@ +# -*- coding: utf-8 -*- +# +# Configuration file for the Sphinx documentation builder. +# +# This file does only contain a selection of the most common options. For a +# full list see the documentation: +# http://www.sphinx-doc.org/en/master/config + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +import os +import sys +sys.path.insert(0, os.path.abspath('../..')) + + +# -- Project information ----------------------------------------------------- + +project = u'PyRoboLearn' +copyright = u'2019, Brian Delhaisse' +author = u'Brian Delhaisse' + +# The short X.Y version +version = u'' +# The full version, including alpha/beta/rc tags +release = u'0.0.1' + + +# -- General configuration --------------------------------------------------- + +# If your documentation needs a minimal Sphinx version, state it here. +# +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.intersphinx', + 'sphinx.ext.coverage', + 'sphinx.ext.mathjax', + 'sphinx.ext.viewcode', + 'sphinx.ext.githubpages', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +# source_suffix = ['.rst', '.md'] +source_suffix = '.rst' + +# The master toctree document. +master_doc = 'index' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# +# This is also used if you do content translation via gettext catalogs. +# Usually you set "language" from the command line for these cases. +language = None + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = None + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = 'sphinx_rtd_theme' # 'alabaster' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +# html_theme_options = {} + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Custom sidebar templates, must be a dictionary that maps document names +# to template names. +# +# The default sidebars (for documents that don't match any pattern) are +# defined by theme itself. Builtin themes are using these templates by +# default: ``['localtoc.html', 'relations.html', 'sourcelink.html', +# 'searchbox.html']``. +# +# html_sidebars = {} + + +# -- Options for HTMLHelp output --------------------------------------------- + +# Output file base name for HTML help builder. +htmlhelp_basename = 'PyRoboLearndoc' + + +# -- Options for LaTeX output ------------------------------------------------ + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + (master_doc, 'PyRoboLearn.tex', u'PyRoboLearn Documentation', + u'Brian Delhaisse', 'manual'), +] + + +# -- Options for manual page output ------------------------------------------ + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + (master_doc, 'pyrobolearn', u'PyRoboLearn Documentation', + [author], 1) +] + + +# -- Options for Texinfo output ---------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + (master_doc, 'PyRoboLearn', u'PyRoboLearn Documentation', + author, 'PyRoboLearn', 'One line description of project.', + 'Miscellaneous'), +] + + +# -- Options for Epub output ------------------------------------------------- + +# Bibliographic Dublin Core info. +epub_title = project + +# The unique identifier of the text. This can be a ISBN number +# or the project homepage. +# +# epub_identifier = '' + +# A unique identification for the text. +# +# epub_uid = '' + +# A list of files that should not be packed into the epub file. +epub_exclude_files = ['search.html'] + + +# -- Extension configuration ------------------------------------------------- + +# -- Options for intersphinx extension --------------------------------------- + +# Example configuration for intersphinx: refer to the Python standard library. +intersphinx_mapping = {'https://docs.python.org/': None} diff --git a/docs/source/examples.rst b/docs/source/examples.rst new file mode 100644 index 0000000..0e1d223 --- /dev/null +++ b/docs/source/examples.rst @@ -0,0 +1,2 @@ +.. include:: ../../examples/README.rst + diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..be750f3 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,38 @@ +.. PyRoboLearn documentation master file, created by + sphinx-quickstart on Thu Jun 20 20:28:11 2019. + You can adapt this file completely to your liking, but it should at least + contain the root toctree directive. + +Welcome to PyRoboLearn's documentation! +======================================= + +.. toctree:: + :maxdepth: 2 + :caption: PyRoboLearn + + readme + +.. toctree:: + :maxdepth: 3 + :caption: Installation + + installation + +.. toctree:: + :maxdepth: 2 + :caption: Examples + + examples + +.. toctree:: + :maxdepth: 3 + :caption: Package Reference + + docstring/modules + +.. toctree:: + :maxdepth: 2 + :caption: Index + + indices + diff --git a/docs/source/indices.rst b/docs/source/indices.rst new file mode 100644 index 0000000..0dcc748 --- /dev/null +++ b/docs/source/indices.rst @@ -0,0 +1,6 @@ +Indices and tables +================== +* :ref:`genindex` +* :ref:`modindex` +* :ref:`search` + diff --git a/docs/source/installation.rst b/docs/source/installation.rst new file mode 100644 index 0000000..99bd765 --- /dev/null +++ b/docs/source/installation.rst @@ -0,0 +1,145 @@ +Installation +============ + +There are 2 ways to install the PyRoboLearn framework. + +1. via :ref:`Docker` +2. using a :ref:`Virtual Environment` + + +.. _Docker: + +Docker +------- + +At the moment the docker is a self contained Ubuntu image with all the libraries installed. When launched we have access to a Python3.6 interpreter and we can import pyrobolearn directly. +In the future, ROS may be splitted in another container and linked to this one. + +1. Install Docker and nvidia-docker + +.. code-block:: bash + + sudo apt-get update + sudo apt install apt-transport-https ca-certificates curl software-properties-common + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - + sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable # you should replace bionic by your version + sudo apt update + sudo apt install docker-ce + sudo systemctl status docker # check that docker is active + +2. Build the image + +.. code-block:: bash + + docker build -t pyrobolearn . + +3. You can now start the python interpreter with every library already installed + +.. code-block:: bash + + docker run -p 11311:11311 -v catkin_ws:/pyrobolearn/catkin_ws/ -ti pyrobolearn python3 + + +To open an interactive terminal in the docker image use: + +.. code-block:: bash + + docker run -p 11311:11311 -v catkin_ws:/pyrobolearn/catkin_ws/ -ti pyrobolearn /bin/bash + + +4. If the GPU is not recognized in the interpreter, you can install ``nvidia-docker`` + +.. code-block:: bash + + curl -sL https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - + distribution=$(. /etc/os-release;echo $ID$VERSION_ID) + curl -sL https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list + sudo apt-get update + sudo apt-get install nvidia-docker2 + sudo pkill -SIGHUP dockerd + +And use: + +.. code-block:: bash + + nvidia-docker run -p 11311:11311 -v catkin_ws:/pyrobolearn/catkin_ws/ -ti pyrobolearn + + +.. _Virtual Environment: + +Virtual Environment +------------------- + +0. Prerequisites: install the following packages on your Ubuntu system + +.. code-block:: bash + + sudo apt-get install cmake gfortran + + +1. First download the ``pip`` Python package manager and create a virtual environment for Python as described in the following link: https://packaging.python.org/guides/installing-using-pip-and-virtualenv/ + +On Ubuntu, you can install ``pip`` and ``virtualenv`` by typing in the terminal: + +- In Python 2.7: + +.. code-block:: bash + + sudo apt install python-pip + sudo pip install virtualenv + +- In Python 3.5: + +.. code-block:: bash + + sudo apt install python3-pip + sudo pip install virtualenv + + +You can then create the virtual environment by typing: + +.. code-block:: bash + + virtualenv -p /usr/bin/python + # activate the virtual environment + source /bin/activate + +where ```` is the python version you want to use (select between ``2.7`` or ``3.5``), and ```` is a name of your choice for the virtual environment. For instance, it can be ``py2.7`` or ``py3.5``. + +To deactivate the virtual environment, just type: + +.. code-block:: bash + + deactivate + + +2. clone this repository and install the requirements by executing the ``setup.py`` + +In Python 2.7: + +.. code-block:: bash + + git clone https://github.com/robotlearn/pyrobolearn + cd pyrobolearn + pip install numpy cython + pip install http://github.com/cornellius-gp/gpytorch/archive/alpha.zip # this is for Python 2.7 + pip install -e . # this will install pyrobolearn as well as the required packages (so no need for: pip install -r requirements.txt) + +In Python 3.5: + +.. code-block:: bash + + git clone https://github.com/robotlearn/pyrobolearn + cd pyrobolearn + pip install numpy cython + pip install gpytorch # this is for Python 3.5 + pip install -e . # this will install pyrobolearn as well as the required packages (so no need for: pip install -r requirements.txt) + + +Depending on your computer configuration and the python version you use, you might need to install also the following packages through ``apt-get``: + +.. code-block:: bash + + sudo apt install python-tk # if python 2.7 + sudo apt install python3-tk # if python 3.5 + diff --git a/docs/source/readme.rst b/docs/source/readme.rst new file mode 100644 index 0000000..7868920 --- /dev/null +++ b/docs/source/readme.rst @@ -0,0 +1,22 @@ +PyRoboLearn +=========== + +.. include:: ../../README.md + +Design Decisions +================ + +.. image:: ../UML/pyrobolearn_uml.png + +Citation +======== + +.. code-block:: latex + + @misc{delhaisse2019pyrobolearn, + author = {Delhaisse, Brian and Xin, Songyan and Rozo, Leonel, and Caldwell, Darwin}, + title = {PyRoboLearn: A Python Framework for Robot Learning Practitioners}, + howpublished = {\url{https://github.com/robotlearn/pyrobolearn}}, + year=2019, + } + diff --git a/examples/README.md b/examples/README.md deleted file mode 100644 index 8684c1a..0000000 --- a/examples/README.md +++ /dev/null @@ -1,21 +0,0 @@ -## Examples - -In this folder, you will find different examples on how to use the framework. - -Warning: this folder is currently being updated; few files might still have some bugs or not -implemented completely. Some other folders will be added in the upcoming days. - -You can check the following folders: -- `worlds`: how to create a world in the simulator, load various objects inside and interact with -them, use the camera, and load or generate terrains. -- `robots`: check how to load a specific robot (biped, quadruped, wheeled, etc) into the world. -- `interfaces`: the various interfaces (game controllers, webcam, etc) and bridges that you can use. -- `kinematics`: check how to use forward and inverse kinematics as well as position and velocity control. -- `manipulability`: check how to use the velocity and dynamic manipulability ellipsoids. - -- `states`: how to query the states / observations. -- `models`: the different learning models that you can use. - -- `imitation`: how to use imitation learning with the framework. -- `gym/cartpole`: policies are trained with different algorithms on the gym Cartpole environment. - diff --git a/examples/README.rst b/examples/README.rst new file mode 100644 index 0000000..37a233a --- /dev/null +++ b/examples/README.rst @@ -0,0 +1,20 @@ +Examples +======== + +In this folder, you will find different examples on how to use the framework. + +Warning: this folder is currently being updated; few files might still have some bugs or not +implemented completely. Some other folders will be added in the upcoming days. + +You can check the following folders: + +- ``worlds``: how to create a world in the simulator, load various objects inside and interact with them, use the camera, and load or generate terrains. +- ``robots``: check how to load a specific robot (biped, quadruped, wheeled, etc) into the world. +- ``interfaces``: the various interfaces (game controllers, webcam, etc) and bridges that you can use. +- ``kinematics``: check how to use forward and inverse kinematics as well as position and velocity control. +- ``manipulability``: check how to use the velocity and dynamic manipulability ellipsoids. +- ``states``: how to query the states / observations. +- ``models``: the different learning models that you can use. +- ``imitation``: how to use imitation learning with the framework. +- ``gym/cartpole``: policies are trained with different algorithms on the gym Cartpole environment. +