Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
davetcoleman committed Aug 23, 2016
0 parents commit 8d14989
Show file tree
Hide file tree
Showing 113 changed files with 6,900 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*~
*.pyc
doc/manifest.yaml
doc/html
build
36 changes: 36 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 2.8.3)
project(moveit_tutorials)

find_package(catkin REQUIRED
COMPONENTS
moveit_core
moveit_ros_planning
moveit_ros_planning_interface
pluginlib
cmake_modules
geometric_shapes
)

find_package(Boost REQUIRED system filesystem date_time thread)

catkin_package(
CATKIN_DEPENDS
moveit_core
moveit_ros_planning_interface
interactive_markers
)
find_package(Eigen REQUIRED)

###########
## Build ##
###########

include_directories(SYSTEM ${Boost_INCLUDE_DIR} ${EIGEN_INCLUDE_DIRS})
include_directories(${catkin_INCLUDE_DIRS})
link_directories(${catkin_LIBRARY_DIRS})

add_subdirectory(doc/pr2_tutorials/kinematics)
add_subdirectory(doc/pr2_tutorials/planning)
add_subdirectory(doc/pr2_tutorials/state_display)
add_subdirectory(doc/pr2_tutorials/interactivity)
add_subdirectory(doc/pr2_tutorials/pick_place)
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# MoveIt! Tutorials

To build locally:

. build_locally.sh

Then open ``/build/html/build/doc/index.html`` in your web browser.
200 changes: 200 additions & 0 deletions _scripts/tutorialformatter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
"""
tutorialformatter
===========================
This extension provides a directive to include a source code file
in a document, but with certain comments from the file formatted
as regular document text. This allows code for a tutorial to look like:
/// BEGIN_TUTORIAL
/// This next line adds one.
i = i + 1;
/// Then we need to double it.
i = i * 2;
/// END_TUTORIAL
And have it formatted as
This next line adds one.::
i = i + 1;
Then we need to double it.::
i = i * 2;
The special-looking comment character sequence at the start of
each text line can be anything not starting or ending with
whitespace. tutorialformatter starts by scanning the file for the
string BEGIN_TUTORIAL. When it finds it, it takes all the
characters before BEGIN_TUTORIAL on that line, strips whitespace
from the left, and uses that as the text marker. So this would
also be fine:
#My Tutorial# BEGIN_TUTORIAL
#My Tutorial# This next line adds one.
i = i + 1
#My Tutorial# Then we need to double it.
i = i * 2
#My Tutorial# END_TUTORIAL
Sometimes the order that makes sense in the tutorial is not
compatible with the computer language of the code, like when a
callback function in C++ is defined outside of the main tutorial
code. To support this, you can use the tags BEGIN_SUB_TUTORIAL,
END_SUB_TUTORIAL, and CALL_SUB_TUTORIAL. They look like this:
# BEGIN_SUB_TUTORIAL callbackFunction
def callback():
print "in callback"
# END_SUB_TUTORIAL
# BEGIN_TUTORIAL
# Here we call a special callback:
callback()
# which is defined as:
# CALL_SUB_TUTORIAL callbackFunction
# and then we move on to the next topic.
Both the BEGIN_SUB_TUTORIAL and CALL_SUB_TUTORIAL tags take an
argument, which is the name of the "sub-tutorial". That name does
not need to correspond to anything in the code. Sub-tutorials
cannot be nested, and they only work within a single source file
processed by tutorialformatter. They have no outside meaning.
The implementation simply slices out sub-tutorials from the input
lines and copies them into the output lines where-ever the
corresponding "call" tags are found.
.. moduleauthor:: Dave Hershberger <hersh@willowgarage.com>
"""

# 0.1.0: First version.
# 0.1.1: fixed a bug in source file directory lookup: now source paths are
# relative to the directory in which the including document lives.
# 0.1.2: Added SUB_TUTORIAL support.
__version__ = '0.1.2'

import os
from docutils.parsers import rst
from docutils.parsers.rst.directives import flag, unchanged
from docutils.statemachine import string2lines
from pygments.lexers import get_lexer_for_filename

class TutorialFormatterDirective(rst.Directive):
has_content = False
final_argument_whitespace = True
required_arguments = 1

option_spec = dict(shell=flag, prompt=flag, nostderr=flag,
in_srcdir=flag, extraargs=unchanged,
until=unchanged)

def flatten_sub_tutorials(self, file_):
lines = []
in_sub = False
begin_sub_tutorial = 'BEGIN_SUB_TUTORIAL'
end_sub_tutorial = 'END_SUB_TUTORIAL'
call_sub_tutorial = 'CALL_SUB_TUTORIAL'
sub_name = ''
subs = {}
sub_lines = []
regular_lines = []
for line in file_:
begin_pos = line.find( begin_sub_tutorial )
if begin_pos != -1:
sub_name = line[begin_pos + len(begin_sub_tutorial) : ].strip()
in_sub = True
elif line.find( end_sub_tutorial ) != -1 and in_sub:
in_sub = False
subs[sub_name] = sub_lines
sub_lines = []
elif in_sub:
sub_lines.append(line)
else:
regular_lines.append(line)
flattened_lines = []
for line in regular_lines:
call_pos = line.find( call_sub_tutorial )
if call_pos != -1:
sub_name = line[call_pos + len(call_sub_tutorial) : ].strip()
if sub_name in subs:
flattened_lines.extend( subs[sub_name] )
else:
print 'tutorialformatter.py error: sub-tutorial %s not found.' % sub_name
else:
flattened_lines.append( line )
return flattened_lines

