-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from rland93/documentation-#8
Hosted Documentation, YAY! #8
- Loading branch information
Showing
12 changed files
with
581 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v1 | ||
# Standard drop-in approach that should work for most people. | ||
- uses: ammaraskar/sphinx-action@master | ||
with: | ||
pre-build-command: "pip install sphinx-rtd-theme sphinx-autoapi numpydoc" | ||
docs-folder: "docs/" | ||
# Great extra actions to compose with: | ||
# Create an artifact of the html output. | ||
- uses: actions/upload-artifact@v1 | ||
with: | ||
name: DocumentationHTML | ||
path: docs/_build/html/ | ||
# Publish built docs to gh-pages branch. | ||
# =============================== | ||
- name: Commit documentation changes | ||
run: | | ||
git clone https://github.com/ammaraskar/sphinx-action-test.git --branch gh-pages --single-branch gh-pages | ||
cp -r docs/_build/html/* gh-pages/ | ||
cd gh-pages | ||
touch .nojekyll | ||
git config --local user.email "[email protected]" | ||
git config --local user.name "GitHub Action" | ||
git add . | ||
git commit -m "Update documentation" -a || true | ||
# The above command will fail if no changes were present, so we ignore | ||
# that. | ||
- name: Push changes | ||
uses: ad-m/github-push-action@master | ||
with: | ||
force: true | ||
branch: gh-pages | ||
directory: gh-pages | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
# =============================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Minimal makefile for Sphinx documentation | ||
# | ||
|
||
# You can set these variables from the command line, and also | ||
# from the environment for the first two. | ||
SPHINXOPTS ?= | ||
SPHINXBUILD ?= sphinx-build | ||
SOURCEDIR = . | ||
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) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
# Configuration file for the Sphinx documentation builder. | ||
# | ||
# This file only contains a selection of the most common options. For a full | ||
# list see the documentation: | ||
# https://www.sphinx-doc.org/en/master/usage/configuration.html | ||
|
||
# -- 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("..")) | ||
try: | ||
import rrtplanner | ||
except ImportError: | ||
raise ImportError("check that `rrtplanner` is available to your system path.") | ||
|
||
# -- Project information ----------------------------------------------------- | ||
|
||
project = "RRT Planner" | ||
copyright = "2021, Mike Sutherland" | ||
author = "Mike Sutherland" | ||
|
||
|
||
# -- General configuration --------------------------------------------------- | ||
|
||
# Add any Sphinx extension module names here, as strings. They can be | ||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom | ||
# ones. | ||
extensions = [ | ||
"autoapi.extension", | ||
"sphinx.ext.autodoc", | ||
"sphinx.ext.autosummary", | ||
"sphinx.ext.doctest", | ||
"sphinx.ext.mathjax", | ||
"sphinx.ext.viewcode", | ||
"sphinx.ext.githubpages", | ||
"sphinx.ext.intersphinx", | ||
"numpydoc", | ||
] | ||
|
||
autoapi_type = "python" | ||
autoapi_dirs = ["../rrtplanner/"] | ||
|
||
|
||
# Add any paths that contain templates here, relative to this directory. | ||
templates_path = ["_templates"] | ||
|
||
# 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 = ["_build", "Thumbs.db", ".DS_Store"] | ||
|
||
pygments_style = "solarized-dark" | ||
|
||
autodoc_mock_imports = ["scipy", "numpy", "matplotlib", "cvxpy"] | ||
|
||
# -- Options for HTML output ------------------------------------------------- | ||
|
||
# The theme to use for HTML and HTML Help pages. See the documentation for | ||
# a list of builtin themes. | ||
# | ||
on_rtd = os.environ.get("READTHEDOCS", None) == "True" | ||
|
||
if not on_rtd: # only import and set the theme if we're building docs locally | ||
import sphinx_rtd_theme | ||
|
||
html_theme = "sphinx_rtd_theme" | ||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] | ||
|
||
|
||
# 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"] | ||
|
||
master_doc = "index" | ||
|
||
intersphinx_mapping = { | ||
"python": ("https://docs.python.org/3/", None), | ||
"numpy": ("https://numpy.org/doc/stable/", None), | ||
"matplotlib": ("https://matplotlib.org/stable", None), | ||
"scipy": ("https://docs.scipy.org/doc/scipy/reference", None), | ||
"networkx": ("https://networkx.org/documentation/stable/", None), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
Getting Started | ||
=============== | ||
|
||
|
||
Installation | ||
------------ | ||
|
||
Installation is done with ``pip`` | ||
|
||
.. code-block:: bash | ||
pip install rrtplanner | ||
How to Plan | ||
----------- | ||
|
||
Path Planning is the process of finding a viable path from one point to another in some configuration space. This package provides some example implementations of RRT, RRT*, and RRT*Informed planners. These planners can be used to plan in a two dimensional configuration space, with no differential constraints on the motion of the robot. This means that a path between two points is simply a straight line. | ||
|
||
Plans are computed by these objects: | ||
|
||
* :class:`rrtplanner.RRTStandard` | ||
* :class:`rrtplanner.RRTStar` | ||
* :class:`rrtplanner.RRTStarInformed` | ||
|
||
Plans are computed on an OccupancyGrid, which is a MxN array of integers. This package considers a value of 0 to be free space, and anything other than 0 to be an obstacle. We can create random, boolean arrays with the built-in ``perlin_occupancygrid`` function: | ||
|
||
.. code-block:: python | ||
from rrtplanner import perlin_occupancygrid | ||
og = perlin_occupancygrid(240, 240, 0.33) | ||
This will create an occupancy grid (really, just an 400x400 array) of points, with blocks of 1 where obstacles are present and blocks of 0 that are free space. | ||
|
||
.. important:: | ||
|
||
Using Perlin noise often generates good random obstacles. However, it sometimes creates an occupancygrid with free space that is split -- from a given point, there is no guarantee that all free space is reachable if you are using the ``perlin_occupancygrid`` noise generator. | ||
|
||
In real applications, occupancyGrids can be generated by e.g. a SLAM algorithm or pre-computed map. | ||
|
||
With our occupancy grid, we are ready to plan. | ||
|
||
First, we create the planner object. This object takes three important arguments: ``og``, which is the occupancy grid over which we want to plan, ``n`` which is the number of **attempted** sample points, and ``r_rewire``, which is the radius for which to rewire. | ||
|
||
As a general rule, we choose ``n`` appropriately, according to the amount of time we have to compute new plans vs the optimality of computed plans. When ``n`` is large, more samples are attempted, and so there are more opportunities to generate an optimal plan. When ``n`` is small, plan time is short, but plans are less optimal. | ||
|
||
We also want to choose ``r_rewire`` so that it is sized to the obstacle features. Very large values of ``r_rewire`` will result in the algorithm taking a long time to compute a plan, with little benefit, since obstacles block long straight-line paths. While very small values of ``r_rewire`` will result in the algorithm quickly finding a sub-optimal plan. | ||
|
||
.. code-block:: python | ||
from rrtplanner import RRTStar, random_point_og | ||
n = 1200 | ||
r_rewire = 80 | ||
rrts = RRTStar(og, n, r_rewire) | ||
Now, we can plan a path. We choose a start and a goal point randomly from the free space of the world, and call the ``RRTStar``'s ``plan`` method. | ||
|
||
.. code-block:: python | ||
xstart = random_point_og(og) | ||
xgoal = random_point_og(og) | ||
T, gv = rrts.plan(xstart, xgoal) | ||
The plan is computed, and we have two return values. The first is the tree itself, formatted as a `NetworkX DiGraph object <https://networkx.org/documentation/stable/reference/classes/digraph.html>`_ Points are stored in keys called ```pt`` and edges have the attribute ``cost``, which is the cost of the leaf node connected to that edge. The second return value is the vertex of the goal point on the tree. | ||
|
||
Once our tree is created, we traverse it to find a path from vertex 0 to the goal vertex, and subsequently find each point in the order of that traversal: | ||
|
||
.. code-block:: python | ||
path = rrts.route2gv(T, gv) | ||
path_pts = rrts.vertices_as_ndarray(T, path) | ||
Then, we have computed our path and it is stored in ``path_pts``. | ||
|
||
This package includes a number of plotting functions (which use `matplotlib`<https://matplotlib.org/>_) that can be used to visualize the 2-D world and plans in it. | ||
|
||
.. code-block:: python | ||
from rrtplanner import plot_rrt_lines, plot_path, plot_og, plot_start_goal | ||
import matplotlib.pyplot as plt | ||
# create figure and ax. | ||
fig = plt.figure() | ||
ax = fig.add_subplot() | ||
# these functions alter ax in-place. | ||
plot_og(ax, og) | ||
plot_start_goal(ax, xstart, xgoal) | ||
plot_rrt_lines(ax, T) | ||
plot_path(ax, path_pts) | ||
plt.show() | ||
We see the results of our plan. Because points and obstacles are generated randomly when you run this script, your result should bear a superficial resemblance to the figure below: | ||
|
||
.. image:: _static/getting-started-plan.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
RRTPlanner Documentation | ||
######################## | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents | ||
|
||
Getting Started<getting-started> | ||
Git Repository<https://github.com/rland93/rrtplanner> | ||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Installation | ||
============ | ||
|
||
Installation is done with pip: | ||
|
||
.. code-block:: bash | ||
pip install rrtplanner |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@ECHO OFF | ||
|
||
pushd %~dp0 | ||
|
||
REM Command file for Sphinx documentation | ||
|
||
if "%SPHINXBUILD%" == "" ( | ||
set SPHINXBUILD=sphinx-build | ||
) | ||
set SOURCEDIR=. | ||
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% %O% | ||
goto end | ||
|
||
:help | ||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% | ||
|
||
:end | ||
popd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
"""Top-level package for rrtplanner.""" | ||
|
||
__author__ = """Mike Sutherland""" | ||
__email__ = '[email protected]' | ||
__version__ = '0.1.0' | ||
__email__ = "[email protected]" | ||
__version__ = "0.1.0" | ||
|
||
from .rrt import * | ||
from .anim import * | ||
from .oggen import * | ||
from .plots import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.