def run(self):
filename = self.arguments[0]
text_tag = None
tag_len = 0

filepath = os.path.dirname(self.state.document.settings.env.docname)
absfilename = os.path.abspath(os.path.join( filepath, filename ))
if absfilename.endswith('.h'):
language = 'c++'
elif absfilename.endswith('CMakeLists.txt'):
language = 'cmake'
else:
try:
language = get_lexer_for_filename( absfilename ).name.lower()
if language == 'text only':
language = 'none'
except:
language = 'none'
code_prefix = '\n.. code-block:: ' + language + '\n\n'
code_suffix = '\n'

print "tutorial-formatter running on", absfilename
file_ = open( absfilename, 'r' )
text_to_process = ""
current_block = ""
in_code = False
in_text = False
in_tutorial = False
lines = self.flatten_sub_tutorials(file_)
for line in lines:
if not in_tutorial:
begin_pos = line.find( 'BEGIN_TUTORIAL' )
if begin_pos != -1:
text_tag = line[:begin_pos].lstrip()
tag_len = len( text_tag )
in_tutorial = True
continue
if line.find( 'END_TUTORIAL' ) != -1:
break
stripped = line.lstrip()
if stripped.startswith( text_tag.strip() ):
if in_code:
text_to_process += code_prefix + current_block + code_suffix
current_block = ""
in_code = False
in_text = True
addition = stripped[tag_len:]
if addition == '' or addition[-1] != '\n':
addition += '\n'
current_block += addition
else:
if in_text:
text_to_process += current_block
current_block = ""
in_text = False
in_code = True # Code to show begins right after tagged text
if in_code:
current_block += ' ' + line
if in_code:
text_to_process += code_prefix + current_block + code_suffix
elif in_text:
text_to_process += current_block

# Debug writes...
# print 'text_to_process ='
# print text_to_process
# print '= text_to_process'

lines = string2lines( text_to_process )
self.state_machine.insert_input( lines, absfilename )

return []

def setup(app):
app.add_directive('tutorial-formatter', TutorialFormatterDirective)
Binary file added _static/favicon.ico
Binary file not shown.
Binary file added _static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions _static/override.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.icon:before {
white-space: pre-wrap !important;
}
.header-override {
margin-bottom: 20px;
}
.header-override p {
padding: 5px;
font-size: 1.2em;
text-align: right;
float: right;
}
.header-override img {
width: 200px;
}
17 changes: 17 additions & 0 deletions _themes/sphinx_rtd_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Sphinx ReadTheDocs theme.
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""
import os

VERSION = (0, 1, 8)

__version__ = ".".join(str(v) for v in VERSION)
__version_full__ = __version__


def get_html_theme_path():
"""Return list of HTML theme paths."""
cur_dir = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
return cur_dir
23 changes: 23 additions & 0 deletions _themes/sphinx_rtd_theme/breadcrumbs.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="{{ pathto(master_doc) }}">Docs</a> &raquo;</li>
{% for doc in parents %}
<li><a href="{{ doc.link|e }}">{{ doc.title }}</a> &raquo;</li>
{% endfor %}
<li>{{ title }}</li>
<li class="wy-breadcrumbs-aside">
{% if pagename != "search" %}
{% if display_github %}
<a href="https://{{ github_host|default("github.com") }}/{{ github_user }}/{{ github_repo }}/blob/{{ github_version }}{{ conf_py_path }}{{ pagename }}{{ source_suffix }}" class="fa fa-github"> Edit on GitHub</a>
{% elif display_bitbucket %}
<a href="https://bitbucket.org/{{ bitbucket_user }}/{{ bitbucket_repo }}/src/{{ bitbucket_version}}{{ conf_py_path }}{{ pagename }}{{ source_suffix }}" class="fa fa-bitbucket"> Edit on Bitbucket</a>
{% elif show_source and source_url_prefix %}
<a href="{{ source_url_prefix }}{{ pagename }}{{ source_suffix }}">View page source</a>
{% elif show_source and has_source and sourcename %}
<a href="{{ pathto('_sources/' + sourcename, true)|e }}" rel="nofollow"> View page source</a>
{% endif %}
{% endif %}
</li>
</ul>
<hr/>
</div>
27 changes: 27 additions & 0 deletions _themes/sphinx_rtd_theme/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<footer>
{% if next or prev %}
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
{% if next %}
<a href="{{ next.link|e }}" class="btn btn-neutral float-right" title="{{ next.title|striptags|e }}" accesskey="n">Next <span class="fa fa-arrow-circle-right"></span></a>
{% endif %}
{% if prev %}
<a href="{{ prev.link|e }}" class="btn btn-neutral" title="{{ prev.title|striptags|e }}" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous</a>
{% endif %}
</div>
{% endif %}

<hr/>

<div role="contentinfo">
<p>
{%- if last_updated %}
{% trans last_updated=last_updated|e %}Last updated on {{ last_updated }}.{% endtrans %}
{%- endif %}
</p>
</div>

{%- if show_sphinx %}
{% trans %}Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>{% endtrans %}.
{%- endif %}

</footer>
Loading

0 comments on commit 8d14989

Please sign in to comment.